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:
committed by
Copybara-Service
parent
5b00b033af
commit
fe1b6b7c80
@@ -57,17 +57,23 @@ class Generator:
|
||||
autogenned_struct_definitions,
|
||||
))
|
||||
|
||||
for _, struct_data in self.structs_to_bind_data.items():
|
||||
# Bindings
|
||||
autogenned_struct_source = []
|
||||
for struct_name in sorted_struct_names:
|
||||
struct_data = self.structs_to_bind_data[struct_name]
|
||||
if struct_data.wrapped_source:
|
||||
autogenned_struct_source.append(
|
||||
struct_data.wrapped_source + "\n"
|
||||
)
|
||||
|
||||
# Bindings with markers
|
||||
markers_and_content.append((
|
||||
f"// INSERT-GENERATED-{struct_data.wrap_name}-BINDINGS",
|
||||
[l.binding for l in struct_data.wrapped_fields],
|
||||
))
|
||||
|
||||
# Special member functions
|
||||
markers_and_content.append((
|
||||
f"// INSERT-GENERATED-{struct_data.wrap_name}-CONSTRUCTOR",
|
||||
[struct_data.wrapped_source],
|
||||
))
|
||||
markers_and_content.append((
|
||||
"// {{ AUTOGENNED_STRUCTS_SOURCE }}",
|
||||
autogenned_struct_source,
|
||||
))
|
||||
|
||||
return markers_and_content
|
||||
|
||||
Reference in New Issue
Block a user