Reorganization of the WASM bindings.cc template
* Move all bindings into a single EMSCRIPTEN_BINDINGS block * Move all auto generated bindings line to the start of the block * Alphabetically sort the constants binding lines PiperOrigin-RevId: 837142009 Change-Id: I218a37dbc0ca6c6f16a455718889c08fe1b41d56
This commit is contained in:
committed by
Copybara-Service
parent
c7e0c01e80
commit
05f194c412
@@ -27,15 +27,13 @@ def generate(
|
||||
"""Generates all Embind code for the provided enums."""
|
||||
|
||||
builder = code_builder.CodeBuilder()
|
||||
with builder.block('EMSCRIPTEN_BINDINGS(mujoco_enums)'):
|
||||
for e in sorted(enums, key=lambda e: e.name):
|
||||
if e.values: # Skip empty enums.
|
||||
with builder.block(f'enum_<{e.name}>("{e.name}")', braces=False):
|
||||
names = list(e.values.keys())
|
||||
for name in names[:-1]:
|
||||
builder.line(f'.value("{name}", {name})')
|
||||
builder.line(f'.value("{names[-1]}", {names[-1]});')
|
||||
builder.newline()
|
||||
for e in sorted(enums, key=lambda e: e.name):
|
||||
if e.values: # Skip empty enums.
|
||||
with builder.block(f'enum_<{e.name}>("{e.name}")', braces=False):
|
||||
names = list(e.values.keys())
|
||||
for name in names[:-1]:
|
||||
builder.line(f'.value("{name}", {name})')
|
||||
builder.line(f'.value("{names[-1]}", {names[-1]});')
|
||||
|
||||
content = builder.to_string()
|
||||
marker = '// {{ ENUM_BINDINGS }}'
|
||||
|
||||
Reference in New Issue
Block a user