Simplified struct code generation for WASM bindings

PiperOrigin-RevId: 827878780
Change-Id: I97ab732eb11c63a6aaf7fa95add0b51bc0a56525
This commit is contained in:
Matija Kecman
2025-11-04 02:50:09 -08:00
committed by Copybara-Service
parent c22d94e470
commit 3d59b20b65
6 changed files with 122 additions and 137 deletions
+1 -8
View File
@@ -18,23 +18,16 @@ from typing import Optional
from wasm.codegen.helpers import constants
from wasm.codegen.helpers import structs_parser
from wasm.codegen.helpers import structs_wrappers_data
class Generator:
"""Generates C++ code for binding and wrapping MuJoCo structs."""
def __init__(self):
# Set up the correct input dict based on the structs we want to bind
# and already have a wrapper manually created in the template/bindings.cc
wrapped_structs = structs_wrappers_data.create_wrapped_structs_set_up_data(
constants.STRUCTS_TO_BIND
)
# Traverse the introspect dictionary to get the field
# wrapper/bindings statements set up for each struct
self.structs_to_bind_data = structs_parser.generate_wasm_bindings(
wrapped_structs
constants.STRUCTS_TO_BIND
)
def generate_header(