summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/netlist/nl_base.cpp4
-rw-r--r--src/lib/netlist/nl_base.h6
-rw-r--r--src/lib/netlist/nl_setup.cpp2
-rw-r--r--src/lib/netlist/nl_setup.h4
-rw-r--r--src/lib/netlist/plib/palloc.h29
-rw-r--r--src/lib/netlist/plib/pdynlib.h2
-rw-r--r--src/lib/netlist/plib/pfmtlog.h8
-rw-r--r--src/lib/netlist/plib/plists.h4
-rw-r--r--src/lib/netlist/plib/poptions.h2
-rw-r--r--src/lib/netlist/plib/pparser.h2
-rw-r--r--src/lib/netlist/plib/pstate.h2
-rw-r--r--src/lib/netlist/plib/pstream.h14
-rw-r--r--src/lib/netlist/prg/nltool.cpp27
13 files changed, 59 insertions, 47 deletions
diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp
index e20c240a374..2450ad9e83e 100644
--- a/src/lib/netlist/nl_base.cpp
+++ b/src/lib/netlist/nl_base.cpp
@@ -583,9 +583,9 @@ net_t::net_t(netlist_t &nl, const pstring &aname, core_terminal_t *mr)
{
m_railterminal = mr;
if (mr != nullptr)
- nl.m_nets.push_back(std::shared_ptr<net_t>(this, do_nothing_deleter()));
+ nl.m_nets.push_back(std::move(plib::owned_ptr<net_t>(this, false)));
else
- nl.m_nets.push_back(std::shared_ptr<net_t>(this));
+ nl.m_nets.push_back(std::move(plib::owned_ptr<net_t>(this, true)));
}
net_t::~net_t()
diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h
index 1451e18038d..79b651f2058 100644
--- a/src/lib/netlist/nl_base.h
+++ b/src/lib/netlist/nl_base.h
@@ -1044,7 +1044,7 @@ namespace netlist
public plib::state_manager_t::callback_t
{
public:
- queue_t(netlist_t &nl);
+ explicit queue_t(netlist_t &nl);
protected:
@@ -1070,7 +1070,7 @@ namespace netlist
P_PREVENT_COPYING(netlist_t)
public:
- netlist_t(const pstring &aname);
+ explicit netlist_t(const pstring &aname);
virtual ~netlist_t();
pstring name() const { return m_name; }
@@ -1155,7 +1155,7 @@ namespace netlist
std::vector<plib::owned_ptr<core_device_t>> m_devices;
/* sole use is to manage lifetime of net objects */
- std::vector<std::shared_ptr<net_t>> m_nets;
+ std::vector<plib::owned_ptr<net_t>> m_nets;
/* sole use is to manage lifetime of family objects */
std::vector<std::pair<pstring, std::unique_ptr<logic_family_desc_t>>> m_family_cache;
diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp
index 0582f8a9070..99fb8962546 100644
--- a/src/lib/netlist/nl_setup.cpp
+++ b/src/lib/netlist/nl_setup.cpp
@@ -399,7 +399,7 @@ core_terminal_t *setup_t::find_terminal(const pstring &terminal_in, device_objec
return term;
}
-param_t *setup_t::find_param(const pstring &param_in, bool required)
+param_t *setup_t::find_param(const pstring &param_in, bool required) const
{
const pstring param_in_fqn = build_fqn(param_in);
diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h
index 2fee7210aa9..5d3cda4bd39 100644
--- a/src/lib/netlist/nl_setup.h
+++ b/src/lib/netlist/nl_setup.h
@@ -173,7 +173,7 @@ namespace netlist
using link_t = std::pair<pstring, pstring>;
- setup_t(netlist_t &netlist);
+ explicit setup_t(netlist_t &netlist);
~setup_t();
netlist_t &netlist() { return m_netlist; }
@@ -210,7 +210,7 @@ namespace netlist
bool device_exists(const pstring name) const;
- param_t *find_param(const pstring &param_in, bool required = true);
+ param_t *find_param(const pstring &param_in, bool required = true) const;
void start_devices();
void resolve_inputs();
diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h
index 1529cd38194..72617aa603b 100644
--- a/src/lib/netlist/plib/palloc.h
+++ b/src/lib/netlist/plib/palloc.h
@@ -79,8 +79,15 @@ public:
: m_ptr(p), m_is_owned(owned)
{ }
owned_ptr(const owned_ptr &r) = delete;
- owned_ptr & operator =(const owned_ptr &r) = delete;
-
+ owned_ptr & operator =(owned_ptr &r) = delete;
+ owned_ptr & operator =(owned_ptr &&r)
+ {
+ m_is_owned = r.m_is_owned;
+ m_ptr = r.m_ptr;
+ r.m_is_owned = false;
+ r.m_ptr = nullptr;
+ return *this;
+ }
owned_ptr(owned_ptr &&r)
{
m_is_owned = r.m_is_owned;
@@ -92,17 +99,17 @@ public:
template<typename DC>
owned_ptr(owned_ptr<DC> &&r)
{
- SC *dest_ptr = &dynamic_cast<SC &>(*r.get());
- bool o = r.is_owned();
+ m_ptr = static_cast<SC *>(r.get());
+ m_is_owned = r.is_owned();
r.release();
- m_is_owned = o;
- m_ptr = dest_ptr;
}
~owned_ptr()
{
- if (m_is_owned)
+ if (m_is_owned && m_ptr != nullptr)
delete m_ptr;
+ m_is_owned = false;
+ m_ptr = nullptr;
}
template<typename DC, typename... Args>
static owned_ptr Create(Args&&... args)
@@ -110,7 +117,7 @@ public:
owned_ptr a;
DC *x = new DC(std::forward<Args>(args)...);
a.m_ptr = static_cast<SC *>(x);
- return a;
+ return std::move(a);
}
template<typename... Args>
@@ -118,7 +125,7 @@ public:
{
owned_ptr a;
a.m_ptr = new SC(std::forward<Args>(args)...);
- return a;
+ return std::move(a);
}
void release()
{
@@ -128,8 +135,9 @@ public:
bool is_owned() const { return m_is_owned; }
+#if 1
template<typename DC>
- owned_ptr<DC> & operator =(owned_ptr<DC> &r)
+ owned_ptr & operator =(owned_ptr<DC> &&r)
{
m_is_owned = r.m_is_owned;
m_ptr = r.m_ptr;
@@ -137,6 +145,7 @@ public:
r.m_ptr = nullptr;
return *this;
}
+#endif
SC * operator ->() const { return m_ptr; }
SC & operator *() const { return *m_ptr; }
SC * get() const { return m_ptr; }
diff --git a/src/lib/netlist/plib/pdynlib.h b/src/lib/netlist/plib/pdynlib.h
index 08aa531d1bf..097f5b069ae 100644
--- a/src/lib/netlist/plib/pdynlib.h
+++ b/src/lib/netlist/plib/pdynlib.h
@@ -22,7 +22,7 @@ namespace plib {
class dynlib
{
public:
- dynlib(const pstring libname);
+ explicit dynlib(const pstring libname);
dynlib(const pstring path, const pstring libname);
~dynlib();
diff --git a/src/lib/netlist/plib/pfmtlog.h b/src/lib/netlist/plib/pfmtlog.h
index af899c35a26..7d8677b5725 100644
--- a/src/lib/netlist/plib/pfmtlog.h
+++ b/src/lib/netlist/plib/pfmtlog.h
@@ -154,8 +154,8 @@ protected:
class pfmt : public pformat_base<pfmt>
{
public:
- pfmt(const pstring &fmt);
- pfmt(const char *fmt);
+ explicit pfmt(const pstring &fmt);
+ explicit pfmt(const char *fmt);
virtual ~pfmt();
operator pstring() const { return m_str; }
@@ -245,7 +245,7 @@ template <plog_level::e L, bool build_enabled = true>
class plog_channel : public pfmt_writer_t<build_enabled>
{
public:
- plog_channel(plog_dispatch_intf *b) : pfmt_writer_t<build_enabled>(), m_base(b) { }
+ explicit plog_channel(plog_dispatch_intf *b) : pfmt_writer_t<build_enabled>(), m_base(b) { }
virtual ~plog_channel() { }
protected:
@@ -270,7 +270,7 @@ class plog_base
{
public:
- plog_base(plog_dispatch_intf *proxy)
+ explicit plog_base(plog_dispatch_intf *proxy)
: debug(proxy),
info(proxy),
verbose(proxy),
diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h
index 030b172f50e..97d55120806 100644
--- a/src/lib/netlist/plib/plists.h
+++ b/src/lib/netlist/plib/plists.h
@@ -96,8 +96,8 @@ public:
{
LC* p;
public:
- constexpr iter_t(LC* x) noexcept : p(x) {}
- iter_t(const iter_t &rhs) noexcept = default;
+ explicit constexpr iter_t(LC* x) noexcept : p(x) {}
+ explicit iter_t(const iter_t &rhs) noexcept = default;
iter_t(iter_t &&rhs) noexcept = default;
iter_t& operator++() noexcept {p = p->next();return *this;}
iter_t operator++(int) noexcept {iter_t tmp(*this); operator++(); return tmp;}
diff --git a/src/lib/netlist/plib/poptions.h b/src/lib/netlist/plib/poptions.h
index 6ddac682d66..13e11971709 100644
--- a/src/lib/netlist/plib/poptions.h
+++ b/src/lib/netlist/plib/poptions.h
@@ -111,7 +111,7 @@ class options
public:
options();
- options(option *o[]);
+ explicit options(option *o[]);
~options();
diff --git a/src/lib/netlist/plib/pparser.h b/src/lib/netlist/plib/pparser.h
index e6b6dd8f989..a1a0c138f51 100644
--- a/src/lib/netlist/plib/pparser.h
+++ b/src/lib/netlist/plib/pparser.h
@@ -25,7 +25,7 @@ class ptokenizer
public:
virtual ~ptokenizer() {}
- ptokenizer(pistream &strm)
+ explicit ptokenizer(pistream &strm)
: m_strm(strm), m_lineno(1), m_px(0), m_string('"')
{}
diff --git a/src/lib/netlist/plib/pstate.h b/src/lib/netlist/plib/pstate.h
index cbfa2b06d1d..23aef80f176 100644
--- a/src/lib/netlist/plib/pstate.h
+++ b/src/lib/netlist/plib/pstate.h
@@ -30,7 +30,7 @@ public:
datatype_t(std::size_t bsize, bool bptr, bool bintegral, bool bfloat)
: size(bsize), is_ptr(bptr), is_integral(bintegral), is_float(bfloat), is_custom(false)
{}
- datatype_t(bool bcustom)
+ explicit datatype_t(bool bcustom)
: size(0), is_ptr(false), is_integral(false), is_float(false), is_custom(bcustom)
{}
diff --git a/src/lib/netlist/plib/pstream.h b/src/lib/netlist/plib/pstream.h
index 42379a7da4b..a7f81723262 100644
--- a/src/lib/netlist/plib/pstream.h
+++ b/src/lib/netlist/plib/pstream.h
@@ -31,7 +31,7 @@ public:
static const pos_type SEEK_EOF = (pos_type) -1;
- pstream(const unsigned flags) : m_flags(flags)
+ explicit pstream(const unsigned flags) : m_flags(flags)
{
}
virtual ~pstream()
@@ -99,7 +99,7 @@ class pistream : public pstream
P_PREVENT_COPYING(pistream)
public:
- pistream(const unsigned flags) : pstream(flags) {}
+ explicit pistream(const unsigned flags) : pstream(flags) {}
virtual ~pistream() {}
bool eof() const { return ((flags() & FLAG_EOF) != 0) || bad(); }
@@ -134,7 +134,7 @@ class postream : public pstream
P_PREVENT_COPYING(postream)
public:
- postream(unsigned flags) : pstream(flags) {}
+ explicit postream(unsigned flags) : pstream(flags) {}
virtual ~postream() {}
/* this digests linux & dos/windows text files */
@@ -230,7 +230,7 @@ class pofilestream : public postream
P_PREVENT_COPYING(pofilestream)
public:
- pofilestream(const pstring &fname);
+ explicit pofilestream(const pstring &fname);
virtual ~pofilestream();
void close();
@@ -281,7 +281,7 @@ class pifilestream : public pistream
P_PREVENT_COPYING(pifilestream)
public:
- pifilestream(const pstring &fname);
+ explicit pifilestream(const pstring &fname);
virtual ~pifilestream();
void close();
@@ -324,7 +324,7 @@ class pimemstream : public pistream
public:
pimemstream(const void *mem, const pos_type len);
- pimemstream(const pomemstream &ostrm);
+ explicit pimemstream(const pomemstream &ostrm);
virtual ~pimemstream();
protected:
@@ -364,7 +364,7 @@ class pstream_fmt_writer_t : public plib::pfmt_writer_t<>
P_PREVENT_COPYING(pstream_fmt_writer_t)
public:
- pstream_fmt_writer_t(postream &strm) : m_strm(strm) {}
+ explicit pstream_fmt_writer_t(postream &strm) : m_strm(strm) {}
virtual ~pstream_fmt_writer_t() { }
protected:
diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp
index 8d753e212c6..0f7b7ffb565 100644
--- a/src/lib/netlist/prg/nltool.cpp
+++ b/src/lib/netlist/prg/nltool.cpp
@@ -118,6 +118,8 @@ public:
}
}
+ netlist::setup_t &setup() { return *m_setup; }
+
tool_options_t *m_opts;
protected:
@@ -143,11 +145,13 @@ void usage(tool_options_t &opts)
struct input_t
{
+#if 0
input_t()
: m_param(nullptr), m_value(0.0)
{
}
- input_t(netlist::netlist_t *netlist, const pstring &line)
+#endif
+ input_t(const netlist::setup_t &setup, const pstring &line)
{
char buf[400];
double t;
@@ -155,7 +159,7 @@ struct input_t
if ( e!= 3)
throw netlist::fatalerror_e(plib::pfmt("error {1} scanning line {2}\n")(e)(line));
m_time = netlist::netlist_time::from_double(t);
- m_param = netlist->setup().find_param(buf, true);
+ m_param = setup.find_param(buf, true);
}
void setparam()
@@ -183,9 +187,9 @@ struct input_t
};
-std::vector<input_t> *read_input(netlist::netlist_t *netlist, pstring fname)
+static std::vector<input_t> read_input(const netlist::setup_t &setup, pstring fname)
{
- std::vector<input_t> *ret = plib::palloc<std::vector<input_t>>();
+ std::vector<input_t> ret;
if (fname != "")
{
plib::pifilestream f(fname);
@@ -194,8 +198,8 @@ std::vector<input_t> *read_input(netlist::netlist_t *netlist, pstring fname)
{
if (l != "")
{
- input_t inp(netlist, l);
- ret->push_back(inp);
+ input_t inp(setup, l);
+ ret.push_back(inp);
}
}
}
@@ -220,7 +224,7 @@ static void run(tool_options_t &opts)
nt.read_netlist(opts.opt_file(), opts.opt_name());
- std::vector<input_t> *inps = read_input(&nt, opts.opt_inp());
+ std::vector<input_t> inps = read_input(nt.setup(), opts.opt_inp());
double ttr = opts.opt_ttr();
t.stop();
@@ -234,16 +238,15 @@ static void run(tool_options_t &opts)
unsigned pos = 0;
netlist::netlist_time nlt = netlist::netlist_time::zero();
- while (pos < inps->size() && (*inps)[pos].m_time < netlist::netlist_time::from_double(ttr))
+ while (pos < inps.size() && inps[pos].m_time < netlist::netlist_time::from_double(ttr))
{
- nt.process_queue((*inps)[pos].m_time - nlt);
- (*inps)[pos].setparam();
- nlt = (*inps)[pos].m_time;
+ nt.process_queue(inps[pos].m_time - nlt);
+ inps[pos].setparam();
+ nlt = inps[pos].m_time;
pos++;
}
nt.process_queue(netlist::netlist_time::from_double(ttr) - nlt);
nt.stop();
- plib::pfree(inps);
t.stop();