diff --git a/src/emu/devdelegate.h b/src/emu/devdelegate.h index 2c7ba3a5562..96d9512d79b 100644 --- a/src/emu/devdelegate.h +++ b/src/emu/devdelegate.h @@ -35,10 +35,6 @@ protected: // internal state const char *m_device_name; - -public: - // getter (for validation purposes) - const char *device_name() const { return m_device_name; } }; @@ -102,6 +98,9 @@ public: // perform the binding void bind_relative_to(device_t &search_root) { if (!basetype::isnull()) basetype::late_bind(bound_object(search_root)); } + + // getter (for validation purposes) + const char *device_name() const { return m_device_name; } }; diff --git a/src/emu/driver.cpp b/src/emu/driver.cpp index 49be813c8cb..37c63d113fb 100644 --- a/src/emu/driver.cpp +++ b/src/emu/driver.cpp @@ -173,8 +173,7 @@ const tiny_rom_entry *driver_device::device_rom_region() const void driver_device::device_add_mconfig(machine_config &config) { assert(m_system); - machine_config_delegate creator(m_system->machine_creator, *this); - creator(config); + m_system->machine_creator(config, *this); } @@ -202,7 +201,7 @@ void driver_device::device_start() throw device_missing_dependencies(); // call the game-specific init - m_system->driver_init(machine()); + m_system->driver_init(*this); // finish image devices init process machine().image().postdevice_init(); diff --git a/src/emu/emu.h b/src/emu/emu.h index 363017c18ab..cc837b04d4f 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -115,7 +115,4 @@ typedef void (*machine_config_constructor)(machine_config &config, device_t *own // member templates that don't like incomplete types #include "device.ipp" -template void game_driver::driver_init_helper_impl::invoke(driver_init_helper const &helper, running_machine &machine) -{ (machine.driver_data()->*static_cast const &>(helper).m_method)(); } - #endif /* __EMU_H__ */ diff --git a/src/emu/gamedrv.h b/src/emu/gamedrv.h index 36d5417aca2..2acafd7ca6c 100644 --- a/src/emu/gamedrv.h +++ b/src/emu/gamedrv.h @@ -101,31 +101,8 @@ constexpr u64 MACHINE_IS_SKELETON_MECHANICAL = MACHINE_IS_SKELETON | MACHINE_ class game_driver { public: - class driver_init_helper - { - public: - void operator()(running_machine &machine) const { m_function(*this, machine); } - protected: - constexpr driver_init_helper(void (*function)(driver_init_helper const &, running_machine &)) : m_function(function) { } - constexpr driver_init_helper(driver_init_helper const &) = default; - private: - void (* const m_function)(driver_init_helper const &, running_machine &); - }; - - template class driver_init_helper_impl : public driver_init_helper - { - public: - constexpr driver_init_helper_impl(void (DriverClass::*method)()) : driver_init_helper(&driver_init_helper_impl::invoke), m_method(method) { } - constexpr driver_init_helper_impl(driver_init_helper_impl const &) = default; - private: - static void invoke(driver_init_helper const &helper, running_machine &machine); - void (DriverClass::*const m_method)(); - }; - - template static constexpr auto make_driver_init(void (DriverClass::*method)()) - { - return driver_init_helper_impl(method); - } + typedef void (*machine_creator_wrapper)(machine_config &, device_t &); + typedef void (*driver_init_wrapper)(device_t &); static constexpr device_t::feature_type unemulated_features(u64 flags) { @@ -152,9 +129,9 @@ public: const char * parent; // if this is a clone, the name of the parent const char * year; // year the game was released const char * manufacturer; // manufacturer of the game - machine_config_delegate machine_creator; // machine driver tokens + machine_creator_wrapper machine_creator; // machine driver tokens ioport_constructor ipt; // pointer to constructor for input ports - driver_init_helper const & driver_init; // DRIVER_INIT callback + driver_init_wrapper driver_init; // DRIVER_INIT callback const tiny_rom_entry * rom; // pointer to list of ROMs for the game const char * compatible_with; const internal_layout * default_layout; // default internally defined layout @@ -202,9 +179,9 @@ extern game_driver const GAME_NAME(NAME) \ #PARENT, \ #YEAR, \ COMPANY, \ - machine_config_delegate(FUNC(CLASS::MACHINE), DEVICE_SELF, (CLASS *)nullptr), \ + [] (machine_config &config, device_t &owner) { downcast(owner).MACHINE(config); }, \ INPUT_PORTS_NAME(INPUT), \ - game_driver::make_driver_init(&CLASS::init_##INIT), \ + [] (device_t &owner) { downcast(owner).init_##INIT(); }, \ ROM_NAME(NAME), \ nullptr, \ nullptr, \ @@ -221,9 +198,9 @@ extern game_driver const GAME_NAME(NAME) \ #PARENT, \ #YEAR, \ COMPANY, \ - machine_config_delegate(FUNC(CLASS::MACHINE), DEVICE_SELF, (CLASS *)nullptr), \ + [] (machine_config &config, device_t &owner) { downcast(owner).MACHINE(config); }, \ INPUT_PORTS_NAME(INPUT), \ - game_driver::make_driver_init(&CLASS::init_##INIT), \ + [] (device_t &owner) { downcast(owner).init_##INIT(); }, \ ROM_NAME(NAME), \ nullptr, \ &LAYOUT, \ @@ -241,9 +218,9 @@ extern game_driver const GAME_NAME(NAME) \ #PARENT, \ #YEAR, \ COMPANY, \ - machine_config_delegate(FUNC(CLASS::MACHINE), DEVICE_SELF, (CLASS *)nullptr), \ + [] (machine_config &config, device_t &owner) { downcast(owner).MACHINE(config); }, \ INPUT_PORTS_NAME(INPUT), \ - game_driver::make_driver_init(&CLASS::init_##INIT), \ + [] (device_t &owner) { downcast(owner).init_##INIT(); }, \ ROM_NAME(NAME), \ #COMPAT, \ nullptr, \ @@ -260,9 +237,9 @@ extern game_driver const GAME_NAME(NAME) \ #PARENT, \ #YEAR, \ COMPANY, \ - machine_config_delegate(FUNC(CLASS::MACHINE), DEVICE_SELF, (CLASS *)nullptr), \ + [] (machine_config &config, device_t &owner) { downcast(owner).MACHINE(config); }, \ INPUT_PORTS_NAME(INPUT), \ - game_driver::make_driver_init(&CLASS::init_##INIT), \ + [] (device_t &owner) { downcast(owner).init_##INIT(); }, \ ROM_NAME(NAME), \ #COMPAT, \ nullptr, \ @@ -279,9 +256,9 @@ extern game_driver const GAME_NAME(NAME) \ #PARENT, \ #YEAR, \ COMPANY, \ - machine_config_delegate(FUNC(CLASS::MACHINE), DEVICE_SELF, (CLASS *)nullptr), \ + [] (machine_config &config, device_t &owner) { downcast(owner).MACHINE(config); }, \ INPUT_PORTS_NAME(INPUT), \ - game_driver::make_driver_init(&CLASS::init_##INIT), \ + [] (device_t &owner) { downcast(owner).init_##INIT(); }, \ ROM_NAME(NAME), \ #COMPAT, \ nullptr, \ diff --git a/src/emu/mconfig.h b/src/emu/mconfig.h index a04b77d9589..1e0cb8c8e5a 100644 --- a/src/emu/mconfig.h +++ b/src/emu/mconfig.h @@ -83,8 +83,6 @@ private: std::unique_ptr m_root_device; }; -typedef device_delegate machine_config_delegate; - //*************************************************************************/ /** @name Machine config start/end macros */