Refactor MuJoCo WASM struct codegen.
PiperOrigin-RevId: 837530063 Change-Id: I57518b2fbb536f356a5e15839d8e17f455bccde9
This commit is contained in:
committed by
Copybara-Service
parent
5163dfa823
commit
9ca1598b23
@@ -37,7 +37,7 @@ PRIMITIVE_TYPES: Set[str] = {
|
||||
# go/keep-sorted end
|
||||
}
|
||||
|
||||
_SKIPPED_PLUGIN_FUNCTIONS: List[str] = [
|
||||
_SKIPPED_PLUGIN_FUNCTIONS = (
|
||||
# go/keep-sorted start
|
||||
"mj_getPluginConfig",
|
||||
"mj_loadAllPluginLibraries",
|
||||
@@ -59,10 +59,10 @@ _SKIPPED_PLUGIN_FUNCTIONS: List[str] = [
|
||||
"mjp_registerResourceProvider",
|
||||
"mjp_resourceProviderCount",
|
||||
# go/keep-sorted end
|
||||
]
|
||||
)
|
||||
|
||||
# Functions that are bound as class methods
|
||||
_SKIPPED_CLASS_METHODS: List[str] = [
|
||||
_SKIPPED_CLASS_METHODS = (
|
||||
# go/keep-sorted start
|
||||
"mj_compile",
|
||||
"mj_copyData",
|
||||
@@ -81,15 +81,15 @@ _SKIPPED_CLASS_METHODS: List[str] = [
|
||||
"mj_saveXML", # TODO(manevi): Bind this function.
|
||||
"mj_saveXMLString", # TODO(manevi): Bind this function.
|
||||
# go/keep-sorted end
|
||||
]
|
||||
)
|
||||
|
||||
# Omitted because not very useful
|
||||
_SKIPPED_WRITABLE_ERROR: List[str] = [
|
||||
_SKIPPED_WRITABLE_ERROR = (
|
||||
"mj_printSchema",
|
||||
]
|
||||
)
|
||||
|
||||
# Omitted thread management functions
|
||||
_SKIPPED_THREAD_FUNCTIONS: List[str] = [
|
||||
_SKIPPED_THREAD_FUNCTIONS = (
|
||||
# go/keep-sorted start
|
||||
"mju_bindThreadPool",
|
||||
"mju_defaultTask",
|
||||
@@ -98,10 +98,10 @@ _SKIPPED_THREAD_FUNCTIONS: List[str] = [
|
||||
"mju_threadPoolDestroy",
|
||||
"mju_threadPoolEnqueue",
|
||||
# go/keep-sorted end
|
||||
]
|
||||
)
|
||||
|
||||
# Omitted asset cache functions
|
||||
_SKIPPED_ASSET_CACHE_FUNCTIONS: List[str] = [
|
||||
_SKIPPED_ASSET_CACHE_FUNCTIONS = (
|
||||
# go/keep-sorted start
|
||||
"mj_clearCache",
|
||||
"mj_getCache",
|
||||
@@ -109,10 +109,10 @@ _SKIPPED_ASSET_CACHE_FUNCTIONS: List[str] = [
|
||||
"mj_getCacheSize",
|
||||
"mj_setCacheCapacity",
|
||||
# go/keep-sorted end
|
||||
]
|
||||
)
|
||||
|
||||
# Omitted Virtual Filesystem (VFS) functions
|
||||
_SKIPPED_VFS_FUNCTIONS: List[str] = [
|
||||
_SKIPPED_VFS_FUNCTIONS = (
|
||||
# go/keep-sorted start
|
||||
"mj_addBufferVFS",
|
||||
"mj_addFileVFS",
|
||||
@@ -120,10 +120,10 @@ _SKIPPED_VFS_FUNCTIONS: List[str] = [
|
||||
"mj_deleteFileVFS",
|
||||
"mj_deleteVFS",
|
||||
# go/keep-sorted end
|
||||
]
|
||||
)
|
||||
|
||||
# Omitted irrelevant visual functions
|
||||
_SKIPPED_VISUAL_FUNCTIONS: List[str] = [
|
||||
_SKIPPED_VISUAL_FUNCTIONS = (
|
||||
# go/keep-sorted start
|
||||
"mjv_averageCamera",
|
||||
"mjv_copyData",
|
||||
@@ -132,9 +132,9 @@ _SKIPPED_VISUAL_FUNCTIONS: List[str] = [
|
||||
"mjv_freeScene",
|
||||
"mjv_makeScene",
|
||||
# go/keep-sorted end
|
||||
]
|
||||
)
|
||||
|
||||
_SKIPPED_MEMORY_FUNCTIONS: List[str] = [
|
||||
_SKIPPED_MEMORY_FUNCTIONS = (
|
||||
# go/keep-sorted start
|
||||
"mj_freeLastXML",
|
||||
"mj_freeStack",
|
||||
@@ -158,9 +158,9 @@ _SKIPPED_MEMORY_FUNCTIONS: List[str] = [
|
||||
"mju_warning_i",
|
||||
"mju_warning_s",
|
||||
# go/keep-sorted end
|
||||
]
|
||||
)
|
||||
|
||||
_SKIPPED_GETTERS_AND_SETTERS: List[str] = [
|
||||
_SKIPPED_GETTERS_AND_SETTERS = (
|
||||
# go/keep-sorted start
|
||||
"mjs_appendFloatVec",
|
||||
"mjs_appendIntVec",
|
||||
@@ -179,26 +179,26 @@ _SKIPPED_GETTERS_AND_SETTERS: List[str] = [
|
||||
"mjs_setStringVec",
|
||||
"mjs_setUserValue",
|
||||
# go/keep-sorted end
|
||||
]
|
||||
)
|
||||
|
||||
_SKIPPED_UTILITY_FUNCTIONS: List[str] = [
|
||||
_SKIPPED_UTILITY_FUNCTIONS = (
|
||||
# go/keep-sorted start
|
||||
"mju_getXMLDependencies",
|
||||
# go/keep-sorted end
|
||||
]
|
||||
)
|
||||
|
||||
# Functions that require special wrappers.
|
||||
# These functions are not bound automatically but are written by hand instead.
|
||||
MANUAL_WRAPPER_FUNCTIONS: List[str] = [
|
||||
MANUAL_WRAPPER_FUNCTIONS = (
|
||||
# go/keep-sorted start
|
||||
"mj_saveLastXML",
|
||||
"mj_setLengthRange",
|
||||
"mju_error",
|
||||
# go/keep-sorted end
|
||||
]
|
||||
)
|
||||
|
||||
# List of functions that should be skipped during the code generation process.
|
||||
SKIPPED_FUNCTIONS: List[str] = (
|
||||
SKIPPED_FUNCTIONS = (
|
||||
_SKIPPED_CLASS_METHODS
|
||||
+ _SKIPPED_THREAD_FUNCTIONS
|
||||
+ _SKIPPED_MEMORY_FUNCTIONS
|
||||
@@ -212,7 +212,7 @@ SKIPPED_FUNCTIONS: List[str] = (
|
||||
)
|
||||
|
||||
# List of structs that should be skipped during the code generation process.
|
||||
SKIPPED_STRUCTS: List[str] = [
|
||||
SKIPPED_STRUCTS = (
|
||||
# go/keep-sorted start
|
||||
"mjCache",
|
||||
"mjSDF",
|
||||
@@ -229,14 +229,22 @@ SKIPPED_STRUCTS: List[str] = [
|
||||
"mjuiThemeColor",
|
||||
"mjuiThemeSpacing"
|
||||
# go/keep-sorted end
|
||||
]
|
||||
)
|
||||
|
||||
# These structs require specific function calls for creation and/or deletion,
|
||||
# or some of their fields need to be handled manually for now;
|
||||
# making their wrapper constructors/destructors non-trivial.
|
||||
MANUAL_STRUCTS: List[str] = [
|
||||
"MjvScene",
|
||||
]
|
||||
# Structs for which header generation is done manually.
|
||||
# mjvScene is included here because buffer sizes need to be calculated based on
|
||||
# introspect doc strings, which was considered a brittle unreliable solution in
|
||||
# the past.
|
||||
MANUAL_STRUCTS_HEADERS = (
|
||||
"mjvScene",
|
||||
)
|
||||
# Structs for which source code generation is done manually.
|
||||
MANUAL_STRUCTS_SOURCES = (
|
||||
"mjData",
|
||||
"mjModel",
|
||||
"mjvScene",
|
||||
"mjSpec",
|
||||
)
|
||||
|
||||
# Dictionary that maps anonymous structs to their parent struct and field name.
|
||||
# Anonymous structs are not defined as independent structs in the MuJoCo
|
||||
@@ -262,7 +270,7 @@ STRUCTS_TO_BIND: List[str] = list(
|
||||
)
|
||||
|
||||
# List of structs that do not have a default constructor.
|
||||
NO_DEFAULT_CONSTRUCTORS: List[str] = [
|
||||
NO_DEFAULT_CONSTRUCTORS = (
|
||||
# go/keep-sorted start
|
||||
"mjContact",
|
||||
"mjSolverStat",
|
||||
@@ -277,12 +285,12 @@ NO_DEFAULT_CONSTRUCTORS: List[str] = [
|
||||
"mjvGLCamera",
|
||||
"mjvLight",
|
||||
# go/keep-sorted end
|
||||
]
|
||||
)
|
||||
|
||||
# List of `mjData` fields where the array size should be obtained from other
|
||||
# `mjData` members, instead of from `mjModel` members. This is typically the
|
||||
# case for fields that are dynamically allocated during the simulation.
|
||||
MJDATA_SIZES: List[str] = [
|
||||
MJDATA_SIZES = (
|
||||
# go/keep-sorted start
|
||||
"contact",
|
||||
"efc_AR",
|
||||
@@ -352,7 +360,7 @@ MJDATA_SIZES: List[str] = [
|
||||
"map_efc2iefc",
|
||||
"map_iefc2efc",
|
||||
# go/keep-sorted end
|
||||
]
|
||||
)
|
||||
|
||||
# Fields that should be entirely omitted from the bindings.
|
||||
SKIPPED_FIELDS: Dict[str, List[str]] = {}
|
||||
|
||||
Reference in New Issue
Block a user