summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2018-01-18 18:56:01 +1100
committer Vas Crabb <vas@vastheman.com>2018-01-18 18:56:01 +1100
commita0dfee78d6c06440c0d702b63eb6f3aa09e5329e (patch)
tree9c3ee096e146e4872c820adf4393168aafd8a1c1
parentd853daeae3913932c87590f871a9825bffc59831 (diff)
std::function and delegate both require runtime relocations, slowing down startup - just use function pointers; also, most downcast, and get rid of a circular dependency between gamedrv.h and mconfig.h (nw)
-rw-r--r--src/emu/devdelegate.h7
-rw-r--r--src/emu/driver.cpp5
-rw-r--r--src/emu/emu.h3
-rw-r--r--src/emu/gamedrv.h51
-rw-r--r--src/emu/mconfig.h2
5 files changed, 19 insertions, 49 deletions
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 <class DriverClass> void game_driver::driver_init_helper_impl<DriverClass>::invoke(driver_init_helper const &helper, running_machine &machine)
-{ (machine.driver_data<DriverClass>()->*static_cast<driver_init_helper_impl<DriverClass> 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 DriverClass> 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<DriverClass>::invoke), m_method(method) { }
- constexpr driver_init_helper_impl(driver_init_helper_impl<DriverClass> const &) = default;
- private:
- static void invoke(driver_init_helper const &helper, running_machine &machine);
- void (DriverClass::*const m_method)();
- };
-
- template <class DriverClass> static constexpr auto make_driver_init(void (DriverClass::*method)())
- {
- return driver_init_helper_impl<DriverClass>(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<CLASS &>(owner).MACHINE(config); }, \
INPUT_PORTS_NAME(INPUT), \
- game_driver::make_driver_init(&CLASS::init_##INIT), \
+ [] (device_t &owner) { downcast<CLASS &>(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<CLASS &>(owner).MACHINE(config); }, \
INPUT_PORTS_NAME(INPUT), \
- game_driver::make_driver_init(&CLASS::init_##INIT), \
+ [] (device_t &owner) { downcast<CLASS &>(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<CLASS &>(owner).MACHINE(config); }, \
INPUT_PORTS_NAME(INPUT), \
- game_driver::make_driver_init(&CLASS::init_##INIT), \
+ [] (device_t &owner) { downcast<CLASS &>(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<CLASS &>(owner).MACHINE(config); }, \
INPUT_PORTS_NAME(INPUT), \
- game_driver::make_driver_init(&CLASS::init_##INIT), \
+ [] (device_t &owner) { downcast<CLASS &>(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<CLASS &>(owner).MACHINE(config); }, \
INPUT_PORTS_NAME(INPUT), \
- game_driver::make_driver_init(&CLASS::init_##INIT), \
+ [] (device_t &owner) { downcast<CLASS &>(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<device_t> m_root_device;
};
-typedef device_delegate<void (machine_config &)> machine_config_delegate;
-
//*************************************************************************/
/** @name Machine config start/end macros */