diff --git a/src/emu/state.c b/src/emu/state.c index 01f6ca18de6..cdcdd23add9 100644 --- a/src/emu/state.c +++ b/src/emu/state.c @@ -163,8 +163,42 @@ INLINE void flip_data(state_entry *entry) all registrations -------------------------------------------------*/ +enum test_enum_type { test_val }; + +class test_class_type { public: int dummy; }; + void state_init(running_machine *machine) { + bool test_bool; + INT8 test_INT8; + UINT8 test_UINT8; + INT16 test_INT16; + UINT16 test_UINT16; + INT32 test_INT32; + UINT32 test_UINT32; + INT64 test_INT64; + UINT64 test_UINT64; + float test_float; + double test_double; + test_enum_type test_enum; + test_class_type test_class; + + assert_always(IS_VALID_SAVE_TYPE(test_bool), "bool is not a valid type for save"); + assert_always(IS_VALID_SAVE_TYPE(test_INT8), "INT8 is not a valid type for save"); + assert_always(IS_VALID_SAVE_TYPE(test_UINT8), "UINT8 is not a valid type for save"); + assert_always(IS_VALID_SAVE_TYPE(test_INT16), "INT16 is not a valid type for save"); + assert_always(IS_VALID_SAVE_TYPE(test_UINT16), "UINT16 is not a valid type for save"); + assert_always(IS_VALID_SAVE_TYPE(test_INT32), "INT32 is not a valid type for save"); + assert_always(IS_VALID_SAVE_TYPE(test_UINT32), "UINT32 is not a valid type for save"); + assert_always(IS_VALID_SAVE_TYPE(test_INT64), "INT64 is not a valid type for save"); + assert_always(IS_VALID_SAVE_TYPE(test_UINT64), "UINT64 is not a valid type for save"); + assert_always(IS_VALID_SAVE_TYPE(test_float), "float is not a valid type for save"); + assert_always(IS_VALID_SAVE_TYPE(test_double), "double is not a valid type for save"); + assert_always(IS_VALID_SAVE_TYPE(test_enum), "enums are not a valid type for save"); +#ifdef __GNUC__ + assert_always(!IS_VALID_SAVE_TYPE(test_class), "classes are a valid type for save"); +#endif + machine->state_data = auto_alloc_clear(machine, state_private); } diff --git a/src/emu/state.h b/src/emu/state.h index 31de65ee824..4512503b645 100644 --- a/src/emu/state.h +++ b/src/emu/state.h @@ -18,6 +18,9 @@ #ifndef __STATE_H__ #define __STATE_H__ +#ifdef __GNUC__ +#include +#endif /*************************************************************************** @@ -53,16 +56,13 @@ typedef enum _state_save_error state_save_error; #define STATE_POSTLOAD(name) void name(running_machine *machine, void *param) -#define IS_COMPATIBLE_TYPE(_valtype, _checktype) \ - (sizeof(_valtype) == sizeof(_checktype) && TYPES_COMPATIBLE(_valtype, _checktype)) - -#define IS_VALID_SAVE_TYPE(_valtype) \ - (IS_COMPATIBLE_TYPE(_valtype, double) || IS_COMPATIBLE_TYPE(_valtype, float) || \ - IS_COMPATIBLE_TYPE(_valtype, INT64) || IS_COMPATIBLE_TYPE(_valtype, UINT64) || \ - IS_COMPATIBLE_TYPE(_valtype, INT32) || IS_COMPATIBLE_TYPE(_valtype, UINT32) || \ - IS_COMPATIBLE_TYPE(_valtype, INT16) || IS_COMPATIBLE_TYPE(_valtype, UINT16) || \ - IS_COMPATIBLE_TYPE(_valtype, INT8) || IS_COMPATIBLE_TYPE(_valtype, UINT8) || \ - IS_COMPATIBLE_TYPE(_valtype, PAIR) || IS_COMPATIBLE_TYPE(_valtype, PAIR64)) +#ifdef __GNUC__ +#define IS_VALID_SAVE_TYPE(_var) \ + (std::tr1::is_arithmetic::value || std::tr1::is_enum::value) +#else +#define IS_VALID_SAVE_TYPE(_var) \ + (sizeof(_var) == 1 || sizeof(_var) == 2 || sizeof(_var) == 4 || sizeof(_var) == 8) +#endif /* generic registration; all further registrations are based on this */ diff --git a/src/emu/validity.c b/src/emu/validity.c index 5d1b88c737c..9c8a7aa5fcc 100644 --- a/src/emu/validity.c +++ b/src/emu/validity.c @@ -470,7 +470,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_info for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo->entries); rgnnum++) { /* stop when we hit an empty */ - if (rgninfo->entries[rgnnum].tag.len() == NULL) + if (rgninfo->entries[rgnnum].tag.len() == 0) { currgn = &rgninfo->entries[rgnnum]; currgn->tag.cpy(fulltag);