[vlc-commits] Rethink the configuration item type identifiers to give more space
Rémi Denis-Courmont
git at videolan.org
Wed Jun 29 22:36:20 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jun 29 22:57:15 2011 +0300| [20692b9c217819421844394feeffd105fb12f00c] | committer: 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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=20692b9c217819421844394feeffd105fb12f00c
---
include/vlc_configuration.h | 31 +++++++++++++---------------
src/config/configuration.h | 14 ++++++++++--
src/config/core.c | 46 ++++--------------------------------------
3 files changed, 30 insertions(+), 61 deletions(-)
diff --git a/include/vlc_configuration.h b/include/vlc_configuration.h
index fe57b3c..2284f1c 100644
--- a/include/vlc_configuration.h
+++ b/include/vlc_configuration.h
@@ -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
diff --git a/src/config/configuration.h b/src/config/configuration.h
index 2d4d2a1..bb3f2ec 100644
--- a/src/config/configuration.h
+++ b/src/config/configuration.h
@@ -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;
}
diff --git a/src/config/core.c b/src/config/core.c
index 27f24ac..1fe7328 100644
--- a/src/config/core.c
+++ b/src/config/core.c
@@ -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;
More information about the vlc-commits
mailing list