Return 0 on success from mjs_activatePlugin instead of using mju_error.
PiperOrigin-RevId: 684102823 Change-Id: I86b7702094ae886539e1dfb6294381952d507bc1
This commit is contained in:
committed by
Copybara-Service
parent
5dcc31a6aa
commit
a26ba2012e
@@ -206,14 +206,15 @@ void mjs_addSpec(mjSpec* s, mjSpec* child) {
|
||||
|
||||
|
||||
// activate plugin
|
||||
void mjs_activatePlugin(mjSpec* s, const char* name) {
|
||||
int mjs_activatePlugin(mjSpec* s, const char* name) {
|
||||
int plugin_slot = -1;
|
||||
const mjpPlugin* plugin = mjp_getPlugin(name, &plugin_slot);
|
||||
if (!plugin) {
|
||||
mju_error("unknown plugin '%s'", name);
|
||||
return -1;
|
||||
}
|
||||
mjCModel* model = static_cast<mjCModel*>(s->element);
|
||||
model->ActivatePlugin(plugin, plugin_slot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -63,8 +63,8 @@ MJAPI void mj_deleteSpec(mjSpec* s);
|
||||
// Add spec (model asset) to spec.
|
||||
MJAPI void mjs_addSpec(mjSpec* s, mjSpec* child);
|
||||
|
||||
// Activate plugin.
|
||||
MJAPI void mjs_activatePlugin(mjSpec* s, const char* name);
|
||||
// Activate plugin, return 0 on success.
|
||||
MJAPI int mjs_activatePlugin(mjSpec* s, const char* name);
|
||||
|
||||
|
||||
//---------------------------------- Attachment ----------------------------------------------------
|
||||
|
||||
@@ -2890,7 +2890,9 @@ void mjXReader::Extension(XMLElement* section) {
|
||||
if (name == "plugin") {
|
||||
string plugin_name;
|
||||
ReadAttrTxt(elem, "plugin", plugin_name, /* required = */ true);
|
||||
mjs_activatePlugin(spec, plugin_name.c_str());
|
||||
if (mjs_activatePlugin(spec, plugin_name.c_str())) {
|
||||
throw mjXError(elem, "plugin %s not found", plugin_name.c_str());
|
||||
}
|
||||
|
||||
XMLElement* child = FirstChildElement(elem);
|
||||
while (child) {
|
||||
|
||||
Reference in New Issue
Block a user