aboutsummaryrefslogtreecommitdiff
path: root/base/plugins.h
diff options
context:
space:
mode:
authorJordi Vilalta Prat2008-05-06 03:00:26 +0000
committerJordi Vilalta Prat2008-05-06 03:00:26 +0000
commit38a8aa516e0fa315e318801e5399f82e51efa8df (patch)
treec6f7bc89fe2340a846ef891cefc9031cfdb32ec9 /base/plugins.h
parent3ac46924e311afb6b02615af04556da823c4f3f3 (diff)
downloadscummvm-rg350-38a8aa516e0fa315e318801e5399f82e51efa8df.tar.gz
scummvm-rg350-38a8aa516e0fa315e318801e5399f82e51efa8df.tar.bz2
scummvm-rg350-38a8aa516e0fa315e318801e5399f82e51efa8df.zip
Allow static and dynamic plugins to be used at the same time
svn-id: r31888
Diffstat (limited to 'base/plugins.h')
-rw-r--r--base/plugins.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/base/plugins.h b/base/plugins.h
index f317a533ae..ca08a0c628 100644
--- a/base/plugins.h
+++ b/base/plugins.h
@@ -100,6 +100,15 @@ public:
};
+#define STATIC_PLUGIN 1
+#define DYNAMIC_PLUGIN 2
+
+#define PLUGIN_ENABLED_STATIC(ID) \
+ (defined(ENABLE_##ID) && !PLUGIN_ENABLED_DYNAMIC(ID))
+
+#define PLUGIN_ENABLED_DYNAMIC(ID) \
+ (defined(ENABLE_##ID) && (ENABLE_##ID == DYNAMIC_PLUGIN) && defined(DYNAMIC_MODULES))
+
/**
* REGISTER_PLUGIN is a convenience macro meant to ease writing
* the plugin interface for our modules. In particular, using it
@@ -109,15 +118,16 @@ public:
* @todo add some means to query the plugin API version etc.
*/
-#ifndef DYNAMIC_MODULES
-#define REGISTER_PLUGIN(ID,TYPE,PLUGINCLASS) \
+#define REGISTER_PLUGIN_STATIC(ID,TYPE,PLUGINCLASS) \
PluginType g_##ID##_type = TYPE; \
PluginObject *g_##ID##_getObject() { \
return new PLUGINCLASS(); \
} \
void dummyFuncToAllowTrailingSemicolon()
-#else
-#define REGISTER_PLUGIN(ID,TYPE,PLUGINCLASS) \
+
+#ifdef DYNAMIC_MODULES
+
+#define REGISTER_PLUGIN_DYNAMIC(ID,TYPE,PLUGINCLASS) \
extern "C" { \
PLUGIN_EXPORT int32 PLUGIN_getVersion() { return PLUGIN_VERSION; } \
PLUGIN_EXPORT int32 PLUGIN_getType() { return TYPE; } \
@@ -127,7 +137,8 @@ public:
} \
} \
void dummyFuncToAllowTrailingSemicolon()
-#endif
+
+#endif // DYNAMIC_MODULES
/** List of plugins. */