X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=include%2Fmodules_inner.h;h=6cbdd05c2b0a3b13f387c5d4e93a1453d9e2e99a;hb=8a764762d0c7be0accaf7cac704a1bc6d085d902;hp=dcfe4a408dfc619721b7b6954ffeecb05bbf2851;hpb=bbe70b81a082f6abb87250ea101419ae0368cc0d;p=vlc diff --git a/include/modules_inner.h b/include/modules_inner.h index dcfe4a408d..6cbdd05c2b 100644 --- a/include/modules_inner.h +++ b/include/modules_inner.h @@ -1,8 +1,8 @@ /***************************************************************************** * modules_inner.h : Macros used from within a module. ***************************************************************************** - * Copyright (C) 2001 VideoLAN - * $Id: modules_inner.h,v 1.26 2002/08/01 11:04:46 tcastley Exp $ + * Copyright (C) 2001-2006 the VideoLAN team + * $Id$ * * Authors: Samuel Hocevar * @@ -10,7 +10,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** @@ -43,10 +43,10 @@ * this can't easily be done with the C preprocessor, thus a few ugly hacks. */ -/* I can't believe I need to do this to change « foo » to « "foo" » */ +/* I can't believe I need to do this to change « foo » to « "foo" » */ #define STRINGIFY( z ) UGLY_KLUDGE( z ) #define UGLY_KLUDGE( z ) #z -/* And I need to do _this_ to change « foo bar » to « module_foo_bar » ! */ +/* And I need to do _this_ to change « foo bar » to « module_foo_bar » ! */ #define CONCATENATE( y, z ) CRUDE_HACK( y, z ) #define CRUDE_HACK( y, z ) y##__##z @@ -55,13 +55,21 @@ #if defined( __BUILTIN__ ) # define E_( function ) CONCATENATE( function, MODULE_NAME ) # define __VLC_SYMBOL( symbol ) CONCATENATE( symbol, MODULE_NAME ) -# define DECLARE_SYMBOLS ; -# define STORE_SYMBOLS ; +# define DECLARE_SYMBOLS struct _u_n_u_s_e_d_ +# define STORE_SYMBOLS struct _u_n_u_s_e_d_ #elif defined( __PLUGIN__ ) -# define E_( function ) function +# 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; +# define DECLARE_SYMBOLS module_symbols_t* p_symbols +# define STORE_SYMBOLS p_symbols = p_module->p_symbols +#endif + +#if defined( __PLUGIN__ ) && ( defined( WIN32 ) || defined( UNDER_CE ) ) +# define DLL_SYMBOL __declspec(dllexport) +# define CDECL_SYMBOL __cdecl +#else +# define DLL_SYMBOL +# define CDECL_SYMBOL #endif #if defined( __cplusplus ) @@ -70,6 +78,12 @@ # define EXTERN_SYMBOL #endif +#if defined( USE_DLL ) +# define IMPORT_SYMBOL __declspec(dllimport) +#else +# define IMPORT_SYMBOL +#endif + #define MODULE_STRING STRINGIFY( MODULE_NAME ) /* @@ -80,13 +94,23 @@ */ #define vlc_module_begin( ) \ DECLARE_SYMBOLS; \ - EXTERN_SYMBOL int __VLC_SYMBOL(vlc_entry) ( module_t *p_module ) \ + EXTERN_SYMBOL DLL_SYMBOL int CDECL_SYMBOL \ + __VLC_SYMBOL(vlc_entry) ( module_t *p_module ) \ { \ - int i_shortcut = 1, i_config = 0; \ - module_config_t p_config[ 100 ]; \ + int i_shortcut = 1, i_config = -1; \ + module_config_t *p_config = NULL; \ + static module_config_t config_end = { \ + CONFIG_HINT_END, NULL, NULL, 0, NULL, NULL, NULL, 0, 0., 0, 0, \ + 0., 0., NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0, NULL, \ + VLC_FALSE, NULL, VLC_FALSE, VLC_FALSE, NULL, 0, 0., NULL, 0, 0., \ + VLC_FALSE \ + }; \ 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->pp_shortcuts[ 0 ] = MODULE_STRING; \ p_module->i_cpu = 0; \ @@ -101,39 +125,53 @@ #define vlc_module_end( ) \ p_submodule->pp_shortcuts[ i_shortcut ] = NULL; \ } \ + if( p_config ) \ { \ - module_config_t tmp = { CONFIG_HINT_END, NULL, NULL, '\0' }; \ - p_config[ i_config ] = tmp; \ + int i; \ + p_config[ ++i_config ] = config_end; \ + config_Duplicate( p_module, p_config ); \ + for( 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 ); \ } \ - config_Duplicate( p_module, p_config ); \ + else config_Duplicate( p_module, &config_end ); \ if( p_module->p_config == NULL ) \ { \ - return -1; \ + return VLC_EGENERIC; \ } \ - return 0 && i_shortcut; \ + return VLC_SUCCESS && i_shortcut; \ } \ - int __VLC_SYMBOL(vlc_entry) ( module_t * ) /* the ; gets added */ + 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 );\ + 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_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_activate = NULL; \ p_submodule->pf_deactivate = NULL - + #define add_requirement( cap ) \ p_module->i_cpu |= CPU_CAPABILITY_##cap @@ -141,8 +179,11 @@ p_submodule->pp_shortcuts[ i_shortcut ] = shortcut; \ i_shortcut++ +#define set_shortname( desc ) \ + p_submodule->psz_shortname = desc + #define set_description( desc ) \ - p_module->psz_longname = desc + p_submodule->psz_longname = desc #define set_capability( cap, score ) \ p_submodule->psz_capability = cap; \ @@ -155,36 +196,6 @@ p_submodule->pf_activate = activate; \ p_submodule->pf_deactivate = deactivate -/* - * module_activate: this function is called before functions can be accessed, - * we do allocation tasks here, and maybe additional stuff such as large - * table allocation. Once ActivateModule is called we are almost sure the - * module will be used. - */ -#define module_activate( prototype ) \ - __module_activate( prototype ); \ - int __VLC_SYMBOL( module_activate ) ( module_t *p_module ) \ - { \ - STORE_SYMBOLS; \ - config_SetCallbacks( p_module->p_config, p_config ); \ - return __module_activate( p_module ); \ - } \ - \ - static int __module_activate( prototype ) - -/* - * DeactivateModule: this function is called after we are finished with the - * module. Everything that has been done in ActivateModule needs to be undone - * here. - */ -#define module_deactivate( prototype ) \ - __module_deactivate( prototype ); \ - int __VLC_SYMBOL( module_deactivate )( module_t *p_module ) \ - { \ - int i_ret = __module_deactivate( p_module ); \ - config_UnsetCallbacks( p_module->p_config ); \ - return i_ret; \ - } \ - \ - static int __module_deactivate( prototype ) +#define linked_with_a_crap_library_which_uses_atexit( ) \ + p_module->b_unloadable = VLC_FALSE