mirror of
https://github.com/holub/mame
synced 2025-04-19 15:11:37 +03:00
netlist: clang lint readability fixes. (nw)
This commit is contained in:
parent
9431ee68e7
commit
6874b1f7ac
@ -26,7 +26,7 @@ TIDY_FLAGSX += -bugprone-macro-parentheses,-misc-macro-parentheses,
|
||||
TIDY_FLAGSX += -bugprone-too-small-loop-variable,
|
||||
TIDY_FLAGSX += -modernize-use-trailing-return-type,
|
||||
TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||
TIDY_FLAGSX += -readability-magic-numbers,-readability-implicit-bool-conversion,readability-braces-around-statements
|
||||
TIDY_FLAGSX += -readability-magic-numbers,-readability-implicit-bool-conversion,-readability-braces-around-statements
|
||||
|
||||
space :=
|
||||
space +=
|
||||
|
@ -83,7 +83,7 @@ namespace netlist
|
||||
{
|
||||
unsigned a = 0;
|
||||
for (std::size_t i=0; i<11; i++)
|
||||
a |= (m_A[i]() << i);
|
||||
a |= (m_A[i]() << i);
|
||||
|
||||
d = m_ROM[a];
|
||||
|
||||
|
@ -86,7 +86,8 @@ namespace netlist
|
||||
update_outputs(1, 0, 0);
|
||||
return;
|
||||
}
|
||||
else if (m_A[i]() < m_B[i]())
|
||||
|
||||
if (m_A[i]() < m_B[i]())
|
||||
{
|
||||
update_outputs(0, 1, 0);
|
||||
return;
|
||||
|
@ -73,7 +73,7 @@ namespace netlist
|
||||
{
|
||||
unsigned a = 0;
|
||||
for (std::size_t i=0; i<8; i++)
|
||||
a |= (m_A[i]() << i);
|
||||
a |= (m_A[i]() << i);
|
||||
|
||||
o = m_ROM[a];
|
||||
|
||||
|
@ -81,8 +81,8 @@ namespace devices
|
||||
return ret;
|
||||
}
|
||||
|
||||
static constexpr const pbitset all_bits() noexcept { return pbitset(~static_cast<T>(0)); }
|
||||
static constexpr const pbitset no_bits() noexcept{ return pbitset(static_cast<T>(0)); }
|
||||
static constexpr pbitset all_bits() noexcept { return pbitset(~static_cast<T>(0)); }
|
||||
static constexpr pbitset no_bits() noexcept{ return pbitset(static_cast<T>(0)); }
|
||||
private:
|
||||
T m_bs;
|
||||
};
|
||||
|
@ -161,18 +161,16 @@ namespace netlist
|
||||
{
|
||||
if (dynamic_cast<const terminal_t *>(this) != nullptr)
|
||||
return terminal_type::TERMINAL;
|
||||
else if (dynamic_cast<const logic_input_t *>(this) != nullptr
|
||||
if (dynamic_cast<const logic_input_t *>(this) != nullptr
|
||||
|| dynamic_cast<const analog_input_t *>(this) != nullptr)
|
||||
return terminal_type::INPUT;
|
||||
else if (dynamic_cast<const logic_output_t *>(this) != nullptr
|
||||
if (dynamic_cast<const logic_output_t *>(this) != nullptr
|
||||
|| dynamic_cast<const analog_output_t *>(this) != nullptr)
|
||||
return terminal_type::OUTPUT;
|
||||
else
|
||||
{
|
||||
state().log().fatal(MF_UNKNOWN_TYPE_FOR_OBJECT(name()));
|
||||
throw nl_exception(MF_UNKNOWN_TYPE_FOR_OBJECT(name()));
|
||||
//return terminal_type::TERMINAL; // please compiler
|
||||
}
|
||||
|
||||
state().log().fatal(MF_UNKNOWN_TYPE_FOR_OBJECT(name()));
|
||||
throw nl_exception(MF_UNKNOWN_TYPE_FOR_OBJECT(name()));
|
||||
//return terminal_type::TERMINAL; // please compiler
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -198,7 +196,6 @@ namespace netlist
|
||||
netlist_state_t::netlist_state_t(const pstring &aname,
|
||||
plib::unique_ptr<callbacks_t> &&callbacks)
|
||||
: m_name(aname)
|
||||
, m_state()
|
||||
, m_callbacks(std::move(callbacks)) // Order is important here
|
||||
, m_log(*m_callbacks)
|
||||
, m_extended_validation(false)
|
||||
@ -442,7 +439,7 @@ namespace netlist
|
||||
for (auto & j : index)
|
||||
{
|
||||
auto entry = m_state.m_devices[j].second.get();
|
||||
auto stats = m_state.m_devices[j].second.get()->m_stats.get();
|
||||
auto stats = entry->m_stats.get();
|
||||
log().verbose("Device {1:20} : {2:12} {3:12} {4:15} {5:12}", entry->name(),
|
||||
stats->m_stat_call_count(), stats->m_stat_total_time.count(),
|
||||
stats->m_stat_total_time.total(), stats->m_stat_inc_active());
|
||||
@ -520,8 +517,7 @@ namespace netlist
|
||||
m_log.fatal(MF_MORE_THAN_ONE_1_DEVICE_FOUND(classname));
|
||||
throw nl_exception(MF_MORE_THAN_ONE_1_DEVICE_FOUND(classname));
|
||||
}
|
||||
else
|
||||
ret = d.second.get();
|
||||
ret = d.second.get();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -534,7 +530,6 @@ namespace netlist
|
||||
|
||||
core_device_t::core_device_t(netlist_state_t &owner, const pstring &name)
|
||||
: object_t(name)
|
||||
, logic_family_t()
|
||||
, netlist_ref(owner.exec())
|
||||
, m_hint_deactivate(false)
|
||||
, m_active_outputs(*this, "m_active_outputs", 1)
|
||||
@ -547,7 +542,6 @@ namespace netlist
|
||||
|
||||
core_device_t::core_device_t(core_device_t &owner, const pstring &name)
|
||||
: object_t(owner.name() + "." + name)
|
||||
, logic_family_t()
|
||||
, netlist_ref(owner.state().exec())
|
||||
, m_hint_deactivate(false)
|
||||
, m_active_outputs(*this, "m_active_outputs", 1)
|
||||
@ -759,7 +753,6 @@ namespace netlist
|
||||
detail::core_terminal_t::core_terminal_t(core_device_t &dev, const pstring &aname,
|
||||
const state_e state, nldelegate delegate)
|
||||
: device_object_t(dev, dev.name() + "." + aname)
|
||||
, plib::linkedlist_t<core_terminal_t>::element_t()
|
||||
#if NL_USE_COPY_INSTEAD_OF_REFERENCE
|
||||
, m_Q(*this, "m_Q", 0)
|
||||
#endif
|
||||
@ -778,7 +771,6 @@ namespace netlist
|
||||
logic_t::logic_t(core_device_t &dev, const pstring &aname, const state_e state,
|
||||
nldelegate delegate)
|
||||
: core_terminal_t(dev, aname, state, delegate)
|
||||
, logic_family_t()
|
||||
{
|
||||
}
|
||||
|
||||
@ -896,19 +888,17 @@ namespace netlist
|
||||
{
|
||||
if (dynamic_cast<const param_str_t *>(this) != nullptr)
|
||||
return STRING;
|
||||
else if (dynamic_cast<const param_fp_t *>(this) != nullptr)
|
||||
if (dynamic_cast<const param_fp_t *>(this) != nullptr)
|
||||
return DOUBLE;
|
||||
else if (dynamic_cast<const param_int_t *>(this) != nullptr)
|
||||
if (dynamic_cast<const param_int_t *>(this) != nullptr)
|
||||
return INTEGER;
|
||||
else if (dynamic_cast<const param_logic_t *>(this) != nullptr)
|
||||
if (dynamic_cast<const param_logic_t *>(this) != nullptr)
|
||||
return LOGIC;
|
||||
else if (dynamic_cast<const param_ptr_t *>(this) != nullptr)
|
||||
if (dynamic_cast<const param_ptr_t *>(this) != nullptr)
|
||||
return POINTER;
|
||||
else
|
||||
{
|
||||
state().log().fatal(MF_UNKNOWN_PARAM_TYPE(name()));
|
||||
throw nl_exception(MF_UNKNOWN_PARAM_TYPE(name()));
|
||||
}
|
||||
|
||||
state().log().fatal(MF_UNKNOWN_PARAM_TYPE(name()));
|
||||
throw nl_exception(MF_UNKNOWN_PARAM_TYPE(name()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -632,7 +632,7 @@ namespace netlist
|
||||
|
||||
state_var_sig m_Q;
|
||||
#else
|
||||
static void set_copied_input(netlist_sig_t val) noexcept { plib::unused_var(val); }
|
||||
void set_copied_input(netlist_sig_t val) noexcept { plib::unused_var(val); }
|
||||
#endif
|
||||
|
||||
void set_delegate(const nldelegate &delegate) noexcept { m_delegate = delegate; }
|
||||
|
@ -218,11 +218,11 @@ namespace netlist
|
||||
template <>
|
||||
struct fp_constants<float>
|
||||
{
|
||||
static inline constexpr float DIODE_MAXDIFF() noexcept { return 1e20f; }
|
||||
static inline constexpr float DIODE_MAXVOLT() noexcept { return 90.0f; }
|
||||
static inline constexpr float DIODE_MAXDIFF() noexcept { return 1e20F; }
|
||||
static inline constexpr float DIODE_MAXVOLT() noexcept { return 90.0F; }
|
||||
|
||||
static inline constexpr float TIMESTEP_MAXDIFF() noexcept { return 1e30f; }
|
||||
static inline constexpr float TIMESTEP_MINDIV() noexcept { return 1e-8f; }
|
||||
static inline constexpr float TIMESTEP_MAXDIFF() noexcept { return 1e30F; }
|
||||
static inline constexpr float TIMESTEP_MINDIV() noexcept { return 1e-8F; }
|
||||
|
||||
static inline constexpr const char * name() noexcept { return "float"; }
|
||||
static inline constexpr const char * suffix() noexcept { return "f"; }
|
||||
|
@ -86,8 +86,9 @@ bool parser_t::parse(const pstring &nlname)
|
||||
{
|
||||
parse_netlist(name.str());
|
||||
return true;
|
||||
} else
|
||||
in_nl = true;
|
||||
}
|
||||
|
||||
in_nl = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace netlist
|
||||
void nlparse_t::register_dip_alias_arr(const pstring &terms)
|
||||
{
|
||||
std::vector<pstring> list(plib::psplit(terms,", "));
|
||||
if (list.size() == 0 || (list.size() % 2) == 1)
|
||||
if (list.empty() || (list.size() % 2) == 1)
|
||||
{
|
||||
log().fatal(MF_DIP_PINS_MUST_BE_AN_EQUAL_NUMBER_OF_PINS_1(build_fqn("")));
|
||||
throw nl_exception(MF_DIP_PINS_MUST_BE_AN_EQUAL_NUMBER_OF_PINS_1(build_fqn("")));
|
||||
@ -80,7 +80,7 @@ namespace netlist
|
||||
|
||||
register_dev(classname, name);
|
||||
|
||||
if (params_and_connections.size() > 0)
|
||||
if (!params_and_connections.empty())
|
||||
{
|
||||
auto ptok(params_and_connections.begin());
|
||||
auto ptok_end(params_and_connections.end());
|
||||
@ -146,19 +146,17 @@ namespace netlist
|
||||
log().fatal(MF_CLASS_1_NOT_FOUND(classname));
|
||||
throw nl_exception(MF_CLASS_1_NOT_FOUND(classname));
|
||||
}
|
||||
else
|
||||
|
||||
// make sure we parse macro library entries
|
||||
f->macro_actions(*this, name);
|
||||
pstring key = build_fqn(name);
|
||||
if (device_exists(key))
|
||||
{
|
||||
// make sure we parse macro library entries
|
||||
f->macro_actions(*this, name);
|
||||
pstring key = build_fqn(name);
|
||||
if (device_exists(key))
|
||||
{
|
||||
log().fatal(MF_DEVICE_ALREADY_EXISTS_1(name));
|
||||
throw nl_exception(MF_DEVICE_ALREADY_EXISTS_1(name));
|
||||
}
|
||||
else
|
||||
m_device_factory.insert(m_device_factory.end(), {key, f});
|
||||
log().fatal(MF_DEVICE_ALREADY_EXISTS_1(name));
|
||||
throw nl_exception(MF_DEVICE_ALREADY_EXISTS_1(name));
|
||||
}
|
||||
|
||||
m_device_factory.insert(m_device_factory.end(), {key, f});
|
||||
}
|
||||
|
||||
void nlparse_t::register_link(const pstring &sin, const pstring &sout)
|
||||
@ -281,11 +279,8 @@ namespace netlist
|
||||
|
||||
pstring nlparse_t::build_fqn(const pstring &obj_name) const
|
||||
{
|
||||
if (m_namespace_stack.empty())
|
||||
//return netlist().name() + "." + obj_name;
|
||||
return obj_name;
|
||||
else
|
||||
return m_namespace_stack.top() + "." + obj_name;
|
||||
return (m_namespace_stack.empty()) ? obj_name
|
||||
: m_namespace_stack.top() + "." + obj_name;
|
||||
}
|
||||
|
||||
void nlparse_t::register_alias_nofqn(const pstring &alias, const pstring &out)
|
||||
@ -343,7 +338,7 @@ setup_t::setup_t(netlist_state_t &nlstate)
|
||||
{
|
||||
}
|
||||
|
||||
pstring setup_t::termtype_as_str(detail::core_terminal_t &in) const
|
||||
pstring setup_t::termtype_as_str(detail::core_terminal_t &in)
|
||||
{
|
||||
switch (in.type())
|
||||
{
|
||||
@ -362,10 +357,7 @@ pstring setup_t::termtype_as_str(detail::core_terminal_t &in) const
|
||||
pstring setup_t::get_initial_param_val(const pstring &name, const pstring &def) const
|
||||
{
|
||||
auto i = m_param_values.find(name);
|
||||
if (i != m_param_values.end())
|
||||
return i->second;
|
||||
else
|
||||
return def;
|
||||
return (i != m_param_values.end()) ? i->second : def;
|
||||
}
|
||||
|
||||
void setup_t::register_term(detail::core_terminal_t &term)
|
||||
@ -544,8 +536,8 @@ detail::core_terminal_t *setup_t::find_terminal(const pstring &terminal_in,
|
||||
log().fatal(MF_OBJECT_1_2_WRONG_TYPE(terminal_in, tname));
|
||||
throw nl_exception(MF_OBJECT_1_2_WRONG_TYPE(terminal_in, tname));
|
||||
}
|
||||
else
|
||||
term = nullptr;
|
||||
|
||||
term = nullptr;
|
||||
}
|
||||
if (term != nullptr)
|
||||
log().debug("Found input {1}\n", tname);
|
||||
@ -576,39 +568,38 @@ devices::nld_base_proxy *setup_t::get_d_a_proxy(detail::core_terminal_t &out)
|
||||
auto &out_cast = static_cast<logic_output_t &>(out);
|
||||
auto iter_proxy(m_proxies.find(&out));
|
||||
|
||||
if (iter_proxy == m_proxies.end())
|
||||
{
|
||||
// create a new one ...
|
||||
pstring x = plib::pfmt("proxy_da_{1}_{2}")(out.name())(m_proxy_cnt);
|
||||
auto new_proxy =
|
||||
out_cast.logic_family()->create_d_a_proxy(m_nlstate, x, &out_cast);
|
||||
m_proxy_cnt++;
|
||||
// connect all existing terminals to new net
|
||||
|
||||
for (auto & p : out.net().core_terms())
|
||||
{
|
||||
p->clear_net(); // de-link from all nets ...
|
||||
if (!connect(new_proxy->proxy_term(), *p))
|
||||
{
|
||||
log().fatal(MF_CONNECTING_1_TO_2(
|
||||
new_proxy->proxy_term().name(), (*p).name()));
|
||||
throw nl_exception(MF_CONNECTING_1_TO_2(
|
||||
new_proxy->proxy_term().name(), (*p).name()));
|
||||
}
|
||||
}
|
||||
out.net().core_terms().clear();
|
||||
|
||||
out.net().add_terminal(new_proxy->in());
|
||||
|
||||
auto proxy(new_proxy.get());
|
||||
if (!m_proxies.insert({&out, proxy}).second)
|
||||
throw nl_exception(MF_DUPLICATE_PROXY_1(out.name()));
|
||||
|
||||
m_nlstate.register_device(new_proxy->name(), std::move(new_proxy));
|
||||
return proxy;
|
||||
}
|
||||
else
|
||||
if (iter_proxy != m_proxies.end())
|
||||
return iter_proxy->second;
|
||||
|
||||
// create a new one ...
|
||||
pstring x = plib::pfmt("proxy_da_{1}_{2}")(out.name())(m_proxy_cnt);
|
||||
auto new_proxy =
|
||||
out_cast.logic_family()->create_d_a_proxy(m_nlstate, x, &out_cast);
|
||||
m_proxy_cnt++;
|
||||
// connect all existing terminals to new net
|
||||
|
||||
for (auto & p : out.net().core_terms())
|
||||
{
|
||||
p->clear_net(); // de-link from all nets ...
|
||||
if (!connect(new_proxy->proxy_term(), *p))
|
||||
{
|
||||
log().fatal(MF_CONNECTING_1_TO_2(
|
||||
new_proxy->proxy_term().name(), (*p).name()));
|
||||
throw nl_exception(MF_CONNECTING_1_TO_2(
|
||||
new_proxy->proxy_term().name(), (*p).name()));
|
||||
}
|
||||
}
|
||||
out.net().core_terms().clear();
|
||||
|
||||
out.net().add_terminal(new_proxy->in());
|
||||
|
||||
auto proxy(new_proxy.get());
|
||||
if (!m_proxies.insert({&out, proxy}).second)
|
||||
throw nl_exception(MF_DUPLICATE_PROXY_1(out.name()));
|
||||
|
||||
m_nlstate.register_device(new_proxy->name(), std::move(new_proxy));
|
||||
return proxy;
|
||||
|
||||
}
|
||||
|
||||
devices::nld_base_proxy *setup_t::get_a_d_proxy(detail::core_terminal_t &inp)
|
||||
@ -621,42 +612,40 @@ devices::nld_base_proxy *setup_t::get_a_d_proxy(detail::core_terminal_t &inp)
|
||||
|
||||
if (iter_proxy != m_proxies.end())
|
||||
return iter_proxy->second;
|
||||
else
|
||||
|
||||
log().debug("connect_terminal_input: connecting proxy\n");
|
||||
pstring x = plib::pfmt("proxy_ad_{1}_{2}")(inp.name())(m_proxy_cnt);
|
||||
auto new_proxy = incast.logic_family()->create_a_d_proxy(m_nlstate, x, &incast);
|
||||
//auto new_proxy = plib::owned_ptr<devices::nld_a_to_d_proxy>::Create(netlist(), x, &incast);
|
||||
|
||||
auto ret(new_proxy.get());
|
||||
|
||||
if (!m_proxies.insert({&inp, ret}).second)
|
||||
throw nl_exception(MF_DUPLICATE_PROXY_1(inp.name()));
|
||||
|
||||
m_proxy_cnt++;
|
||||
|
||||
// connect all existing terminals to new net
|
||||
|
||||
if (inp.has_net())
|
||||
{
|
||||
log().debug("connect_terminal_input: connecting proxy\n");
|
||||
pstring x = plib::pfmt("proxy_ad_{1}_{2}")(inp.name())(m_proxy_cnt);
|
||||
auto new_proxy = incast.logic_family()->create_a_d_proxy(m_nlstate, x, &incast);
|
||||
//auto new_proxy = plib::owned_ptr<devices::nld_a_to_d_proxy>::Create(netlist(), x, &incast);
|
||||
|
||||
auto ret(new_proxy.get());
|
||||
|
||||
if (!m_proxies.insert({&inp, ret}).second)
|
||||
throw nl_exception(MF_DUPLICATE_PROXY_1(inp.name()));
|
||||
|
||||
m_proxy_cnt++;
|
||||
|
||||
// connect all existing terminals to new net
|
||||
|
||||
if (inp.has_net())
|
||||
for (auto & p : inp.net().core_terms())
|
||||
{
|
||||
for (auto & p : inp.net().core_terms())
|
||||
p->clear_net(); // de-link from all nets ...
|
||||
if (!connect(ret->proxy_term(), *p))
|
||||
{
|
||||
p->clear_net(); // de-link from all nets ...
|
||||
if (!connect(ret->proxy_term(), *p))
|
||||
{
|
||||
log().fatal(MF_CONNECTING_1_TO_2(
|
||||
ret->proxy_term().name(), (*p).name()));
|
||||
throw nl_exception(MF_CONNECTING_1_TO_2(
|
||||
ret->proxy_term().name(), (*p).name()));
|
||||
log().fatal(MF_CONNECTING_1_TO_2(
|
||||
ret->proxy_term().name(), (*p).name()));
|
||||
throw nl_exception(MF_CONNECTING_1_TO_2(
|
||||
ret->proxy_term().name(), (*p).name()));
|
||||
|
||||
}
|
||||
}
|
||||
inp.net().core_terms().clear(); // clear the list
|
||||
}
|
||||
ret->out().net().add_terminal(inp);
|
||||
m_nlstate.register_device(new_proxy->name(), std::move(new_proxy));
|
||||
return ret;
|
||||
inp.net().core_terms().clear(); // clear the list
|
||||
}
|
||||
ret->out().net().add_terminal(inp);
|
||||
m_nlstate.register_device(new_proxy->name(), std::move(new_proxy));
|
||||
return ret;
|
||||
}
|
||||
|
||||
detail::core_terminal_t &setup_t::resolve_proxy(detail::core_terminal_t &term)
|
||||
@ -901,7 +890,7 @@ void setup_t::resolve_inputs()
|
||||
// after all other terminals were connected.
|
||||
|
||||
unsigned tries = m_netlist_params->m_max_link_loops();
|
||||
while (m_links.size() > 0 && tries > 0)
|
||||
while (!m_links.empty() > 0 && tries > 0)
|
||||
{
|
||||
|
||||
for (auto li = m_links.begin(); li != m_links.end(); )
|
||||
@ -1079,26 +1068,22 @@ pstring models_t::value_str(const pstring &model, const pstring &entity)
|
||||
{
|
||||
model_map_t &map = m_cache[model];
|
||||
|
||||
if (map.size() == 0)
|
||||
if (map.empty())
|
||||
model_parse(model , map);
|
||||
|
||||
pstring ret;
|
||||
|
||||
if (entity != plib::ucase(entity))
|
||||
throw nl_exception(MF_MODEL_PARAMETERS_NOT_UPPERCASE_1_2(entity, model_string(map)));
|
||||
if (map.find(entity) == map.end())
|
||||
throw nl_exception(MF_ENTITY_1_NOT_FOUND_IN_MODEL_2(entity, model_string(map)));
|
||||
else
|
||||
ret = map[entity];
|
||||
|
||||
return ret;
|
||||
return map[entity];
|
||||
}
|
||||
|
||||
nl_fptype models_t::value(const pstring &model, const pstring &entity)
|
||||
{
|
||||
model_map_t &map = m_cache[model];
|
||||
|
||||
if (map.size() == 0)
|
||||
if (map.empty())
|
||||
model_parse(model , map);
|
||||
|
||||
pstring tmp = value_str(model, entity);
|
||||
@ -1210,8 +1195,7 @@ void setup_t::delete_empty_nets()
|
||||
x->state().run_state_manager().remove_save_items(x.get());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return false;
|
||||
}), m_nlstate.nets().end());
|
||||
}
|
||||
|
||||
@ -1275,7 +1259,7 @@ void setup_t::prepare_to_run()
|
||||
}
|
||||
}
|
||||
|
||||
bool use_deactivate = m_netlist_params->m_use_deactivate() ? true : false;
|
||||
const bool use_deactivate = m_netlist_params->m_use_deactivate();
|
||||
|
||||
for (auto &d : m_nlstate.devices())
|
||||
{
|
||||
@ -1346,10 +1330,7 @@ void setup_t::prepare_to_run()
|
||||
bool source_netlist_t::parse(nlparse_t &setup, const pstring &name)
|
||||
{
|
||||
auto strm(stream(name));
|
||||
if (strm)
|
||||
return setup.parse_stream(std::move(strm), name);
|
||||
else
|
||||
return false;
|
||||
return (strm) ? setup.parse_stream(std::move(strm), name) : false;
|
||||
}
|
||||
|
||||
source_string_t::stream_ptr source_string_t::stream(const pstring &name)
|
||||
@ -1372,10 +1353,7 @@ source_file_t::stream_ptr source_file_t::stream(const pstring &name)
|
||||
{
|
||||
plib::unused_var(name);
|
||||
auto ret(plib::make_unique<std::ifstream>(plib::filesystem::u8path(m_filename)));
|
||||
if (ret->is_open())
|
||||
return std::move(ret);
|
||||
else
|
||||
return stream_ptr(nullptr);
|
||||
return (ret->is_open()) ? std::move(ret) : stream_ptr(nullptr);
|
||||
}
|
||||
|
||||
bool source_proc_t::parse(nlparse_t &setup, const pstring &name)
|
||||
@ -1385,8 +1363,8 @@ bool source_proc_t::parse(nlparse_t &setup, const pstring &name)
|
||||
m_setup_func(setup);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
source_proc_t::stream_ptr source_proc_t::stream(const pstring &name)
|
||||
|
@ -184,9 +184,7 @@ namespace netlist
|
||||
|
||||
friend class setup_t;
|
||||
|
||||
source_netlist_t()
|
||||
: plib::psource_t()
|
||||
{}
|
||||
source_netlist_t() = default;
|
||||
|
||||
COPYASSIGNMOVE(source_netlist_t, delete)
|
||||
~source_netlist_t() noexcept override = default;
|
||||
@ -200,9 +198,7 @@ namespace netlist
|
||||
|
||||
friend class setup_t;
|
||||
|
||||
source_data_t()
|
||||
: plib::psource_t()
|
||||
{}
|
||||
source_data_t() = default;
|
||||
|
||||
COPYASSIGNMOVE(source_data_t, delete)
|
||||
~source_data_t() noexcept override = default;
|
||||
@ -243,7 +239,7 @@ namespace netlist
|
||||
public:
|
||||
using link_t = std::pair<pstring, pstring>;
|
||||
|
||||
nlparse_t(setup_t &netlist, log_type &log);
|
||||
nlparse_t(setup_t &setup, log_type &log);
|
||||
|
||||
void register_model(const pstring &model_in) { m_models.register_model(model_in); }
|
||||
void register_alias(const pstring &alias, const pstring &out);
|
||||
@ -261,7 +257,7 @@ namespace netlist
|
||||
void register_param(const pstring ¶m, const pstring &value);
|
||||
|
||||
// FIXME: quick hack
|
||||
void register_param_x(const pstring ¶m, const nl_fptype value);
|
||||
void register_param_x(const pstring ¶m, nl_fptype value);
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_floating_point<T>::value || std::is_integral<T>::value>::type
|
||||
@ -278,7 +274,7 @@ namespace netlist
|
||||
#endif
|
||||
|
||||
void register_lib_entry(const pstring &name, const pstring &sourcefile);
|
||||
void register_frontier(const pstring &attach, const nl_fptype r_IN, const nl_fptype r_OUT);
|
||||
void register_frontier(const pstring &attach, nl_fptype r_IN, nl_fptype r_OUT);
|
||||
|
||||
// register a source
|
||||
void register_source(plib::unique_ptr<plib::psource_t> &&src)
|
||||
@ -390,10 +386,7 @@ namespace netlist
|
||||
terminal_t *get_connected_terminal(const terminal_t &term) const noexcept
|
||||
{
|
||||
auto ret(m_connected_terminals.find(&term));
|
||||
if (ret != m_connected_terminals.end())
|
||||
return ret->second;
|
||||
else
|
||||
return nullptr;
|
||||
return (ret != m_connected_terminals.end()) ? ret->second : nullptr;
|
||||
}
|
||||
|
||||
void remove_connections(const pstring &pin);
|
||||
@ -424,7 +417,7 @@ namespace netlist
|
||||
const log_type &log() const;
|
||||
|
||||
// needed by proxy
|
||||
detail::core_terminal_t *find_terminal(const pstring &outname_in, const detail::terminal_type atype, bool required = true) const;
|
||||
detail::core_terminal_t *find_terminal(const pstring &terminal_in, detail::terminal_type atype, bool required = true) const;
|
||||
detail::core_terminal_t *find_terminal(const pstring &terminal_in, bool required = true) const;
|
||||
|
||||
// core net handling
|
||||
@ -446,7 +439,7 @@ namespace netlist
|
||||
bool connect_input_input(detail::core_terminal_t &t1, detail::core_terminal_t &t2);
|
||||
|
||||
// helpers
|
||||
pstring termtype_as_str(detail::core_terminal_t &in) const;
|
||||
static pstring termtype_as_str(detail::core_terminal_t &in);
|
||||
|
||||
devices::nld_base_proxy *get_d_a_proxy(detail::core_terminal_t &out);
|
||||
devices::nld_base_proxy *get_a_d_proxy(detail::core_terminal_t &inp);
|
||||
@ -473,7 +466,7 @@ namespace netlist
|
||||
public:
|
||||
|
||||
explicit source_string_t(const pstring &source)
|
||||
: source_netlist_t(), m_str(source)
|
||||
: m_str(source)
|
||||
{
|
||||
}
|
||||
|
||||
@ -489,7 +482,7 @@ namespace netlist
|
||||
public:
|
||||
|
||||
explicit source_file_t(const pstring &filename)
|
||||
: source_netlist_t(), m_filename(filename)
|
||||
: m_filename(filename)
|
||||
{
|
||||
}
|
||||
|
||||
@ -504,7 +497,7 @@ namespace netlist
|
||||
{
|
||||
public:
|
||||
explicit source_mem_t(const char *mem)
|
||||
: source_netlist_t(), m_str(mem)
|
||||
: m_str(mem)
|
||||
{
|
||||
}
|
||||
|
||||
@ -519,9 +512,8 @@ namespace netlist
|
||||
{
|
||||
public:
|
||||
source_proc_t(const pstring &name, void (*setup_func)(nlparse_t &))
|
||||
: source_netlist_t(),
|
||||
m_setup_func(setup_func),
|
||||
m_setup_func_name(name)
|
||||
: m_setup_func(setup_func)
|
||||
, m_setup_func_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -107,15 +107,15 @@ namespace netlist
|
||||
using netlist_time = plib::ptime<std::int64_t, NETLIST_INTERNAL_RES>;
|
||||
using netlist_time_ext = netlist_time;
|
||||
#endif
|
||||
static_assert(noexcept(netlist_time::from_nsec(1)) == true, "Not evaluated as constexpr");
|
||||
static_assert(noexcept(netlist_time::from_nsec(1)), "Not evaluated as constexpr");
|
||||
|
||||
//============================================================
|
||||
// MACROS
|
||||
//============================================================
|
||||
|
||||
template <typename T> inline constexpr const netlist_time NLTIME_FROM_NS(T &&t) noexcept { return netlist_time::from_nsec(t); }
|
||||
template <typename T> inline constexpr const netlist_time NLTIME_FROM_US(T &&t) noexcept { return netlist_time::from_usec(t); }
|
||||
template <typename T> inline constexpr const netlist_time NLTIME_FROM_MS(T &&t) noexcept { return netlist_time::from_msec(t); }
|
||||
template <typename T> inline constexpr netlist_time NLTIME_FROM_NS(T &&t) noexcept { return netlist_time::from_nsec(t); }
|
||||
template <typename T> inline constexpr netlist_time NLTIME_FROM_US(T &&t) noexcept { return netlist_time::from_usec(t); }
|
||||
template <typename T> inline constexpr netlist_time NLTIME_FROM_MS(T &&t) noexcept { return netlist_time::from_msec(t); }
|
||||
|
||||
} // namespace netlist
|
||||
|
||||
|
@ -296,8 +296,7 @@ namespace plib
|
||||
vec_add_mult_scalar(n, x, m_v[i], m_y[i]);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
template <int k, typename OPS, typename VT>
|
||||
|
@ -337,8 +337,8 @@ namespace plib
|
||||
void gaussian_elimination_parallel(V & RHS)
|
||||
{
|
||||
//printf("omp: %ld %d %d\n", m_ge_par.size(), nz_num, (int)m_ge_par[m_ge_par.size()-2].size());
|
||||
for (auto l = 0ul; l < m_ge_par.size(); l++)
|
||||
plib::omp::for_static(base::nz_num, 0ul, m_ge_par[l].size(), [this, &RHS, &l] (unsigned ll)
|
||||
for (auto l = 0UL; l < m_ge_par.size(); l++)
|
||||
plib::omp::for_static(base::nz_num, 0UL, m_ge_par[l].size(), [this, &RHS, &l] (unsigned ll)
|
||||
{
|
||||
auto &i = m_ge_par[l][ll];
|
||||
{
|
||||
|
@ -92,21 +92,21 @@ namespace plib {
|
||||
{
|
||||
if (v == "(" || v == ")")
|
||||
return 1;
|
||||
else if (plib::left(v, 1) >= "a" && plib::left(v, 1) <= "z")
|
||||
if (plib::left(v, 1) >= "a" && plib::left(v, 1) <= "z")
|
||||
return 0;
|
||||
else if (v == "*" || v == "/")
|
||||
if (v == "*" || v == "/")
|
||||
return 20;
|
||||
else if (v == "+" || v == "-")
|
||||
if (v == "+" || v == "-")
|
||||
return 10;
|
||||
else if (v == "^")
|
||||
if (v == "^")
|
||||
return 30;
|
||||
else
|
||||
return -1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static pstring pop_check(std::stack<pstring> &stk, const pstring &expr) noexcept(false)
|
||||
{
|
||||
if (stk.size() == 0)
|
||||
if (stk.empty())
|
||||
throw pexception(plib::pfmt("pfunction: stack underflow during infix parsing of: <{1}>")(expr));
|
||||
pstring res = stk.top();
|
||||
stk.pop();
|
||||
@ -183,7 +183,7 @@ namespace plib {
|
||||
postfix.push_back(x);
|
||||
x = pop_check(opstk, expr);
|
||||
}
|
||||
if (opstk.size() > 0 && get_prio(opstk.top()) == 0)
|
||||
if (!opstk.empty() && get_prio(opstk.top()) == 0)
|
||||
postfix.push_back(pop_check(opstk, expr));
|
||||
}
|
||||
else if (s==",")
|
||||
@ -200,7 +200,7 @@ namespace plib {
|
||||
int p = get_prio(s);
|
||||
if (p>0)
|
||||
{
|
||||
if (opstk.size() == 0)
|
||||
if (opstk.empty())
|
||||
opstk.push(s);
|
||||
else
|
||||
{
|
||||
@ -220,7 +220,7 @@ namespace plib {
|
||||
postfix.push_back(s);
|
||||
}
|
||||
}
|
||||
while (opstk.size() > 0)
|
||||
while (!opstk.empty())
|
||||
{
|
||||
postfix.push_back(opstk.top());
|
||||
opstk.pop();
|
||||
@ -238,8 +238,8 @@ namespace plib {
|
||||
std::uint16_t lsb = lfsr & 1;
|
||||
lfsr >>= 1;
|
||||
if (lsb)
|
||||
lfsr ^= 0xB400u; // taps 15, 13, 12, 10
|
||||
return static_cast<NT>(lfsr) / static_cast<NT>(0xffffu);
|
||||
lfsr ^= 0xB400U; // taps 15, 13, 12, 10
|
||||
return static_cast<NT>(lfsr) / static_cast<NT>(0xffffU);
|
||||
}
|
||||
|
||||
template <typename NT>
|
||||
@ -249,7 +249,7 @@ namespace plib {
|
||||
std::uint16_t lsb = lfsr & 1;
|
||||
lfsr >>= 1;
|
||||
if (lsb)
|
||||
lfsr ^= 0xB400u; // taps 15, 13, 12, 10
|
||||
lfsr ^= 0xB400U; // taps 15, 13, 12, 10
|
||||
return static_cast<NT>(lfsr);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ namespace plib {
|
||||
///
|
||||
///
|
||||
pfunction(const pstring &name, const void *owner, state_manager_t &state_manager)
|
||||
: m_lfsr(0xACE1u)
|
||||
: m_lfsr(0xace1U)
|
||||
{
|
||||
state_manager.save_item(owner, m_lfsr, name + ".lfsr");
|
||||
}
|
||||
@ -66,7 +66,7 @@ namespace plib {
|
||||
/// \brief Constructor without state saving support
|
||||
///
|
||||
pfunction()
|
||||
: m_lfsr(0xACE1u)
|
||||
: m_lfsr(0xace1U)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,7 @@ namespace plib {
|
||||
#endif
|
||||
|
||||
app::app()
|
||||
: options()
|
||||
, pout(&std::cout)
|
||||
: pout(&std::cout)
|
||||
, perr(&std::cerr)
|
||||
{
|
||||
|
||||
|
@ -77,10 +77,8 @@ namespace plib {
|
||||
{
|
||||
throw pexception("other args can only be specified once!");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_other_args = ov;
|
||||
}
|
||||
|
||||
m_other_args = ov;
|
||||
}
|
||||
else
|
||||
throw pexception("found option with neither short or long tag!" );
|
||||
@ -105,7 +103,7 @@ namespace plib {
|
||||
if (!seen_other_args && plib::startsWith(arg, "--"))
|
||||
{
|
||||
auto v = psplit(arg.substr(2),"=");
|
||||
if (v.size() && v[0] != "")
|
||||
if (!v.empty() && v[0] != "")
|
||||
{
|
||||
opt = getopt_long(v[0]);
|
||||
has_equal_arg = (v.size() > 1);
|
||||
|
@ -139,8 +139,8 @@ namespace plib {
|
||||
m_val = static_cast<T>(raw);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -162,7 +162,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<const entry_t *> save_list() const
|
||||
std::vector<const entry_t *> save_list() const
|
||||
{
|
||||
std::vector<const entry_t *> ret;
|
||||
for (auto &i : m_save)
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
{
|
||||
if (c == 10)
|
||||
break;
|
||||
else if (c != 13) // ignore CR
|
||||
if (c != 13) // ignore CR
|
||||
m_linebuf += putf8string(1, c);
|
||||
if (!this->readcode(c))
|
||||
break;
|
||||
@ -83,9 +83,7 @@ public:
|
||||
if (m_strm->eof())
|
||||
return false;
|
||||
m_strm->read(&b, 1);
|
||||
if (m_strm->eof())
|
||||
return false;
|
||||
return true;
|
||||
return (!m_strm->eof());
|
||||
}
|
||||
|
||||
bool readcode(putf8string::traits_type::code_t &c)
|
||||
@ -170,8 +168,7 @@ class putf8_fmt_writer : public pfmt_writer_t<putf8_fmt_writer>, public putf8_wr
|
||||
public:
|
||||
|
||||
explicit putf8_fmt_writer(std::ostream *strm)
|
||||
: pfmt_writer_t()
|
||||
, putf8_writer(strm)
|
||||
: putf8_writer(strm)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,9 @@ int pstring_t<F>::compare(const pstring_t &right) const noexcept
|
||||
{
|
||||
if (mem_t_size() == 0 && right.mem_t_size() == 0)
|
||||
return 0;
|
||||
else if (right.mem_t_size() == 0)
|
||||
if (right.mem_t_size() == 0)
|
||||
return 1;
|
||||
else if (mem_t_size() == 0)
|
||||
if (mem_t_size() == 0)
|
||||
return -1;
|
||||
|
||||
auto si = this->begin();
|
||||
|
@ -90,28 +90,28 @@ namespace plib
|
||||
}
|
||||
|
||||
template <typename O>
|
||||
constexpr const ptime operator-(const ptime<O, RES> &rhs) const noexcept
|
||||
constexpr ptime operator-(const ptime<O, RES> &rhs) const noexcept
|
||||
{
|
||||
static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
|
||||
return ptime(m_time - rhs.m_time);
|
||||
}
|
||||
|
||||
template <typename O>
|
||||
constexpr const ptime operator+(const ptime<O, RES> &rhs) const noexcept
|
||||
constexpr ptime operator+(const ptime<O, RES> &rhs) const noexcept
|
||||
{
|
||||
static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
|
||||
return ptime(m_time + rhs.m_time);
|
||||
}
|
||||
|
||||
template <typename M>
|
||||
constexpr const ptime operator*(const M &factor) const noexcept
|
||||
constexpr ptime operator*(const M &factor) const noexcept
|
||||
{
|
||||
static_assert(plib::is_integral<M>::value, "Factor must be an integral type");
|
||||
return ptime(m_time * static_cast<mult_type>(factor));
|
||||
}
|
||||
|
||||
template <typename O>
|
||||
constexpr const mult_type operator/(const ptime<O, RES> &rhs) const noexcept
|
||||
constexpr mult_type operator/(const ptime<O, RES> &rhs) const noexcept
|
||||
{
|
||||
static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
|
||||
return static_cast<mult_type>(m_time / rhs.m_time);
|
||||
@ -175,34 +175,34 @@ namespace plib
|
||||
// for save states ....
|
||||
C14CONSTEXPR internal_type *get_internaltype_ptr() noexcept { return &m_time; }
|
||||
|
||||
static constexpr const ptime from_nsec(const internal_type ns) noexcept { return ptime(ns, UINT64_C(1000000000)); }
|
||||
static constexpr const ptime from_usec(const internal_type us) noexcept { return ptime(us, UINT64_C( 1000000)); }
|
||||
static constexpr const ptime from_msec(const internal_type ms) noexcept { return ptime(ms, UINT64_C( 1000)); }
|
||||
static constexpr const ptime from_sec(const internal_type s) noexcept { return ptime(s, UINT64_C( 1)); }
|
||||
static constexpr const ptime from_hz(const internal_type hz) noexcept { return ptime(1 , hz); }
|
||||
static constexpr const ptime from_raw(const internal_type raw) noexcept { return ptime(raw); }
|
||||
static constexpr ptime from_nsec(internal_type ns) noexcept { return ptime(ns, UINT64_C(1000000000)); }
|
||||
static constexpr ptime from_usec(internal_type us) noexcept { return ptime(us, UINT64_C( 1000000)); }
|
||||
static constexpr ptime from_msec(internal_type ms) noexcept { return ptime(ms, UINT64_C( 1000)); }
|
||||
static constexpr ptime from_sec(internal_type s) noexcept { return ptime(s, UINT64_C( 1)); }
|
||||
static constexpr ptime from_hz(internal_type hz) noexcept { return ptime(1 , hz); }
|
||||
static constexpr ptime from_raw(internal_type raw) noexcept { return ptime(raw); }
|
||||
|
||||
template <typename FT>
|
||||
static constexpr const typename std::enable_if<std::is_floating_point<FT>::value
|
||||
static constexpr typename std::enable_if<std::is_floating_point<FT>::value
|
||||
#if PUSE_FLOAT128
|
||||
|| std::is_same<FT, __float128>::value
|
||||
#endif
|
||||
, ptime>::type
|
||||
from_fp(const FT t) noexcept { return ptime(static_cast<internal_type>(plib::floor(t * static_cast<FT>(RES) + static_cast<FT>(0.5))), RES); }
|
||||
from_fp(FT t) noexcept { return ptime(static_cast<internal_type>(plib::floor(t * static_cast<FT>(RES) + static_cast<FT>(0.5))), RES); }
|
||||
|
||||
static constexpr const ptime from_double(const double t) noexcept
|
||||
static constexpr ptime from_double(double t) noexcept
|
||||
{ return from_fp<double>(t); }
|
||||
|
||||
static constexpr const ptime from_float(const float t) noexcept
|
||||
static constexpr ptime from_float(float t) noexcept
|
||||
{ return from_fp<float>(t); }
|
||||
|
||||
static constexpr const ptime from_long_double(const long double t) noexcept
|
||||
static constexpr ptime from_long_double(long double t) noexcept
|
||||
{ return from_fp<long double>(t); }
|
||||
|
||||
static constexpr const ptime zero() noexcept { return ptime(0, RES); }
|
||||
static constexpr const ptime quantum() noexcept { return ptime(1, RES); }
|
||||
static constexpr const ptime never() noexcept { return ptime(plib::numeric_limits<internal_type>::max(), RES); }
|
||||
static constexpr const internal_type resolution() noexcept { return RES; }
|
||||
static constexpr ptime zero() noexcept { return ptime(0, RES); }
|
||||
static constexpr ptime quantum() noexcept { return ptime(1, RES); }
|
||||
static constexpr ptime never() noexcept { return ptime(plib::numeric_limits<internal_type>::max(), RES); }
|
||||
static constexpr internal_type resolution() noexcept { return RES; }
|
||||
|
||||
constexpr internal_type in_nsec() const noexcept { return m_time / (RES / UINT64_C(1000000000)); }
|
||||
constexpr internal_type in_usec() const noexcept { return m_time / (RES / UINT64_C( 1000000)); }
|
||||
|
@ -66,11 +66,11 @@ namespace plib {
|
||||
struct token_t
|
||||
{
|
||||
explicit token_t(token_type type)
|
||||
: m_type(type), m_id(), m_token("")
|
||||
: m_type(type), m_token("")
|
||||
{
|
||||
}
|
||||
token_t(token_type type, const pstring &str)
|
||||
: m_type(type), m_id(), m_token(str)
|
||||
: m_type(type), m_token(str)
|
||||
{
|
||||
}
|
||||
token_t(const token_id_t &id, const pstring &str)
|
||||
|
@ -23,10 +23,7 @@ namespace plib
|
||||
pstring basename(const pstring &filename)
|
||||
{
|
||||
auto p=find_last_of(filename, pstring(1, PATH_SEP));
|
||||
if (p == pstring::npos)
|
||||
return filename;
|
||||
else
|
||||
return filename.substr(p+1);
|
||||
return (p == pstring::npos) ? filename : filename.substr(p+1);
|
||||
}
|
||||
|
||||
pstring path(const pstring &filename)
|
||||
@ -34,10 +31,10 @@ namespace plib
|
||||
auto p=find_last_of(filename, pstring(1, PATH_SEP));
|
||||
if (p == pstring::npos)
|
||||
return "";
|
||||
else if (p == 0) // root case
|
||||
if (p == 0) // root case
|
||||
return filename.substr(0, 1);
|
||||
else
|
||||
return filename.substr(0, p);
|
||||
|
||||
return filename.substr(0, p);
|
||||
}
|
||||
|
||||
pstring buildpath(std::initializer_list<pstring> list )
|
||||
@ -55,10 +52,8 @@ namespace plib
|
||||
|
||||
pstring environment(const pstring &var, const pstring &default_val)
|
||||
{
|
||||
if (std::getenv(var.c_str()) == nullptr)
|
||||
return default_val;
|
||||
else
|
||||
return pstring(std::getenv(var.c_str()));
|
||||
return (std::getenv(var.c_str()) == nullptr) ? default_val
|
||||
: pstring(std::getenv(var.c_str()));
|
||||
}
|
||||
} // namespace util
|
||||
|
||||
@ -94,7 +89,7 @@ namespace plib
|
||||
std::vector<std::string> result;
|
||||
std::size_t splits = 0;
|
||||
|
||||
while(str.size())
|
||||
while(!str.empty())
|
||||
{
|
||||
std::size_t index = str.rfind(token);
|
||||
bool found = index!=std::string::npos;
|
||||
@ -104,7 +99,7 @@ namespace plib
|
||||
{
|
||||
result.push_back(str.substr(index+token.size()));
|
||||
str = str.substr(0, index);
|
||||
if (str.size()==0)
|
||||
if (str.empty())
|
||||
result.push_back(str);
|
||||
}
|
||||
else
|
||||
|
@ -299,7 +299,8 @@ namespace plib
|
||||
template <typename T> explicit ename(T val) { m_v = static_cast<E>(val); } \
|
||||
bool set_from_string (const pstring &s) { \
|
||||
int f = from_string_int(strings(), s); \
|
||||
if (f>=0) { m_v = static_cast<E>(f); return true; } else { return false; } \
|
||||
if (f>=0) { m_v = static_cast<E>(f); return true; } \
|
||||
return false;\
|
||||
} \
|
||||
operator E() const noexcept {return m_v;} \
|
||||
bool operator==(const ename &rhs) const noexcept {return m_v == rhs.m_v;} \
|
||||
|
@ -76,15 +76,13 @@ namespace plib
|
||||
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
using b8 = std::array<T, 8>;
|
||||
PALIGNAS_VECTOROPT() b8 value = {0};
|
||||
for (std::size_t i = 0; i < n ; i++ )
|
||||
value[i & 7] += v[i];
|
||||
|
||||
return ((value[0] + value[1]) + (value[2] + value[3])) + ((value[4] + value[5]) + (value[6] + value[7]));
|
||||
}
|
||||
using b8 = std::array<T, 8>;
|
||||
PALIGNAS_VECTOROPT() b8 value = {0};
|
||||
for (std::size_t i = 0; i < n ; i++ )
|
||||
value[i & 7] += v[i];
|
||||
|
||||
return ((value[0] + value[1]) + (value[2] + value[3])) + ((value[4] + value[5]) + (value[6] + value[7]));
|
||||
}
|
||||
|
||||
template<typename VV, typename T, typename VR>
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
{
|
||||
pstring res = plib::pfmt(fmt)(std::forward<ARGS>(args)...);
|
||||
auto lines(plib::psplit(res, "\n", false));
|
||||
if (lines.size() == 0)
|
||||
if (lines.empty())
|
||||
pout(prefix + "\n");
|
||||
else
|
||||
for (auto &l : lines)
|
||||
@ -134,7 +134,7 @@ private:
|
||||
void convert();
|
||||
void static_compile();
|
||||
|
||||
void mac_out(const pstring &s, const bool cont = true);
|
||||
void mac_out(const pstring &s, bool cont = true);
|
||||
void header_entry(const netlist::factory::element_t *e);
|
||||
void mac(const netlist::factory::element_t *e);
|
||||
|
||||
@ -163,8 +163,7 @@ class netlist_data_folder_t : public netlist::source_data_t
|
||||
{
|
||||
public:
|
||||
explicit netlist_data_folder_t(const pstring &folder)
|
||||
: netlist::source_data_t()
|
||||
, m_folder(folder)
|
||||
: m_folder(folder)
|
||||
{
|
||||
}
|
||||
|
||||
@ -174,11 +173,9 @@ public:
|
||||
auto strm(plib::make_unique<std::ifstream>(plib::filesystem::u8path(name)));
|
||||
if (strm->fail())
|
||||
return stream_ptr(nullptr);
|
||||
else
|
||||
{
|
||||
strm->imbue(std::locale::classic());
|
||||
return std::move(strm);
|
||||
}
|
||||
|
||||
strm->imbue(std::locale::classic());
|
||||
return std::move(strm);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -189,8 +186,7 @@ class netlist_tool_callbacks_t : public netlist::callbacks_t
|
||||
{
|
||||
public:
|
||||
explicit netlist_tool_callbacks_t(tool_app_t &app)
|
||||
: netlist::callbacks_t()
|
||||
, m_app(app)
|
||||
: m_app(app)
|
||||
{ }
|
||||
|
||||
void vlog(const plib::plog_level &l, const pstring &ls) const noexcept override;
|
||||
@ -584,7 +580,7 @@ static doc_ext read_docsrc(const pstring &fname, const pstring &id)
|
||||
if (l != "")
|
||||
{
|
||||
auto a(plib::psplit(l, ":", true));
|
||||
if ((a.size() < 1) || (a.size() > 2))
|
||||
if (a.empty() || (a.size() > 2))
|
||||
throw netlist::nl_exception(l+" size mismatch");
|
||||
pstring n(plib::trim(a[0]));
|
||||
pstring v(a.size() < 2 ? "" : plib::trim(a[1]));
|
||||
@ -621,7 +617,7 @@ static doc_ext read_docsrc(const pstring &fname, const pstring &id)
|
||||
else if (n == "Example")
|
||||
{
|
||||
ret.example = plib::psplit(plib::trim(v),",",true);
|
||||
if (ret.example.size() != 2 && ret.example.size() != 0)
|
||||
if (ret.example.size() != 2 && !ret.example.empty())
|
||||
throw netlist::nl_exception("Example requires 2 parameters, but found {1}", ret.example.size());
|
||||
}
|
||||
else
|
||||
@ -696,7 +692,7 @@ void tool_app_t::mac(const netlist::factory::element_t *e)
|
||||
vs += ", " + plib::replace_all(plib::replace_all(s, "+", ""), ".", "_");
|
||||
|
||||
pout("{1}(name{2})\n", e->name(), vs);
|
||||
if (v.size() > 0)
|
||||
if (!v.empty())
|
||||
{
|
||||
pout("/*\n");
|
||||
for (const auto &s : v)
|
||||
@ -827,7 +823,7 @@ void tool_app_t::create_docheader()
|
||||
poutprefix("///", " @section {}_2 Connection Diagram", d.id);
|
||||
poutprefix("///", "");
|
||||
|
||||
if (d.pinalias.size() > 0)
|
||||
if (!d.pinalias.empty())
|
||||
{
|
||||
poutprefix("///", " <pre>");
|
||||
if (d.package == "DIP")
|
||||
@ -857,7 +853,7 @@ void tool_app_t::create_docheader()
|
||||
poutprefix("///", " @section {}_4 Limitations", d.id);
|
||||
poutprefix("///", "");
|
||||
poutprefix("///", " {}", d.limitations);
|
||||
if (d.example.size() > 0)
|
||||
if (!d.example.empty())
|
||||
{
|
||||
poutprefix("///", "");
|
||||
poutprefix("///", " @section {}_5 Example", d.id);
|
||||
@ -911,7 +907,7 @@ void tool_app_t::listdevices()
|
||||
}
|
||||
out += ")";
|
||||
pout("{}\n", out);
|
||||
if (terms.size() > 0)
|
||||
if (!terms.empty())
|
||||
{
|
||||
pstring t = "";
|
||||
for (auto & j : terms)
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
m_f.write(reinterpret_cast<const std::ostream::char_type *>(&val), sizeof(T));
|
||||
}
|
||||
|
||||
void write_sample(int *sample)
|
||||
void write_sample(const int *sample)
|
||||
{
|
||||
m_data.len += m_fmt.block_align;
|
||||
for (std::size_t i = 0; i < channels(); i++)
|
||||
|
@ -180,8 +180,8 @@ namespace solver
|
||||
const netlist_time solve(netlist_time_ext now);
|
||||
void update_inputs();
|
||||
|
||||
bool has_dynamic_devices() const noexcept { return m_dynamic_devices.size() > 0; }
|
||||
bool has_timestep_devices() const noexcept { return m_step_devices.size() > 0; }
|
||||
bool has_dynamic_devices() const noexcept { return !m_dynamic_devices.empty(); }
|
||||
bool has_timestep_devices() const noexcept { return !m_step_devices.empty(); }
|
||||
|
||||
void update_forced();
|
||||
void update_after(netlist_time after) noexcept
|
||||
@ -211,8 +211,8 @@ namespace solver
|
||||
const analog_net_t::list_t &nets,
|
||||
const solver_parameters_t *params);
|
||||
|
||||
virtual unsigned vsolve_non_dynamic(const bool newton_raphson) = 0;
|
||||
virtual netlist_time compute_next_timestep(const nl_fptype cur_ts) = 0;
|
||||
virtual unsigned vsolve_non_dynamic(bool newton_raphson) = 0;
|
||||
virtual netlist_time compute_next_timestep(nl_fptype cur_ts) = 0;
|
||||
|
||||
plib::pmatrix2d<nl_fptype, aligned_alloc<nl_fptype>> m_gonn;
|
||||
plib::pmatrix2d<nl_fptype, aligned_alloc<nl_fptype>> m_gtn;
|
||||
|
@ -42,8 +42,8 @@ namespace solver
|
||||
static constexpr const std::size_t SIZEABS = plib::parray<FT, SIZE>::SIZEABS();
|
||||
static constexpr const std::size_t m_pitch_ABS = (((SIZEABS + 0) + 7) / 8) * 8;
|
||||
|
||||
unsigned vsolve_non_dynamic(const bool newton_raphson) override;
|
||||
unsigned solve_non_dynamic(const bool newton_raphson);
|
||||
unsigned vsolve_non_dynamic(bool newton_raphson) override;
|
||||
unsigned solve_non_dynamic(bool newton_raphson);
|
||||
|
||||
void LE_solve();
|
||||
|
||||
@ -158,7 +158,7 @@ namespace solver
|
||||
}
|
||||
|
||||
template <typename FT, int SIZE>
|
||||
unsigned matrix_solver_direct_t<FT, SIZE>::solve_non_dynamic(const bool newton_raphson)
|
||||
unsigned matrix_solver_direct_t<FT, SIZE>::solve_non_dynamic(bool newton_raphson)
|
||||
{
|
||||
this->LE_solve();
|
||||
this->LE_back_subst(this->m_new_V);
|
||||
@ -171,7 +171,7 @@ namespace solver
|
||||
}
|
||||
|
||||
template <typename FT, int SIZE>
|
||||
unsigned matrix_solver_direct_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
unsigned matrix_solver_direct_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
|
||||
{
|
||||
// populate matrix
|
||||
this->clear_square_mat(m_A);
|
||||
|
@ -32,7 +32,7 @@ namespace solver
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// matrix_solver - Direct1
|
||||
// ----------------------------------------------------------------------------------------
|
||||
unsigned vsolve_non_dynamic(const bool newton_raphson) override
|
||||
unsigned vsolve_non_dynamic(bool newton_raphson) override
|
||||
{
|
||||
this->clear_square_mat(this->m_A);
|
||||
this->fill_matrix_and_rhs();
|
||||
|
@ -32,7 +32,7 @@ namespace solver
|
||||
const solver_parameters_t *params)
|
||||
: matrix_solver_direct_t<FT, 2>(anetlist, name, nets, params, 2)
|
||||
{}
|
||||
unsigned vsolve_non_dynamic(const bool newton_raphson) override
|
||||
unsigned vsolve_non_dynamic(bool newton_raphson) override
|
||||
{
|
||||
this->clear_square_mat(this->m_A);
|
||||
this->fill_matrix_and_rhs();
|
||||
|
@ -38,12 +38,12 @@ public:
|
||||
|
||||
unsigned N() const { if (m_N == 0) return m_dim; else return m_N; }
|
||||
|
||||
int vsolve_non_dynamic(const bool newton_raphson);
|
||||
int vsolve_non_dynamic(bool newton_raphson);
|
||||
|
||||
protected:
|
||||
virtual void add_term(int net_idx, terminal_t *term) override;
|
||||
|
||||
int solve_non_dynamic(const bool newton_raphson);
|
||||
int solve_non_dynamic(bool newton_raphson);
|
||||
void build_LE_A();
|
||||
void build_LE_RHS(nl_double * RESTRICT rhs);
|
||||
|
||||
@ -565,7 +565,7 @@ void matrix_solver_direct_t<m_N, storage_N>::store(
|
||||
|
||||
|
||||
template <unsigned m_N, unsigned storage_N>
|
||||
unsigned matrix_solver_direct_t<m_N, storage_N>::solve_non_dynamic(const bool newton_raphson)
|
||||
unsigned matrix_solver_direct_t<m_N, storage_N>::solve_non_dynamic(bool newton_raphson)
|
||||
{
|
||||
nl_double new_V[storage_N]; // = { 0.0 };
|
||||
|
||||
@ -587,7 +587,7 @@ unsigned matrix_solver_direct_t<m_N, storage_N>::solve_non_dynamic(const bool ne
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned storage_N>
|
||||
int matrix_solver_direct_t<m_N, storage_N>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
int matrix_solver_direct_t<m_N, storage_N>::vsolve_non_dynamic(bool newton_raphson)
|
||||
{
|
||||
this->build_LE_A();
|
||||
this->build_LE_RHS(m_RHS);
|
||||
|
@ -110,7 +110,7 @@ namespace solver
|
||||
}
|
||||
}
|
||||
|
||||
unsigned vsolve_non_dynamic(const bool newton_raphson) override;
|
||||
unsigned vsolve_non_dynamic(bool newton_raphson) override;
|
||||
|
||||
std::pair<pstring, pstring> create_solver_code() override;
|
||||
|
||||
@ -226,7 +226,7 @@ namespace solver
|
||||
}
|
||||
|
||||
template <typename FT, int SIZE>
|
||||
unsigned matrix_solver_GCR_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
unsigned matrix_solver_GCR_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
|
||||
{
|
||||
// populate matrix
|
||||
mat.set_scalar(plib::constants<FT>::zero());
|
||||
|
@ -78,7 +78,7 @@ namespace solver
|
||||
}
|
||||
}
|
||||
|
||||
unsigned vsolve_non_dynamic(const bool newton_raphson) override;
|
||||
unsigned vsolve_non_dynamic(bool newton_raphson) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -95,7 +95,7 @@ namespace solver
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <typename FT, int SIZE>
|
||||
unsigned matrix_solver_GMRES_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
unsigned matrix_solver_GMRES_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
|
||||
{
|
||||
const std::size_t iN = this->size();
|
||||
|
||||
|
@ -67,8 +67,8 @@ namespace solver
|
||||
void reset() override { matrix_solver_t::reset(); }
|
||||
|
||||
protected:
|
||||
unsigned vsolve_non_dynamic(const bool newton_raphson) override;
|
||||
unsigned solve_non_dynamic(const bool newton_raphson);
|
||||
unsigned vsolve_non_dynamic(bool newton_raphson) override;
|
||||
unsigned solve_non_dynamic(bool newton_raphson);
|
||||
|
||||
void LE_invert();
|
||||
|
||||
@ -197,7 +197,7 @@ namespace solver
|
||||
}
|
||||
|
||||
template <typename FT, int SIZE>
|
||||
unsigned matrix_solver_sm_t<FT, SIZE>::solve_non_dynamic(const bool newton_raphson)
|
||||
unsigned matrix_solver_sm_t<FT, SIZE>::solve_non_dynamic(bool newton_raphson)
|
||||
{
|
||||
static constexpr const bool incremental = true;
|
||||
const std::size_t iN = this->size();
|
||||
@ -283,7 +283,7 @@ namespace solver
|
||||
}
|
||||
|
||||
template <typename FT, int SIZE>
|
||||
unsigned matrix_solver_sm_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
unsigned matrix_solver_sm_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
|
||||
{
|
||||
|
||||
this->clear_square_mat(this->m_A);
|
||||
|
@ -39,7 +39,7 @@ namespace solver
|
||||
{
|
||||
}
|
||||
|
||||
unsigned vsolve_non_dynamic(const bool newton_raphson) override;
|
||||
unsigned vsolve_non_dynamic(bool newton_raphson) override;
|
||||
|
||||
private:
|
||||
state_var<float_type> m_lp_fact;
|
||||
@ -52,7 +52,7 @@ namespace solver
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <typename FT, int SIZE>
|
||||
unsigned matrix_solver_SOR_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
unsigned matrix_solver_SOR_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
|
||||
{
|
||||
const std::size_t iN = this->size();
|
||||
bool resched = false;
|
||||
|
@ -40,7 +40,7 @@ namespace solver
|
||||
{
|
||||
}
|
||||
|
||||
unsigned vsolve_non_dynamic(const bool newton_raphson) override;
|
||||
unsigned vsolve_non_dynamic(bool newton_raphson) override;
|
||||
|
||||
private:
|
||||
state_var<float_type> m_omega;
|
||||
@ -51,7 +51,7 @@ namespace solver
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <typename FT, int SIZE>
|
||||
unsigned matrix_solver_SOR_mat_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
unsigned matrix_solver_SOR_mat_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
|
||||
{
|
||||
// The matrix based code looks a lot nicer but actually is 30% slower than
|
||||
// the optimized code which works directly on the data structures.
|
||||
|
@ -75,8 +75,8 @@ namespace solver
|
||||
void reset() override { matrix_solver_t::reset(); }
|
||||
|
||||
protected:
|
||||
unsigned vsolve_non_dynamic(const bool newton_raphson) override;
|
||||
unsigned solve_non_dynamic(const bool newton_raphson);
|
||||
unsigned vsolve_non_dynamic(bool newton_raphson) override;
|
||||
unsigned solve_non_dynamic(bool newton_raphson);
|
||||
|
||||
void LE_invert();
|
||||
|
||||
@ -208,7 +208,7 @@ namespace solver
|
||||
|
||||
|
||||
template <typename FT, int SIZE>
|
||||
unsigned matrix_solver_w_t<FT, SIZE>::solve_non_dynamic(const bool newton_raphson)
|
||||
unsigned matrix_solver_w_t<FT, SIZE>::solve_non_dynamic(bool newton_raphson)
|
||||
{
|
||||
const auto iN = this->size();
|
||||
|
||||
@ -351,7 +351,7 @@ namespace solver
|
||||
}
|
||||
|
||||
template <typename FT, int SIZE>
|
||||
unsigned matrix_solver_w_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
unsigned matrix_solver_w_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
|
||||
{
|
||||
this->clear_square_mat(this->m_A);
|
||||
this->fill_matrix_and_rhs();
|
||||
|
@ -201,7 +201,7 @@ void nl_convert_base_t::dump_nl()
|
||||
m_ext_alias.clear();
|
||||
}
|
||||
|
||||
const pstring nl_convert_base_t::get_nl_val(const double val)
|
||||
pstring nl_convert_base_t::get_nl_val(double val)
|
||||
{
|
||||
for (auto &e : m_units)
|
||||
{
|
||||
@ -501,7 +501,8 @@ void nl_convert_eagle_t::convert(const pstring &contents)
|
||||
out("NETLIST_END()\n");
|
||||
return;
|
||||
}
|
||||
else if (token.is(tok.m_tok_SEMICOLON))
|
||||
|
||||
if (token.is(tok.m_tok_SEMICOLON))
|
||||
{
|
||||
// ignore empty statements
|
||||
token = tok.get_token();
|
||||
@ -648,7 +649,8 @@ void nl_convert_rinf_t::convert(const pstring &contents)
|
||||
out("NETLIST_END()\n");
|
||||
return;
|
||||
}
|
||||
else if (token.is(tok.m_tok_HEA))
|
||||
|
||||
if (token.is(tok.m_tok_HEA))
|
||||
{
|
||||
// seems to be start token - ignore
|
||||
token = tok.get_token();
|
||||
|
@ -46,7 +46,7 @@ protected:
|
||||
|
||||
void dump_nl();
|
||||
|
||||
const pstring get_nl_val(const double val);
|
||||
pstring get_nl_val(double val);
|
||||
double get_sp_unit(const pstring &unit);
|
||||
|
||||
double get_sp_val(const pstring &sin);
|
||||
@ -153,7 +153,7 @@ class nl_convert_spice_t : public nl_convert_base_t
|
||||
{
|
||||
public:
|
||||
|
||||
nl_convert_spice_t() : nl_convert_base_t() {}
|
||||
nl_convert_spice_t() = default;
|
||||
|
||||
void convert(const pstring &contents) override;
|
||||
|
||||
@ -169,7 +169,7 @@ class nl_convert_eagle_t : public nl_convert_base_t
|
||||
{
|
||||
public:
|
||||
|
||||
nl_convert_eagle_t() : nl_convert_base_t() {}
|
||||
nl_convert_eagle_t() = default;
|
||||
|
||||
class tokenizer : public plib::ptokenizer
|
||||
{
|
||||
@ -202,7 +202,7 @@ class nl_convert_rinf_t : public nl_convert_base_t
|
||||
{
|
||||
public:
|
||||
|
||||
nl_convert_rinf_t() : nl_convert_base_t() {}
|
||||
nl_convert_rinf_t() = default;
|
||||
|
||||
class tokenizer : public plib::ptokenizer
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user