Slovak translation update by Marián Hikaník
[vlc.git] / include / vlc_modules_macros.h
blob0e544fddf8b6e776d3ab4685e77c03e1e108108b
1 /*****************************************************************************
2 * modules_inner.h : Macros used from within a module.
3 *****************************************************************************
4 * Copyright (C) 2001-2006 the VideoLAN team
5 * $Id$
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #if !defined( __LIBVLC__ )
25 #error You are not libvlc or one of its plugins. You cannot include this file
26 #endif
28 /*****************************************************************************
29 * If we are not within a module, assume we're in the vlc core.
30 *****************************************************************************/
31 #if !defined( __PLUGIN__ ) && !defined( __BUILTIN__ )
32 # define MODULE_NAME main
33 #endif
35 /**
36 * Current plugin ABI version
38 # define MODULE_SYMBOL 0_9_0g
39 # define MODULE_SUFFIX "__0_9_0g"
41 /*****************************************************************************
42 * Add a few defines. You do not want to read this section. Really.
43 *****************************************************************************/
45 /* Explanation:
47 * if user has #defined MODULE_NAME foo, then we will need:
48 * #define MODULE_STRING "foo"
50 * and, if HAVE_DYNAMIC_PLUGINS is NOT set, we will also need:
51 * #define MODULE_FUNC( zog ) module_foo_zog
53 * this can't easily be done with the C preprocessor, thus a few ugly hacks.
56 /* I can't believe I need to do this to change « foo » to « "foo" » */
57 #define STRINGIFY( z ) UGLY_KLUDGE( z )
58 #define UGLY_KLUDGE( z ) #z
59 /* And I need to do _this_ to change « foo bar » to « module_foo_bar » ! */
60 #define CONCATENATE( y, z ) CRUDE_HACK( y, z )
61 #define CRUDE_HACK( y, z ) y##__##z
63 /* If the module is built-in, then we need to define foo_InitModule instead
64 * of InitModule. Same for Activate- and DeactivateModule. */
65 #if defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
66 # define E_( function ) CONCATENATE( function, MODULE_SYMBOL )
67 # define __VLC_SYMBOL( symbol ) CONCATENATE( symbol, MODULE_SYMBOL )
68 #else
69 # define E_( function ) CONCATENATE( function, MODULE_NAME )
70 # define __VLC_SYMBOL( symbol ) CONCATENATE( symbol, MODULE_NAME )
71 #endif
73 #if defined( __PLUGIN__ ) && ( defined( WIN32 ) || defined( UNDER_CE ) )
74 # define DLL_SYMBOL __declspec(dllexport)
75 # define CDECL_SYMBOL __cdecl
76 #elif defined (HAVE_ATTRIBUTE_VISIBILITY)
77 # define DLL_SYMBOL __attribute__((visibility("default")))
78 # define CDECL_SYMBOL
79 #else
80 # define DLL_SYMBOL
81 # define CDECL_SYMBOL
82 #endif
84 #if defined( __cplusplus )
85 # define EXTERN_SYMBOL extern "C"
86 #else
87 # define EXTERN_SYMBOL
88 #endif
90 #if defined( USE_DLL )
91 # define IMPORT_SYMBOL __declspec(dllimport)
92 #else
93 # define IMPORT_SYMBOL
94 #endif
96 #define MODULE_STRING STRINGIFY( MODULE_NAME )
99 * InitModule: this function is called once and only once, when the module
100 * is looked at for the first time. We get the useful data from it, for
101 * instance the module name, its shortcuts, its capabilities... we also create
102 * a copy of its config because the module can be unloaded at any time.
104 #if defined (__PLUGIN__) || defined (__BUILTIN__)
105 EXTERN_SYMBOL DLL_SYMBOL int CDECL_SYMBOL
106 E_(vlc_entry) ( module_t *p_module );
107 #endif
109 #define vlc_module_begin( ) \
110 EXTERN_SYMBOL DLL_SYMBOL int CDECL_SYMBOL \
111 __VLC_SYMBOL(vlc_entry) ( module_t *p_module ) \
113 module_config_t *p_config = NULL; \
114 if (vlc_module_set (p_module, VLC_MODULE_NAME, \
115 (void *)(MODULE_STRING))) \
116 goto error; \
118 module_t *p_submodule = p_module /* the ; gets added */
120 #define vlc_module_end( ) \
122 (void)p_config; \
123 return VLC_SUCCESS; \
125 error: \
126 /* FIXME: config_Free( p_module ); */ \
127 /* FIXME: cleanup submodules objects ??? */ \
128 return VLC_EGENERIC; \
130 struct _u_n_u_s_e_d_ /* the ; gets added */
133 #define add_submodule( ) \
134 p_submodule = vlc_submodule_create( p_module )
136 #define add_requirement( cap ) \
137 if (vlc_module_set (p_module, VLC_MODULE_CPU_REQUIREMENT, \
138 (void *)(intptr_t)(CPU_CAPABILITY_##cap))) goto error
140 #define add_shortcut( shortcut ) \
141 if (vlc_module_set (p_submodule, VLC_MODULE_SHORTCUT, (void*)(shortcut))) \
142 goto error
144 #define set_shortname( shortname ) \
145 if (vlc_module_set (p_submodule, VLC_MODULE_SHORTNAME, \
146 (void*)(shortname))) goto error;
148 #define set_description( desc ) \
149 if (vlc_module_set (p_submodule, VLC_MODULE_DESCRIPTION, (void*)(desc))) \
150 goto error
152 #define set_help( help ) \
153 if (vlc_module_set (p_submodule, VLC_MODULE_HELP, (void*)(help))) \
154 goto error
156 #define set_capability( cap, score ) \
157 if (vlc_module_set (p_submodule, VLC_MODULE_CAPABILITY, (void *)(cap)) \
158 || vlc_module_set (p_submodule, VLC_MODULE_SCORE, \
159 (void *)(intptr_t)(score))) \
160 goto error
162 #define set_callbacks( activate, deactivate ) \
163 if (vlc_module_set (p_submodule, VLC_MODULE_CB_OPEN, (void *)(activate)) \
164 || vlc_module_set (p_submodule, VLC_MODULE_CB_CLOSE, \
165 (void *)(deactivate))) \
166 goto error
168 #define linked_with_a_crap_library_which_uses_atexit( ) \
169 if (vlc_module_set (p_submodule, VLC_MODULE_UNLOADABLE, NULL)) goto error