diff options
author | 2016-06-16 00:01:47 +0200 | |
---|---|---|
committer | 2016-06-16 00:01:47 +0200 | |
commit | 404e589cff3123bd146e8339570cd07869b2e91b (patch) | |
tree | 99a1a99e8f061178ff398a30da181184a8621110 /src/lib/netlist/plib/pstate.cpp | |
parent | 809de6dd7ff20bcb2a214596bb9232825e944524 (diff) |
Merge netlist_dev branch, all code_refactoring: (nw)
Object model optimisation.
Merge remote-tracking branch 'origin/master' into netlist_dev
Fix a merge issue.
#if ==> #elif. Ouch.
Default PHAS_PMF_INTERNAL=0 for 32bit windows mingw.
Change UINT8 to uint_[fast|least|8_t.
Move state_var so it can be used by base devices as well.
Remove last traces of ATTR_ALIGN.
Refactored netlist_time into a template.
Removed implicit double assignment to netlist. Doomed to produce
bugs.
Instead, use netlist_time::from_double.
Switch to using proper (i.e. bool type) param_logic_t.
Formally differentiate between logic inputs (e.g. switches) and int
inputs (e.g. resistor ladders or selection switches).
Added parameter USE_DEACTIVATE to truthtable devices.
Added more constexpr to netlist_time.
Fixed some ifdef code paths.
- More c++.
- Simplify main processing loop. As a nice side-effect that squeezed
out some cycles.
- More cycle squeezing.
- Removed pvector_t.
- Use std::sort.
- Refactored netlist state manager.
- Introduction of state_var object template to be used on device
state
members.
- Changed remaining save occurrences to state_var.
- Rewrote nltool's listdevices command. This allowed removal of one
member from devices which served solely for listdevices.
- Remove hashmap_t. Fix kidniki regression.
Diffstat (limited to 'src/lib/netlist/plib/pstate.cpp')
-rw-r--r-- | src/lib/netlist/plib/pstate.cpp | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/src/lib/netlist/plib/pstate.cpp b/src/lib/netlist/plib/pstate.cpp index c8c4c5725c6..ee44eede27a 100644 --- a/src/lib/netlist/plib/pstate.cpp +++ b/src/lib/netlist/plib/pstate.cpp @@ -9,70 +9,53 @@ namespace plib { -pstate_manager_t::pstate_manager_t() +state_manager_t::state_manager_t() { } -pstate_manager_t::~pstate_manager_t() +state_manager_t::~state_manager_t() { m_save.clear(); } -void pstate_manager_t::save_state_ptr(const void *owner, const pstring &stname, const pstate_data_type_e dt, const int size, const int count, void *ptr, bool is_ptr) +void state_manager_t::save_state_ptr(const void *owner, const pstring &stname, const datatype_t dt, const int count, void *ptr) { - pstring fullname = stname; - ATTR_UNUSED pstring ts[] = { - "NOT_SUPPORTED", - "DT_CUSTOM", - "DT_DOUBLE", -#if (PHAS_INT128) - "DT_INT128", -#endif - "DT_INT64", - "DT_INT16", - "DT_INT8", - "DT_INT", - "DT_BOOLEAN", - "DT_FLOAT" - }; - - auto p = plib::make_unique<pstate_entry_t>(stname, dt, owner, size, count, ptr, is_ptr); + auto p = plib::make_unique<entry_t>(stname, dt, owner, count, ptr); m_save.push_back(std::move(p)); } -void pstate_manager_t::remove_save_items(const void *owner) +void state_manager_t::remove_save_items(const void *owner) { - unsigned i = 0; - while (i < m_save.size()) + for (auto i = m_save.begin(); i != m_save.end(); ) { - if (m_save[i]->m_owner == owner) - m_save.remove_at(i); + if (i->get()->m_owner == owner) + i = m_save.erase(i); else i++; } } -void pstate_manager_t::pre_save() +void state_manager_t::pre_save() { for (auto & s : m_save) - if (s->m_dt == DT_CUSTOM) + if (s->m_dt.is_custom) s->m_callback->on_pre_save(); } -void pstate_manager_t::post_load() +void state_manager_t::post_load() { for (auto & s : m_save) - if (s->m_dt == DT_CUSTOM) + if (s->m_dt.is_custom) s->m_callback->on_post_load(); } -template<> void pstate_manager_t::save_item(const void *owner, pstate_callback_t &state, const pstring &stname) +template<> void state_manager_t::save_item(const void *owner, callback_t &state, const pstring &stname) { //save_state_ptr(stname, DT_CUSTOM, 0, 1, &state); - pstate_callback_t *state_p = &state; - auto p = plib::make_unique<pstate_entry_t>(stname, owner, state_p); + callback_t *state_p = &state; + auto p = plib::make_unique<entry_t>(stname, owner, state_p); m_save.push_back(std::move(p)); state.register_state(*this, stname); } |