mirror of
https://github.com/holub/mame
synced 2025-04-24 17:30:55 +03:00
Add constexpr add noexcept. (nw)
This commit is contained in:
parent
6a770d7086
commit
ced71c2b58
@ -568,7 +568,7 @@ void netlist_t::print_stats() const
|
||||
}
|
||||
}
|
||||
|
||||
core_device_t *netlist_t::pget_single_device(const pstring classname, bool (*cc)(core_device_t *))
|
||||
core_device_t *netlist_t::get_single_device(const pstring classname, bool (*cc)(core_device_t *))
|
||||
{
|
||||
core_device_t *ret = nullptr;
|
||||
for (auto &d : m_devices)
|
||||
@ -772,7 +772,7 @@ void detail::net_t::update_devs() NL_NOEXCEPT
|
||||
{
|
||||
nl_assert(this->isRailNet());
|
||||
|
||||
static const unsigned masks[4] =
|
||||
const unsigned masks[4] =
|
||||
{
|
||||
0,
|
||||
core_terminal_t::STATE_INP_LH | core_terminal_t::STATE_INP_ACTIVE,
|
||||
@ -780,10 +780,10 @@ void detail::net_t::update_devs() NL_NOEXCEPT
|
||||
0
|
||||
};
|
||||
|
||||
const unsigned mask = masks[ m_cur_Q * 2 + m_new_Q ];
|
||||
const unsigned mask = masks[ (m_cur_Q << 1) | m_new_Q ];
|
||||
|
||||
m_in_queue = 2; /* mark as taken ... */
|
||||
m_cur_Q = m_new_Q;
|
||||
m_in_queue = 2; /* mark as taken ... */
|
||||
|
||||
for (auto & p : m_list_active)
|
||||
{
|
||||
@ -1199,4 +1199,26 @@ std::unique_ptr<plib::pistream> param_data_t::stream()
|
||||
|
||||
|
||||
} //namespace devices
|
||||
|
||||
bool detail::core_terminal_t::is_logic() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const logic_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
bool detail::core_terminal_t::is_analog() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const analog_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
bool detail::net_t::is_logic() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const logic_net_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
bool detail::net_t::is_analog() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const analog_net_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
|
||||
} // namespace netlist
|
||||
|
@ -316,15 +316,15 @@ namespace netlist
|
||||
//! Move Constructor.
|
||||
state_var(state_var &&rhs) NL_NOEXCEPT = default;
|
||||
//! Assignment operator to assign value of a state var.
|
||||
state_var &operator=(const state_var &rhs) { m_value = rhs; return *this; }
|
||||
state_var &operator=(const state_var &rhs) NL_NOEXCEPT { m_value = rhs; return *this; }
|
||||
//! Assignment operator to assign value of type T.
|
||||
state_var &operator=(const T &rhs) { m_value = rhs; return *this; }
|
||||
state_var &operator=(const T &rhs) NL_NOEXCEPT { m_value = rhs; return *this; }
|
||||
//! Return value of state variable.
|
||||
operator T & () { return m_value; }
|
||||
operator T & () NL_NOEXCEPT { return m_value; }
|
||||
//! Return const value of state variable.
|
||||
constexpr operator const T & () const { return m_value; }
|
||||
constexpr operator const T & () const NL_NOEXCEPT { return m_value; }
|
||||
T * ptr() { return &m_value; }
|
||||
constexpr T * ptr() const { return &m_value; }
|
||||
constexpr T * ptr() const NL_NOEXCEPT{ return &m_value; }
|
||||
private:
|
||||
T m_value;
|
||||
};
|
||||
@ -347,10 +347,10 @@ namespace netlist
|
||||
state_var(const state_var &rhs) NL_NOEXCEPT = default;
|
||||
//! Move Constructor.
|
||||
state_var(state_var &&rhs) NL_NOEXCEPT = default;
|
||||
state_var &operator=(const state_var &rhs) { m_value = rhs.m_value; return *this; }
|
||||
state_var &operator=(const T &rhs) { m_value = rhs; return *this; }
|
||||
T & operator[](const std::size_t i) { return m_value[i]; }
|
||||
constexpr T & operator[](const std::size_t i) const { return m_value[i]; }
|
||||
state_var &operator=(const state_var &rhs) NL_NOEXCEPT { m_value = rhs.m_value; return *this; }
|
||||
state_var &operator=(const T &rhs) NL_NOEXCEPT { m_value = rhs; return *this; }
|
||||
T & operator[](const std::size_t i) NL_NOEXCEPT { return m_value[i]; }
|
||||
constexpr T & operator[](const std::size_t i) const NL_NOEXCEPT { return m_value[i]; }
|
||||
private:
|
||||
T m_value[N];
|
||||
};
|
||||
@ -443,7 +443,7 @@ namespace netlist
|
||||
/*! returns reference to owning device.
|
||||
* \returns reference to owning device.
|
||||
*/
|
||||
core_device_t &device() const { return m_device; }
|
||||
core_device_t &device() const NL_NOEXCEPT { return m_device; }
|
||||
|
||||
/*! The netlist owning the owner of this object.
|
||||
* \returns reference to netlist object.
|
||||
@ -495,17 +495,17 @@ namespace netlist
|
||||
|
||||
void set_net(net_t *anet);
|
||||
void clear_net();
|
||||
bool has_net() const { return (m_net != nullptr); }
|
||||
bool has_net() const NL_NOEXCEPT { return (m_net != nullptr); }
|
||||
|
||||
const net_t & net() const { return *m_net;}
|
||||
net_t & net() { return *m_net;}
|
||||
const net_t & net() const NL_NOEXCEPT { return *m_net;}
|
||||
net_t & net() NL_NOEXCEPT { return *m_net;}
|
||||
|
||||
bool is_logic() const NL_NOEXCEPT;
|
||||
bool is_analog() const NL_NOEXCEPT;
|
||||
|
||||
bool is_state(const state_e astate) const { return (m_state == astate); }
|
||||
state_e state() const { return m_state; }
|
||||
void set_state(const state_e astate) { m_state = astate; }
|
||||
bool is_state(const state_e astate) const NL_NOEXCEPT { return (m_state == astate); }
|
||||
state_e state() const NL_NOEXCEPT { return m_state; }
|
||||
void set_state(const state_e astate) NL_NOEXCEPT { m_state = astate; }
|
||||
|
||||
void reset();
|
||||
|
||||
@ -666,7 +666,7 @@ namespace netlist
|
||||
/*! returns voltage at terminal.
|
||||
* \returns voltage at terminal.
|
||||
*/
|
||||
nl_double operator()() const { return Q_Analog(); }
|
||||
nl_double operator()() const NL_NOEXCEPT { return Q_Analog(); }
|
||||
|
||||
/*! returns voltage at terminal.
|
||||
* \returns voltage at terminal.
|
||||
@ -690,17 +690,17 @@ namespace netlist
|
||||
|
||||
void reset();
|
||||
|
||||
void toggle_new_Q() { m_new_Q ^= 1; }
|
||||
void force_queue_execution() { m_new_Q = (m_cur_Q ^ 1); }
|
||||
void toggle_new_Q() NL_NOEXCEPT { m_new_Q ^= 1; }
|
||||
void force_queue_execution() NL_NOEXCEPT { m_new_Q = (m_cur_Q ^ 1); }
|
||||
|
||||
void push_to_queue(const netlist_time delay) NL_NOEXCEPT;
|
||||
void reschedule_in_queue(const netlist_time delay) NL_NOEXCEPT;
|
||||
bool is_queued() const { return m_in_queue == 1; }
|
||||
bool is_queued() const NL_NOEXCEPT { return m_in_queue == 1; }
|
||||
|
||||
void update_devs() NL_NOEXCEPT;
|
||||
|
||||
const netlist_time time() const { return m_time; }
|
||||
void set_time(const netlist_time ntime) { m_time = ntime; }
|
||||
const netlist_time time() const NL_NOEXCEPT { return m_time; }
|
||||
void set_time(const netlist_time ntime) NL_NOEXCEPT { m_time = ntime; }
|
||||
|
||||
bool isRailNet() const { return !(m_railterminal == nullptr); }
|
||||
core_terminal_t & railterminal() const { return *m_railterminal; }
|
||||
@ -748,9 +748,9 @@ namespace netlist
|
||||
logic_net_t(netlist_t &nl, const pstring &aname, detail::core_terminal_t *mr = nullptr);
|
||||
virtual ~logic_net_t();
|
||||
|
||||
netlist_sig_t Q() const { return m_cur_Q; }
|
||||
netlist_sig_t new_Q() const { return m_new_Q; }
|
||||
void initial(const netlist_sig_t val) { m_cur_Q = m_new_Q = val; }
|
||||
netlist_sig_t Q() const NL_NOEXCEPT { return m_cur_Q; }
|
||||
netlist_sig_t new_Q() const NL_NOEXCEPT { return m_new_Q; }
|
||||
void initial(const netlist_sig_t val) NL_NOEXCEPT { m_cur_Q = m_new_Q = val; }
|
||||
|
||||
void set_Q(const netlist_sig_t newQ, const netlist_time delay) NL_NOEXCEPT
|
||||
{
|
||||
@ -1027,8 +1027,6 @@ namespace netlist
|
||||
m_stat_total_time.stop();
|
||||
}
|
||||
|
||||
void set_delegate_pointer();
|
||||
|
||||
void do_inc_active() NL_NOEXCEPT
|
||||
{
|
||||
if (m_hint_deactivate)
|
||||
@ -1047,6 +1045,8 @@ namespace netlist
|
||||
void do_reset() { reset(); }
|
||||
void set_hint_deactivate(bool v) { m_hint_deactivate = v; }
|
||||
|
||||
void set_delegate_pointer();
|
||||
|
||||
/* stats */
|
||||
nperftime_t m_stat_total_time;
|
||||
nperfcount_t m_stat_call_count;
|
||||
@ -1232,7 +1232,7 @@ namespace netlist
|
||||
template<class C>
|
||||
C *get_single_device(const pstring classname)
|
||||
{
|
||||
return dynamic_cast<C *>(pget_single_device(classname, check_class<C>));
|
||||
return dynamic_cast<C *>(get_single_device(classname, check_class<C>));
|
||||
}
|
||||
|
||||
/* logging and name */
|
||||
@ -1254,8 +1254,6 @@ namespace netlist
|
||||
this->state().save_state_ptr(static_cast<void *>(&owner), from_utf8(owner.name()) + pstring(".") + stname, plib::state_manager_t::datatype_f<C>::f(), count, state);
|
||||
}
|
||||
|
||||
void rebuild_lists(); /* must be called after post_load ! */
|
||||
|
||||
plib::dynlib &lib() { return *m_lib; }
|
||||
|
||||
// FIXME: find something better
|
||||
@ -1264,7 +1262,11 @@ namespace netlist
|
||||
/* sole use is to manage lifetime of family objects */
|
||||
std::vector<std::pair<pstring, std::unique_ptr<logic_family_desc_t>>> m_family_cache;
|
||||
|
||||
// FIXME: sort rebuild_lists out
|
||||
void rebuild_lists(); /* must be called after post_load ! */
|
||||
|
||||
protected:
|
||||
|
||||
void print_stats() const;
|
||||
|
||||
private:
|
||||
@ -1273,7 +1275,7 @@ namespace netlist
|
||||
static pstring from_utf8(const char *c) { return pstring(c, pstring::UTF8); }
|
||||
static pstring from_utf8(const pstring &c) { return c; }
|
||||
|
||||
core_device_t *pget_single_device(const pstring classname, bool (*cc)(core_device_t *));
|
||||
core_device_t *get_single_device(const pstring classname, bool (*cc)(core_device_t *));
|
||||
|
||||
/* mostly rw */
|
||||
netlist_time m_time;
|
||||
@ -1333,26 +1335,6 @@ namespace netlist
|
||||
device.netlist().log().warning("Rom {1} not found", Value());
|
||||
}
|
||||
|
||||
inline bool detail::core_terminal_t::is_logic() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const logic_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
inline bool detail::core_terminal_t::is_analog() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const analog_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
inline bool detail::net_t::is_logic() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const logic_net_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
inline bool detail::net_t::is_analog() const NL_NOEXCEPT
|
||||
{
|
||||
return dynamic_cast<const analog_net_t *>(this) != nullptr;
|
||||
}
|
||||
|
||||
inline void logic_input_t::inactivate()
|
||||
{
|
||||
if (!is_state(STATE_INP_PASSIVE))
|
||||
@ -1453,6 +1435,16 @@ namespace netlist
|
||||
}
|
||||
}
|
||||
|
||||
inline netlist_t &detail::device_object_t::netlist()
|
||||
{
|
||||
return m_device.netlist();
|
||||
}
|
||||
|
||||
inline const netlist_t &detail::device_object_t::netlist() const
|
||||
{
|
||||
return m_device.netlist();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename O>
|
||||
state_var<T>::state_var(O &owner, const pstring name, const T &value)
|
||||
@ -1470,15 +1462,6 @@ namespace netlist
|
||||
m_value[i] = value;
|
||||
}
|
||||
|
||||
inline netlist_t &detail::device_object_t::netlist()
|
||||
{
|
||||
return m_device.netlist();
|
||||
}
|
||||
|
||||
inline const netlist_t &detail::device_object_t::netlist() const
|
||||
{
|
||||
return m_device.netlist();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -52,12 +52,13 @@ namespace netlist
|
||||
{
|
||||
public:
|
||||
|
||||
struct entry_t
|
||||
struct entry_t final
|
||||
{
|
||||
entry_t() { }
|
||||
entry_t(const Time &t, const Element &o) : m_exec_time(t), m_object(o) { }
|
||||
entry_t(const entry_t &e) : m_exec_time(e.m_exec_time), m_object(e.m_object) { }
|
||||
entry_t(entry_t &&e) : m_exec_time(e.m_exec_time), m_object(e.m_object) { }
|
||||
constexpr entry_t() { }
|
||||
constexpr entry_t(const Time &t, const Element &o) : m_exec_time(t), m_object(o) { }
|
||||
constexpr entry_t(const entry_t &e) : m_exec_time(e.m_exec_time), m_object(e.m_object) { }
|
||||
constexpr entry_t(entry_t &&e) : m_exec_time(e.m_exec_time), m_object(e.m_object) { }
|
||||
~entry_t() = default;
|
||||
|
||||
entry_t& operator=(entry_t && other)
|
||||
{
|
||||
@ -76,8 +77,8 @@ namespace netlist
|
||||
clear();
|
||||
}
|
||||
|
||||
std::size_t capacity() const { return m_list.size(); }
|
||||
bool empty() const { return (m_end == &m_list[1]); }
|
||||
constexpr std::size_t capacity() const { return m_list.size(); }
|
||||
constexpr bool empty() const { return (m_end == &m_list[1]); }
|
||||
|
||||
void push(entry_t &&e) noexcept
|
||||
{
|
||||
@ -95,9 +96,13 @@ namespace netlist
|
||||
m_prof_call.inc();
|
||||
}
|
||||
|
||||
#if 0
|
||||
entry_t pop() noexcept { return std::move(*(--m_end)); }
|
||||
const entry_t &top() const noexcept { return std::move(*(m_end-1)); }
|
||||
|
||||
#else
|
||||
entry_t pop() noexcept { return *(--m_end); }
|
||||
const entry_t &top() const noexcept { return *(m_end-1); }
|
||||
#endif
|
||||
void remove(const Element &elem) noexcept
|
||||
{
|
||||
/* Lock */
|
||||
@ -137,9 +142,9 @@ namespace netlist
|
||||
|
||||
// save state support & mame disasm
|
||||
|
||||
const entry_t *listptr() const { return &m_list[1]; }
|
||||
std::size_t size() const noexcept { return static_cast<std::size_t>(m_end - &m_list[1]); }
|
||||
const entry_t & operator[](const std::size_t index) const { return m_list[ 1 + index]; }
|
||||
constexpr const entry_t *listptr() const { return &m_list[1]; }
|
||||
constexpr std::size_t size() const noexcept { return static_cast<std::size_t>(m_end - &m_list[1]); }
|
||||
constexpr const entry_t & operator[](const std::size_t index) const { return m_list[ 1 + index]; }
|
||||
|
||||
private:
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
|
@ -81,32 +81,40 @@ public:
|
||||
|
||||
friend class linkedlist_t<LC>;
|
||||
|
||||
element_t() : m_next(nullptr) {}
|
||||
virtual ~element_t() = default;
|
||||
constexpr element_t() : m_next(nullptr) {}
|
||||
constexpr element_t(const element_t &rhs) = delete;
|
||||
constexpr element_t(element_t &&rhs) = delete;
|
||||
|
||||
LC *next() const noexcept { return m_next; }
|
||||
constexpr LC *next() const noexcept { return m_next; }
|
||||
|
||||
protected:
|
||||
~element_t() = default;
|
||||
private:
|
||||
LC * m_next;
|
||||
};
|
||||
|
||||
struct iter_t final : public std::iterator<std::forward_iterator_tag, LC>
|
||||
{
|
||||
private:
|
||||
LC* p;
|
||||
public:
|
||||
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;
|
||||
explicit constexpr iter_t(const iter_t &rhs) noexcept = default;
|
||||
constexpr 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;}
|
||||
bool operator==(const iter_t& rhs) noexcept {return p==rhs.p;}
|
||||
bool operator!=(const iter_t& rhs) noexcept {return p!=rhs.p;}
|
||||
LC& operator*() noexcept {return *p;}
|
||||
LC* operator->() noexcept {return p;}
|
||||
constexpr bool operator==(const iter_t& rhs) const noexcept {return p == rhs.p;}
|
||||
constexpr bool operator!=(const iter_t& rhs) const noexcept {return p != rhs.p;}
|
||||
/* constexpr */ LC& operator*() noexcept {return *p;}
|
||||
/* constexpr */ LC* operator->() noexcept {return p;}
|
||||
|
||||
constexpr LC& operator*() const noexcept {return *p;}
|
||||
constexpr LC* operator->() const noexcept {return p;}
|
||||
};
|
||||
|
||||
linkedlist_t() : m_head(nullptr) {}
|
||||
constexpr linkedlist_t() : m_head(nullptr) {}
|
||||
|
||||
iter_t begin() const noexcept { return iter_t(m_head); }
|
||||
constexpr iter_t begin() const noexcept { return iter_t(m_head); }
|
||||
constexpr iter_t end() const noexcept { return iter_t(nullptr); }
|
||||
|
||||
void push_front(LC *elem)
|
||||
@ -138,7 +146,7 @@ public:
|
||||
|
||||
LC *front() const { return m_head; }
|
||||
void clear() { m_head = nullptr; }
|
||||
bool empty() const { return (m_head == nullptr); }
|
||||
constexpr bool empty() const { return (m_head == nullptr); }
|
||||
|
||||
private:
|
||||
LC *m_head;
|
||||
|
Loading…
Reference in New Issue
Block a user