From 40fb13e6e714cd4a1ef08cf162341270fbdf939f Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Wed, 13 Jun 2018 13:25:15 +1000 Subject: lift some stuff needed by devcb3 out of address map entry (nw) --- src/emu/addrmap.h | 74 +++++++------------------------- src/emu/emumem.h | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+), 59 deletions(-) diff --git a/src/emu/addrmap.h b/src/emu/addrmap.h index 302b21827cf..1654856dd62 100644 --- a/src/emu/addrmap.h +++ b/src/emu/addrmap.h @@ -65,56 +65,12 @@ class address_map_entry { friend class address_map; - template - struct is_read8_method { static constexpr bool value = std::is_constructible::value; }; - template - struct is_read16_method { static constexpr bool value = std::is_constructible::value; }; - template - struct is_read32_method { static constexpr bool value = std::is_constructible::value; }; - template - struct is_read64_method { static constexpr bool value = std::is_constructible::value; }; - - template - struct is_write8_method { static constexpr bool value = std::is_constructible::value; }; - template - struct is_write16_method { static constexpr bool value = std::is_constructible::value; }; - template - struct is_write32_method { static constexpr bool value = std::is_constructible::value; }; - template - struct is_write64_method { static constexpr bool value = std::is_constructible::value; }; - template struct is_addrmap_method { static constexpr bool value = std::is_constructible::value; }; template struct is_setoffset_method { static constexpr bool value = std::is_constructible::value; }; - template - static std::enable_if_t::value, read8_delegate> make_delegate(Ret (T::*func)(Params...), const char *name, const char *tag, T *obj) - { return read8_delegate(func, name, tag, obj); } - template - static std::enable_if_t::value, read16_delegate> make_delegate(Ret (T::*func)(Params...), const char *name, const char *tag, T *obj) - { return read16_delegate(func, name, tag, obj); } - template - static std::enable_if_t::value, read32_delegate> make_delegate(Ret (T::*func)(Params...), const char *name, const char *tag, T *obj) - { return read32_delegate(func, name, tag, obj); } - template - static std::enable_if_t::value, read64_delegate> make_delegate(Ret (T::*func)(Params...), const char *name, const char *tag, T *obj) - { return read64_delegate(func, name, tag, obj); } - - template - static std::enable_if_t::value, write8_delegate> make_delegate(Ret (T::*func)(Params...), const char *name, const char *tag, T *obj) - { return write8_delegate(func, name, tag, obj); } - template - static std::enable_if_t::value, write16_delegate> make_delegate(Ret (T::*func)(Params...), const char *name, const char *tag, T *obj) - { return write16_delegate(func, name, tag, obj); } - template - static std::enable_if_t::value, write32_delegate> make_delegate(Ret (T::*func)(Params...), const char *name, const char *tag, T *obj) - { return write32_delegate(func, name, tag, obj); } - template - static std::enable_if_t::value, write64_delegate> make_delegate(Ret (T::*func)(Params...), const char *name, const char *tag, T *obj) - { return write64_delegate(func, name, tag, obj); } - template static std::enable_if_t::value, address_map_constructor> make_delegate(Ret (T::*func)(Params...), const char *name, T *obj) { return address_map_constructor(func, name, obj); } @@ -226,15 +182,15 @@ public: // implicit base -> delegate converter template address_map_entry &r(Ret (T::*read)(Params...), const char *read_name) - { return r(make_delegate(read, read_name, m_devbase.tag(), make_pointer(m_devbase))); } + { return r(emu::detail::make_delegate(read, read_name, m_devbase.tag(), make_pointer(m_devbase))); } template address_map_entry &w(Ret (T::*write)(Params...), const char *write_name) - { return w(make_delegate(write, write_name, m_devbase.tag(), make_pointer(m_devbase))); } + { return w(emu::detail::make_delegate(write, write_name, m_devbase.tag(), make_pointer(m_devbase))); } template address_map_entry &rw(RetR (T::*read)(ParamsR...), const char *read_name, RetW (U::*write)(ParamsW...), const char *write_name) - { return rw(make_delegate(read, read_name, m_devbase.tag(), make_pointer(m_devbase)), make_delegate(write, write_name, m_devbase.tag(), make_pointer(m_devbase))); } + { return rw(emu::detail::make_delegate(read, read_name, m_devbase.tag(), make_pointer(m_devbase)), emu::detail::make_delegate(write, write_name, m_devbase.tag(), make_pointer(m_devbase))); } template address_map_entry &m(Ret (T::*map)(Params...), const char *map_name) @@ -248,15 +204,15 @@ public: // device tag -> delegate converter template address_map_entry &r(const char *tag, Ret (T::*read)(Params...), const char *read_name) - { return r(make_delegate(read, read_name, tag, static_cast(nullptr))); } + { return r(emu::detail::make_delegate(read, read_name, tag, nullptr)); } template address_map_entry &w(const char *tag, Ret (T::*write)(Params...), const char *write_name) - { return w(make_delegate(write, write_name, tag, static_cast(nullptr))); } + { return w(emu::detail::make_delegate(write, write_name, tag, nullptr)); } template address_map_entry &rw(const char *tag, RetR (T::*read)(ParamsR...), const char *read_name, RetW (U::*write)(ParamsW...), const char *write_name) - { return rw(make_delegate(read, read_name, tag, static_cast(nullptr)), make_delegate(write, write_name, tag, static_cast(nullptr))); } + { return rw(emu::detail::make_delegate(read, read_name, tag, nullptr), emu::detail::make_delegate(write, write_name, tag, nullptr)); } template address_map_entry &m(const char *tag, Ret (T::*map)(Params...), const char *map_name) @@ -270,15 +226,15 @@ public: // device reference -> delegate converter template address_map_entry &r(T &obj, Ret (U::*read)(Params...), const char *read_name) - { return r(make_delegate(read, read_name, get_tag(obj), make_pointer(obj))); } + { return r(emu::detail::make_delegate(read, read_name, get_tag(obj), make_pointer(obj))); } template address_map_entry &w(T &obj, Ret (U::*write)(Params...), const char *write_name) - { return w(make_delegate(write, write_name, get_tag(obj), make_pointer(obj))); } + { return w(emu::detail::make_delegate(write, write_name, get_tag(obj), make_pointer(obj))); } template address_map_entry &rw(T &obj, RetR (U::*read)(ParamsR...), const char *read_name, RetW (V::*write)(ParamsW...), const char *write_name) - { return rw(make_delegate(read, read_name, get_tag(obj), make_pointer(obj)), make_delegate(write, write_name, get_tag(obj), make_pointer(obj))); } + { return rw(emu::detail::make_delegate(read, read_name, get_tag(obj), make_pointer(obj)), emu::detail::make_delegate(write, write_name, get_tag(obj), make_pointer(obj))); } template address_map_entry &m(T &obj, Ret (U::*map)(Params...), const char *map_name) @@ -292,27 +248,27 @@ public: // device finder -> delegate converter template address_map_entry &r(device_finder &finder, Ret (U::*read)(Params...), const char *read_name) - { const std::pair target(finder.finder_target()); device_t &device(*target.first.subdevice(target.second)); return r(make_delegate(read, read_name, device.tag(), make_pointer(device))); } + { const std::pair target(finder.finder_target()); device_t &device(*target.first.subdevice(target.second)); return r(emu::detail::make_delegate(read, read_name, device.tag(), make_pointer(device))); } template address_map_entry &r(const device_finder &finder, Ret (U::*read)(Params...), const char *read_name) - { const std::pair target(finder.finder_target()); device_t &device(*target.first.subdevice(target.second)); return r(make_delegate(read, read_name, device.tag(), make_pointer(device))); } + { const std::pair target(finder.finder_target()); device_t &device(*target.first.subdevice(target.second)); return r(emu::detail::make_delegate(read, read_name, device.tag(), make_pointer(device))); } template address_map_entry &w(device_finder &finder, Ret (U::*write)(Params...), const char *write_name) - { const std::pair target(finder.finder_target()); device_t &device(*target.first.subdevice(target.second)); return w(make_delegate(write, write_name, device.tag(), make_pointer(device))); } + { const std::pair target(finder.finder_target()); device_t &device(*target.first.subdevice(target.second)); return w(emu::detail::make_delegate(write, write_name, device.tag(), make_pointer(device))); } template address_map_entry &w(const device_finder &finder, Ret (U::*write)(Params...), const char *write_name) - { const std::pair target(finder.finder_target()); device_t &device(*target.first.subdevice(target.second)); return w(make_delegate(write, write_name, device.tag(), make_pointer(device))); } + { const std::pair target(finder.finder_target()); device_t &device(*target.first.subdevice(target.second)); return w(emu::detail::make_delegate(write, write_name, device.tag(), make_pointer(device))); } template address_map_entry &rw(device_finder &finder, RetR (U::*read)(ParamsR...), const char *read_name, RetW (V::*write)(ParamsW...), const char *write_name) - { const std::pair target(finder.finder_target()); device_t &device(*target.first.subdevice(target.second)); return rw(make_delegate(read, read_name, device.tag(), make_pointer(device)), make_delegate(write, write_name, device.tag(), make_pointer(device))); } + { const std::pair target(finder.finder_target()); device_t &device(*target.first.subdevice(target.second)); return rw(emu::detail::make_delegate(read, read_name, device.tag(), make_pointer(device)), emu::detail::make_delegate(write, write_name, device.tag(), make_pointer(device))); } template address_map_entry &rw(const device_finder &finder, RetR (U::*read)(ParamsR...), const char *read_name, RetW (V::*write)(ParamsW...), const char *write_name) - { const std::pair target(finder.finder_target()); device_t &device(*target.first.subdevice(target.second)); return rw(make_delegate(read, read_name, device.tag(), make_pointer(device)), make_delegate(write, write_name, device.tag(), make_pointer(device))); } + { const std::pair target(finder.finder_target()); device_t &device(*target.first.subdevice(target.second)); return rw(emu::detail::make_delegate(read, read_name, device.tag(), make_pointer(device)), emu::detail::make_delegate(write, write_name, device.tag(), make_pointer(device))); } template address_map_entry &m(device_finder &finder, Ret (U::*map)(Params...), const char *map_name) diff --git a/src/emu/emumem.h b/src/emu/emumem.h index 83908baa1f4..045e4d33a76 100644 --- a/src/emu/emumem.h +++ b/src/emu/emumem.h @@ -17,6 +17,8 @@ #ifndef MAME_EMU_EMUMEM_H #define MAME_EMU_EMUMEM_H +#include + using s8 = std::int8_t; using u8 = std::uint8_t; using s16 = std::int16_t; @@ -103,6 +105,129 @@ typedef device_delegate write16_delega typedef device_delegate write32_delegate; typedef device_delegate write64_delegate; +namespace emu { namespace detail { + +template struct read8_device_class { }; +template struct read16_device_class { }; +template struct read32_device_class { }; +template struct read64_device_class { }; + +template +struct read8_device_class::value> > { using type = T; }; +template +struct read8_device_class::value> > { using type = T; }; +template +struct read8_device_class::value> > { using type = T; }; +template +struct read8_device_class::value> > { using type = T; }; + +template +struct read16_device_class::value> > { using type = T; }; +template +struct read16_device_class::value> > { using type = T; }; +template +struct read16_device_class::value> > { using type = T; }; +template +struct read16_device_class::value> > { using type = T; }; + +template +struct read32_device_class::value> > { using type = T; }; +template +struct read32_device_class::value> > { using type = T; }; +template +struct read32_device_class::value> > { using type = T; }; +template +struct read32_device_class::value> > { using type = T; }; + +template +struct read64_device_class::value> > { using type = T; }; +template +struct read64_device_class::value> > { using type = T; }; +template +struct read64_device_class::value> > { using type = T; }; +template +struct read64_device_class::value> > { using type = T; }; + +template using read8_device_class_t = typename read8_device_class::type; +template using read16_device_class_t = typename read16_device_class::type; +template using read32_device_class_t = typename read32_device_class::type; +template using read64_device_class_t = typename read64_device_class::type; + +template struct write8_device_class { }; +template struct write16_device_class { }; +template struct write32_device_class { }; +template struct write64_device_class { }; + +template +struct write8_device_class::value> > { using type = T; }; +template +struct write8_device_class::value> > { using type = T; }; +template +struct write8_device_class::value> > { using type = T; }; +template +struct write8_device_class::value> > { using type = T; }; + +template +struct write16_device_class::value> > { using type = T; }; +template +struct write16_device_class::value> > { using type = T; }; +template +struct write16_device_class::value> > { using type = T; }; +template +struct write16_device_class::value> > { using type = T; }; + +template +struct write32_device_class::value> > { using type = T; }; +template +struct write32_device_class::value> > { using type = T; }; +template +struct write32_device_class::value> > { using type = T; }; +template +struct write32_device_class::value> > { using type = T; }; + +template +struct write64_device_class::value> > { using type = T; }; +template +struct write64_device_class::value> > { using type = T; }; +template +struct write64_device_class::value> > { using type = T; }; +template +struct write64_device_class::value> > { using type = T; }; + +template using write8_device_class_t = typename write8_device_class::type; +template using write16_device_class_t = typename write16_device_class::type; +template using write32_device_class_t = typename write32_device_class::type; +template using write64_device_class_t = typename write64_device_class::type; + +template +inline read8_delegate make_delegate(T &&func, const char *name, const char *tag, read8_device_class_t > *obj) +{ return read8_delegate(func, name, tag, obj); } +template +inline read16_delegate make_delegate(T &&func, const char *name, const char *tag, read16_device_class_t > *obj) +{ return read16_delegate(func, name, tag, obj); } +template +inline read32_delegate make_delegate(T &&func, const char *name, const char *tag, read32_device_class_t > *obj) +{ return read32_delegate(func, name, tag, obj); } +template +inline read64_delegate make_delegate(T &&func, const char *name, const char *tag, read64_device_class_t > *obj) +{ return read64_delegate(func, name, tag, obj); } + +template +inline write8_delegate make_delegate(T &&func, const char *name, const char *tag, write8_device_class_t > *obj) +{ return write8_delegate(func, name, tag, obj); } +template +inline write16_delegate make_delegate(T &&func, const char *name, const char *tag, write16_device_class_t > *obj) +{ return write16_delegate(func, name, tag, obj); } +template +inline write32_delegate make_delegate(T &&func, const char *name, const char *tag, write32_device_class_t > *obj) +{ return write32_delegate(func, name, tag, obj); } +template +inline write64_delegate make_delegate(T &&func, const char *name, const char *tag, write64_device_class_t > *obj) +{ return write64_delegate(func, name, tag, obj); } + +} } // namespace emu::detail + + // ======================> setoffset_delegate typedef device_delegate setoffset_delegate; -- cgit v1.2.3