Add const to mjsDefault when used as function argument.
Fixes #2197. PiperOrigin-RevId: 692346264 Change-Id: Iddb9be1377a7d59c86911802d8c5563f6bf6b043
This commit is contained in:
committed by
Copybara-Service
parent
47ebb0614e
commit
ebe60b9ad5
@@ -2383,7 +2383,7 @@ void mjXReader::OneActuator(XMLElement* elem, mjsActuator* actuator) {
|
||||
|
||||
|
||||
// make composite
|
||||
void mjXReader::OneComposite(XMLElement* elem, mjsBody* body, mjsDefault* def) {
|
||||
void mjXReader::OneComposite(XMLElement* elem, mjsBody* body, const mjsDefault* def) {
|
||||
string text;
|
||||
int n;
|
||||
|
||||
@@ -3188,7 +3188,7 @@ void mjXReader::Asset(XMLElement* section, const mjVFS* vfs) {
|
||||
name = elem->Value();
|
||||
|
||||
// get class if specified, otherwise use default0
|
||||
mjsDefault* def = GetClass(elem);
|
||||
const mjsDefault* def = GetClass(elem);
|
||||
if (!def) {
|
||||
def = mjs_getSpecDefault(spec);
|
||||
}
|
||||
@@ -3408,7 +3408,7 @@ void mjXReader::Body(XMLElement* section, mjsBody* body, mjsFrame* frame,
|
||||
name = elem->Value();
|
||||
|
||||
// get class if specified, otherwise use body
|
||||
mjsDefault* def = GetClass(elem);
|
||||
const mjsDefault* def = GetClass(elem);
|
||||
if (!def) {
|
||||
def = mjs_getDefault(frame ? frame->element : body->element);
|
||||
}
|
||||
@@ -3519,13 +3519,10 @@ void mjXReader::Body(XMLElement* section, mjsBody* body, mjsFrame* frame,
|
||||
// frame sub-element
|
||||
else if (name=="frame") {
|
||||
// read childdef
|
||||
mjsDefault* childdef = 0;
|
||||
if (ReadAttrTxt(elem, "childclass", text)) {
|
||||
childdef = mjs_findDefault(spec, text.c_str());
|
||||
mjs_findDefault(spec, text.c_str());
|
||||
if (!childdef) {
|
||||
throw mjXError(elem, "unknown default childclass");
|
||||
}
|
||||
bool has_childclass = ReadAttrTxt(elem, "childclass", text);
|
||||
const mjsDefault* childdef = has_childclass ? mjs_findDefault(spec, text.c_str()) : nullptr;
|
||||
if (has_childclass && !childdef) {
|
||||
throw mjXError(elem, "unknown default childclass");
|
||||
}
|
||||
|
||||
// create frame
|
||||
@@ -3568,13 +3565,10 @@ void mjXReader::Body(XMLElement* section, mjsBody* body, mjsFrame* frame,
|
||||
mjs_resolveOrientation(rotation, spec->compiler.degree, spec->compiler.eulerseq, &alt);
|
||||
|
||||
// read childdef
|
||||
mjsDefault* childdef = 0;
|
||||
if (ReadAttrTxt(elem, "childclass", text)) {
|
||||
childdef = mjs_findDefault(spec, text.c_str());
|
||||
mjs_findDefault(spec, text.c_str());
|
||||
if (!childdef) {
|
||||
throw mjXError(elem, "unknown default childclass");
|
||||
}
|
||||
bool has_childclass = ReadAttrTxt(elem, "childclass", text);
|
||||
const mjsDefault* childdef = has_childclass ? mjs_findDefault(spec, text.c_str()) : nullptr;
|
||||
if (has_childclass && !childdef) {
|
||||
throw mjXError(elem, "unknown default childclass");
|
||||
}
|
||||
|
||||
// create subtree
|
||||
@@ -3622,13 +3616,10 @@ void mjXReader::Body(XMLElement* section, mjsBody* body, mjsFrame* frame,
|
||||
// body sub-element
|
||||
else if (name=="body") {
|
||||
// read childdef
|
||||
mjsDefault* childdef = 0;
|
||||
if (ReadAttrTxt(elem, "childclass", text)) {
|
||||
childdef = mjs_findDefault(spec, text.c_str());
|
||||
mjs_findDefault(spec, text.c_str());
|
||||
if (!childdef) {
|
||||
throw mjXError(elem, "unknown default childclass");
|
||||
}
|
||||
bool has_childclass = ReadAttrTxt(elem, "childclass", text);
|
||||
const mjsDefault* childdef = has_childclass ? mjs_findDefault(spec, text.c_str()) : nullptr;
|
||||
if (has_childclass && !childdef) {
|
||||
throw mjXError(elem, "unknown default childclass");
|
||||
}
|
||||
|
||||
// create child body
|
||||
@@ -3720,7 +3711,7 @@ void mjXReader::Contact(XMLElement* section) {
|
||||
name = elem->Value();
|
||||
|
||||
// get class if specified, otherwise use default0
|
||||
mjsDefault* def = GetClass(elem);
|
||||
const mjsDefault* def = GetClass(elem);
|
||||
if (!def) {
|
||||
def = mjs_getSpecDefault(spec);
|
||||
}
|
||||
@@ -3765,7 +3756,7 @@ void mjXReader::Equality(XMLElement* section) {
|
||||
elem = FirstChildElement(section);
|
||||
while (elem) {
|
||||
// get class if specified, otherwise use default0
|
||||
mjsDefault* def = GetClass(elem);
|
||||
const mjsDefault* def = GetClass(elem);
|
||||
if (!def) {
|
||||
def = mjs_getSpecDefault(spec);
|
||||
}
|
||||
@@ -3793,7 +3784,7 @@ void mjXReader::Deformable(XMLElement* section, const mjVFS* vfs) {
|
||||
name = elem->Value();
|
||||
|
||||
// get class if specified, otherwise use default0
|
||||
mjsDefault* def = GetClass(elem);
|
||||
const mjsDefault* def = GetClass(elem);
|
||||
if (!def) {
|
||||
def = mjs_getSpecDefault(spec);
|
||||
}
|
||||
@@ -3829,7 +3820,7 @@ void mjXReader::Tendon(XMLElement* section) {
|
||||
elem = FirstChildElement(section);
|
||||
while (elem) {
|
||||
// get class if specified, otherwise use default0
|
||||
mjsDefault* def = GetClass(elem);
|
||||
const mjsDefault* def = GetClass(elem);
|
||||
if (!def) {
|
||||
def = mjs_getSpecDefault(spec);
|
||||
}
|
||||
@@ -3895,7 +3886,7 @@ void mjXReader::Actuator(XMLElement* section) {
|
||||
elem = FirstChildElement(section);
|
||||
while (elem) {
|
||||
// get class if specified, otherwise use default0
|
||||
mjsDefault* def = GetClass(elem);
|
||||
const mjsDefault* def = GetClass(elem);
|
||||
if (!def) {
|
||||
def = mjs_getSpecDefault(spec);
|
||||
}
|
||||
@@ -4306,19 +4297,19 @@ void mjXReader::Keyframe(XMLElement* section) {
|
||||
|
||||
|
||||
// get defaults class
|
||||
mjsDefault* mjXReader::GetClass(XMLElement* section) {
|
||||
const mjsDefault* mjXReader::GetClass(XMLElement* section) {
|
||||
string text;
|
||||
mjsDefault* def = nullptr;
|
||||
|
||||
if (ReadAttrTxt(section, "class", text)) {
|
||||
def = mjs_findDefault(spec, text.c_str());
|
||||
if (!def) {
|
||||
throw mjXError(
|
||||
section,
|
||||
string("unknown default class name '" + text + "'").c_str());
|
||||
}
|
||||
if (!ReadAttrTxt(section, "class", text)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const mjsDefault* def = mjs_findDefault(spec, text.c_str());
|
||||
if (!def) {
|
||||
throw mjXError(
|
||||
section,
|
||||
string("unknown default class name '" + text + "'").c_str());
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user