Rename <required> tag to <plugin>.
PiperOrigin-RevId: 509237786 Change-Id: I35e812830b479004ac5025cbd9477888f51fb43e
This commit is contained in:
committed by
Copybara-Service
parent
239e00e3b1
commit
db28c31f05
@@ -190,11 +190,11 @@ static const char* MJCF[nMJCF][mjXATTRNUM] = {
|
||||
|
||||
{"extension", "*", "0"},
|
||||
{"<"},
|
||||
{"required", "*", "1", "plugin"},
|
||||
{"plugin", "*", "1", "plugin"},
|
||||
{"<"},
|
||||
{"instance", "*", "1", "name"},
|
||||
{"<"},
|
||||
{"config", "*", "2", "key", "value"},
|
||||
{"config", "*", "2", "key", "value"},
|
||||
{">"},
|
||||
{">"},
|
||||
{">"},
|
||||
@@ -2196,7 +2196,7 @@ void mjXReader::Extension(XMLElement* section) {
|
||||
// get sub-element name
|
||||
std::string_view name = elem->Value();
|
||||
|
||||
if (name == "required") {
|
||||
if (name == "plugin") {
|
||||
std::string plugin_name;
|
||||
int plugin_slot = -1;
|
||||
ReadAttrTxt(elem, "plugin", plugin_name, /* required = */ true);
|
||||
|
||||
@@ -1081,12 +1081,12 @@ void mjXWriter::Extension(XMLElement* root) {
|
||||
// create section
|
||||
XMLElement* section = InsertEnd(root, "extension");
|
||||
|
||||
// keep track of plugins whose <required> section have been created
|
||||
// keep track of plugins whose <plugin> section have been created
|
||||
std::unordered_set<const mjpPlugin*> seen_plugins;
|
||||
|
||||
// write all plugins
|
||||
const mjpPlugin* last_plugin = nullptr;
|
||||
XMLElement* required_elem = nullptr;
|
||||
XMLElement* plugin_elem = nullptr;
|
||||
for (int i = 0; i < model->plugins.size(); ++i) {
|
||||
mjCPlugin* pp = static_cast<mjCPlugin*>(model->GetObject(mjOBJ_PLUGIN, i));
|
||||
|
||||
@@ -1096,17 +1096,17 @@ void mjXWriter::Extension(XMLElement* root) {
|
||||
break;
|
||||
}
|
||||
|
||||
// check if we need to open a new <required> section
|
||||
// check if we need to open a new <plugin> section
|
||||
const mjpPlugin* plugin = mjp_getPluginAtSlot(pp->plugin_slot);
|
||||
if (plugin != last_plugin) {
|
||||
required_elem = InsertEnd(section, "required");
|
||||
WriteAttrTxt(required_elem, "plugin", plugin->name);
|
||||
plugin_elem = InsertEnd(section, "plugin");
|
||||
WriteAttrTxt(plugin_elem, "plugin", plugin->name);
|
||||
seen_plugins.insert(plugin);
|
||||
last_plugin = plugin;
|
||||
}
|
||||
|
||||
// write instance element
|
||||
XMLElement* elem = InsertEnd(required_elem, "instance");
|
||||
XMLElement* elem = InsertEnd(plugin_elem, "instance");
|
||||
WriteAttrTxt(elem, "name", pp->name);
|
||||
|
||||
// write plugin config attributes
|
||||
@@ -1123,11 +1123,11 @@ void mjXWriter::Extension(XMLElement* root) {
|
||||
}
|
||||
}
|
||||
|
||||
// write <required> elements for plugins without explicit instances
|
||||
// write <plugin> elements for plugins without explicit instances
|
||||
for (const auto& [plugin, slot] : model->active_plugins) {
|
||||
if (seen_plugins.find(plugin) == seen_plugins.end()) {
|
||||
required_elem = InsertEnd(section, "required");
|
||||
WriteAttrTxt(required_elem, "plugin", plugin->name);
|
||||
plugin_elem = InsertEnd(section, "plugin");
|
||||
WriteAttrTxt(plugin_elem, "plugin", plugin->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user