Add mjs_getOriginSpec to retrieve the original spec of an element.

The new function mjs_getOriginSpec returns the mjSpec that was used to define a given mjsElement. Unlike mjs_getSpec, this value remains constant even after the element has been attached to a different model.

PiperOrigin-RevId: 911930951
Change-Id: Ia9cd79d9dfabc513d6121eadcffc5d41075224c9
This commit is contained in:
Sam Haves
2026-05-07 06:32:54 -07:00
committed by Copybara-Service
parent 8b06fe4c16
commit ec50260e26
9 changed files with 90 additions and 0 deletions
+16
View File
@@ -11126,6 +11126,22 @@ FUNCTIONS: Mapping[str, FunctionDecl] = dict([
),
doc='Get spec from body.',
)),
('mjs_getOriginSpec',
FunctionDecl(
name='mjs_getOriginSpec',
return_type=PointerType(
inner_type=ValueType(name='mjSpec'),
),
parameters=(
FunctionParameterDecl(
name='element',
type=PointerType(
inner_type=ValueType(name='mjsElement', is_const=True),
),
),
),
doc='get spec that originally defined an element contrary to mjs_getSpec, this does not change after attachment', # pylint: disable=line-too-long
)),
('mjs_getCompiler',
FunctionDecl(
name='mjs_getCompiler',