]> git.sesse.net Git - vlc/commitdiff
Rethink the configuration item type identifiers to give more space
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 29 Jun 2011 19:57:15 +0000 (22:57 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 29 Jun 2011 20:32:09 +0000 (23:32 +0300)
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.

include/vlc_configuration.h
src/config/configuration.h
src/config/core.c

index fe57b3c7dbf2892bcc5f53ec09612434b8ac6b96..2284f1c27d9b64eb9b9433f4b5a415ba33661261 100644 (file)
@@ -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
index 2d4d2a1f63c291c0dcc05faaf76609f1e496c4fc..bb3f2ec4d0938d6ee41670c01404b285e40d26de 100644 (file)
@@ -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;
 }
index 27f24ac1160a6a71fa32d96c87977b53c0d46e95..1fe7328c767ac547f154427c7aa480fa1aa960ac 100644 (file)
@@ -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;