Skip to content

Commit

Permalink
Fix: Use correct methods when writing toposorted structs
Browse files Browse the repository at this point in the history
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 5439fa1.
  • Loading branch information
phil-opp committed Feb 28, 2024
1 parent 7eef562 commit eabcb31
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gen/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit eabcb31

Please sign in to comment.