summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar npwoods <npwoods@mess.org>2019-06-16 16:56:47 -0400
committerGravatarGravatar npwoods <npwoods@mess.org>2019-06-16 16:56:47 -0400
commit1dc37ed292565ac95a81cba2755f46fe92a12c81 (patch) (github)
treec791c8e4d5ae86277861caeb6ba4c8d4dc7f7b8f
parente979607ad8afab9fe09e43e0598ef4786ee7a793 (diff)
downloadmame-list_xml_light.tar.bz2
mame-list_xml_light.zip
Created a -listxml -lightxml option to emit a lighter version of thelist_xml_light
XML, omitting data that requires building machine_config objects
-rw-r--r--src/frontend/mame/clifront.cpp4
-rw-r--r--src/frontend/mame/info.cpp131
-rw-r--r--src/frontend/mame/info.h3
3 files changed, 81 insertions, 57 deletions
diff --git a/src/frontend/mame/clifront.cpp b/src/frontend/mame/clifront.cpp
index 28249e7bd3e..c89b4608400 100644
--- a/src/frontend/mame/clifront.cpp
+++ b/src/frontend/mame/clifront.cpp
@@ -71,6 +71,7 @@
// command options
#define CLIOPTION_DTD "dtd"
+#define CLIOPTION_LIGHTXML "lightxml"
namespace {
@@ -114,6 +115,7 @@ const options_entry cli_option_entries[] =
{ nullptr, nullptr, OPTION_HEADER, "FRONTEND COMMAND OPTIONS" },
{ CLIOPTION_DTD, "1", OPTION_BOOLEAN, "include DTD in XML output" },
+ { CLIOPTION_LIGHTXML, "0", OPTION_BOOLEAN, "emit light XML output" },
{ nullptr }
};
@@ -352,7 +354,7 @@ int cli_frontend::execute(std::vector<std::string> &args)
void cli_frontend::listxml(const std::vector<std::string> &args)
{
// create the XML and print it to stdout
- info_xml_creator creator(m_options, m_options.bool_value(CLIOPTION_DTD));
+ info_xml_creator creator(m_options, m_options.bool_value(CLIOPTION_DTD), m_options.bool_value(CLIOPTION_LIGHTXML));
creator.output(stdout, args);
}
diff --git a/src/frontend/mame/info.cpp b/src/frontend/mame/info.cpp
index 1fe65d7ea3c..798d068c9f5 100644
--- a/src/frontend/mame/info.cpp
+++ b/src/frontend/mame/info.cpp
@@ -206,9 +206,10 @@ const char info_xml_creator::s_dtd_string[] =
// info_xml_creator - constructor
//-------------------------------------------------
-info_xml_creator::info_xml_creator(emu_options const &options, bool dtd)
+info_xml_creator::info_xml_creator(emu_options const &options, bool dtd, bool light)
: m_output(nullptr)
, m_dtd(dtd)
+ , m_light(light)
{
}
@@ -387,51 +388,58 @@ void info_xml_creator::output_footer()
void info_xml_creator::output_one(driver_enumerator &drivlist, device_type_set *devtypes)
{
const game_driver &driver = drivlist.driver();
- std::shared_ptr<machine_config> const config(drivlist.config());
- device_iterator iter(config->root_device());
+ std::shared_ptr<machine_config> config;
+ std::unique_ptr<ioport_list> portlist;
- // allocate input ports and build overall emulation status
- ioport_list portlist;
- std::string errors;
device_t::feature_type overall_unemulated(driver.type.unemulated_features());
device_t::feature_type overall_imperfect(driver.type.imperfect_features());
- for (device_t &device : iter)
+
+ if (!m_light)
{
- portlist.append(device, errors);
- overall_unemulated |= device.type().unemulated_features();
- overall_imperfect |= device.type().imperfect_features();
+ config = drivlist.config();
+ device_iterator iter(config->root_device());
+ portlist = std::make_unique<ioport_list>();
- if (devtypes && device.owner())
- devtypes->insert(&device.type());
- }
+ // allocate input ports and build overall emulation status
+ std::string errors;
+ for (device_t &device : iter)
+ {
+ portlist->append(device, errors);
+ overall_unemulated |= device.type().unemulated_features();
+ overall_imperfect |= device.type().imperfect_features();
- // renumber player numbers for controller ports
- int player_offset = 0;
- // but treat keyboard count separately from players' number
- int kbd_offset = 0;
- for (device_t &device : iter)
- {
- int nplayers = 0;
- bool new_kbd = false;
- for (auto &port : portlist)
- if (&port.second->device() == &device)
- for (ioport_field &field : port.second->fields())
- if (field.type() >= IPT_START && field.type() < IPT_ANALOG_LAST)
- {
- if (field.type() == IPT_KEYBOARD)
- {
- if (!new_kbd)
- new_kbd = true;
- field.set_player(field.player() + kbd_offset);
- }
- else
+ if (devtypes && device.owner())
+ devtypes->insert(&device.type());
+ }
+
+ // renumber player numbers for controller ports
+ int player_offset = 0;
+ // but treat keyboard count separately from players' number
+ int kbd_offset = 0;
+ for (device_t &device : iter)
+ {
+ int nplayers = 0;
+ bool new_kbd = false;
+ for (auto &port : *portlist)
+ if (&port.second->device() == &device)
+ for (ioport_field &field : port.second->fields())
+ if (field.type() >= IPT_START && field.type() < IPT_ANALOG_LAST)
{
- nplayers = std::max(nplayers, field.player() + 1);
- field.set_player(field.player() + player_offset);
+ if (field.type() == IPT_KEYBOARD)
+ {
+ if (!new_kbd)
+ new_kbd = true;
+ field.set_player(field.player() + kbd_offset);
+ }
+ else
+ {
+ nplayers = std::max(nplayers, field.player() + 1);
+ field.set_player(field.player() + player_offset);
+ }
}
- }
- player_offset += nplayers;
- if (new_kbd) kbd_offset++;
+ player_offset += nplayers;
+ if (new_kbd) kbd_offset++;
+ }
}
// print the header and the machine name
@@ -458,7 +466,8 @@ void info_xml_creator::output_one(driver_enumerator &drivlist, device_type_set *
fprintf(m_output, " romof=\"%s\"", util::xml::normalize_string(drivlist.driver(clone_of).name));
// display sample information and close the game tag
- output_sampleof(config->root_device());
+ if (config)
+ output_sampleof(config->root_device());
fprintf(m_output, ">\n");
// output game description
@@ -474,24 +483,36 @@ void info_xml_creator::output_one(driver_enumerator &drivlist, device_type_set *
fprintf(m_output, "\t\t<manufacturer>%s</manufacturer>\n", util::xml::normalize_string(driver.manufacturer));
// now print various additional information
- output_bios(config->root_device());
- output_rom(&drivlist, config->root_device());
- output_device_refs(config->root_device());
- output_sample(config->root_device());
- output_chips(config->root_device(), "");
- output_display(config->root_device(), &drivlist.driver().flags, "");
- output_sound(config->root_device());
- output_input(portlist);
- output_switches(portlist, "", IPT_DIPSWITCH, "dipswitch", "diplocation", "dipvalue");
- output_switches(portlist, "", IPT_CONFIG, "configuration", "conflocation", "confsetting");
- output_ports(portlist);
- output_adjusters(portlist);
+ if (config)
+ {
+ output_bios(config->root_device());
+ output_rom(&drivlist, config->root_device());
+ output_device_refs(config->root_device());
+ output_sample(config->root_device());
+ output_chips(config->root_device(), "");
+ output_display(config->root_device(), &drivlist.driver().flags, "");
+ output_sound(config->root_device());
+ }
+
+ if (portlist)
+ {
+ output_input(*portlist);
+ output_switches(*portlist, "", IPT_DIPSWITCH, "dipswitch", "diplocation", "dipvalue");
+ output_switches(*portlist, "", IPT_CONFIG, "configuration", "conflocation", "confsetting");
+ output_ports(*portlist);
+ output_adjusters(*portlist);
+ }
+
output_driver(driver, overall_unemulated, overall_imperfect);
output_features(driver.type, overall_unemulated, overall_imperfect);
- output_images(config->root_device(), "");
- output_slots(*config, config->root_device(), "", devtypes);
- output_software_list(config->root_device());
- output_ramoptions(config->root_device());
+
+ if (config)
+ {
+ output_images(config->root_device(), "");
+ output_slots(*config, config->root_device(), "", devtypes);
+ output_software_list(config->root_device());
+ output_ramoptions(config->root_device());
+ }
// close the topmost tag
fprintf(m_output, "\t</%s>\n", XML_TOP);
diff --git a/src/frontend/mame/info.h b/src/frontend/mame/info.h
index 40b3739d895..2ae54893af2 100644
--- a/src/frontend/mame/info.h
+++ b/src/frontend/mame/info.h
@@ -32,7 +32,7 @@ class info_xml_creator
{
public:
// construction/destruction
- info_xml_creator(emu_options const &options, bool dtd = true);
+ info_xml_creator(emu_options const &options, bool dtd = true, bool light = false);
// output
void output(FILE *out, std::vector<std::string> const &patterns);
@@ -77,6 +77,7 @@ private:
static const char s_dtd_string[];
bool m_dtd;
+ bool m_light;
};
#endif // MAME_FRONTEND_MAME_INFO_H