Refactor: Group autogenerated structs source in bindings.cc

This change modifies the code generation for structs in `bindings.cc`. Instead of placing each struct's constructor and member functions under individual markers, all autogenerated struct source code is now grouped together under a single `// {{ AUTOGENNED_STRUCTS_SOURCE }}` marker. This improves the organization of the generated file and simplifies the template.

Future work would move the rest of the structs into this pattern

PiperOrigin-RevId: 828390272
Change-Id: Iee9d0e8766db86b2c1d4296a37ac7a8e6e05428b
This commit is contained in:
Google DeepMind
2025-11-05 03:25:18 -08:00
committed by Copybara-Service
parent 5b00b033af
commit fe1b6b7c80
4 changed files with 638 additions and 813 deletions
+10
View File
@@ -592,6 +592,16 @@ def build_struct_source(
wrapped_fields: List[WrappedFieldData],
):
"""Builds the C++ .cc file code for a struct."""
# These structs require specific function calls for creation and/or deletion
# which, for now, are hardcoded in the template file.
if struct_name in [
"mjData",
"mjModel",
"mjvScene",
"mjSpec",
]:
return ""
s = struct_name
w = common.uppercase_first_letter(s)
is_mjs = "Mjs" in w