Avoid changing semantics of mjsPlugin.name across XML sections.
The `extension` section used to discard the plugin name and write the instance name in `plugin.name`, while all of the other sections wrote the instance name in `plugin.instance_name` and optionally the plugin name in `plugin.name` (via the function `OnePlugin`). Now all plugin names are in `plugin.plugin_name` and the instance is written in `plugin.name`, so that it is possible to lookup a plugin via its unique instance name. PiperOrigin-RevId: 683183804 Change-Id: I179ef5d221143b720db24d745b09e327bf1449ef
This commit is contained in:
committed by
Copybara-Service
parent
5bfc7da7de
commit
66faba9aa5
@@ -2769,8 +2769,8 @@ void mjXReader::OnePlugin(XMLElement* elem, mjsPlugin* plugin) {
|
||||
string instance_name = "";
|
||||
ReadAttrTxt(elem, "plugin", name);
|
||||
ReadAttrTxt(elem, "instance", instance_name);
|
||||
mjs_setString(plugin->name, name.c_str());
|
||||
mjs_setString(plugin->instance_name, instance_name.c_str());
|
||||
mjs_setString(plugin->plugin_name, name.c_str());
|
||||
mjs_setString(plugin->name, instance_name.c_str());
|
||||
if (instance_name.empty()) {
|
||||
plugin->element = mjs_addPlugin(spec)->element;
|
||||
ReadPluginConfigs(elem, plugin);
|
||||
@@ -2901,6 +2901,7 @@ void mjXReader::Extension(XMLElement* section) {
|
||||
}
|
||||
string name;
|
||||
mjsPlugin* p = mjs_addPlugin(spec);
|
||||
mjs_setString(p->plugin_name, plugin_name.c_str());
|
||||
mjs_setString(p->info, ("line " + std::to_string(elem->GetLineNum())).c_str());
|
||||
ReadAttrTxt(child, "name", name, /* required = */ true);
|
||||
mjs_setString(p->name, name.c_str());
|
||||
|
||||
Reference in New Issue
Block a user