From eabcb3178eceed12f556eaf0510a86ec5dfd441b Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 28 Feb 2024 11:44:35 +0100 Subject: [PATCH] Fix: Use correct methods when writing toposorted structs If there are other structs in `toposorted_structs` before `strct`, they were written with the methods of `strct` instead of their own. This commit fixes that. This commit also fixes the check against `out.types.cxx` that should prevent duplicate definitions. I didn't encounter any such issues, but I still think that it makes sense to fix it. Both issues were introduced in commit 5439fa195bbece443d261d40bf08d77012d44e58. --- gen/src/write.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gen/src/write.rs b/gen/src/write.rs index 8eef0a76b..89037e16f 100644 --- a/gen/src/write.rs +++ b/gen/src/write.rs @@ -85,10 +85,10 @@ fn write_data_structures<'a>(out: &mut OutFile<'a>, apis: &'a [Api]) { match api { Api::Struct(strct) if !structs_written.contains(&strct.name.rust) => { for next in &mut toposorted_structs { - if !out.types.cxx.contains(&strct.name.rust) { + if !out.types.cxx.contains(&next.name.rust) { out.next_section(); let methods = methods_for_type - .get(&strct.name.rust) + .get(&next.name.rust) .map(Vec::as_slice) .unwrap_or_default(); write_struct(out, next, methods);