Worked around the OPTION_GUIDE_EXTERN issue by using a crazy trick involving namespaces

Caveats:
  1.  Because of how this trick works, it is no longer possible to declare an option guide as static, so I had to make a bunch of changes
  2.  I'm going to want the hardcore C++ guys (i.e. - Vas) to review this with a fine toothed comb
This commit is contained in:
Nathan Woods 2016-09-03 16:11:58 -04:00
parent be3c18302e
commit 4251194fe5
18 changed files with 37 additions and 29 deletions

View File

@ -10,7 +10,7 @@
#include "diablo.h"
static OPTION_GUIDE_START(dsk_option_guide)
OPTION_GUIDE_START(dsk_option_guide)
OPTION_INT('C', "cylinders", "Cylinders")
OPTION_INT('H', "heads", "Heads")
OPTION_INT('S', "sectors", "Sectors")

View File

@ -19,7 +19,7 @@
#include "harddriv.h"
static OPTION_GUIDE_START(hd_option_guide)
OPTION_GUIDE_START(hd_option_guide)
OPTION_INT('C', "cylinders", "Cylinders")
OPTION_INT('H', "heads", "Heads")
OPTION_INT('S', "sectors", "Sectors")

View File

@ -1227,7 +1227,7 @@ void device_image_interface::unload()
// create_option_guide
//-------------------------------------------------
static OPTION_GUIDE_START(null_option_guide)
OPTION_GUIDE_START(null_option_guide)
OPTION_GUIDE_END
const util::option_guide &device_image_interface::create_option_guide() const

View File

@ -58,7 +58,7 @@ struct floppy_params
static floperr_t floppy_track_unload(floppy_image_legacy *floppy);
OPTION_GUIDE_START(floppy_option_guide_actual)
OPTION_GUIDE_START(floppy_option_guide)
OPTION_INT('H', "heads", "Heads")
OPTION_INT('T', "tracks", "Tracks")
OPTION_INT('S', "sectors", "Sectors")
@ -66,7 +66,6 @@ OPTION_GUIDE_START(floppy_option_guide_actual)
OPTION_INT('I', "interleave", "Interleave")
OPTION_INT('F', "firstsectorid", "First Sector")
OPTION_GUIDE_END
const util::option_guide &floppy_option_guide = floppy_option_guide_actual;
static void floppy_close_internal(floppy_image_legacy *floppy, int close_file);

View File

@ -50,19 +50,28 @@
// TYPE DEFINITIONS
//**************************************************************************
#define OPTION_GUIDE_START(option_guide_) \
const auto option_guide_ = util::make_option_guide(0
#define OPTION_GUIDE_END \
);
#define OPTION_GUIDE_EXTERN(option_guide_) \
#define OPTION_GUIDE_START(option_guide_) \
namespace option_guide_impl_##option_guide_ \
{ \
static const util::option_guide &get(); \
}; \
const util::option_guide &option_guide_ = option_guide_impl_##option_guide_::get(); \
namespace option_guide_impl_##option_guide_ \
{ \
static const auto actual = util::make_option_guide(0
#define OPTION_GUIDE_END \
); \
static const util::option_guide &get() { return actual; } \
};
#define OPTION_GUIDE_EXTERN(option_guide_) \
extern const util::option_guide &option_guide_
#define OPTION_INT(option_char, identifier, display_name) \
#define OPTION_INT(option_char, identifier, display_name) \
,util::option_guide::entry(util::option_guide::entry::option_type::INT, (option_char), (identifier), (display_name))
#define OPTION_STRING(option_char, identifier, display_name) \
#define OPTION_STRING(option_char, identifier, display_name) \
,util::option_guide::entry(util::option_guide::entry::option_type::STRING, (option_char), (identifier), (display_name))
#define OPTION_ENUM_START(option_char, identifier, display_name) \
#define OPTION_ENUM_START(option_char, identifier, display_name) \
,util::option_guide::entry(util::option_guide::entry::option_type::ENUM_BEGIN, (option_char), (identifier), (display_name))
#define OPTION_ENUM(value, identifier, display_name) \
#define OPTION_ENUM(value, identifier, display_name) \
,util::option_guide::entry(util::option_guide::entry::option_type::ENUM_VALUE, (value), (identifier), (display_name))
#define OPTION_ENUM_END

View File

@ -40,7 +40,7 @@
#define OPK_HEAD_SIZE 6
static OPTION_GUIDE_START( datapack_option_guide )
OPTION_GUIDE_START( datapack_option_guide )
OPTION_INT('S', "size", "Datapack size" )
OPTION_INT('R', "ram", "RAM/EPROM" )
OPTION_INT('P', "paged", "Paged" )

View File

@ -226,7 +226,7 @@ enum
mess_hd_createopts_seclen = 'F'
};
static OPTION_GUIDE_START( mess_hd_create_optionguide )
OPTION_GUIDE_START( mess_hd_create_optionguide )
OPTION_INT(mess_hd_createopts_blocksize, "blocksize", "Sectors Per Block" )
OPTION_INT(mess_hd_createopts_cylinders, "cylinders", "Cylinders" )
OPTION_INT(mess_hd_createopts_heads, "heads", "Heads" )

View File

@ -2342,7 +2342,7 @@ static imgtoolerr_t amiga_image_suggesttransfer(imgtool_partition *partition, co
*****************************************************************************/
static OPTION_GUIDE_START(amiga_createimage_optionguide)
OPTION_GUIDE_START(amiga_createimage_optionguide)
OPTION_STRING( 'N', "name", "Volume name" )
OPTION_ENUM_START( 'S', "density", "Density" )
OPTION_ENUM( 0, "dd", "Double Density" )

View File

@ -882,7 +882,7 @@ static imgtoolerr_t bml3_diskimage_suggesttransfer(imgtool_partition *partition,
Imgtool module declaration
*********************************************************************/
static OPTION_GUIDE_START( bml3_writefile_optionguide )
OPTION_GUIDE_START( bml3_writefile_optionguide )
OPTION_ENUM_START( BML3_OPTIONS_FTYPE, "ftype", "File type" )
OPTION_ENUM( 0, "basic", "Basic" )
OPTION_ENUM( 1, "data", "Data" )

View File

@ -531,7 +531,7 @@ static imgtoolerr_t cybiko_image_delete_file( imgtool_partition *partition, cons
return IMGTOOLERR_SUCCESS;
}
static OPTION_GUIDE_START( cybiko_image_createimage_optguide )
OPTION_GUIDE_START( cybiko_image_createimage_optguide )
OPTION_ENUM_START( 'F', "flash", "Flash Type" )
OPTION_ENUM( 0, "AT45DB041", "AT45DB041 (528 KByte)" )
OPTION_ENUM( 1, "AT45DB081", "AT45DB081 (1056 KByte)" )

View File

@ -136,7 +136,7 @@ static const char* hp48_prefix = "HPHP48-R";
static OPTION_GUIDE_START( hp48_create_optionguide )
OPTION_GUIDE_START( hp48_create_optionguide )
OPTION_INT('S', "size", "Size in KB" )
OPTION_GUIDE_END

View File

@ -55,7 +55,7 @@
#define FAT_SECLEN 512
static OPTION_GUIDE_START( pc_chd_create_optionguide )
OPTION_GUIDE_START( pc_chd_create_optionguide )
OPTION_INT('T', "cylinders", "Cylinders" )
OPTION_INT('H', "heads", "Heads" )
OPTION_INT('S', "sectors", "Sectors" )

View File

@ -626,7 +626,7 @@ static imgtoolerr_t datapack_delete_file( imgtool_partition *partition, const ch
return IMGTOOLERR_FILENOTFOUND;
}
static OPTION_GUIDE_START( psion_create_optguide )
OPTION_GUIDE_START( psion_create_optguide )
OPTION_ENUM_START( 'S', "size", "datapack size" )
OPTION_ENUM( 1, "8k", "8 kbyte" )
OPTION_ENUM( 2, "16k", "16 kbyts" )
@ -641,7 +641,7 @@ static OPTION_GUIDE_START( psion_create_optguide )
OPTION_INT('C', "copy", "copyable datapack" )
OPTION_GUIDE_END
static OPTION_GUIDE_START( psion_write_optguide )
OPTION_GUIDE_START( psion_write_optguide )
OPTION_ENUM_START( 'T', "type", "file type" )
OPTION_ENUM( 1, "OB3", "OB3 files" )
OPTION_ENUM( 2, "OPL", "OPL files" )

View File

@ -579,7 +579,7 @@ static imgtoolerr_t rsdos_diskimage_suggesttransfer(imgtool_partition *partition
Imgtool module declaration
*********************************************************************/
static OPTION_GUIDE_START( coco_rsdos_writefile_optionguide )
OPTION_GUIDE_START( coco_rsdos_writefile_optionguide )
OPTION_ENUM_START( RSDOS_OPTIONS_FTYPE, "ftype", "File type" )
OPTION_ENUM( 0, "basic", "Basic" )
OPTION_ENUM( 1, "data", "Data" )

View File

@ -1519,7 +1519,7 @@ FILTER( thombas128,
/************************* driver ***************************/
static OPTION_GUIDE_START( thom_createimage_optguide )
OPTION_GUIDE_START( thom_createimage_optguide )
OPTION_INT( 'H', "heads", "Heads" )
OPTION_INT( 'T', "tracks", "Tracks" )
OPTION_ENUM_START( 'D', "density", "Density" )
@ -1529,7 +1529,7 @@ static OPTION_GUIDE_START( thom_createimage_optguide )
OPTION_STRING( 'N', "name", "Floppy name" )
OPTION_GUIDE_END
static OPTION_GUIDE_START( thom_writefile_optguide )
OPTION_GUIDE_START( thom_writefile_optguide )
OPTION_ENUM_START( 'T', "ftype", "File type" )
OPTION_ENUM( 0, "auto", "Automatic (by extension)" )
OPTION_ENUM( 1, "B", "Program" )

View File

@ -3877,7 +3877,7 @@ enum
dsk_createopts_density = 'F'
};
static OPTION_GUIDE_START( dsk_create_optionguide )
OPTION_GUIDE_START( dsk_create_optionguide )
OPTION_STRING(dsk_createopts_volname, "label", "Volume name" )
OPTION_INT(dsk_createopts_sides, "sides", "Sides" )
OPTION_INT(dsk_createopts_tracks, "tracks", "Tracks" )

View File

@ -409,7 +409,7 @@ enum
ti990_createopts_sectorsize = 'E'
};
static OPTION_GUIDE_START( ti990_create_optionguide )
OPTION_GUIDE_START( ti990_create_optionguide )
/*OPTION_STRING(ti990_createopts_volname, "label", "Volume name" )*/
OPTION_INT(ti990_createopts_cylinders, "cylinders", "Cylinders" )
OPTION_INT(ti990_createopts_heads, "heads", "Heads" )

View File

@ -903,7 +903,7 @@ void filter_vzsnapshot_getinfo(UINT32 state, union filterinfo *info)
Imgtool module declaration
*********************************************************************/
static OPTION_GUIDE_START(vzdos_writefile_optionguide)
OPTION_GUIDE_START(vzdos_writefile_optionguide)
OPTION_ENUM_START( 'T', "ftype", "File type" )
OPTION_ENUM( 0, "basic", "Basic" )
OPTION_ENUM( 1, "binary", "Binary" )