mirror of
https://github.com/holub/mame
synced 2025-04-20 23:42:22 +03:00
Rewrote for loops to use auto : semantics. (nw)
This commit is contained in:
parent
20be9611af
commit
07ec6f4378
@ -163,13 +163,13 @@ public:
|
||||
plib::pstring_vector_t out(io[1], ",");
|
||||
nl_assert_always(out.size() == m_NO, "output count wrong");
|
||||
|
||||
for (unsigned i=0; i < m_NI; i++)
|
||||
for (std::size_t i=0; i < m_NI; i++)
|
||||
{
|
||||
//new (&m_I[i]) logic_input_t();
|
||||
inout[i] = inout[i].trim();
|
||||
m_I.emplace(i, *this, inout[i]);
|
||||
}
|
||||
for (unsigned i=0; i < m_NO; i++)
|
||||
for (std::size_t i=0; i < m_NO; i++)
|
||||
{
|
||||
//new (&m_Q[i]) logic_output_t();
|
||||
out[i] = out[i].trim();
|
||||
@ -179,7 +179,7 @@ public:
|
||||
// Connect output "Q" to input "_Q" if this exists
|
||||
// This enables timed state without having explicit state ....
|
||||
UINT32 disabled_ignore = 0;
|
||||
for (unsigned i=0; i < m_NO; i++)
|
||||
for (std::size_t i=0; i < m_NO; i++)
|
||||
{
|
||||
pstring tmp = "_" + out[i];
|
||||
const int idx = inout.indexof(tmp);
|
||||
@ -213,9 +213,9 @@ public:
|
||||
{
|
||||
m_active = 0;
|
||||
m_ign = 0;
|
||||
for (unsigned i = 0; i < m_NI; i++)
|
||||
for (std::size_t i = 0; i < m_NI; i++)
|
||||
m_I[i].activate();
|
||||
for (unsigned i=0; i<m_NO;i++)
|
||||
for (std::size_t i=0; i<m_NO;i++)
|
||||
if (this->m_Q[i].net().num_cons()>0)
|
||||
m_active++;
|
||||
m_last_state = 0;
|
||||
@ -249,7 +249,7 @@ public:
|
||||
if (m_NI > 1 && has_state == 0)
|
||||
if (--m_active == 0)
|
||||
{
|
||||
for (unsigned i = 0; i< m_NI; i++)
|
||||
for (std::size_t i = 0; i< m_NI; i++)
|
||||
m_I[i].inactivate();
|
||||
m_ign = (1<<m_NI)-1;
|
||||
}
|
||||
@ -271,20 +271,20 @@ private:
|
||||
|
||||
UINT32 state = 0;
|
||||
if (m_NI > 1 && !has_state)
|
||||
for (unsigned i = 0; i < m_NI; i++)
|
||||
for (std::size_t i = 0; i < m_NI; i++)
|
||||
{
|
||||
if (!doOUT || (m_ign & (1<<i)))
|
||||
m_I[i].activate();
|
||||
}
|
||||
|
||||
if (!doOUT)
|
||||
for (unsigned i = 0; i < m_NI; i++)
|
||||
for (std::size_t i = 0; i < m_NI; i++)
|
||||
{
|
||||
state |= (INPLOGIC(m_I[i]) << i);
|
||||
mt = std::max(this->m_I[i].net().time(), mt);
|
||||
}
|
||||
else
|
||||
for (unsigned i = 0; i < m_NI; i++)
|
||||
for (std::size_t i = 0; i < m_NI; i++)
|
||||
state |= (INPLOGIC(m_I[i]) << i);
|
||||
|
||||
const UINT32 nstate = state | (has_state ? (m_last_state << m_NI) : 0);
|
||||
@ -297,16 +297,16 @@ private:
|
||||
const UINT32 timebase = nstate * m_NO;
|
||||
if (doOUT)
|
||||
{
|
||||
for (unsigned i = 0; i < m_NO; i++)
|
||||
for (std::size_t i = 0; i < m_NO; i++)
|
||||
OUTLOGIC(m_Q[i], (out >> i) & 1, m_ttp->m_timing_nt[m_ttp->m_timing[timebase + i]]);
|
||||
}
|
||||
else
|
||||
for (unsigned i = 0; i < m_NO; i++)
|
||||
for (std::size_t i = 0; i < m_NO; i++)
|
||||
m_Q[i].net().set_Q_time((out >> i) & 1, mt + m_ttp->m_timing_nt[m_ttp->m_timing[timebase + i]]);
|
||||
|
||||
if (m_NI > 1 && !has_state)
|
||||
{
|
||||
for (unsigned i = 0; i < m_NI; i++)
|
||||
for (std::size_t i = 0; i < m_NI; i++)
|
||||
if (m_ign & (1 << i))
|
||||
m_I[i].inactivate();
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ namespace netlist
|
||||
, m_Q(*this, "Q")
|
||||
{
|
||||
|
||||
for (int i=0; i < m_N; i++)
|
||||
for (std::size_t i=0; i < m_N; i++)
|
||||
m_I.emplace(i, *this, plib::pfmt("A{1}")(i));
|
||||
|
||||
plib::pstring_vector_t cmds(m_func.Value(), " ");
|
||||
|
@ -299,8 +299,8 @@ void netlist_t::reset()
|
||||
// m_solver->do_reset();
|
||||
|
||||
// Reset all nets once !
|
||||
for (std::size_t i = 0; i < m_nets.size(); i++)
|
||||
m_nets[i]->reset();
|
||||
for (auto & n : m_nets)
|
||||
n->reset();
|
||||
|
||||
// Reset all devices once !
|
||||
for (auto & dev : m_devices)
|
||||
@ -384,9 +384,8 @@ void netlist_t::print_stats() const
|
||||
{
|
||||
#if (NL_KEEP_STATISTICS)
|
||||
{
|
||||
for (std::size_t i = 0; i < m_devices.size(); i++)
|
||||
for (auto & entry : m_devices)
|
||||
{
|
||||
core_device_t *entry = m_devices[i].get();
|
||||
printf("Device %20s : %12d %12d %15ld\n", entry->name().cstr(), entry->stat_call_count, entry->stat_update_count, (long int) entry->stat_total_time / (entry->stat_update_count + 1));
|
||||
}
|
||||
printf("Queue Pushes %15d\n", queue().m_prof_call);
|
||||
@ -642,7 +641,7 @@ void net_t::rebuild_list()
|
||||
|
||||
unsigned cnt = 0;
|
||||
m_list_active.clear();
|
||||
for (core_terminal_t *term : m_core_terms)
|
||||
for (auto & term : m_core_terms)
|
||||
if (term->state() != logic_t::STATE_INP_PASSIVE)
|
||||
{
|
||||
m_list_active.add(*term);
|
||||
|
@ -461,7 +461,7 @@ devices::nld_base_proxy *setup_t::get_d_a_proxy(core_terminal_t &out)
|
||||
|
||||
/* connect all existing terminals to new net */
|
||||
|
||||
for (core_terminal_t *p : out.net().m_core_terms)
|
||||
for (auto & p : out.net().m_core_terms)
|
||||
{
|
||||
p->clear_net(); // de-link from all nets ...
|
||||
if (!connect(new_proxy->proxy_term(), *p))
|
||||
@ -615,7 +615,7 @@ bool setup_t::connect_input_input(core_terminal_t &t1, core_terminal_t &t2)
|
||||
ret = connect(t2, t1.net().railterminal());
|
||||
if (!ret)
|
||||
{
|
||||
for (core_terminal_t *t : t1.net().m_core_terms)
|
||||
for (auto & t : t1.net().m_core_terms)
|
||||
{
|
||||
if (t->is_type(core_terminal_t::TERMINAL))
|
||||
ret = connect(t2, *t);
|
||||
@ -630,7 +630,7 @@ bool setup_t::connect_input_input(core_terminal_t &t1, core_terminal_t &t2)
|
||||
ret = connect(t1, t2.net().railterminal());
|
||||
if (!ret)
|
||||
{
|
||||
for (core_terminal_t *t : t2.net().m_core_terms)
|
||||
for (auto & t : t2.net().m_core_terms)
|
||||
{
|
||||
if (t->is_type(core_terminal_t::TERMINAL))
|
||||
ret = connect(t1, *t);
|
||||
@ -723,8 +723,8 @@ void setup_t::resolve_inputs()
|
||||
}
|
||||
if (tries == 0)
|
||||
{
|
||||
for (std::size_t i = 0; i < m_links.size(); i++ )
|
||||
log().warning("Error connecting {1} to {2}\n", m_links[i].first, m_links[i].second);
|
||||
for (auto & link : m_links)
|
||||
log().warning("Error connecting {1} to {2}\n", link.first, link.second);
|
||||
|
||||
log().fatal("Error connecting -- bailing out\n");
|
||||
}
|
||||
@ -767,16 +767,12 @@ void setup_t::resolve_inputs()
|
||||
|
||||
|
||||
log().verbose("looking for two terms connected to rail nets ...\n");
|
||||
for (std::size_t i=0; i < netlist().m_devices.size(); i++)
|
||||
for (auto & t : netlist().get_device_list<devices::NETLIB_NAME(twoterm)>())
|
||||
{
|
||||
devices::NETLIB_NAME(twoterm) *t = dynamic_cast<devices::NETLIB_NAME(twoterm) *>(netlist().m_devices[i].get());
|
||||
if (t != nullptr)
|
||||
{
|
||||
has_twoterms = true;
|
||||
if (t->m_N.net().isRailNet() && t->m_P.net().isRailNet())
|
||||
log().warning("Found device {1} connected only to railterminals {2}/{3}\n",
|
||||
t->name(), t->m_N.net().name(), t->m_P.net().name());
|
||||
}
|
||||
has_twoterms = true;
|
||||
if (t->m_N.net().isRailNet() && t->m_P.net().isRailNet())
|
||||
log().warning("Found device {1} connected only to railterminals {2}/{3}\n",
|
||||
t->name(), t->m_N.net().name(), t->m_P.net().name());
|
||||
}
|
||||
|
||||
log().verbose("initialize solver ...\n");
|
||||
|
@ -103,7 +103,7 @@ public:
|
||||
|
||||
int indexof(const LC &elem) const
|
||||
{
|
||||
for (unsigned i = 0; i < this->size(); i++)
|
||||
for (std::size_t i = 0; i < this->size(); i++)
|
||||
{
|
||||
if (this->at(i) == elem)
|
||||
return i;
|
||||
|
@ -182,9 +182,8 @@ public:
|
||||
{
|
||||
pstring ret;
|
||||
|
||||
for (std::size_t i=0; i<m_opts.size(); i++ )
|
||||
for (auto & opt : m_opts )
|
||||
{
|
||||
option *opt = m_opts[i];
|
||||
pstring line = "";
|
||||
if (opt->m_short != "")
|
||||
line += " -" + opt->m_short;
|
||||
@ -207,19 +206,19 @@ private:
|
||||
|
||||
option *getopt_short(pstring arg)
|
||||
{
|
||||
for (std::size_t i=0; i < m_opts.size(); i++)
|
||||
for (auto & opt : m_opts)
|
||||
{
|
||||
if (m_opts[i]->m_short == arg)
|
||||
return m_opts[i];
|
||||
if (opt->m_short == arg)
|
||||
return opt;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
option *getopt_long(pstring arg)
|
||||
{
|
||||
for (std::size_t i=0; i < m_opts.size(); i++)
|
||||
for (auto & opt : m_opts)
|
||||
{
|
||||
if (m_opts[i]->m_long == arg)
|
||||
return m_opts[i];
|
||||
if (opt->m_long == arg)
|
||||
return opt;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -360,13 +360,13 @@ pstring ppreprocessor::replace_macros(const pstring &line)
|
||||
{
|
||||
pstring_vector_t elems(line, m_expr_sep);
|
||||
pstringbuffer ret = "";
|
||||
for (std::size_t i=0; i<elems.size(); i++)
|
||||
for (auto & elem : elems)
|
||||
{
|
||||
define_t *def = get_define(elems[i]);
|
||||
define_t *def = get_define(elem);
|
||||
if (def != nullptr)
|
||||
ret.cat(def->m_replace);
|
||||
else
|
||||
ret.cat(elems[i]);
|
||||
ret.cat(elem);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -374,9 +374,9 @@ pstring ppreprocessor::replace_macros(const pstring &line)
|
||||
static pstring catremainder(const pstring_vector_t &elems, std::size_t start, pstring sep)
|
||||
{
|
||||
pstringbuffer ret = "";
|
||||
for (std::size_t i=start; i<elems.size(); i++)
|
||||
for (auto & elem : elems)
|
||||
{
|
||||
ret.cat(elems[i]);
|
||||
ret.cat(elem);
|
||||
ret.cat(sep);
|
||||
}
|
||||
return ret;
|
||||
|
@ -56,16 +56,16 @@ void pstate_manager_t::remove_save_items(const void *owner)
|
||||
|
||||
void pstate_manager_t::pre_save()
|
||||
{
|
||||
for (std::size_t i=0; i < m_save.size(); i++)
|
||||
if (m_save[i]->m_dt == DT_CUSTOM)
|
||||
m_save[i]->m_callback->on_pre_save();
|
||||
for (auto & s : m_save)
|
||||
if (s->m_dt == DT_CUSTOM)
|
||||
s->m_callback->on_pre_save();
|
||||
}
|
||||
|
||||
void pstate_manager_t::post_load()
|
||||
{
|
||||
for (std::size_t i=0; i < m_save.size(); i++)
|
||||
if (m_save[i]->m_dt == DT_CUSTOM)
|
||||
m_save[i]->m_callback->on_post_load();
|
||||
for (auto & s : m_save)
|
||||
if (s->m_dt == DT_CUSTOM)
|
||||
s->m_callback->on_post_load();
|
||||
}
|
||||
|
||||
template<> void pstate_manager_t::save_item(const void *owner, pstate_callback_t &state, const pstring &stname)
|
||||
|
@ -147,7 +147,7 @@ const pstring_t<F> pstring_t<F>::ucase() const
|
||||
{
|
||||
pstring_t ret = *this;
|
||||
ret.pcopy(cstr(), blen());
|
||||
for (unsigned i=0; i<ret.len(); i++)
|
||||
for (std::size_t i=0; i<ret.len(); i++)
|
||||
ret.m_ptr->str()[i] = toupper((unsigned) ret.m_ptr->str()[i]);
|
||||
return ret;
|
||||
}
|
||||
@ -158,11 +158,11 @@ int pstring_t<F>::find_first_not_of(const pstring_t &no) const
|
||||
char *t = m_ptr->str();
|
||||
unsigned nolen = no.len();
|
||||
unsigned tlen = len();
|
||||
for (unsigned i=0; i < tlen; i++)
|
||||
for (std::size_t i=0; i < tlen; i++)
|
||||
{
|
||||
char *n = no.m_ptr->str();
|
||||
bool f = true;
|
||||
for (unsigned j=0; j < nolen; j++)
|
||||
for (std::size_t j=0; j < nolen; j++)
|
||||
{
|
||||
if (F::code(t) == F::code(n))
|
||||
f = false;
|
||||
@ -182,11 +182,11 @@ int pstring_t<F>::find_last_not_of(const pstring_t &no) const
|
||||
unsigned nolen = no.len();
|
||||
unsigned tlen = len();
|
||||
int last_found = -1;
|
||||
for (unsigned i=0; i < tlen; i++)
|
||||
for (std::size_t i=0; i < tlen; i++)
|
||||
{
|
||||
char *n = no.m_ptr->str();
|
||||
bool f = true;
|
||||
for (unsigned j=0; j < nolen; j++)
|
||||
for (std::size_t j=0; j < nolen; j++)
|
||||
{
|
||||
if (F::code(t) == F::code(n))
|
||||
f = false;
|
||||
@ -392,7 +392,7 @@ void pstring_t<F>::resetmem()
|
||||
{
|
||||
if (stk != nullptr)
|
||||
{
|
||||
for (unsigned i=0; i<=16; i++)
|
||||
for (std::size_t i=0; i<=16; i++)
|
||||
{
|
||||
for (; stk[i].size() > 0; )
|
||||
{
|
||||
@ -448,7 +448,7 @@ int pstring_t<F>::find(const pstring_t &search, unsigned start) const
|
||||
const char *s = search.cstr();
|
||||
const unsigned startt = std::min(start, tlen);
|
||||
const char *t = cstr();
|
||||
for (unsigned i=0; i<startt; i++)
|
||||
for (std::size_t i=0; i<startt; i++)
|
||||
t += F::codelen(t);
|
||||
for (int i=0; i <= (int) tlen - (int) startt - (int) slen; i++)
|
||||
{
|
||||
@ -477,7 +477,7 @@ int pstring_t<F>::find(const mem_t *search, unsigned start) const
|
||||
const char *s = search;
|
||||
const unsigned startt = std::min(start, tlen);
|
||||
const char *t = cstr();
|
||||
for (unsigned i=0; i<startt; i++)
|
||||
for (std::size_t i=0; i<startt; i++)
|
||||
t += F::codelen(t);
|
||||
for (int i=0; i <= (int) tlen - (int) startt - (int) slen; i++)
|
||||
{
|
||||
|
@ -112,11 +112,11 @@ public:
|
||||
{
|
||||
log().debug("Creating dynamic logs ...\n");
|
||||
plib::pstring_vector_t ll(m_opts ? m_opts->opt_logs() : "" , ":");
|
||||
for (unsigned i=0; i < ll.size(); i++)
|
||||
for (auto & log : ll)
|
||||
{
|
||||
pstring name = "log_" + ll[i];
|
||||
pstring name = "log_" + log;
|
||||
/*netlist_device_t *nc = */ m_setup->register_dev("LOG", name);
|
||||
m_setup->register_link(name + ".I", ll[i]);
|
||||
m_setup->register_link(name + ".I", log);
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,18 +284,16 @@ static void listdevices()
|
||||
nt.setup().start_devices();
|
||||
nt.setup().resolve_inputs();
|
||||
|
||||
for (unsigned i=0; i < list.size(); i++)
|
||||
for (auto & f : list)
|
||||
{
|
||||
auto &f = list[i];
|
||||
pstring out = plib::pfmt("{1} {2}(<id>")(f->classname(),"-20")(f->name());
|
||||
pstring terms("");
|
||||
|
||||
auto d = f->Create(nt.setup().netlist(), plib::pfmt("dummy{1}")(i));
|
||||
auto d = f->Create(nt.setup().netlist(), "dummy");
|
||||
|
||||
// get the list of terminals ...
|
||||
for (unsigned j=0; j < d->m_terminals.size(); j++)
|
||||
for (auto & inp : d->m_terminals)
|
||||
{
|
||||
pstring inp = d->m_terminals[j];
|
||||
if (inp.startsWith(d->name() + "."))
|
||||
inp = inp.substr(d->name().len() + 1);
|
||||
terms += "," + inp;
|
||||
|
Loading…
Reference in New Issue
Block a user