]> git.sesse.net Git - vlc/blobdiff - src/modules/entry.c
SSE3 detection (runtime)
[vlc] / src / modules / entry.c
index cd03b08fbee4268bd34a24cb46b3669a5672ec14..f259673c5b1cb81be0a636139503ff9b6f510671 100644 (file)
 #include <assert.h>
 #include <stdarg.h>
 
+#ifdef ENABLE_NLS
+# include <libintl.h>
+#endif
+
 #include "modules/modules.h"
 #include "config/configuration.h"
 #include "libvlc.h"
-#ifndef ENABLE_NLS
-# define dgettext(d, m) ((char *)(m))
+
+static const char *mdgettext (const char *domain, const char *msg)
+{
+    assert (msg);
+#ifdef ENABLE_NLS
+    if (*msg) /* Do not translate ""! */
+        return dgettext (domain, msg);
+#else
+    VLC_UNUSED(domain);
 #endif
+    return msg;
+}
 
 static void vlc_module_destruct (gc_object_t *obj)
 {
@@ -110,8 +123,9 @@ module_t *vlc_submodule_create (module_t *module)
     module->submodule_count++;
 
     /* Muahahaha! Heritage! Polymorphism! Ugliness!! */
-    memcpy (submodule->pp_shortcuts, module->pp_shortcuts,
-            sizeof (submodule->pp_shortcuts));
+    submodule->pp_shortcuts[0] = module->pp_shortcuts[0]; /* object name */
+    for (unsigned i = 1; i < MODULE_SHORTCUT_MAX; i++)
+        submodule->pp_shortcuts[i] = NULL;
 
     submodule->psz_object_name = strdup( module->psz_object_name );
     submodule->psz_shortname = module->psz_shortname;
@@ -123,7 +137,7 @@ module_t *vlc_submodule_create (module_t *module)
     return submodule;
 }
 
-module_config_t *vlc_config_create (module_t *module, int type)
+static module_config_t *vlc_config_create (module_t *module, int type)
 {
     unsigned confsize = module->confsize;
     module_config_t *tab = module->p_config;
@@ -161,6 +175,25 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
     va_start (ap, propid);
     switch (propid)
     {
+        case VLC_SUBMODULE_CREATE:
+        {
+            module_t **pp = va_arg (ap, module_t **);
+            *pp = vlc_submodule_create (module);
+            if (*pp == NULL)
+                ret = -1;
+            break;
+        }
+
+        case VLC_CONFIG_CREATE:
+        {
+            int type = va_arg (ap, int);
+            module_config_t **pp = va_arg (ap, module_config_t **);
+            *pp = vlc_config_create (module, type);
+            if (*pp == NULL)
+                ret = -1;
+            break;
+        }
+
         case VLC_MODULE_CPU_REQUIREMENT:
             assert (!module->b_submodule);
             module->i_cpu |= va_arg (ap, int);
@@ -213,7 +246,7 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
             const char *domain = va_arg (ap, const char *);
             if (domain == NULL)
                 domain = PACKAGE;
-            module->psz_shortname = dgettext (domain, va_arg (ap, char *));
+            module->psz_shortname = mdgettext (domain, va_arg (ap, char *));
             break;
         }
 
@@ -222,7 +255,7 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
             const char *domain = va_arg (ap, const char *);
             if (domain == NULL)
                 domain = PACKAGE;
-            module->psz_longname = dgettext (domain, va_arg (ap, char *));
+            module->psz_longname = mdgettext (domain, va_arg (ap, char *));
             break;
         }
 
@@ -231,7 +264,7 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
             const char *domain = va_arg (ap, const char *);
             if (domain == NULL)
                 domain = PACKAGE;
-            module->psz_help = dgettext (domain, va_arg (ap, char *));
+            module->psz_help = mdgettext (domain, va_arg (ap, char *));
             break;
         }
 
@@ -342,9 +375,9 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
 
             if (domain == NULL)
                 domain = PACKAGE;
-            item->psz_text = text ? strdup (dgettext (domain, text)) : NULL;
+            item->psz_text = text ? strdup (mdgettext (domain, text)) : NULL;
             item->psz_longtext =
-                longtext ? strdup (dgettext (domain, longtext)) : NULL;
+                longtext ? strdup (mdgettext (domain, longtext)) : NULL;
             break;
         }
 
@@ -367,21 +400,6 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
                 item->pi_list = dst;
             }
             else
-#if 0
-            if (IsConfigFloatType (item->i_type))
-            {
-                const float *src = va_arg (ap, const float *);
-                float *dst = malloc (sizeof (float) * (len + 1));
-
-                if (dst != NULL)
-                {
-                    memcpy (dst, src, sizeof (float) * len);
-                    dst[len] = 0.;
-                }
-                item->pf_list = dst;
-            }
-            else
-#endif
             if (IsConfigStringType (item->i_type))
             {
                 const char *const *src = va_arg (ap, const char *const *);
@@ -410,7 +428,7 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
                 {
                     for (size_t i = 0; i < len; i++)
                         dtext[i] = text[i] ?
-                                        strdup( dgettext( domain, text[i] ) ) :
+                                        strdup (mdgettext( domain, text[i] )) :
                                         NULL;
                     dtext[len] = NULL;
                 }
@@ -448,7 +466,7 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
             if (domain == NULL)
                 domain = PACKAGE;
             if (name)
-                tabtext[item->i_action] = strdup (dgettext (domain, name));
+                tabtext[item->i_action] = strdup (mdgettext (domain, name));
             else
                 tabtext[item->i_action] = NULL;
             tabtext[item->i_action + 1] = NULL;