summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/ccastles.h
diff options
context:
space:
mode:
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
commitc85c035c5df40c68195b50ba995369eaf8bd18da (patch)
treee8f9b512e63268a668d55116f992c12e5777692f /src/mame/includes/ccastles.h
parentb8b87c341ac498766daad95ac743285a14e0e5d8 (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/ccastles.h')
-rw-r--r--src/mame/includes/ccastles.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/mame/includes/ccastles.h b/src/mame/includes/ccastles.h
index bd0d80cf48a..320ee4cd42d 100644
--- a/src/mame/includes/ccastles.h
+++ b/src/mame/includes/ccastles.h
@@ -4,12 +4,13 @@
*************************************************************************/
-class ccastles_state
+class ccastles_state : public driver_data_t
{
public:
- static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ccastles_state(machine)); }
+ static driver_data_t *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ccastles_state(machine)); }
- ccastles_state(running_machine &machine) { }
+ ccastles_state(running_machine &machine)
+ : driver_data_t(machine) { }
/* memory pointers */
UINT8 * videoram;