Refactor struct dependency sorting to use wrapped field data.

The `sort_structs_by_dependency` function now takes a dictionary of `WrappedStructData` and uses the pre-computed `typename` within `WrappedFieldData` for dependency analysis, instead of re-introspecting the AST. This change also includes populating the `typename` in various `WrappedFieldData` generation methods.

PiperOrigin-RevId: 828389481
Change-Id: Ie97c1a66e5e69bd148a928fda26afdaa09f56687
This commit is contained in:
Google DeepMind
2025-11-05 03:22:41 -08:00
committed by Copybara-Service
parent 29c1a3a0a5
commit 5b00b033af
2 changed files with 27 additions and 17 deletions
+1 -3
View File
@@ -14,8 +14,6 @@
"""Generates Embind bindings for MuJoCo structs."""
from typing import Optional
from wasm.codegen.helpers import constants
from wasm.codegen.helpers import structs
@@ -37,7 +35,7 @@ class Generator:
# Sort by struct name by dependency to ensure deterministic output order
sorted_struct_names = structs.sort_structs_by_dependency(
constants.STRUCTS_TO_BIND
self.structs_to_bind_data
)
for struct_name in sorted_struct_names: