Rename mjBuffer to mjByteVec.
PiperOrigin-RevId: 664872558 Change-Id: I7b003374c390958667635fb21089faf2ece54b14
This commit is contained in:
committed by
Copybara-Service
parent
4aab00fa2d
commit
5d91231d31
@@ -1393,7 +1393,7 @@ Alternative orientation specifiers.
|
|||||||
|
|
||||||
.. _ArrayHandles:
|
.. _ArrayHandles:
|
||||||
|
|
||||||
.. _mjBuffer:
|
.. _mjByteVec:
|
||||||
|
|
||||||
.. _mjString:
|
.. _mjString:
|
||||||
|
|
||||||
@@ -1419,7 +1419,6 @@ C handles for C++ strings and vector types. When using from C, use the provided
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
// C++: defined to be compatible with corresponding std types
|
// C++: defined to be compatible with corresponding std types
|
||||||
using mjBuffer = std::vector<std::byte>;
|
|
||||||
using mjString = std::string;
|
using mjString = std::string;
|
||||||
using mjStringVec = std::vector<std::string>;
|
using mjStringVec = std::vector<std::string>;
|
||||||
using mjIntVec = std::vector<int>;
|
using mjIntVec = std::vector<int>;
|
||||||
@@ -1427,9 +1426,9 @@ C handles for C++ strings and vector types. When using from C, use the provided
|
|||||||
using mjFloatVec = std::vector<float>;
|
using mjFloatVec = std::vector<float>;
|
||||||
using mjFloatVecVec = std::vector<std::vector<float>>;
|
using mjFloatVecVec = std::vector<std::vector<float>>;
|
||||||
using mjDoubleVec = std::vector<double>;
|
using mjDoubleVec = std::vector<double>;
|
||||||
|
using mjByteVec = std::vector<std::byte>;
|
||||||
#else
|
#else
|
||||||
// C: opaque types
|
// C: opaque types
|
||||||
typedef void mjBuffer;
|
|
||||||
typedef void mjString;
|
typedef void mjString;
|
||||||
typedef void mjStringVec;
|
typedef void mjStringVec;
|
||||||
typedef void mjIntVec;
|
typedef void mjIntVec;
|
||||||
@@ -1437,6 +1436,7 @@ C handles for C++ strings and vector types. When using from C, use the provided
|
|||||||
typedef void mjFloatVec;
|
typedef void mjFloatVec;
|
||||||
typedef void mjFloatVecVec;
|
typedef void mjFloatVecVec;
|
||||||
typedef void mjDoubleVec;
|
typedef void mjDoubleVec;
|
||||||
|
typedef void mjByteVec;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2028,7 +2028,7 @@ typedef struct mjsTexture_ { // texture specification
|
|||||||
mjStringVec* cubefiles; // different file for each side of the cube
|
mjStringVec* cubefiles; // different file for each side of the cube
|
||||||
|
|
||||||
// method 4: from buffer read by user
|
// method 4: from buffer read by user
|
||||||
mjBuffer* data; // texture data
|
mjByteVec* data; // texture data
|
||||||
|
|
||||||
// flip options
|
// flip options
|
||||||
mjtByte hflip; // horizontal flip
|
mjtByte hflip; // horizontal flip
|
||||||
@@ -3588,7 +3588,7 @@ mjsHField* mjs_asHField(mjsElement* element);
|
|||||||
mjsSkin* mjs_asSkin(mjsElement* element);
|
mjsSkin* mjs_asSkin(mjsElement* element);
|
||||||
mjsTexture* mjs_asTexture(mjsElement* element);
|
mjsTexture* mjs_asTexture(mjsElement* element);
|
||||||
mjsMaterial* mjs_asMaterial(mjsElement* element);
|
mjsMaterial* mjs_asMaterial(mjsElement* element);
|
||||||
void mjs_setBuffer(mjBuffer* dest, const void* array, int size);
|
void mjs_setBuffer(mjByteVec* dest, const void* array, int size);
|
||||||
void mjs_setString(mjString* dest, const char* text);
|
void mjs_setString(mjString* dest, const char* text);
|
||||||
void mjs_setStringVec(mjStringVec* dest, const char* text);
|
void mjs_setStringVec(mjStringVec* dest, const char* text);
|
||||||
mjtByte mjs_setInStringVec(mjStringVec* dest, int i, const char* text);
|
mjtByte mjs_setInStringVec(mjStringVec* dest, int i, const char* text);
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ extern "C" {
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
// C++: defined to be compatible with corresponding std types
|
// C++: defined to be compatible with corresponding std types
|
||||||
using mjBuffer = std::vector<std::byte>;
|
|
||||||
using mjString = std::string;
|
using mjString = std::string;
|
||||||
using mjStringVec = std::vector<std::string>;
|
using mjStringVec = std::vector<std::string>;
|
||||||
using mjIntVec = std::vector<int>;
|
using mjIntVec = std::vector<int>;
|
||||||
@@ -41,9 +40,9 @@ extern "C" {
|
|||||||
using mjFloatVec = std::vector<float>;
|
using mjFloatVec = std::vector<float>;
|
||||||
using mjFloatVecVec = std::vector<std::vector<float>>;
|
using mjFloatVecVec = std::vector<std::vector<float>>;
|
||||||
using mjDoubleVec = std::vector<double>;
|
using mjDoubleVec = std::vector<double>;
|
||||||
|
using mjByteVec = std::vector<std::byte>;
|
||||||
#else
|
#else
|
||||||
// C: opaque types
|
// C: opaque types
|
||||||
typedef void mjBuffer;
|
|
||||||
typedef void mjString;
|
typedef void mjString;
|
||||||
typedef void mjStringVec;
|
typedef void mjStringVec;
|
||||||
typedef void mjIntVec;
|
typedef void mjIntVec;
|
||||||
@@ -51,6 +50,7 @@ extern "C" {
|
|||||||
typedef void mjFloatVec;
|
typedef void mjFloatVec;
|
||||||
typedef void mjFloatVecVec;
|
typedef void mjFloatVecVec;
|
||||||
typedef void mjDoubleVec;
|
typedef void mjDoubleVec;
|
||||||
|
typedef void mjByteVec;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -515,7 +515,7 @@ typedef struct mjsTexture_ { // texture specification
|
|||||||
mjStringVec* cubefiles; // different file for each side of the cube
|
mjStringVec* cubefiles; // different file for each side of the cube
|
||||||
|
|
||||||
// method 4: from buffer read by user
|
// method 4: from buffer read by user
|
||||||
mjBuffer* data; // texture data
|
mjByteVec* data; // texture data
|
||||||
|
|
||||||
// flip options
|
// flip options
|
||||||
mjtByte hflip; // horizontal flip
|
mjtByte hflip; // horizontal flip
|
||||||
|
|||||||
@@ -1630,7 +1630,7 @@ MJAPI mjsMaterial* mjs_asMaterial(mjsElement* element);
|
|||||||
//---------------------------------- Attribute setters ---------------------------------------------
|
//---------------------------------- Attribute setters ---------------------------------------------
|
||||||
|
|
||||||
// Copy buffer.
|
// Copy buffer.
|
||||||
MJAPI void mjs_setBuffer(mjBuffer* dest, const void* array, int size);
|
MJAPI void mjs_setBuffer(mjByteVec* dest, const void* array, int size);
|
||||||
|
|
||||||
// Copy text to string.
|
// Copy text to string.
|
||||||
MJAPI void mjs_setString(mjString* dest, const char* text);
|
MJAPI void mjs_setString(mjString* dest, const char* text);
|
||||||
|
|||||||
@@ -10253,7 +10253,7 @@ FUNCTIONS: Mapping[str, FunctionDecl] = dict([
|
|||||||
FunctionParameterDecl(
|
FunctionParameterDecl(
|
||||||
name='dest',
|
name='dest',
|
||||||
type=PointerType(
|
type=PointerType(
|
||||||
inner_type=ValueType(name='mjBuffer'),
|
inner_type=ValueType(name='mjByteVec'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
FunctionParameterDecl(
|
FunctionParameterDecl(
|
||||||
|
|||||||
@@ -10014,7 +10014,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='data',
|
name='data',
|
||||||
type=PointerType(
|
type=PointerType(
|
||||||
inner_type=ValueType(name='mjBuffer'),
|
inner_type=ValueType(name='mjByteVec'),
|
||||||
),
|
),
|
||||||
doc='texture data',
|
doc='texture data',
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ def _ptr_binding_code(
|
|||||||
self.{fullvarname}->push_back(py::cast<{vartype}>(val));
|
self.{fullvarname}->push_back(py::cast<{vartype}>(val));
|
||||||
}}
|
}}
|
||||||
}}, py::return_value_policy::reference_internal);"""
|
}}, py::return_value_policy::reference_internal);"""
|
||||||
elif vartype == 'mjBuffer': # C++ buffer -> Python list
|
elif vartype == 'mjByteVec': # C++ buffer -> Python list
|
||||||
return f"""\
|
return f"""\
|
||||||
{classname}.def_property(
|
{classname}.def_property(
|
||||||
"{varname}",
|
"{varname}",
|
||||||
|
|||||||
@@ -885,7 +885,7 @@ mjsMaterial* mjs_asMaterial(mjsElement* element) {
|
|||||||
|
|
||||||
|
|
||||||
// copy buffer to destination buffer
|
// copy buffer to destination buffer
|
||||||
void mjs_setBuffer(mjBuffer* dest, const void* array, int size) {
|
void mjs_setBuffer(mjByteVec* dest, const void* array, int size) {
|
||||||
const std::byte* buffer = static_cast<const std::byte*>(array);
|
const std::byte* buffer = static_cast<const std::byte*>(array);
|
||||||
dest->clear();
|
dest->clear();
|
||||||
dest->reserve(size);
|
dest->reserve(size);
|
||||||
|
|||||||
+1
-1
@@ -303,7 +303,7 @@ MJAPI mjsMaterial* mjs_asMaterial(mjsElement* element);
|
|||||||
//---------------------------------- Attribute setters ---------------------------------------------
|
//---------------------------------- Attribute setters ---------------------------------------------
|
||||||
|
|
||||||
// Copy buffer.
|
// Copy buffer.
|
||||||
MJAPI void mjs_setBuffer(mjBuffer* dest, const void* array, int size);
|
MJAPI void mjs_setBuffer(mjByteVec* dest, const void* array, int size);
|
||||||
|
|
||||||
// Copy text to string.
|
// Copy text to string.
|
||||||
MJAPI void mjs_setString(mjString* dest, const char* text);
|
MJAPI void mjs_setString(mjString* dest, const char* text);
|
||||||
|
|||||||
Reference in New Issue
Block a user