diff options
author | AJR <ajrhacker@users.noreply.github.com> | 2018-01-17 11:25:14 -0500 |
---|---|---|
committer | AJR <ajrhacker@users.noreply.github.com> | 2018-01-17 11:25:34 -0500 |
commit | d1b698af363fed1eb62846179e536c230502befa (patch) | |
tree | cd38ee57c28761f9f6e7ecbb0002295d72ffc451 | |
parent | d469cc04bcace0f601802301caeddc5b473b75f2 (diff) |
std::function is too inefficient, use a device delegate instead (nw)
-rw-r--r-- | src/emu/devdelegate.h | 7 | ||||
-rw-r--r-- | src/emu/driver.cpp | 3 | ||||
-rw-r--r-- | src/emu/gamedrv.h | 12 | ||||
-rw-r--r-- | src/emu/mconfig.h | 2 |
4 files changed, 14 insertions, 10 deletions
diff --git a/src/emu/devdelegate.h b/src/emu/devdelegate.h index 47af86d84c3..a9b2f5aca95 100644 --- a/src/emu/devdelegate.h +++ b/src/emu/devdelegate.h @@ -35,6 +35,10 @@ protected: // internal state const char *m_device_name; + +public: + // getter (for validation purposes) + const char *device_name() const { return m_device_name; } }; @@ -98,9 +102,6 @@ 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 889730da59c..49be813c8cb 100644 --- a/src/emu/driver.cpp +++ b/src/emu/driver.cpp @@ -173,7 +173,8 @@ const tiny_rom_entry *driver_device::device_rom_region() const void driver_device::device_add_mconfig(machine_config &config) { assert(m_system); - m_system->machine_creator(config, this); + machine_config_delegate creator(m_system->machine_creator, *this); + creator(config); } diff --git a/src/emu/gamedrv.h b/src/emu/gamedrv.h index 8a9faf4b8f8..36d5417aca2 100644 --- a/src/emu/gamedrv.h +++ b/src/emu/gamedrv.h @@ -152,7 +152,7 @@ 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 - std::function<void (machine_config &, device_t *)> machine_creator; // machine driver tokens + machine_config_delegate machine_creator; // machine driver tokens ioport_constructor ipt; // pointer to constructor for input ports driver_init_helper const & driver_init; // DRIVER_INIT callback const tiny_rom_entry * rom; // pointer to list of ROMs for the game @@ -202,7 +202,7 @@ extern game_driver const GAME_NAME(NAME) \ #PARENT, \ #YEAR, \ COMPANY, \ - [] (machine_config &config, device_t *owner) { static_cast<CLASS *>(owner)->MACHINE(config); }, \ + machine_config_delegate(FUNC(CLASS::MACHINE), DEVICE_SELF, (CLASS *)nullptr), \ INPUT_PORTS_NAME(INPUT), \ game_driver::make_driver_init(&CLASS::init_##INIT), \ ROM_NAME(NAME), \ @@ -221,7 +221,7 @@ extern game_driver const GAME_NAME(NAME) \ #PARENT, \ #YEAR, \ COMPANY, \ - [] (machine_config &config, device_t *owner) { static_cast<CLASS *>(owner)->MACHINE(config); }, \ + machine_config_delegate(FUNC(CLASS::MACHINE), DEVICE_SELF, (CLASS *)nullptr), \ INPUT_PORTS_NAME(INPUT), \ game_driver::make_driver_init(&CLASS::init_##INIT), \ ROM_NAME(NAME), \ @@ -241,7 +241,7 @@ extern game_driver const GAME_NAME(NAME) \ #PARENT, \ #YEAR, \ COMPANY, \ - [] (machine_config &config, device_t *owner) { static_cast<CLASS *>(owner)->MACHINE(config); }, \ + machine_config_delegate(FUNC(CLASS::MACHINE), DEVICE_SELF, (CLASS *)nullptr), \ INPUT_PORTS_NAME(INPUT), \ game_driver::make_driver_init(&CLASS::init_##INIT), \ ROM_NAME(NAME), \ @@ -260,7 +260,7 @@ extern game_driver const GAME_NAME(NAME) \ #PARENT, \ #YEAR, \ COMPANY, \ - [] (machine_config &config, device_t *owner) { static_cast<CLASS *>(owner)->MACHINE(config); }, \ + machine_config_delegate(FUNC(CLASS::MACHINE), DEVICE_SELF, (CLASS *)nullptr), \ INPUT_PORTS_NAME(INPUT), \ game_driver::make_driver_init(&CLASS::init_##INIT), \ ROM_NAME(NAME), \ @@ -279,7 +279,7 @@ extern game_driver const GAME_NAME(NAME) \ #PARENT, \ #YEAR, \ COMPANY, \ - [] (machine_config &config, device_t *owner) { static_cast<CLASS *>(owner)->MACHINE(config); }, \ + machine_config_delegate(FUNC(CLASS::MACHINE), DEVICE_SELF, (CLASS *)nullptr), \ INPUT_PORTS_NAME(INPUT), \ game_driver::make_driver_init(&CLASS::init_##INIT), \ ROM_NAME(NAME), \ diff --git a/src/emu/mconfig.h b/src/emu/mconfig.h index 1e0cb8c8e5a..a04b77d9589 100644 --- a/src/emu/mconfig.h +++ b/src/emu/mconfig.h @@ -83,6 +83,8 @@ private: std::unique_ptr<device_t> m_root_device; }; +typedef device_delegate<void (machine_config &)> machine_config_delegate; + //*************************************************************************/ /** @name Machine config start/end macros */ |