Introduce mjtBool for boolean types.
PiperOrigin-RevId: 920201340 Change-Id: I3b19c11a00357e06a1df08b8819832955c37f9ff
This commit is contained in:
committed by
Copybara-Service
parent
466d068089
commit
7667e7110e
@@ -84,13 +84,29 @@ changed by the user.
|
|||||||
mjtByte
|
mjtByte
|
||||||
^^^^^^^
|
^^^^^^^
|
||||||
|
|
||||||
Byte type used to represent boolean variables.
|
Byte type used to represent small integers and binary data.
|
||||||
|
|
||||||
.. code-block:: C
|
.. code-block:: C
|
||||||
|
|
||||||
typedef unsigned char mjtByte;
|
typedef unsigned char mjtByte;
|
||||||
|
|
||||||
|
|
||||||
|
.. _mjtBool:
|
||||||
|
|
||||||
|
mjtBool
|
||||||
|
^^^^^^^
|
||||||
|
|
||||||
|
Boolean type used to represent true/false values.
|
||||||
|
|
||||||
|
.. code-block:: C
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
typedef _Bool mjtBool;
|
||||||
|
#else
|
||||||
|
typedef bool mjtBool;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
.. _mjtSize:
|
.. _mjtSize:
|
||||||
|
|
||||||
mjtSize
|
mjtSize
|
||||||
|
|||||||
@@ -230,8 +230,7 @@ to which the symbol belongs. First we list the prefixes corresponding to type de
|
|||||||
Core simulation data structure (C struct), for example :ref:`mjModel`. If all characters
|
Core simulation data structure (C struct), for example :ref:`mjModel`. If all characters
|
||||||
after the prefix are capital, for example :ref:`mjMIN`, this is a macro or a symbol (#define).
|
after the prefix are capital, for example :ref:`mjMIN`, this is a macro or a symbol (#define).
|
||||||
``mjt``
|
``mjt``
|
||||||
Primitive type, for example :ref:`mjtGeom`. Except for mjtByte and mjtNum, all other
|
Primitive type, for example :ref:`mjtNum` and :ref:`mjtGeom`. Most types in this family are enums.
|
||||||
definitions in this family are enums.
|
|
||||||
``mjf``
|
``mjf``
|
||||||
Callback function type, for example :ref:`mjfGeneric`.
|
Callback function type, for example :ref:`mjfGeneric`.
|
||||||
``mjv``
|
``mjv``
|
||||||
|
|||||||
@@ -36,16 +36,17 @@
|
|||||||
typedef char mj_assert_##type[sizeof(type) == (size) ? 1 : -1]
|
typedef char mj_assert_##type[sizeof(type) == (size) ? 1 : -1]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// mjtnum.h
|
// primitive types
|
||||||
MJ_ASSERT_SIZE(mjtByte, 1);
|
|
||||||
MJ_ASSERT_SIZE(mjtSize, 8);
|
|
||||||
#if !defined(mjUSESINGLE)
|
#if !defined(mjUSESINGLE)
|
||||||
MJ_ASSERT_SIZE(mjtNum, 8);
|
MJ_ASSERT_SIZE(mjtNum, 8);
|
||||||
#else
|
#else
|
||||||
MJ_ASSERT_SIZE(mjtNum, 4);
|
MJ_ASSERT_SIZE(mjtNum, 4);
|
||||||
#endif
|
#endif
|
||||||
|
MJ_ASSERT_SIZE(mjtByte, 1);
|
||||||
|
MJ_ASSERT_SIZE(mjtBool, 1);
|
||||||
|
MJ_ASSERT_SIZE(mjtSize, 8);
|
||||||
|
|
||||||
// mjmodel.h
|
// mjModel enums
|
||||||
MJ_ASSERT_SIZE(mjtDisableBit, 4);
|
MJ_ASSERT_SIZE(mjtDisableBit, 4);
|
||||||
MJ_ASSERT_SIZE(mjtEnableBit, 4);
|
MJ_ASSERT_SIZE(mjtEnableBit, 4);
|
||||||
MJ_ASSERT_SIZE(mjtJoint, 4);
|
MJ_ASSERT_SIZE(mjtJoint, 4);
|
||||||
@@ -79,7 +80,7 @@ MJ_ASSERT_SIZE(mjtLRMode, 4);
|
|||||||
MJ_ASSERT_SIZE(mjtFlexSelf, 4);
|
MJ_ASSERT_SIZE(mjtFlexSelf, 4);
|
||||||
MJ_ASSERT_SIZE(mjtSDFType, 4);
|
MJ_ASSERT_SIZE(mjtSDFType, 4);
|
||||||
|
|
||||||
// mjdata.h
|
// mjData enums
|
||||||
MJ_ASSERT_SIZE(mjtState, 4);
|
MJ_ASSERT_SIZE(mjtState, 4);
|
||||||
MJ_ASSERT_SIZE(mjtConstraint, 4);
|
MJ_ASSERT_SIZE(mjtConstraint, 4);
|
||||||
MJ_ASSERT_SIZE(mjtConstraintState, 4);
|
MJ_ASSERT_SIZE(mjtConstraintState, 4);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#ifndef MUJOCO_INCLUDE_MJTYPE_H_
|
#ifndef MUJOCO_INCLUDE_MJTYPE_H_
|
||||||
#define MUJOCO_INCLUDE_MJTYPE_H_
|
#define MUJOCO_INCLUDE_MJTYPE_H_
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -33,9 +34,13 @@
|
|||||||
|
|
||||||
//---------------------------------- byte definition -----------------------------------------------
|
//---------------------------------- byte definition -----------------------------------------------
|
||||||
|
|
||||||
typedef unsigned char mjtByte; // used for true/false
|
typedef unsigned char mjtByte; // used for small integers and binary data
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
typedef _Bool mjtBool; // used for boolean values
|
||||||
|
#else
|
||||||
|
typedef bool mjtBool; // used for boolean values
|
||||||
|
#endif
|
||||||
|
|
||||||
//---------------------------------- size definition -----------------------------------------------
|
//---------------------------------- size definition -----------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from introspect import ast_nodes
|
|||||||
from introspect import structs
|
from introspect import structs
|
||||||
|
|
||||||
|
|
||||||
SCALAR_TYPES = {'int', 'double', 'float', 'mjtByte', 'mjtNum'}
|
SCALAR_TYPES = {'int', 'double', 'float', 'mjtByte', 'mjtBool', 'mjtNum'}
|
||||||
|
|
||||||
# pylint: disable=bad-whitespace
|
# pylint: disable=bad-whitespace
|
||||||
# key, parent, default, listname, objtype
|
# key, parent, default, listname, objtype
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ PRIMITIVE_TYPES: Set[str] = {
|
|||||||
"float",
|
"float",
|
||||||
"int",
|
"int",
|
||||||
"mjtByte",
|
"mjtByte",
|
||||||
|
"mjtBool",
|
||||||
"mjtMeshBuiltin",
|
"mjtMeshBuiltin",
|
||||||
"mjtNum",
|
"mjtNum",
|
||||||
"mjtObj", # Adding this to the primitives because it is used as int,
|
"mjtObj", # Adding this to the primitives because it is used as int,
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ def get_param_string(p: ast_nodes.FunctionParameterDecl) -> str:
|
|||||||
return f"const String& {p.name}"
|
return f"const String& {p.name}"
|
||||||
elif (
|
elif (
|
||||||
p.type.inner_type.name
|
p.type.inner_type.name
|
||||||
in ["int", "float", "double", "mjtNum", "mjtByte"]
|
in ["int", "float", "double", "mjtNum", "mjtByte", "mjtBool"]
|
||||||
and p.type.inner_type.is_const
|
and p.type.inner_type.is_const
|
||||||
):
|
):
|
||||||
return f"const NumberArray& {p.name}"
|
return f"const NumberArray& {p.name}"
|
||||||
|
|||||||
Reference in New Issue
Block a user