Add an introspect module for structs.

Also missing struct fields to the Python bindings that were discovered as a result of the new `introspect` metadata.

PiperOrigin-RevId: 523947396
Change-Id: I367fd2dc8d5fd7e5712a45b70a5c50da51d152e4
This commit is contained in:
Saran Tunyasuvunakool
2023-04-13 02:49:47 -07:00
committed by Copybara-Service
parent bcb19fd85c
commit 2e23594fe8
13 changed files with 6721 additions and 14 deletions
+5 -5
View File
@@ -28,9 +28,9 @@ from introspect import ast_nodes
from introspect import type_parsing
from . import formatter
FLAGS = flags.FLAGS
flags.DEFINE_string('header_path', None, 'Path to the original mujoco.h')
flags.DEFINE_string(
_HEADER_PATH = flags.DEFINE_string(
'header_path', None, 'Path to the original mujoco.h')
_JSON_PATH = flags.DEFINE_string(
'json_path', None,
'Path to the JSON file representing the Clang AST for mujoco.h')
@@ -113,10 +113,10 @@ def main(argv: Sequence[str]) -> None:
if len(argv) > 1:
raise app.UsageError('Too many command-line arguments.')
with open(FLAGS.json_path, 'r', encoding='utf-8') as f:
with open(_JSON_PATH.value, 'r', encoding='utf-8') as f:
root = json.load(f)
with open(FLAGS.header_path, 'r') as f:
with open(_HEADER_PATH.value, 'r') as f:
visitor = MjFunctionVisitor(f.read())
traverse(root, visitor)