Add a section for element casting in the function API reference, move these functions to the end.

PiperOrigin-RevId: 677783917
Change-Id: I5042e7df20f2a2e0ecfe01a85a1969ccfc2307cd
This commit is contained in:
Yuval Tassa
2024-09-23 07:24:53 -07:00
committed by Copybara-Service
parent 0ba11b9623
commit 41ea95f077
5 changed files with 704 additions and 696 deletions
+1
View File
@@ -52,5 +52,6 @@ API function can be classified as:
- :ref:`Attribute getters<AttributeGetters>`.
- :ref:`Spec utilities<SpecUtilities>`.
- :ref:`Element initialization<ElementInitialization>`.
- :ref:`Element casting<ElementCasting>`.
.. include:: functions.rst
+220 -216
View File
@@ -4225,222 +4225,6 @@ mjs_nextElement
Return spec's next element; return NULL if element is last.
.. _mjs_asBody:
mjs_asBody
~~~~~~~~~~
.. mujoco-include:: mjs_asBody
Safely cast an element as mjsBody, or return NULL if the element is not an mjsBody.
.. _mjs_asGeom:
mjs_asGeom
~~~~~~~~~~
.. mujoco-include:: mjs_asGeom
Safely cast an element as mjsGeom, or return NULL if the element is not an mjsGeom.
.. _mjs_asJoint:
mjs_asJoint
~~~~~~~~~~~
.. mujoco-include:: mjs_asJoint
Safely cast an element as mjsJoint, or return NULL if the element is not an mjsJoint.
.. _mjs_asSite:
mjs_asSite
~~~~~~~~~~
.. mujoco-include:: mjs_asSite
Safely cast an element as mjsSite, or return NULL if the element is not an mjsSite.
.. _mjs_asCamera:
mjs_asCamera
~~~~~~~~~~~~
.. mujoco-include:: mjs_asCamera
Safely cast an element as mjsCamera, or return NULL if the element is not an mjsCamera.
.. _mjs_asLight:
mjs_asLight
~~~~~~~~~~~
.. mujoco-include:: mjs_asLight
Safely cast an element as mjsLight, or return NULL if the element is not an mjsLight.
.. _mjs_asFrame:
mjs_asFrame
~~~~~~~~~~~
.. mujoco-include:: mjs_asFrame
Safely cast an element as mjsFrame, or return NULL if the element is not an mjsFrame.
.. _mjs_asActuator:
mjs_asActuator
~~~~~~~~~~~~~~
.. mujoco-include:: mjs_asActuator
Safely cast an element as mjsActuator, or return NULL if the element is not an mjsActuator.
.. _mjs_asSensor:
mjs_asSensor
~~~~~~~~~~~~
.. mujoco-include:: mjs_asSensor
Safely cast an element as mjsSensor, or return NULL if the element is not an mjsSensor.
.. _mjs_asFlex:
mjs_asFlex
~~~~~~~~~~
.. mujoco-include:: mjs_asFlex
Safely cast an element as mjsFlex, or return NULL if the element is not an mjsFlex.
.. _mjs_asPair:
mjs_asPair
~~~~~~~~~~
.. mujoco-include:: mjs_asPair
Safely cast an element as mjsPair, or return NULL if the element is not an mjsPair.
.. _mjs_asEquality:
mjs_asEquality
~~~~~~~~~~~~~~
.. mujoco-include:: mjs_asEquality
Safely cast an element as mjsEquality, or return NULL if the element is not an mjsEquality.
.. _mjs_asExclude:
mjs_asExclude
~~~~~~~~~~~~~
.. mujoco-include:: mjs_asExclude
Safely cast an element as mjsExclude, or return NULL if the element is not an mjsExclude.
.. _mjs_asTendon:
mjs_asTendon
~~~~~~~~~~~~
.. mujoco-include:: mjs_asTendon
Safely cast an element as mjsTendon, or return NULL if the element is not an mjsTendon.
.. _mjs_asNumeric:
mjs_asNumeric
~~~~~~~~~~~~~
.. mujoco-include:: mjs_asNumeric
Safely cast an element as mjsNumeric, or return NULL if the element is not an mjsNumeric.
.. _mjs_asText:
mjs_asText
~~~~~~~~~~
.. mujoco-include:: mjs_asText
Safely cast an element as mjsText, or return NULL if the element is not an mjsText.
.. _mjs_asTuple:
mjs_asTuple
~~~~~~~~~~~
.. mujoco-include:: mjs_asTuple
Safely cast an element as mjsTuple, or return NULL if the element is not an mjsTuple.
.. _mjs_asKey:
mjs_asKey
~~~~~~~~~
.. mujoco-include:: mjs_asKey
Safely cast an element as mjsKey, or return NULL if the element is not an mjsKey.
.. _mjs_asMesh:
mjs_asMesh
~~~~~~~~~~
.. mujoco-include:: mjs_asMesh
Safely cast an element as mjsMesh, or return NULL if the element is not an mjsMesh.
.. _mjs_asHField:
mjs_asHField
~~~~~~~~~~~~
.. mujoco-include:: mjs_asHField
Safely cast an element as mjsHField, or return NULL if the element is not an mjsHField.
.. _mjs_asSkin:
mjs_asSkin
~~~~~~~~~~
.. mujoco-include:: mjs_asSkin
Safely cast an element as mjsSkin, or return NULL if the element is not an mjsSkin.
.. _mjs_asTexture:
mjs_asTexture
~~~~~~~~~~~~~
.. mujoco-include:: mjs_asTexture
Safely cast an element as mjsTexture, or return NULL if the element is not an mjsTexture.
.. _mjs_asMaterial:
mjs_asMaterial
~~~~~~~~~~~~~~
.. mujoco-include:: mjs_asMaterial
Safely cast an element as mjsMaterial, or return NULL if the element is not an mjsMaterial.
.. _mjs_asPlugin:
mjs_asPlugin
~~~~~~~~~~~~
.. mujoco-include:: mjs_asPlugin
Safely cast an element as mjsPlugin, or return NULL if the element is not an mjsPlugin.
.. _AttributeSetters:
Attribute setters
@@ -4835,3 +4619,223 @@ mjs_defaultPlugin
Default plugin attributes.
.. _ElementCasting:
Element casting
^^^^^^^^^^^^^^^
.. _mjs_asBody:
mjs_asBody
~~~~~~~~~~
.. mujoco-include:: mjs_asBody
Safely cast an element as mjsBody, or return NULL if the element is not an mjsBody.
.. _mjs_asGeom:
mjs_asGeom
~~~~~~~~~~
.. mujoco-include:: mjs_asGeom
Safely cast an element as mjsGeom, or return NULL if the element is not an mjsGeom.
.. _mjs_asJoint:
mjs_asJoint
~~~~~~~~~~~
.. mujoco-include:: mjs_asJoint
Safely cast an element as mjsJoint, or return NULL if the element is not an mjsJoint.
.. _mjs_asSite:
mjs_asSite
~~~~~~~~~~
.. mujoco-include:: mjs_asSite
Safely cast an element as mjsSite, or return NULL if the element is not an mjsSite.
.. _mjs_asCamera:
mjs_asCamera
~~~~~~~~~~~~
.. mujoco-include:: mjs_asCamera
Safely cast an element as mjsCamera, or return NULL if the element is not an mjsCamera.
.. _mjs_asLight:
mjs_asLight
~~~~~~~~~~~
.. mujoco-include:: mjs_asLight
Safely cast an element as mjsLight, or return NULL if the element is not an mjsLight.
.. _mjs_asFrame:
mjs_asFrame
~~~~~~~~~~~
.. mujoco-include:: mjs_asFrame
Safely cast an element as mjsFrame, or return NULL if the element is not an mjsFrame.
.. _mjs_asActuator:
mjs_asActuator
~~~~~~~~~~~~~~
.. mujoco-include:: mjs_asActuator
Safely cast an element as mjsActuator, or return NULL if the element is not an mjsActuator.
.. _mjs_asSensor:
mjs_asSensor
~~~~~~~~~~~~
.. mujoco-include:: mjs_asSensor
Safely cast an element as mjsSensor, or return NULL if the element is not an mjsSensor.
.. _mjs_asFlex:
mjs_asFlex
~~~~~~~~~~
.. mujoco-include:: mjs_asFlex
Safely cast an element as mjsFlex, or return NULL if the element is not an mjsFlex.
.. _mjs_asPair:
mjs_asPair
~~~~~~~~~~
.. mujoco-include:: mjs_asPair
Safely cast an element as mjsPair, or return NULL if the element is not an mjsPair.
.. _mjs_asEquality:
mjs_asEquality
~~~~~~~~~~~~~~
.. mujoco-include:: mjs_asEquality
Safely cast an element as mjsEquality, or return NULL if the element is not an mjsEquality.
.. _mjs_asExclude:
mjs_asExclude
~~~~~~~~~~~~~
.. mujoco-include:: mjs_asExclude
Safely cast an element as mjsExclude, or return NULL if the element is not an mjsExclude.
.. _mjs_asTendon:
mjs_asTendon
~~~~~~~~~~~~
.. mujoco-include:: mjs_asTendon
Safely cast an element as mjsTendon, or return NULL if the element is not an mjsTendon.
.. _mjs_asNumeric:
mjs_asNumeric
~~~~~~~~~~~~~
.. mujoco-include:: mjs_asNumeric
Safely cast an element as mjsNumeric, or return NULL if the element is not an mjsNumeric.
.. _mjs_asText:
mjs_asText
~~~~~~~~~~
.. mujoco-include:: mjs_asText
Safely cast an element as mjsText, or return NULL if the element is not an mjsText.
.. _mjs_asTuple:
mjs_asTuple
~~~~~~~~~~~
.. mujoco-include:: mjs_asTuple
Safely cast an element as mjsTuple, or return NULL if the element is not an mjsTuple.
.. _mjs_asKey:
mjs_asKey
~~~~~~~~~
.. mujoco-include:: mjs_asKey
Safely cast an element as mjsKey, or return NULL if the element is not an mjsKey.
.. _mjs_asMesh:
mjs_asMesh
~~~~~~~~~~
.. mujoco-include:: mjs_asMesh
Safely cast an element as mjsMesh, or return NULL if the element is not an mjsMesh.
.. _mjs_asHField:
mjs_asHField
~~~~~~~~~~~~
.. mujoco-include:: mjs_asHField
Safely cast an element as mjsHField, or return NULL if the element is not an mjsHField.
.. _mjs_asSkin:
mjs_asSkin
~~~~~~~~~~
.. mujoco-include:: mjs_asSkin
Safely cast an element as mjsSkin, or return NULL if the element is not an mjsSkin.
.. _mjs_asTexture:
mjs_asTexture
~~~~~~~~~~~~~
.. mujoco-include:: mjs_asTexture
Safely cast an element as mjsTexture, or return NULL if the element is not an mjsTexture.
.. _mjs_asMaterial:
mjs_asMaterial
~~~~~~~~~~~~~~
.. mujoco-include:: mjs_asMaterial
Safely cast an element as mjsMaterial, or return NULL if the element is not an mjsMaterial.
.. _mjs_asPlugin:
mjs_asPlugin
~~~~~~~~~~~~
.. mujoco-include:: mjs_asPlugin
Safely cast an element as mjsPlugin, or return NULL if the element is not an mjsPlugin.
+24 -24
View File
@@ -3599,30 +3599,6 @@ mjsElement* mjs_firstChild(mjsBody* body, mjtObj type);
mjsElement* mjs_nextChild(mjsBody* body, mjsElement* child);
mjsElement* mjs_firstElement(mjSpec* s, mjtObj type);
mjsElement* mjs_nextElement(mjSpec* s, mjsElement* element);
mjsBody* mjs_asBody(mjsElement* element);
mjsGeom* mjs_asGeom(mjsElement* element);
mjsJoint* mjs_asJoint(mjsElement* element);
mjsSite* mjs_asSite(mjsElement* element);
mjsCamera* mjs_asCamera(mjsElement* element);
mjsLight* mjs_asLight(mjsElement* element);
mjsFrame* mjs_asFrame(mjsElement* element);
mjsActuator* mjs_asActuator(mjsElement* element);
mjsSensor* mjs_asSensor(mjsElement* element);
mjsFlex* mjs_asFlex(mjsElement* element);
mjsPair* mjs_asPair(mjsElement* element);
mjsEquality* mjs_asEquality(mjsElement* element);
mjsExclude* mjs_asExclude(mjsElement* element);
mjsTendon* mjs_asTendon(mjsElement* element);
mjsNumeric* mjs_asNumeric(mjsElement* element);
mjsText* mjs_asText(mjsElement* element);
mjsTuple* mjs_asTuple(mjsElement* element);
mjsKey* mjs_asKey(mjsElement* element);
mjsMesh* mjs_asMesh(mjsElement* element);
mjsHField* mjs_asHField(mjsElement* element);
mjsSkin* mjs_asSkin(mjsElement* element);
mjsTexture* mjs_asTexture(mjsElement* element);
mjsMaterial* mjs_asMaterial(mjsElement* element);
mjsPlugin* mjs_asPlugin(mjsElement* element);
void mjs_setBuffer(mjByteVec* dest, const void* array, int size);
void mjs_setString(mjString* dest, const char* text);
void mjs_setStringVec(mjStringVec* dest, const char* text);
@@ -3666,4 +3642,28 @@ void mjs_defaultText(mjsText* text);
void mjs_defaultTuple(mjsTuple* tuple);
void mjs_defaultKey(mjsKey* key);
void mjs_defaultPlugin(mjsPlugin* plugin);
mjsBody* mjs_asBody(mjsElement* element);
mjsGeom* mjs_asGeom(mjsElement* element);
mjsJoint* mjs_asJoint(mjsElement* element);
mjsSite* mjs_asSite(mjsElement* element);
mjsCamera* mjs_asCamera(mjsElement* element);
mjsLight* mjs_asLight(mjsElement* element);
mjsFrame* mjs_asFrame(mjsElement* element);
mjsActuator* mjs_asActuator(mjsElement* element);
mjsSensor* mjs_asSensor(mjsElement* element);
mjsFlex* mjs_asFlex(mjsElement* element);
mjsPair* mjs_asPair(mjsElement* element);
mjsEquality* mjs_asEquality(mjsElement* element);
mjsExclude* mjs_asExclude(mjsElement* element);
mjsTendon* mjs_asTendon(mjsElement* element);
mjsNumeric* mjs_asNumeric(mjsElement* element);
mjsText* mjs_asText(mjsElement* element);
mjsTuple* mjs_asTuple(mjsElement* element);
mjsKey* mjs_asKey(mjsElement* element);
mjsMesh* mjs_asMesh(mjsElement* element);
mjsHField* mjs_asHField(mjsElement* element);
mjsSkin* mjs_asSkin(mjsElement* element);
mjsTexture* mjs_asTexture(mjsElement* element);
mjsMaterial* mjs_asMaterial(mjsElement* element);
mjsPlugin* mjs_asPlugin(mjsElement* element);
// NOLINTEND