summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatarGravatar npwoods <npwoods@mess.org>2019-08-04 21:20:59 -0400
committerGravatarGravatar npwoods <npwoods@mess.org>2019-08-04 21:20:59 -0400
commit17e194de8f6ba0deb4d75ff683691ad605ff66df (patch)
treeab1da32e986d58498a63c8a4dfe492b501954f70
parentd3383c54ab9cb00e956e3f78dfb0cffa903fdfe7 (diff)
Follow up to previous listxml_refactor PR (nw)
Specifically, this simplifies that change by collapsing the newly introduced enum info_xml_creator::devices_disposition into a bool, more resembling what was there before. It occurred to me that having a tristate was unnecessary, because the need for filtering could be expressed by a null std::function for the filter
-rw-r--r--src/frontend/mame/info.cpp19
-rw-r--r--src/frontend/mame/info.h9
-rw-r--r--src/frontend/mame/ui/miscmenu.cpp6
3 files changed, 10 insertions, 24 deletions
diff --git a/src/frontend/mame/info.cpp b/src/frontend/mame/info.cpp
index 977ee7cbf4b..34eec500c60 100644
--- a/src/frontend/mame/info.cpp
+++ b/src/frontend/mame/info.cpp
@@ -222,11 +222,7 @@ void info_xml_creator::output(FILE *out, const std::vector<std::string> &pattern
if (patterns.empty())
{
// no patterns specified - show everything
- auto filter = [](const char *, bool &) -> bool
- {
- return true;
- };
- output(out, filter, devices_disposition::ALL);
+ output(out);
}
else
{
@@ -262,7 +258,7 @@ void info_xml_creator::output(FILE *out, const std::vector<std::string> &pattern
}
return result;
};
- output(out, filter, devices_disposition::FILTERED);
+ output(out, filter);
// throw an error if there were unmatched patterns
auto iter = std::find(matched.begin(), matched.end(), false);
@@ -280,11 +276,10 @@ void info_xml_creator::output(FILE *out, const std::vector<std::string> &pattern
// known (and filtered) machines
//-------------------------------------------------
-void info_xml_creator::output(FILE *out, const std::function<bool(const char *shortname, bool &done)> &filter, devices_disposition devdisp)
+void info_xml_creator::output(FILE *out, const std::function<bool(const char *shortname, bool &done)> &filter, bool include_devices)
{
// sanity checks
assert(out);
- assert(filter);
// set up output
m_output = out;
@@ -297,7 +292,7 @@ void info_xml_creator::output(FILE *out, const std::function<bool(const char *sh
// only keep a device set when we're asked to track it
std::unique_ptr<device_type_set> devfilter;
- if (devdisp == devices_disposition::FILTERED)
+ if (include_devices && filter)
devfilter = std::make_unique<device_type_set>();
// try enumerating drivers and outputting them
@@ -309,7 +304,7 @@ void info_xml_creator::output(FILE *out, const std::function<bool(const char *sh
// longer safe to call next(), so record that we're done
drivlist_done = true;
}
- else if (filter(drivlist.driver().name, filter_done))
+ else if (!filter || filter(drivlist.driver().name, filter_done))
{
// output the header if we have to
if (!header_outputted)
@@ -328,7 +323,7 @@ void info_xml_creator::output(FILE *out, const std::function<bool(const char *sh
{
for (device_type type : registered_device_types)
{
- if (filter(type.shortname(), filter_done))
+ if (!filter || filter(type.shortname(), filter_done))
devfilter->insert(&type);
if (filter_done)
@@ -337,7 +332,7 @@ void info_xml_creator::output(FILE *out, const std::function<bool(const char *sh
}
// output devices (both devices with roms and slot devices)
- if (devdisp != devices_disposition::NONE && (!devfilter || !devfilter->empty()))
+ if (include_devices && (!devfilter || !devfilter->empty()))
{
if (!header_outputted)
{
diff --git a/src/frontend/mame/info.h b/src/frontend/mame/info.h
index 6fe5fd1d1fb..a4c2f3884ff 100644
--- a/src/frontend/mame/info.h
+++ b/src/frontend/mame/info.h
@@ -31,19 +31,12 @@ class driver_enumerator;
class info_xml_creator
{
public:
- enum class devices_disposition
- {
- NONE,
- FILTERED,
- ALL
- };
-
// construction/destruction
info_xml_creator(emu_options const &options, bool dtd = true);
// output
void output(FILE *out, const std::vector<std::string> &patterns);
- void output(FILE *out, const std::function<bool(const char *shortname, bool &done)> &filter, devices_disposition devdisp);
+ void output(FILE *out, const std::function<bool(const char *shortname, bool &done)> &filter = { }, bool include_devices = true);
private:
typedef std::unordered_set<std::add_pointer_t<device_type> > device_type_set;
diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp
index 8dea46aab79..f79125ee7e1 100644
--- a/src/frontend/mame/ui/miscmenu.cpp
+++ b/src/frontend/mame/ui/miscmenu.cpp
@@ -602,13 +602,11 @@ void menu_export::handle()
};
// do we want to show devices?
- info_xml_creator::devices_disposition devdisp = (uintptr_t(menu_event->itemref) == 1)
- ? info_xml_creator::devices_disposition::FILTERED
- : info_xml_creator::devices_disposition::NONE;
+ bool include_devices = uintptr_t(menu_event->itemref) == 1;
// and do the dirty work
info_xml_creator creator(machine().options());
- creator.output(pfile, filter, devdisp);
+ creator.output(pfile, filter, include_devices);
fclose(pfile);
machine().popmessage(_("%s.xml saved under ui folder."), filename.c_str());
}