From cb16de91c61c387b3215d77c16fbef0376a23677 Mon Sep 17 00:00:00 2001 From: couriersud Date: Fri, 27 Jan 2017 18:36:45 +0100 Subject: [PATCH] Minor refactoring. (nw) --- src/lib/netlist/nl_lists.h | 1 + src/lib/netlist/plib/pconfig.h | 24 ------------------------ src/lib/netlist/plib/pfmtlog.h | 22 +++++++++++----------- src/lib/netlist/plib/ptypes.h | 31 +++++++++++++++++++++++-------- src/lib/netlist/plib/putil.cpp | 4 ++-- 5 files changed, 37 insertions(+), 45 deletions(-) diff --git a/src/lib/netlist/nl_lists.h b/src/lib/netlist/nl_lists.h index 728bba6f440..f643af2020e 100644 --- a/src/lib/netlist/nl_lists.h +++ b/src/lib/netlist/nl_lists.h @@ -17,6 +17,7 @@ #include "nl_config.h" #include "plib/plists.h" #include "plib/pchrono.h" +#include "plib/ptypes.h" // ---------------------------------------------------------------------------------------- // timed queue diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index 71b4b4d955b..105463fe489 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -51,30 +51,6 @@ typedef __int128_t INT128; // Standard defines //============================================================ -// prevent implicit copying -#if 0 -#define P_PREVENT_COPYING(name) \ - private: \ - name(const name &); \ - name(const name &&); \ - name &operator=(const name &); -#else - -namespace plib -{ - struct nocopyassignmove - { - protected: - nocopyassignmove() = default; - ~nocopyassignmove() = default; - private: - nocopyassignmove(const nocopyassignmove &) = delete; - nocopyassignmove(nocopyassignmove &&) = delete; - nocopyassignmove &operator=(const nocopyassignmove &) = delete; - }; -} -#endif - //============================================================ // Pointer to Member Function //============================================================ diff --git a/src/lib/netlist/plib/pfmtlog.h b/src/lib/netlist/plib/pfmtlog.h index 8ee3c75c5f8..1a212e601b8 100644 --- a/src/lib/netlist/plib/pfmtlog.h +++ b/src/lib/netlist/plib/pfmtlog.h @@ -14,6 +14,14 @@ namespace plib { +P_ENUM(plog_level, + DEBUG, + INFO, + VERBOSE, + WARNING, + ERROR, + FATAL) + template struct ptype_traits_base { @@ -175,14 +183,6 @@ private: unsigned m_arg; }; -P_ENUM(plog_level, - DEBUG, - INFO, - VERBOSE, - WARNING, - ERROR, - FATAL) - class plog_dispatch_intf; template @@ -242,7 +242,7 @@ private: }; -template +template class plog_channel : public pfmt_writer_t { public: @@ -258,7 +258,7 @@ private: class plog_dispatch_intf { - template friend class plog_channel; + template friend class plog_channel; public: virtual ~plog_dispatch_intf(); @@ -290,7 +290,7 @@ public: }; -template +template void plog_channel::vdowrite(const pstring &ls) const { m_base->vlog(L, ls); diff --git a/src/lib/netlist/plib/ptypes.h b/src/lib/netlist/plib/ptypes.h index 6aabed738e9..182333875d0 100644 --- a/src/lib/netlist/plib/ptypes.h +++ b/src/lib/netlist/plib/ptypes.h @@ -39,11 +39,26 @@ namespace plib }; #endif + //============================================================ + // prevent implicit copying + //============================================================ + + struct nocopyassignmove + { + protected: + nocopyassignmove() = default; + ~nocopyassignmove() = default; + private: + nocopyassignmove(const nocopyassignmove &) = delete; + nocopyassignmove(nocopyassignmove &&) = delete; + nocopyassignmove &operator=(const nocopyassignmove &) = delete; + }; + //============================================================ // penum - strongly typed enumeration //============================================================ - struct enum_base + struct penum_base { protected: static int from_string_int(const char *str, const char *x); @@ -53,22 +68,22 @@ namespace plib } #define P_ENUM(ename, ...) \ - struct ename : public plib::enum_base { \ - enum e { __VA_ARGS__ }; \ - ename (e v) : m_v(v) { } \ + struct ename : public plib::penum_base { \ + enum E { __VA_ARGS__ }; \ + ename (E v) : m_v(v) { } \ bool set_from_string (const pstring &s) { \ static const char *strings = # __VA_ARGS__; \ int f = from_string_int(strings, s.c_str()); \ - if (f>=0) { m_v = static_cast(f); return true; } else { return false; } \ + if (f>=0) { m_v = static_cast(f); return true; } else { return false; } \ } \ - operator e() const {return m_v;} \ + operator E() const {return m_v;} \ bool operator==(const ename &rhs) const {return m_v == rhs.m_v;} \ - bool operator==(const e &rhs) const {return m_v == rhs;} \ + bool operator==(const E &rhs) const {return m_v == rhs;} \ const pstring name() const { \ static const char *strings = # __VA_ARGS__; \ return nthstr(static_cast(m_v), strings); \ } \ - private: e m_v; }; + private: E m_v; }; #endif /* PTYPES_H_ */ diff --git a/src/lib/netlist/plib/putil.cpp b/src/lib/netlist/plib/putil.cpp index 87ac06b3f75..6a24e8c4012 100644 --- a/src/lib/netlist/plib/putil.cpp +++ b/src/lib/netlist/plib/putil.cpp @@ -104,7 +104,7 @@ namespace plib } - int enum_base::from_string_int(const char *str, const char *x) + int penum_base::from_string_int(const char *str, const char *x) { int cnt = 0; const char *cur = str; @@ -131,7 +131,7 @@ namespace plib return cnt; return -1; } - pstring enum_base::nthstr(int n, const char *str) + pstring penum_base::nthstr(int n, const char *str) { char buf[64]; char *bufp = buf;