diff options
author | Aaron Giles <aaron@aarongiles.com> | 2010-08-04 15:37:08 +0000 |
---|---|---|
committer | Aaron Giles <aaron@aarongiles.com> | 2010-08-04 15:37:08 +0000 |
commit | c85c035c5df40c68195b50ba995369eaf8bd18da (patch) | |
tree | e8f9b512e63268a668d55116f992c12e5777692f /src/mame/includes/gameplan.h | |
parent | b8b87c341ac498766daad95ac743285a14e0e5d8 (diff) |
(Wow, I had no idea quite so many drivers were using driver_data!)
Defined new class driver_data_t, which all driver_data classes must
derive from. Updated all class definitions to inherit from the new
class, and to call it in the constructor. Also changed the alloc()
signature to return a driver_data_t pointer instead of a void *.
Renamed and hid machine->driver_data as machine->m_driver_data.
Added a new templatized method machine->driver_data<class> which returns
a properly downcast'ed version of the driver data. Updated all code
which looked like this:
mydriver_state *state = (mydriver_state *)machine->driver_data;
to this:
mydriver_state *state = machine->driver_data<mydriver_state>();
The new function does a downcast<> which in debug builds dynamically
verifies that you're actually casting to the right type.
Changed atarigen_state to be a base class from which all the related
Atari drivers derive their state from.
For MESS: this was mostly a bulk search/replace, in 4 steps in
src/mame:
1. Add ": public driver_data_t" to each driver state class definition:
Search: (class [a-z0-9_]+_state)$
Replace: \1 : public driver_data_t
2. Change the static alloc function to return a driver_data_t *:
Search: static void \*alloc\(
Replace: static driver_data_t \*alloc\(
3. Change the constructor to initialize driver_data_t:
Search: ([a-z0-9_]+_state\(running_machine \&machine\)) { }
Replace: \1\r\n\t\t: driver_data_t(machine) { }
4. Replace the state fetchers to use the new templatized function:
Search: \(([a-z0-9_]+_state) \*\)(.*)machine->driver_data
Replace: \2machine->driver_data<\1>()
Diffstat (limited to 'src/mame/includes/gameplan.h')
-rw-r--r-- | src/mame/includes/gameplan.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/mame/includes/gameplan.h b/src/mame/includes/gameplan.h index 5de5f48c814..9c10cb348be 100644 --- a/src/mame/includes/gameplan.h +++ b/src/mame/includes/gameplan.h @@ -21,12 +21,13 @@ driver by Chris Moore #define LEPRECHAUN_MAIN_CPU_CLOCK (LEPRECHAUN_MAIN_MASTER_CLOCK / 4) -class gameplan_state +class gameplan_state : public driver_data_t { public: - static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gameplan_state(machine)); } + static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gameplan_state(machine)); } - gameplan_state(running_machine &machine) { } + gameplan_state(running_machine &machine) + : driver_data_t(machine) { } /* machine state */ UINT8 current_port; |