mirror of
https://github.com/holub/mame
synced 2025-07-04 17:38:08 +03:00
netlist: less cpp - more headers (nw)
- move more code in headers - delete some cpp files.
This commit is contained in:
parent
5ad9faa783
commit
cc8114f394
@ -48,10 +48,9 @@ project "netlist"
|
||||
MAME_DIR .. "src/lib/netlist/nl_parser.h",
|
||||
MAME_DIR .. "src/lib/netlist/nl_setup.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/nl_setup.h",
|
||||
MAME_DIR .. "src/lib/netlist/nl_types.h",
|
||||
MAME_DIR .. "src/lib/netlist/nl_types.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pconfig.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/palloc.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pchrono.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pchrono.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pexception.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pexception.h",
|
||||
@ -71,13 +70,11 @@ project "netlist"
|
||||
MAME_DIR .. "src/lib/netlist/plib/pparser.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pparser.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/ppmf.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pstate.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pstate.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pstring.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pstring.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pstream.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/pstream.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/ptime.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/ptime.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/ptypes.h",
|
||||
MAME_DIR .. "src/lib/netlist/plib/putil.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/plib/putil.h",
|
||||
@ -85,9 +82,9 @@ project "netlist"
|
||||
MAME_DIR .. "src/lib/netlist/tools/nl_convert.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_bjt.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_bjt.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_generic_models.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_mosfet.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_mosfet.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_generic_models.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_mosfet.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_mosfet.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nlid_fourterm.cpp",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nlid_fourterm.h",
|
||||
MAME_DIR .. "src/lib/netlist/analog/nld_fourterm.h",
|
||||
|
@ -79,15 +79,12 @@ OBJS = $(POBJS) $(NLOBJS)
|
||||
|
||||
POBJS := \
|
||||
$(POBJ)/pstring.o \
|
||||
$(POBJ)/pchrono.o \
|
||||
$(POBJ)/pdynlib.o \
|
||||
$(POBJ)/pexception.o \
|
||||
$(POBJ)/pfunction.o \
|
||||
$(POBJ)/pfmtlog.o \
|
||||
$(POBJ)/poptions.o \
|
||||
$(POBJ)/pparser.o \
|
||||
$(POBJ)/pstate.o \
|
||||
$(POBJ)/pstream.o \
|
||||
$(POBJ)/putil.o \
|
||||
|
||||
PMAIN := $(POBJ)/pmain.o
|
||||
|
@ -1,79 +0,0 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Couriersud
|
||||
|
||||
#if 0
|
||||
|
||||
#include "pchrono.h"
|
||||
|
||||
namespace plib {
|
||||
namespace chrono {
|
||||
#if defined(__x86_64__) && !defined(_clang__) && !defined(_MSC_VER) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6))
|
||||
|
||||
template <typename T>
|
||||
auto per_sec() -> typename T :: type
|
||||
{
|
||||
using ret_type = typename T :: type;
|
||||
static ret_type persec = 0;
|
||||
if (persec == 0)
|
||||
{
|
||||
ret_type x = 0;
|
||||
system_ticks::type t = system_ticks::start();
|
||||
system_ticks::type e;
|
||||
x = - T :: start();
|
||||
do {
|
||||
e = system_ticks::stop();
|
||||
} while (e - t < system_ticks::per_second() / 100 );
|
||||
x += T :: stop();
|
||||
persec = (ret_type)(double)((double) x * (double) system_ticks::per_second() / double (e - t));
|
||||
}
|
||||
return persec;
|
||||
}
|
||||
|
||||
|
||||
fast_ticks::type fast_ticks::per_second()
|
||||
{
|
||||
#if 1
|
||||
return per_sec<fast_ticks>();
|
||||
#else
|
||||
static type persec = 0;
|
||||
if (persec == 0)
|
||||
{
|
||||
type x = 0;
|
||||
system_ticks::type t = system_ticks::start();
|
||||
system_ticks::type e;
|
||||
x = -start();
|
||||
do {
|
||||
e = system_ticks::stop();
|
||||
} while (e - t < system_ticks::per_second() / 100 );
|
||||
x += stop();
|
||||
persec = (type)(double)((double) x * (double) system_ticks::per_second() / double (e - t));
|
||||
}
|
||||
return persec;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if PUSE_ACCURATE_STATS && PHAS_RDTSCP
|
||||
exact_ticks::type exact_ticks::per_second()
|
||||
{
|
||||
static type persec = 0;
|
||||
if (persec == 0)
|
||||
{
|
||||
type x = 0;
|
||||
system_ticks::type t = system_ticks::start();
|
||||
system_ticks::type e;
|
||||
x = -start();
|
||||
do {
|
||||
e = system_ticks::stop();
|
||||
} while (e - t < system_ticks::per_second() / 100 );
|
||||
x += stop();
|
||||
persec = (type)(double)((double) x * (double) system_ticks::per_second() / double (e - t));
|
||||
}
|
||||
return persec;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace chrono
|
||||
} // namespace plib
|
||||
#endif
|
@ -77,7 +77,7 @@ namespace plib {
|
||||
|
||||
|
||||
fpexception_e::fpexception_e(const pstring &text)
|
||||
: pexception(pfmt("Out of memory: {}")(text))
|
||||
: pexception(pfmt("Exception error: {}")(text))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -110,12 +110,10 @@ pfmt::rtype pfmt::setfmt(std::stringstream &strm, char32_t cfmt_spec)
|
||||
strm << std::setprecision(pstonum<int>(fmt.substr(1)));
|
||||
else if (pdot != pstring::npos)
|
||||
{
|
||||
//strm << std::setprecision(pstonum<int>(fmt.substr(pdot + 1))) << std::setw(pstonum<int>(left(fmt,pdot)));
|
||||
strm << std::setprecision(pstonum<int>(fmt.substr(pdot + 1)));
|
||||
r.width = pstonum<pstring::size_type>(left(fmt,pdot));
|
||||
}
|
||||
else if (fmt != "")
|
||||
//strm << std::setw(pstonum<int>(fmt));
|
||||
r.width = pstonum<pstring::size_type>(fmt);
|
||||
|
||||
switch (r.pend)
|
||||
|
@ -1,57 +0,0 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Couriersud
|
||||
/*
|
||||
* pstate.c
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pstate.h"
|
||||
#include "palloc.h"
|
||||
|
||||
namespace plib {
|
||||
|
||||
void state_manager_t::save_state_ptr(const void *owner, const pstring &stname, const datatype_t &dt, const std::size_t count, void *ptr)
|
||||
{
|
||||
auto p = plib::make_unique<entry_t>(stname, dt, owner, count, ptr);
|
||||
m_save.push_back(std::move(p));
|
||||
}
|
||||
|
||||
void state_manager_t::remove_save_items(const void *owner)
|
||||
{
|
||||
auto i = m_save.end();
|
||||
while (i != m_save.begin())
|
||||
{
|
||||
i--;
|
||||
if (i->get()->m_owner == owner)
|
||||
i = m_save.erase(i);
|
||||
}
|
||||
i = m_custom.end();
|
||||
while (i > m_custom.begin())
|
||||
{
|
||||
i--;
|
||||
if (i->get()->m_owner == owner)
|
||||
i = m_custom.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
void state_manager_t::pre_save()
|
||||
{
|
||||
for (auto & s : m_custom)
|
||||
s->m_callback->on_pre_save(*this);
|
||||
}
|
||||
|
||||
void state_manager_t::post_load()
|
||||
{
|
||||
for (auto & s : m_custom)
|
||||
s->m_callback->on_post_load(*this);
|
||||
}
|
||||
|
||||
template<> void state_manager_t::save_item(const void *owner, callback_t &state, const pstring &stname)
|
||||
{
|
||||
callback_t *state_p = &state;
|
||||
auto p = plib::make_unique<entry_t>(stname, owner, state_p);
|
||||
m_custom.push_back(std::move(p));
|
||||
state.register_state(*this, stname);
|
||||
}
|
||||
|
||||
} // namespace plib
|
@ -113,9 +113,40 @@ public:
|
||||
save_state_ptr(owner, stname, dtype<C>(), N, a.data());
|
||||
}
|
||||
|
||||
void pre_save();
|
||||
void post_load();
|
||||
void remove_save_items(const void *owner);
|
||||
void save_state_ptr(const void *owner, const pstring &stname, const datatype_t &dt, const std::size_t count, void *ptr)
|
||||
{
|
||||
m_save.push_back(plib::make_unique<entry_t>(stname, dt, owner, count, ptr));
|
||||
}
|
||||
|
||||
void pre_save()
|
||||
{
|
||||
for (auto & s : m_custom)
|
||||
s->m_callback->on_pre_save(*this);
|
||||
}
|
||||
|
||||
void post_load()
|
||||
{
|
||||
for (auto & s : m_custom)
|
||||
s->m_callback->on_post_load(*this);
|
||||
}
|
||||
|
||||
void remove_save_items(const void *owner)
|
||||
{
|
||||
auto i = m_save.end();
|
||||
while (i != m_save.begin())
|
||||
{
|
||||
i--;
|
||||
if (i->get()->m_owner == owner)
|
||||
i = m_save.erase(i);
|
||||
}
|
||||
i = m_custom.end();
|
||||
while (i > m_custom.begin())
|
||||
{
|
||||
i--;
|
||||
if (i->get()->m_owner == owner)
|
||||
i = m_custom.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<const entry_t *> save_list() const
|
||||
{
|
||||
@ -125,8 +156,6 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void save_state_ptr(const void *owner, const pstring &stname, const datatype_t &dt, const std::size_t count, void *ptr);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
@ -135,7 +164,12 @@ private:
|
||||
|
||||
};
|
||||
|
||||
template<> void state_manager_t::save_item(const void *owner, callback_t &state, const pstring &stname);
|
||||
template<> inline void state_manager_t::save_item(const void *owner, callback_t &state, const pstring &stname)
|
||||
{
|
||||
m_custom.push_back(plib::make_unique<entry_t>(stname, owner, &state));
|
||||
state.register_state(*this, stname);
|
||||
}
|
||||
|
||||
|
||||
} // namespace plib
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
// license:GPL-2.0+
|
||||
// copyright-holders:Couriersud
|
||||
/*
|
||||
* pstream.c
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pstream.h"
|
||||
#include "palloc.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
//#include <cstdlib>
|
||||
|
||||
// VS2015 prefers _dup
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace plib {
|
||||
|
||||
|
||||
bool putf8_reader::readline(pstring &line)
|
||||
{
|
||||
putf8string::code_t c = 0;
|
||||
m_linebuf = "";
|
||||
if (!this->readcode(c))
|
||||
{
|
||||
line = "";
|
||||
return false;
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
if (c == 10)
|
||||
break;
|
||||
else if (c != 13) /* ignore CR */
|
||||
m_linebuf += putf8string(1, c);
|
||||
if (!this->readcode(c))
|
||||
break;
|
||||
}
|
||||
line = m_linebuf.c_str();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void putf8_fmt_writer::vdowrite(const pstring &ls) const
|
||||
{
|
||||
write(ls);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace plib
|
@ -55,15 +55,37 @@ public:
|
||||
{}
|
||||
|
||||
bool eof() const { return m_strm->eof(); }
|
||||
bool readline(pstring &line);
|
||||
|
||||
bool readbyte1(std::istream::char_type &b)
|
||||
bool readline(pstring &line)
|
||||
{
|
||||
putf8string::code_t c = 0;
|
||||
m_linebuf = "";
|
||||
if (!this->readcode(c))
|
||||
{
|
||||
line = "";
|
||||
return false;
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
if (c == 10)
|
||||
break;
|
||||
else if (c != 13) /* ignore CR */
|
||||
m_linebuf += putf8string(1, c);
|
||||
if (!this->readcode(c))
|
||||
break;
|
||||
}
|
||||
line = m_linebuf.c_str();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool readbyte(std::istream::char_type &b)
|
||||
{
|
||||
if (m_strm->eof())
|
||||
return false;
|
||||
m_strm->read(&b, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool readcode(putf8string::traits_type::code_t &c)
|
||||
{
|
||||
std::array<std::istream::char_type, 4> b{0};
|
||||
@ -154,7 +176,11 @@ public:
|
||||
~putf8_fmt_writer() override = default;
|
||||
|
||||
//protected:
|
||||
void vdowrite(const pstring &ls) const;
|
||||
void vdowrite(const pstring &s) const
|
||||
{
|
||||
write(s);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -57,50 +57,6 @@ pstring_t<F> pstring_t<F>::substr(size_type start, size_type nlen) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
typename pstring_t<F>::size_type pstring_t<F>::find_first_not_of(const pstring_t &no) const
|
||||
{
|
||||
size_type pos = 0;
|
||||
for (auto it = begin(); it != end(); ++it, ++pos)
|
||||
{
|
||||
bool f = true;
|
||||
for (code_t const jt : no)
|
||||
{
|
||||
if (*it == jt)
|
||||
{
|
||||
f = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (f)
|
||||
return pos;
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
typename pstring_t<F>::size_type pstring_t<F>::find_last_not_of(const pstring_t &no) const
|
||||
{
|
||||
/* FIXME: reverse iterator */
|
||||
size_type last_found = npos;
|
||||
size_type pos = 0;
|
||||
for (auto it = begin(); it != end(); ++it, ++pos)
|
||||
{
|
||||
bool f = true;
|
||||
for (code_t const jt : no)
|
||||
{
|
||||
if (*it == jt)
|
||||
{
|
||||
f = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (f)
|
||||
last_found = pos;
|
||||
}
|
||||
return last_found;
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
typename pstring_t<F>::size_type pstring_t<F>::find(const pstring_t &search, size_type start) const
|
||||
{
|
||||
|
@ -178,9 +178,6 @@ public:
|
||||
size_type find(const pstring_t &search, size_type start = 0) const;
|
||||
size_type find(code_t search, size_type start = 0) const;
|
||||
|
||||
size_type find_first_not_of(const pstring_t &no) const;
|
||||
size_type find_last_not_of(const pstring_t &no) const;
|
||||
|
||||
// concatenation operators
|
||||
pstring_t& operator+=(const pstring_t &string) { m_str.append(string.m_str); return *this; }
|
||||
pstring_t& operator+=(const code_t c) { traits_type::encode(c, m_str); return *this; }
|
||||
|
Loading…
Reference in New Issue
Block a user