Cleanup WASM bindings generators so they all have a similar interface

PiperOrigin-RevId: 827965451
Change-Id: I657fc4d3a480fbc62124c84fe9ddc0900a91183f
This commit is contained in:
Matija Kecman
2025-11-04 07:31:36 -08:00
committed by Copybara-Service
parent 776fc32eb4
commit 29c1a3a0a5
10 changed files with 78 additions and 109 deletions
+6 -3
View File
@@ -14,7 +14,7 @@
"""Generates Embind bindings for MuJoCo enums."""
from typing import Mapping
from typing import Mapping, Optional
from introspect import ast_nodes
@@ -38,10 +38,13 @@ class Generator:
code += ";"
return code
def generate(self) -> str:
def generate(self) -> list[tuple[str, list[str]]]:
"""Generates all Embind code for the provided enums."""
code = []
for enum in self.enums.values():
code.append(self._generate_enum_binding(enum))
return "\n\n".join(code) + "\n"
content = "\n\n".join(code)
marker = "// {{ ENUM_BINDINGS }}"
return [(marker, [content])]