]> git.sesse.net Git - vlc/blobdiff - include/vlc_modules_macros.h
new (failing) test for media list player (ticket #1524)
[vlc] / include / vlc_modules_macros.h
index 1d403642242823ea60cd5826e7f19b1d8862814c..426352f0a361fa7375f1f7e1235783e96f1ddcee 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#if !defined( __LIBVLC__ )
+  #error You are not libvlc or one of its plugins. You cannot include this file
+#endif
+
 /*****************************************************************************
  * If we are not within a module, assume we're in the vlc core.
  *****************************************************************************/
 #   define MODULE_NAME main
 #endif
 
+/**
+ * Current plugin ABI version
+ */
+# define MODULE_SYMBOL 0_9_0h
+# define MODULE_SUFFIX "__0_9_0h"
+
 /*****************************************************************************
  * Add a few defines. You do not want to read this section. Really.
  *****************************************************************************/
@@ -37,7 +47,7 @@
  * if user has #defined MODULE_NAME foo, then we will need:
  * #define MODULE_STRING "foo"
  *
- * and, if __BUILTIN__ is set, we will also need:
+ * and, if HAVE_DYNAMIC_PLUGINS is NOT set, we will also need:
  * #define MODULE_FUNC( zog ) module_foo_zog
  *
  * this can't easily be done with the C preprocessor, thus a few ugly hacks.
 
 /* If the module is built-in, then we need to define foo_InitModule instead
  * of InitModule. Same for Activate- and DeactivateModule. */
-#if defined( __BUILTIN__ )
-#   define E_( function )          CONCATENATE( function, MODULE_NAME )
-#   define __VLC_SYMBOL( symbol )  CONCATENATE( symbol, MODULE_NAME )
-#   define DECLARE_SYMBOLS         struct _u_n_u_s_e_d_
-#   define STORE_SYMBOLS           struct _u_n_u_s_e_d_
-#elif defined( __PLUGIN__ )
+#if defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
 #   define E_( function )          CONCATENATE( function, MODULE_SYMBOL )
 #   define __VLC_SYMBOL( symbol  ) CONCATENATE( symbol, MODULE_SYMBOL )
-#   define DECLARE_SYMBOLS         module_symbols_t* p_symbols
-#   define STORE_SYMBOLS           p_symbols = p_module->p_symbols
+#else
+#   define E_( function )          CONCATENATE( function, MODULE_NAME )
+#   define __VLC_SYMBOL( symbol )  CONCATENATE( symbol, MODULE_NAME )
 #endif
 
 #if defined( __PLUGIN__ ) && ( defined( WIN32 ) || defined( UNDER_CE ) )
 #   define DLL_SYMBOL              __declspec(dllexport)
 #   define CDECL_SYMBOL            __cdecl
+#elif defined (HAVE_ATTRIBUTE_VISIBILITY)
+#   define DLL_SYMBOL __attribute__((visibility("default")))
+#   define CDECL_SYMBOL
 #else
 #   define DLL_SYMBOL
 #   define CDECL_SYMBOL
@@ -98,101 +107,64 @@ E_(vlc_entry) ( module_t *p_module );
 #endif
 
 #define vlc_module_begin( )                                                   \
-    DECLARE_SYMBOLS;                                                          \
     EXTERN_SYMBOL DLL_SYMBOL int CDECL_SYMBOL                                 \
     __VLC_SYMBOL(vlc_entry) ( module_t *p_module )                            \
     {                                                                         \
-        int i_shortcut = 1, res;                                              \
-        size_t i_config = (size_t)(-1);                                       \
         module_config_t *p_config = NULL;                                     \
-        STORE_SYMBOLS;                                                        \
-        p_module->b_submodule = VLC_FALSE;                                    \
-        p_module->b_unloadable = VLC_TRUE;                                    \
-        p_module->b_reentrant = VLC_TRUE;                                     \
-        p_module->psz_object_name = MODULE_STRING;                            \
-        p_module->psz_shortname = NULL;                                       \
-        p_module->psz_longname = MODULE_STRING;                               \
-        p_module->psz_help = NULL;                                            \
-        p_module->pp_shortcuts[ 0 ] = MODULE_STRING;                          \
-        p_module->i_cpu = 0;                                                  \
-        p_module->psz_program = NULL;                                         \
-        p_module->psz_capability = "";                                        \
-        p_module->i_score = 1;                                                \
-        p_module->pf_activate = NULL;                                         \
-        p_module->pf_deactivate = NULL;                                       \
+        if (vlc_module_set (p_module, VLC_MODULE_NAME,                        \
+                            (void *)(MODULE_STRING)))                         \
+            goto error;                                                       \
         {                                                                     \
             module_t *p_submodule = p_module /* the ; gets added */
 
 #define vlc_module_end( )                                                     \
-            p_submodule->pp_shortcuts[ i_shortcut ] = NULL;                   \
-        }                                                                     \
-        res = config_Duplicate( p_module, p_config, ++i_config );             \
-        for( size_t i = 0; i < i_config; i++ )                                \
-        {                                                                     \
-            if( p_config[ i ].i_action )                                      \
-            {                                                                 \
-                free( p_config[ i ].ppf_action );                             \
-                free( p_config[ i ].ppsz_action_text );                       \
-            }                                                                 \
         }                                                                     \
-        free( p_config );                                                     \
-        if (res)                                                              \
-            return res;                                                       \
-        (void)i_shortcut;                                                     \
+        (void)p_config;                                                       \
         return VLC_SUCCESS;                                                   \
+                                                                              \
+    error:                                                                    \
+        /* FIXME: config_Free( p_module ); */                                 \
+        /* FIXME: cleanup submodules objects ??? */                           \
+        return VLC_EGENERIC;                                                  \
     }                                                                         \
     struct _u_n_u_s_e_d_ /* the ; gets added */
 
 
-#define add_submodule( )                                                      \
-    p_submodule->pp_shortcuts[ i_shortcut ] = NULL;                           \
-    p_submodule =                                                             \
-            (module_t *)vlc_object_create( p_module, VLC_OBJECT_MODULE );     \
-    vlc_object_attach( p_submodule, p_module );                               \
-    p_submodule->b_submodule = VLC_TRUE;                                      \
-    /* Nuahahaha! Heritage! Polymorphism! Ugliness!! */                       \
-    for( i_shortcut = 0; p_module->pp_shortcuts[ i_shortcut ]; i_shortcut++ ) \
-    {                                                                         \
-        p_submodule->pp_shortcuts[ i_shortcut ] =                             \
-                                p_module->pp_shortcuts[ i_shortcut ];         \
-    }                                                                         \
-    p_submodule->psz_object_name = p_module->psz_object_name;                 \
-    p_submodule->psz_shortname = p_module->psz_shortname;                     \
-    p_submodule->psz_longname = p_module->psz_longname;                       \
-    p_submodule->psz_program = p_module->psz_program;                         \
-    p_submodule->psz_capability = p_module->psz_capability;                   \
-    p_submodule->i_score = p_module->i_score;                                 \
-    p_submodule->i_cpu = p_module->i_cpu;                                     \
-    p_submodule->pf_activate = NULL;                                          \
-    p_submodule->pf_deactivate = NULL
-
-#define add_requirement( cap )                                                \
-    p_module->i_cpu |= CPU_CAPABILITY_##cap
+#define add_submodule( ) \
+    p_submodule = vlc_submodule_create( p_module )
 
-#define add_shortcut( shortcut )                                              \
-    p_submodule->pp_shortcuts[ i_shortcut ] = shortcut;                       \
-    i_shortcut++
+#define add_requirement( cap ) \
+    if (vlc_module_set (p_module, VLC_MODULE_CPU_REQUIREMENT, \
+                        (void *)(intptr_t)(CPU_CAPABILITY_##cap))) goto error
 
-#define set_shortname( desc )                                                 \
-    p_submodule->psz_shortname = desc
+#define add_shortcut( shortcut ) \
+    if (vlc_module_set (p_submodule, VLC_MODULE_SHORTCUT, (void*)(shortcut))) \
+        goto error
 
-#define set_description( desc )                                               \
-    p_submodule->psz_longname = desc
+#define set_shortname( shortname ) \
+    if (vlc_module_set (p_submodule, VLC_MODULE_SHORTNAME, \
+                        (void*)(shortname))) goto error;
 
-#define set_help( help )                                                      \
-    p_submodule->psz_help = help
+#define set_description( desc ) \
+    if (vlc_module_set (p_submodule, VLC_MODULE_DESCRIPTION, (void*)(desc))) \
+        goto error
 
-#define set_capability( cap, score )                                          \
-    p_submodule->psz_capability = cap;                                        \
-    p_submodule->i_score = score
+#define set_help( help ) \
+    if (vlc_module_set (p_submodule, VLC_MODULE_HELP, (void*)(help))) \
+        goto error
 
-#define set_program( program )                                                \
-    p_submodule->psz_program = program
+#define set_capability( cap, score ) \
+    if (vlc_module_set (p_submodule, VLC_MODULE_CAPABILITY, (void *)(cap)) \
+     || vlc_module_set (p_submodule, VLC_MODULE_SCORE, \
+                        (void *)(intptr_t)(score))) \
+        goto error
 
-#define set_callbacks( activate, deactivate )                                 \
-    p_submodule->pf_activate = activate;                                      \
-    p_submodule->pf_deactivate = deactivate
+#define set_callbacks( activate, deactivate ) \
+    if (vlc_module_set (p_submodule, VLC_MODULE_CB_OPEN, (void *)(activate)) \
+     || vlc_module_set (p_submodule, VLC_MODULE_CB_CLOSE, \
+                        (void *)(deactivate))) \
+        goto error
 
-#define linked_with_a_crap_library_which_uses_atexit( )                       \
-    p_module->b_unloadable = VLC_FALSE
+#define linked_with_a_crap_library_which_uses_atexit( ) \
+    if (vlc_module_set (p_submodule, VLC_MODULE_UNLOADABLE, NULL)) goto error