Commit 20692b9c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Rethink the configuration item type identifiers to give more space

Use the high order bits for the intrinsic value type (hint, integer, float
or string) and the low order ones for the more specific sub-types.
parent 8aeec8a4
......@@ -41,8 +41,6 @@ extern "C" {
*****************************************************************************/
/* Configuration hint types */
#define CONFIG_HINT_CATEGORY 0x02 /* Start of new category */
#define CONFIG_HINT_SUBCATEGORY 0x03 /* Start of sub-category */
#define CONFIG_HINT_SUBCATEGORY_END 0x04 /* End of sub-category */
......@@ -53,23 +51,22 @@ extern "C" {
#define CONFIG_SECTION 0x08 /* Start of new section */
/* Configuration item types */
#define CONFIG_ITEM_STRING 0x10 /* String option */
/* unused 0x0020 */
#define CONFIG_ITEM_MODULE 0x30 /* Module option */
#define CONFIG_ITEM_FLOAT 0x20 /* Float option */
#define CONFIG_ITEM_INTEGER 0x40 /* Integer option */
#define CONFIG_ITEM_BOOL 0x50 /* Bool option */
#define CONFIG_ITEM_FLOAT 0x60 /* Float option */
#define CONFIG_ITEM_DIRECTORY 0x70 /* Directory option */
#define CONFIG_ITEM_KEY 0x80 /* Hot key option */
#define CONFIG_ITEM_MODULE_CAT 0x90 /* Module option */
#define CONFIG_ITEM_MODULE_LIST 0xA0 /* Module option */
#define CONFIG_ITEM_MODULE_LIST_CAT 0xB0 /* Module option */
#define CONFIG_ITEM_FONT 0xC0 /* Font option */
#define CONFIG_ITEM_PASSWORD 0xD0 /* Password option (*) */
#define CONFIG_ITEM_LOADFILE 0xE0 /* Read file option */
#define CONFIG_ITEM_SAVEFILE 0xF0 /* Written file option */
#define CONFIG_ITEM(x) (((x) & 0xF0) != 0)
#define CONFIG_ITEM_BOOL 0x60 /* Bool option */
#define CONFIG_ITEM_STRING 0x80 /* String option */
#define CONFIG_ITEM_PASSWORD 0x81 /* Password option (*) */
#define CONFIG_ITEM_KEY 0x82 /* Hot key option */
#define CONFIG_ITEM_MODULE 0x84 /* Module option */
#define CONFIG_ITEM_MODULE_CAT 0x85 /* Module option */
#define CONFIG_ITEM_MODULE_LIST 0x86 /* Module option */
#define CONFIG_ITEM_MODULE_LIST_CAT 0x87 /* Module option */
#define CONFIG_ITEM_LOADFILE 0x8C /* Read file option */
#define CONFIG_ITEM_SAVEFILE 0x8D /* Written file option */
#define CONFIG_ITEM_DIRECTORY 0x8E /* Directory option */
#define CONFIG_ITEM_FONT 0x8F /* Font option */
#define CONFIG_ITEM(x) (((x) & ~0xF) != 0)
/*******************************************************************
* All predefined categories and subcategories
......
......@@ -42,9 +42,17 @@ void config_UnsortConfig (void);
char *config_GetDataDirDefault( void );
int IsConfigStringType( int type );
int IsConfigIntegerType (int type);
static inline int IsConfigFloatType (int type)
static inline bool IsConfigStringType(unsigned type)
{
return (type & CONFIG_ITEM_STRING) != 0;
}
static inline bool IsConfigIntegerType (int type)
{
return (type & CONFIG_ITEM_INTEGER) != 0;
}
static inline bool IsConfigFloatType (int type)
{
return type == CONFIG_ITEM_FLOAT;
}
......
......@@ -43,33 +43,6 @@ static inline char *strdupnull (const char *src)
return src ? strdup (src) : NULL;
}
/* Item types that use a string value (i.e. serialized in the module cache) */
int IsConfigStringType (int type)
{
static const unsigned char config_types[] =
{
CONFIG_ITEM_STRING, CONFIG_ITEM_MODULE, CONFIG_ITEM_DIRECTORY,
CONFIG_ITEM_KEY, CONFIG_ITEM_MODULE_CAT, CONFIG_ITEM_PASSWORD,
CONFIG_ITEM_MODULE_LIST, CONFIG_ITEM_MODULE_LIST_CAT,
CONFIG_ITEM_FONT, CONFIG_ITEM_LOADFILE, CONFIG_ITEM_SAVEFILE,
};
/* NOTE: this needs to be changed if we ever get more than 255 types */
return memchr (config_types, type, sizeof (config_types)) != NULL;
}
int IsConfigIntegerType (int type)
{
static const unsigned char config_types[] =
{
CONFIG_ITEM_INTEGER, CONFIG_ITEM_BOOL,
CONFIG_CATEGORY, CONFIG_SUBCATEGORY
};
return memchr (config_types, type, sizeof (config_types)) != NULL;
}
#undef config_GetType
/*****************************************************************************
* config_GetType: get the type of a variable (bool, int, float, string)
......@@ -90,30 +63,21 @@ int config_GetType( vlc_object_t *p_this, const char *psz_name )
return 0;
}
switch( p_config->i_type )
switch( p_config->i_type & ~0x1F )
{
case CONFIG_ITEM_BOOL:
i_type = VLC_VAR_BOOL;
case CONFIG_ITEM_FLOAT:
i_type = VLC_VAR_FLOAT;
break;
case CONFIG_ITEM_INTEGER:
i_type = VLC_VAR_INTEGER;
break;
case CONFIG_ITEM_FLOAT:
i_type = VLC_VAR_FLOAT;
case CONFIG_ITEM_BOOL:
i_type = VLC_VAR_BOOL;
break;
case CONFIG_ITEM_MODULE:
case CONFIG_ITEM_MODULE_CAT:
case CONFIG_ITEM_MODULE_LIST:
case CONFIG_ITEM_MODULE_LIST_CAT:
case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
case CONFIG_ITEM_LOADFILE:
case CONFIG_ITEM_SAVEFILE:
case CONFIG_ITEM_DIRECTORY:
case CONFIG_ITEM_KEY:
i_type = VLC_VAR_STRING;
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment