Autogenerate more of mjVFS and mjvGeom WASM bindings
PiperOrigin-RevId: 827898643 Change-Id: I95f9eaa129f663cbeb3606d286c2080c47cfbcc4
This commit is contained in:
committed by
Copybara-Service
parent
f808632cf8
commit
34e5eecba5
@@ -7398,7 +7398,9 @@ MjLROpt& MjLROpt::operator=(const MjLROpt &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjLROpt::~MjLROpt() {
|
MjLROpt::~MjLROpt() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjLROpt> MjLROpt::copy() {
|
std::unique_ptr<MjLROpt> MjLROpt::copy() {
|
||||||
return std::make_unique<MjLROpt>(*this);
|
return std::make_unique<MjLROpt>(*this);
|
||||||
@@ -7421,7 +7423,9 @@ MjOption& MjOption::operator=(const MjOption &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjOption::~MjOption() {
|
MjOption::~MjOption() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjOption> MjOption::copy() {
|
std::unique_ptr<MjOption> MjOption::copy() {
|
||||||
return std::make_unique<MjOption>(*this);
|
return std::make_unique<MjOption>(*this);
|
||||||
@@ -7443,7 +7447,9 @@ MjStatistic& MjStatistic::operator=(const MjStatistic &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjStatistic::~MjStatistic() {
|
MjStatistic::~MjStatistic() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjStatistic> MjStatistic::copy() {
|
std::unique_ptr<MjStatistic> MjStatistic::copy() {
|
||||||
return std::make_unique<MjStatistic>(*this);
|
return std::make_unique<MjStatistic>(*this);
|
||||||
@@ -7465,7 +7471,9 @@ MjVisualGlobal& MjVisualGlobal::operator=(const MjVisualGlobal &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjVisualGlobal::~MjVisualGlobal() {
|
MjVisualGlobal::~MjVisualGlobal() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjVisualGlobal> MjVisualGlobal::copy() {
|
std::unique_ptr<MjVisualGlobal> MjVisualGlobal::copy() {
|
||||||
return std::make_unique<MjVisualGlobal>(*this);
|
return std::make_unique<MjVisualGlobal>(*this);
|
||||||
@@ -7486,7 +7494,9 @@ MjVisualQuality& MjVisualQuality::operator=(const MjVisualQuality &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjVisualQuality::~MjVisualQuality() {
|
MjVisualQuality::~MjVisualQuality() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjVisualQuality> MjVisualQuality::copy() {
|
std::unique_ptr<MjVisualQuality> MjVisualQuality::copy() {
|
||||||
return std::make_unique<MjVisualQuality>(*this);
|
return std::make_unique<MjVisualQuality>(*this);
|
||||||
@@ -7507,7 +7517,9 @@ MjVisualHeadlight& MjVisualHeadlight::operator=(const MjVisualHeadlight &other)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjVisualHeadlight::~MjVisualHeadlight() {
|
MjVisualHeadlight::~MjVisualHeadlight() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjVisualHeadlight> MjVisualHeadlight::copy() {
|
std::unique_ptr<MjVisualHeadlight> MjVisualHeadlight::copy() {
|
||||||
return std::make_unique<MjVisualHeadlight>(*this);
|
return std::make_unique<MjVisualHeadlight>(*this);
|
||||||
@@ -7528,7 +7540,9 @@ MjVisualMap& MjVisualMap::operator=(const MjVisualMap &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjVisualMap::~MjVisualMap() {
|
MjVisualMap::~MjVisualMap() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjVisualMap> MjVisualMap::copy() {
|
std::unique_ptr<MjVisualMap> MjVisualMap::copy() {
|
||||||
return std::make_unique<MjVisualMap>(*this);
|
return std::make_unique<MjVisualMap>(*this);
|
||||||
@@ -7549,7 +7563,9 @@ MjVisualScale& MjVisualScale::operator=(const MjVisualScale &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjVisualScale::~MjVisualScale() {
|
MjVisualScale::~MjVisualScale() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjVisualScale> MjVisualScale::copy() {
|
std::unique_ptr<MjVisualScale> MjVisualScale::copy() {
|
||||||
return std::make_unique<MjVisualScale>(*this);
|
return std::make_unique<MjVisualScale>(*this);
|
||||||
@@ -7570,7 +7586,9 @@ MjVisualRgba& MjVisualRgba::operator=(const MjVisualRgba &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjVisualRgba::~MjVisualRgba() {
|
MjVisualRgba::~MjVisualRgba() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjVisualRgba> MjVisualRgba::copy() {
|
std::unique_ptr<MjVisualRgba> MjVisualRgba::copy() {
|
||||||
return std::make_unique<MjVisualRgba>(*this);
|
return std::make_unique<MjVisualRgba>(*this);
|
||||||
@@ -7604,7 +7622,9 @@ MjVisual& MjVisual::operator=(const MjVisual &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjVisual::~MjVisual() {
|
MjVisual::~MjVisual() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjVisual> MjVisual::copy() {
|
std::unique_ptr<MjVisual> MjVisual::copy() {
|
||||||
return std::make_unique<MjVisual>(*this);
|
return std::make_unique<MjVisual>(*this);
|
||||||
@@ -7626,7 +7646,9 @@ MjSolverStat& MjSolverStat::operator=(const MjSolverStat &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjSolverStat::~MjSolverStat() {
|
MjSolverStat::~MjSolverStat() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjSolverStat> MjSolverStat::copy() {
|
std::unique_ptr<MjSolverStat> MjSolverStat::copy() {
|
||||||
return std::make_unique<MjSolverStat>(*this);
|
return std::make_unique<MjSolverStat>(*this);
|
||||||
@@ -7648,7 +7670,9 @@ MjTimerStat& MjTimerStat::operator=(const MjTimerStat &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjTimerStat::~MjTimerStat() {
|
MjTimerStat::~MjTimerStat() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjTimerStat> MjTimerStat::copy() {
|
std::unique_ptr<MjTimerStat> MjTimerStat::copy() {
|
||||||
return std::make_unique<MjTimerStat>(*this);
|
return std::make_unique<MjTimerStat>(*this);
|
||||||
@@ -7670,7 +7694,9 @@ MjWarningStat& MjWarningStat::operator=(const MjWarningStat &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjWarningStat::~MjWarningStat() {
|
MjWarningStat::~MjWarningStat() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjWarningStat> MjWarningStat::copy() {
|
std::unique_ptr<MjWarningStat> MjWarningStat::copy() {
|
||||||
return std::make_unique<MjWarningStat>(*this);
|
return std::make_unique<MjWarningStat>(*this);
|
||||||
@@ -7692,7 +7718,9 @@ MjContact& MjContact::operator=(const MjContact &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjContact::~MjContact() {
|
MjContact::~MjContact() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjContact> MjContact::copy() {
|
std::unique_ptr<MjContact> MjContact::copy() {
|
||||||
return std::make_unique<MjContact>(*this);
|
return std::make_unique<MjContact>(*this);
|
||||||
@@ -7786,7 +7814,9 @@ MjvPerturb& MjvPerturb::operator=(const MjvPerturb &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjvPerturb::~MjvPerturb() {
|
MjvPerturb::~MjvPerturb() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjvPerturb> MjvPerturb::copy() {
|
std::unique_ptr<MjvPerturb> MjvPerturb::copy() {
|
||||||
return std::make_unique<MjvPerturb>(*this);
|
return std::make_unique<MjvPerturb>(*this);
|
||||||
@@ -7809,7 +7839,9 @@ MjvCamera& MjvCamera::operator=(const MjvCamera &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjvCamera::~MjvCamera() {
|
MjvCamera::~MjvCamera() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjvCamera> MjvCamera::copy() {
|
std::unique_ptr<MjvCamera> MjvCamera::copy() {
|
||||||
return std::make_unique<MjvCamera>(*this);
|
return std::make_unique<MjvCamera>(*this);
|
||||||
@@ -7831,23 +7863,24 @@ MjvGLCamera& MjvGLCamera::operator=(const MjvGLCamera &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjvGLCamera::~MjvGLCamera() {
|
MjvGLCamera::~MjvGLCamera() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjvGLCamera> MjvGLCamera::copy() {
|
std::unique_ptr<MjvGLCamera> MjvGLCamera::copy() {
|
||||||
return std::make_unique<MjvGLCamera>(*this);
|
return std::make_unique<MjvGLCamera>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============== MjvGeom =============== //
|
// =============== MjvGeom =============== //
|
||||||
MjvGeom::MjvGeom(mjvGeom *ptr) { ptr_ = ptr; };
|
MjvGeom::MjvGeom(mjvGeom *ptr) : ptr_(ptr) {}
|
||||||
MjvGeom::MjvGeom() : ptr_(new mjvGeom) {
|
MjvGeom::MjvGeom() : ptr_(new mjvGeom) {
|
||||||
owned_ = true;
|
owned_ = true;
|
||||||
mjv_initGeom(ptr_, mjGEOM_NONE, nullptr, nullptr, nullptr, nullptr);
|
mjv_initGeom(ptr_, mjGEOM_NONE, nullptr, nullptr, nullptr, nullptr);
|
||||||
};
|
}
|
||||||
MjvGeom::MjvGeom(const MjvGeom &other) : MjvGeom() {
|
MjvGeom::MjvGeom(const MjvGeom &other) : MjvGeom() {
|
||||||
*ptr_ = *other.get();
|
*ptr_ = *other.get();
|
||||||
}
|
}
|
||||||
MjvGeom &MjvGeom::operator=(
|
MjvGeom& MjvGeom::operator=(const MjvGeom &other) {
|
||||||
const MjvGeom &other) {
|
|
||||||
if (this == &other) {
|
if (this == &other) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -7855,7 +7888,9 @@ MjvGeom &MjvGeom::operator=(
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjvGeom::~MjvGeom() {
|
MjvGeom::~MjvGeom() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjvGeom> MjvGeom::copy() {
|
std::unique_ptr<MjvGeom> MjvGeom::copy() {
|
||||||
return std::make_unique<MjvGeom>(*this);
|
return std::make_unique<MjvGeom>(*this);
|
||||||
@@ -7877,7 +7912,9 @@ MjvLight& MjvLight::operator=(const MjvLight &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjvLight::~MjvLight() {
|
MjvLight::~MjvLight() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjvLight> MjvLight::copy() {
|
std::unique_ptr<MjvLight> MjvLight::copy() {
|
||||||
return std::make_unique<MjvLight>(*this);
|
return std::make_unique<MjvLight>(*this);
|
||||||
@@ -7900,7 +7937,9 @@ MjvOption& MjvOption::operator=(const MjvOption &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjvOption::~MjvOption() {
|
MjvOption::~MjvOption() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjvOption> MjvOption::copy() {
|
std::unique_ptr<MjvOption> MjvOption::copy() {
|
||||||
return std::make_unique<MjvOption>(*this);
|
return std::make_unique<MjvOption>(*this);
|
||||||
@@ -8010,7 +8049,9 @@ MjvFigure& MjvFigure::operator=(const MjvFigure &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjvFigure::~MjvFigure() {
|
MjvFigure::~MjvFigure() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjvFigure> MjvFigure::copy() {
|
std::unique_ptr<MjvFigure> MjvFigure::copy() {
|
||||||
return std::make_unique<MjvFigure>(*this);
|
return std::make_unique<MjvFigure>(*this);
|
||||||
|
|||||||
@@ -311,7 +311,9 @@ MjLROpt& MjLROpt::operator=(const MjLROpt &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjLROpt::~MjLROpt() {
|
MjLROpt::~MjLROpt() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjLROpt> MjLROpt::copy() {
|
std::unique_ptr<MjLROpt> MjLROpt::copy() {
|
||||||
return std::make_unique<MjLROpt>(*this);
|
return std::make_unique<MjLROpt>(*this);
|
||||||
@@ -372,7 +374,9 @@ MjvLight& MjvLight::operator=(const MjvLight &other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
MjvLight::~MjvLight() {
|
MjvLight::~MjvLight() {
|
||||||
if (owned_ && ptr_) delete ptr_;
|
if (owned_ && ptr_) {
|
||||||
|
delete ptr_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<MjvLight> MjvLight::copy() {
|
std::unique_ptr<MjvLight> MjvLight::copy() {
|
||||||
return std::make_unique<MjvLight>(*this);
|
return std::make_unique<MjvLight>(*this);
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ def _build_struct_header_internal(
|
|||||||
return builder.to_string() + ";"
|
return builder.to_string() + ";"
|
||||||
|
|
||||||
|
|
||||||
def _get_default_func_name(struct_name: str) -> str:
|
def _default_function_statement(struct_name: str) -> str:
|
||||||
"""Returns the default function name for the given struct."""
|
"""Returns the default function name for the given struct."""
|
||||||
if (
|
if (
|
||||||
struct_name in constants.ANONYMOUS_STRUCTS.keys()
|
struct_name in constants.ANONYMOUS_STRUCTS.keys()
|
||||||
@@ -505,11 +505,23 @@ def _get_default_func_name(struct_name: str) -> str:
|
|||||||
):
|
):
|
||||||
return ""
|
return ""
|
||||||
elif struct_name.startswith("mjs"):
|
elif struct_name.startswith("mjs"):
|
||||||
return f"mjs_default{struct_name.removeprefix('mjs')}"
|
return f"mjs_default{struct_name.removeprefix('mjs')}(ptr_);"
|
||||||
|
elif struct_name == "mjvGeom":
|
||||||
|
return (
|
||||||
|
"mjv_initGeom(ptr_, mjGEOM_NONE, nullptr, nullptr, nullptr, nullptr);"
|
||||||
|
)
|
||||||
elif struct_name.startswith("mjv"):
|
elif struct_name.startswith("mjv"):
|
||||||
return f"mjv_default{struct_name.removeprefix('mjv')}"
|
return f"mjv_default{struct_name.removeprefix('mjv')}(ptr_);"
|
||||||
else:
|
else:
|
||||||
return f"mj_default{struct_name.removeprefix('mj')}"
|
return f"mj_default{struct_name.removeprefix('mj')}(ptr_);"
|
||||||
|
|
||||||
|
|
||||||
|
def _delete_ptr_statement(struct_name: str) -> str:
|
||||||
|
"""Returns the delete function name for the given struct."""
|
||||||
|
if struct_name == "mjVFS":
|
||||||
|
return "mj_deleteVFS(ptr_);"
|
||||||
|
else:
|
||||||
|
return "delete ptr_;"
|
||||||
|
|
||||||
|
|
||||||
def _find_fields_with_init(
|
def _find_fields_with_init(
|
||||||
@@ -574,18 +586,19 @@ def build_struct_source(
|
|||||||
|
|
||||||
fields_with_init = _find_fields_with_init(wrapped_fields)
|
fields_with_init = _find_fields_with_init(wrapped_fields)
|
||||||
shallow_copy = use_shallow_copy(wrapped_fields)
|
shallow_copy = use_shallow_copy(wrapped_fields)
|
||||||
mj_default_func = _get_default_func_name(struct_name)
|
|
||||||
|
|
||||||
fields_init = ""
|
fields_init = ""
|
||||||
if fields_with_init:
|
if fields_with_init:
|
||||||
fields_init = "".join(
|
fields_init = "".join(
|
||||||
field_with_init.initialization for field_with_init in fields_with_init
|
field_with_init.initialization for field_with_init in fields_with_init
|
||||||
)
|
)
|
||||||
|
|
||||||
# constructor passing native ptr
|
# constructor passing native ptr
|
||||||
builder.line(
|
builder.line(
|
||||||
f"{wrapper_name}::{wrapper_name}({struct_name} *ptr) :"
|
f"{wrapper_name}::{wrapper_name}({struct_name} *ptr) :"
|
||||||
f" ptr_(ptr){fields_init} {{}}"
|
f" ptr_(ptr){fields_init} {{}}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# constructor with default values
|
# constructor with default values
|
||||||
if not is_mjs_struct:
|
if not is_mjs_struct:
|
||||||
with builder.block(
|
with builder.block(
|
||||||
@@ -593,10 +606,12 @@ def build_struct_source(
|
|||||||
f" {struct_name}){fields_init}"
|
f" {struct_name}){fields_init}"
|
||||||
):
|
):
|
||||||
builder.line("owned_ = true;")
|
builder.line("owned_ = true;")
|
||||||
if mj_default_func:
|
default_func = _default_function_statement(struct_name)
|
||||||
builder.line(f"{mj_default_func}(ptr_);")
|
if default_func:
|
||||||
# copy constructor
|
builder.line(default_func)
|
||||||
|
|
||||||
if shallow_copy and not is_mjs_struct:
|
if shallow_copy and not is_mjs_struct:
|
||||||
|
# copy constructor
|
||||||
with builder.block(
|
with builder.block(
|
||||||
f"{wrapper_name}::{wrapper_name}(const {wrapper_name} &other)"
|
f"{wrapper_name}::{wrapper_name}(const {wrapper_name} &other)"
|
||||||
+ (f" : {wrapper_name}()" if not is_mjs_struct else "")
|
+ (f" : {wrapper_name}()" if not is_mjs_struct else "")
|
||||||
@@ -606,6 +621,7 @@ def build_struct_source(
|
|||||||
for field_with_init in fields_with_init:
|
for field_with_init in fields_with_init:
|
||||||
if field_with_init.ptr_copy_reset is not None:
|
if field_with_init.ptr_copy_reset is not None:
|
||||||
builder.line(field_with_init.ptr_copy_reset)
|
builder.line(field_with_init.ptr_copy_reset)
|
||||||
|
|
||||||
# assignment operator
|
# assignment operator
|
||||||
with builder.block(
|
with builder.block(
|
||||||
f"{wrapper_name}&"
|
f"{wrapper_name}&"
|
||||||
@@ -620,18 +636,23 @@ def build_struct_source(
|
|||||||
if field_with_init.ptr_copy_reset is not None:
|
if field_with_init.ptr_copy_reset is not None:
|
||||||
builder.line(field_with_init.ptr_copy_reset)
|
builder.line(field_with_init.ptr_copy_reset)
|
||||||
builder.line("return *this;")
|
builder.line("return *this;")
|
||||||
|
|
||||||
# destructor
|
# destructor
|
||||||
if is_mjs_struct:
|
if is_mjs_struct:
|
||||||
builder.line(f"{wrapper_name}::~{wrapper_name}() {{}}")
|
builder.line(f"{wrapper_name}::~{wrapper_name}() {{}}")
|
||||||
else:
|
else:
|
||||||
with builder.block(f"{wrapper_name}::~{wrapper_name}()"):
|
with builder.block(f"{wrapper_name}::~{wrapper_name}()"):
|
||||||
builder.line("if (owned_ && ptr_) delete ptr_;")
|
with builder.block("if (owned_ && ptr_)"):
|
||||||
|
delete_ptr = _delete_ptr_statement(struct_name)
|
||||||
|
builder.line(delete_ptr)
|
||||||
|
|
||||||
# copy function
|
# copy function
|
||||||
if shallow_copy:
|
if shallow_copy:
|
||||||
with builder.block(
|
with builder.block(
|
||||||
f"std::unique_ptr<{wrapper_name}> {wrapper_name}::copy()"
|
f"std::unique_ptr<{wrapper_name}> {wrapper_name}::copy()"
|
||||||
):
|
):
|
||||||
builder.line(f"return std::make_unique<{wrapper_name}>(*this);")
|
builder.line(f"return std::make_unique<{wrapper_name}>(*this);")
|
||||||
|
|
||||||
return builder.to_string()
|
return builder.to_string()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -563,28 +563,7 @@ std::vector<MjContact> MjData::contact() const {
|
|||||||
// INSERT-GENERATED-MjvGLCamera-CONSTRUCTOR
|
// INSERT-GENERATED-MjvGLCamera-CONSTRUCTOR
|
||||||
|
|
||||||
// =============== MjvGeom =============== //
|
// =============== MjvGeom =============== //
|
||||||
MjvGeom::MjvGeom(mjvGeom *ptr) { ptr_ = ptr; };
|
// INSERT-GENERATED-MjvGeom-CONSTRUCTOR
|
||||||
MjvGeom::MjvGeom() : ptr_(new mjvGeom) {
|
|
||||||
owned_ = true;
|
|
||||||
mjv_initGeom(ptr_, mjGEOM_NONE, nullptr, nullptr, nullptr, nullptr);
|
|
||||||
};
|
|
||||||
MjvGeom::MjvGeom(const MjvGeom &other) : MjvGeom() {
|
|
||||||
*ptr_ = *other.get();
|
|
||||||
}
|
|
||||||
MjvGeom &MjvGeom::operator=(
|
|
||||||
const MjvGeom &other) {
|
|
||||||
if (this == &other) {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
*ptr_ = *other.get();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
MjvGeom::~MjvGeom() {
|
|
||||||
if (owned_ && ptr_) delete ptr_;
|
|
||||||
}
|
|
||||||
std::unique_ptr<MjvGeom> MjvGeom::copy() {
|
|
||||||
return std::make_unique<MjvGeom>(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// =============== MjvLight =============== //
|
// =============== MjvLight =============== //
|
||||||
// INSERT-GENERATED-MjvLight-CONSTRUCTOR
|
// INSERT-GENERATED-MjvLight-CONSTRUCTOR
|
||||||
@@ -823,16 +802,7 @@ MjSpec::~MjSpec() {
|
|||||||
// INSERT-GENERATED-MjsPlugin-CONSTRUCTOR
|
// INSERT-GENERATED-MjsPlugin-CONSTRUCTOR
|
||||||
|
|
||||||
// =============== MjVFS =============== //
|
// =============== MjVFS =============== //
|
||||||
MjVFS::MjVFS(mjVFS *ptr) : ptr_(ptr) {}
|
// INSERT-GENERATED-MjVFS-CONSTRUCTOR
|
||||||
MjVFS::MjVFS() : ptr_(new mjVFS) {
|
|
||||||
owned_ = true;
|
|
||||||
mj_defaultVFS(ptr_);
|
|
||||||
}
|
|
||||||
MjVFS::~MjVFS() {
|
|
||||||
if (owned_ && ptr_) {
|
|
||||||
mj_deleteVFS(ptr_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ======= FACTORY AND HELPER FUNCTIONS ========= //
|
// ======= FACTORY AND HELPER FUNCTIONS ========= //
|
||||||
std::unique_ptr<MjModel> loadFromXML(std::string filename) {
|
std::unique_ptr<MjModel> loadFromXML(std::string filename) {
|
||||||
|
|||||||
Reference in New Issue
Block a user