From 14f58987ee3ea43227b315ef11664c943555c4b0 Mon Sep 17 00:00:00 2001 From: couriersud Date: Wed, 8 Jun 2016 19:03:05 +0200 Subject: [PATCH 01/39] More c++. (nw) --- src/devices/machine/netlist.cpp | 4 ++-- src/lib/netlist/devices/nlid_system.h | 2 +- src/lib/netlist/nl_base.h | 2 +- src/lib/netlist/nl_factory.h | 2 +- src/lib/netlist/nl_setup.cpp | 25 +++++++++++++------------ src/lib/netlist/nl_setup.h | 10 +++++----- src/lib/netlist/plib/plists.h | 2 -- src/lib/netlist/plib/poptions.h | 2 +- src/lib/netlist/plib/pparser.cpp | 6 +++--- src/lib/netlist/plib/pparser.h | 2 +- src/lib/netlist/plib/pstate.cpp | 7 +++---- src/lib/netlist/plib/pstate.h | 4 ++-- src/lib/netlist/plib/putil.h | 19 +++++++++++++++++++ src/lib/netlist/prg/nltool.cpp | 8 ++++---- 14 files changed, 56 insertions(+), 39 deletions(-) diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp index bd65d0b2eef..637a1225891 100644 --- a/src/devices/machine/netlist.cpp +++ b/src/devices/machine/netlist.cpp @@ -566,7 +566,7 @@ void netlist_mame_sound_device_t::device_start() // Configure outputs - plib::pvector_t outdevs = netlist().get_device_list(); + std::vector outdevs = netlist().get_device_list(); if (outdevs.size() == 0) fatalerror("No output devices"); @@ -592,7 +592,7 @@ void netlist_mame_sound_device_t::device_start() m_num_inputs = 0; m_in = nullptr; - plib::pvector_t indevs = netlist().get_device_list(); + std::vector indevs = netlist().get_device_list(); if (indevs.size() > 1) fatalerror("A maximum of one input device is allowed!"); if (indevs.size() == 1) diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index 8547fcfe22f..b28d7ff342f 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -377,7 +377,7 @@ namespace netlist analog_output_t m_Q; plib::uninitialised_array_t m_I; - plib::pvector_t m_precompiled; + std::vector m_precompiled; }; // ----------------------------------------------------------------------------- diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 7828c2f3f61..5dd6a8095f4 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -408,7 +408,7 @@ namespace netlist P_PREVENT_COPYING(core_terminal_t) public: - using list_t = plib::pvector_t; + using list_t = std::vector; /* needed here ... */ diff --git a/src/lib/netlist/nl_factory.h b/src/lib/netlist/nl_factory.h index 780408cd285..b85e85bf6b8 100644 --- a/src/lib/netlist/nl_factory.h +++ b/src/lib/netlist/nl_factory.h @@ -65,7 +65,7 @@ namespace netlist } }; - class factory_list_t : public plib::pvector_t> + class factory_list_t : public std::vector> { public: factory_list_t(setup_t &m_setup); diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp index b311e4b1a68..e4c4949b2a9 100644 --- a/src/lib/netlist/nl_setup.cpp +++ b/src/lib/netlist/nl_setup.cpp @@ -110,7 +110,7 @@ void setup_t::register_dev(plib::owned_ptr dev) void setup_t::register_lib_entry(const pstring &name) { - if (m_lib.contains(name)) + if (plib::container::contains(m_lib, name)) log().warning("Lib entry collection already contains {1}. IGNORED", name); else m_lib.push_back(name); @@ -118,7 +118,7 @@ void setup_t::register_lib_entry(const pstring &name) void setup_t::register_dev(const pstring &classname, const pstring &name) { - if (m_lib.contains(classname)) + if (plib::container::contains(m_lib, classname)) { namespace_push(name); include(classname); @@ -291,15 +291,16 @@ void setup_t::remove_connections(const pstring pin) pstring pinfn = build_fqn(pin); bool found = false; - for (int i = m_links.size() - 1; i >= 0; i--) + for (auto link = m_links.begin(); link != m_links.end(); ) { - auto &link = m_links[i]; - if ((link.first == pinfn) || (link.second == pinfn)) + if ((link->first == pinfn) || (link->second == pinfn)) { - log().verbose("removing connection: {1} <==> {2}\n", link.first, link.second); - m_links.remove_at(i); + log().verbose("removing connection: {1} <==> {2}\n", link->first, link->second); + link = m_links.erase(link); found = true; } + else + link++; } if (!found) log().fatal("remove_connections: found no occurrence of {1}\n", pin); @@ -706,16 +707,16 @@ void setup_t::resolve_inputs() int tries = 100; while (m_links.size() > 0 && tries > 0) // FIXME: convert into constant { - unsigned li = 0; - while (li < m_links.size()) + auto li = m_links.begin(); + while (li != m_links.end()) { - const pstring t1s = m_links[li].first; - const pstring t2s = m_links[li].second; + const pstring t1s = li->first; + const pstring t2s = li->second; core_terminal_t *t1 = find_terminal(t1s); core_terminal_t *t2 = find_terminal(t2s); if (connect(*t1, *t2)) - m_links.remove_at(li); + li = m_links.erase(li); else li++; } diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h index ebf989cb20f..90ef1fe422c 100644 --- a/src/lib/netlist/nl_setup.h +++ b/src/lib/netlist/nl_setup.h @@ -91,7 +91,7 @@ namespace netlist class source_t { public: - using list_t = plib::pvector_t>; + using list_t = std::vector>; source_t() {} @@ -167,7 +167,7 @@ namespace netlist factory_list_t &factory() { return m_factory; } const factory_list_t &factory() const { return m_factory; } - bool is_library_item(const pstring &name) const { return m_lib.contains(name); } + bool is_library_item(const pstring &name) const { return plib::container::contains(m_lib, name); } /* model / family related */ @@ -180,7 +180,7 @@ namespace netlist plib::plog_base &log() { return netlist().log(); } const plib::plog_base &log() const { return netlist().log(); } - plib::pvector_t> m_device_factory; + std::vector> m_device_factory; protected: @@ -208,7 +208,7 @@ namespace netlist plib::hashmap_t m_param_values; plib::hashmap_t m_terminals; - plib::pvector_t m_links; + std::vector m_links; factory_list_t m_factory; @@ -219,7 +219,7 @@ namespace netlist std::stack m_namespace_stack; source_t::list_t m_sources; - plib::pvector_t m_lib; + std::vector m_lib; }; diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h index 66b48e3ab94..ab4b06ce74d 100644 --- a/src/lib/netlist/plib/plists.h +++ b/src/lib/netlist/plib/plists.h @@ -14,8 +14,6 @@ #include #include #include -//#include -//#include #include "palloc.h" #include "pstring.h" diff --git a/src/lib/netlist/plib/poptions.h b/src/lib/netlist/plib/poptions.h index 8a66000053c..d153d08e604 100644 --- a/src/lib/netlist/plib/poptions.h +++ b/src/lib/netlist/plib/poptions.h @@ -224,7 +224,7 @@ private: return nullptr; } - pvector_t