Commit b89c14d5 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Initial work on hiding module_t layout from plugins

parent 58663ffb
......@@ -110,3 +110,24 @@ VLC_EXPORT( module_t *, __module_Need, ( vlc_object_t *, const char *, const cha
VLC_EXPORT( void, __module_Unneed, ( vlc_object_t *, module_t * ) );
#define module_Exists(a,b) __module_Exists(VLC_OBJECT(a),b)
VLC_EXPORT( vlc_bool_t, __module_Exists, ( vlc_object_t *, const char * ) );
VLC_EXPORT( module_t *, vlc_submodule_create, ( module_t * ) );
VLC_EXPORT( int, vlc_module_set, (module_t *module, int propid, void *value) );
enum
{
/* DO NOT EVER REMOVE, INSERT OR REPLACE ANY ITEM! It would break the ABI!
* Append new items at the end ONLY. */
VLC_MODULE_CPU_REQUIREMENT,
VLC_MODULE_SHORTCUT,
VLC_MODULE_SHORTNAME,
VLC_MODULE_DESCRIPTION,
VLC_MODULE_HELP,
VLC_MODULE_CAPABILITY,
VLC_MODULE_SCORE,
VLC_MODULE_PROGRAM,
VLC_MODULE_CB_OPEN,
VLC_MODULE_CB_CLOSE,
VLC_MODULE_UNLOADABLE
} vlc_module_property_t;
......@@ -121,6 +121,8 @@ E_(vlc_entry) ( module_t *p_module );
p_module->psz_longname = MODULE_STRING; \
p_module->psz_help = NULL; \
p_module->pp_shortcuts[ 0 ] = MODULE_STRING; \
for( unsigned i = 1; i < MODULE_SHORTCUT_MAX; i++ ) \
p_module->pp_shortcuts[i] = NULL; \
p_module->i_cpu = 0; \
p_module->psz_program = NULL; \
p_module->psz_capability = ""; \
......@@ -151,55 +153,36 @@ E_(vlc_entry) ( module_t *p_module );
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_submodule( ) \
p_submodule = vlc_submodule_create( p_module )
#define add_requirement( cap ) \
p_module->i_cpu |= CPU_CAPABILITY_##cap
#define add_requirement( cap ) \
vlc_module_set (p_module, VLC_MODULE_CPU_REQUIREMENT, \
(void *)(CPU_CAPABILITY_##cap))
#define add_shortcut( shortcut ) \
p_submodule->pp_shortcuts[ i_shortcut ] = shortcut; \
i_shortcut++
#define add_shortcut( shortcut ) \
vlc_module_set (p_submodule, VLC_MODULE_SHORTCUT, (void*)(shortcut))
#define set_shortname( desc ) \
p_submodule->psz_shortname = desc
#define set_shortname( shortname ) \
vlc_module_set (p_submodule, VLC_MODULE_SHORTNAME, (void*)(shortname))
#define set_description( desc ) \
p_submodule->psz_longname = desc
#define set_description( desc ) \
vlc_module_set (p_submodule, VLC_MODULE_DESCRIPTION, (void*)(desc))
#define set_help( help ) \
p_submodule->psz_help = help
#define set_help( help ) \
vlc_module_set (p_submodule, VLC_MODULE_HELP, (void*)(help))
#define set_capability( cap, score ) \
p_submodule->psz_capability = cap; \
p_submodule->i_score = score
#define set_capability( cap, score ) \
vlc_module_set (p_submodule, VLC_MODULE_CAPABILITY, (void *)(cap)); \
vlc_module_set (p_submodule, VLC_MODULE_SCORE, (void *)(score))
#define set_program( program ) \
p_submodule->psz_program = program
#define set_program( program ) \
vlc_module_set (p_submodule, VLC_MODULE_PROGRAM, (void *)(program))
#define set_callbacks( activate, deactivate ) \
p_submodule->pf_activate = activate; \
p_submodule->pf_deactivate = deactivate
#define set_callbacks( activate, deactivate ) \
vlc_module_set (p_submodule, VLC_MODULE_CB_OPEN, (void *)(activate)); \
vlc_module_set (p_submodule, VLC_MODULE_CB_CLOSE, (void *)(deactivate))
#define linked_with_a_crap_library_which_uses_atexit( ) \
p_module->b_unloadable = VLC_FALSE
#define linked_with_a_crap_library_which_uses_atexit( ) \
vlc_module_set (p_submodule, VLC_MODULE_UNLOADABLE, NULL)
......@@ -288,6 +288,7 @@ SOURCES_libvlc_common = \
misc/block.c \
modules/modules.h \
modules/modules.c \
modules/entry.c \
misc/threads.c \
misc/stats.c \
misc/cpu.c \
......
/*****************************************************************************
* entry.c : Callbacks for module entry point
*****************************************************************************
* Copyright (C) 2001-2007 the VideoLAN team
*
* This program is free software; you can redistribute it and/or modify
* 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
* GNU General Public License for more details.
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <vlc/vlc.h>
#include <assert.h>
module_t *vlc_submodule_create (module_t *module)
{
assert (module != NULL);
assert (!module->b_submodule); // subsubmodules are not supported
module_t *submodule =
(module_t *)vlc_object_create (module, VLC_OBJECT_MODULE);
if (submodule == NULL)
return NULL;
vlc_object_attach (submodule, module);
submodule->b_submodule = VLC_TRUE;
/* Muahahaha! Heritage! Polymorphism! Ugliness!! */
memcpy (submodule->pp_shortcuts, module->pp_shortcuts,
sizeof (submodule->pp_shortcuts));
submodule->psz_object_name = module->psz_object_name;
submodule->psz_shortname = module->psz_shortname;
submodule->psz_longname = module->psz_longname;
submodule->psz_program = module->psz_program;
submodule->psz_capability = module->psz_capability;
submodule->i_score = module->i_score;
submodule->i_cpu = module->i_cpu;
submodule->pf_activate = NULL;
submodule->pf_deactivate = NULL;
return submodule;
}
int vlc_module_set (module_t *module, int propid, void *value)
{
switch (propid)
{
case VLC_MODULE_CPU_REQUIREMENT:
assert (!module->b_submodule);
module->i_cpu |= (int)value;
break;
case VLC_MODULE_SHORTCUT:
{
unsigned i;
for (i = 0; module->pp_shortcuts[i] != NULL; i++);
if (i >= MODULE_SHORTCUT_MAX)
return VLC_ENOMEM;
module->pp_shortcuts[i] = (char *)value;
break;
}
case VLC_MODULE_SHORTNAME:
module->psz_shortname = (char *)value;
break;
case VLC_MODULE_DESCRIPTION:
module->psz_longname = (char *)value;
break;
case VLC_MODULE_HELP:
module->psz_help = (char *)value;
break;
case VLC_MODULE_CAPABILITY:
module->psz_capability = (char *)value;
break;
case VLC_MODULE_SCORE:
module->i_score = (int)value;
break;
case VLC_MODULE_PROGRAM:
module->psz_program = (char *)value;
break;
case VLC_MODULE_CB_OPEN:
module->pf_activate = (int (*) (vlc_object_t *))value;
break;
case VLC_MODULE_CB_CLOSE:
module->pf_deactivate = (void (*) (vlc_object_t *))value;
break;
case VLC_MODULE_UNLOADABLE:
module->b_unloadable = (value != NULL);
break;
default:
msg_Err (module, "unknown module property %d", propid);
msg_Err (module, "LibVLC might be too old to use this module.");
return VLC_EGENERIC;
}
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment