diff options
author | Jordi Vilalta Prat | 2008-02-08 00:02:23 +0000 |
---|---|---|
committer | Jordi Vilalta Prat | 2008-02-08 00:02:23 +0000 |
commit | c103290e2b123510e9d9eb4716ae0336a9e61ede (patch) | |
tree | 5e13c4cd5a990094696b819b852ebbfb7afd89c9 | |
parent | 49d0b1f91e32eda3956c0c1d8c0156ebd5854c66 (diff) | |
download | scummvm-rg350-c103290e2b123510e9d9eb4716ae0336a9e61ede.tar.gz scummvm-rg350-c103290e2b123510e9d9eb4716ae0336a9e61ede.tar.bz2 scummvm-rg350-c103290e2b123510e9d9eb4716ae0336a9e61ede.zip |
Initial support for plugin types
svn-id: r30825
-rw-r--r-- | backends/plugins/dynamic-plugin.h | 15 | ||||
-rw-r--r-- | base/plugins.cpp | 10 | ||||
-rw-r--r-- | base/plugins.h | 14 | ||||
-rw-r--r-- | engines/agi/detection.cpp | 3 | ||||
-rw-r--r-- | engines/agos/detection.cpp | 2 | ||||
-rw-r--r-- | engines/cine/detection.cpp | 2 | ||||
-rw-r--r-- | engines/cruise/detection.cpp | 2 | ||||
-rw-r--r-- | engines/drascula/detection.cpp | 2 | ||||
-rw-r--r-- | engines/gob/detection.cpp | 2 | ||||
-rw-r--r-- | engines/igor/detection.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/detection.cpp | 2 | ||||
-rw-r--r-- | engines/lure/detection.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/detection.cpp | 2 | ||||
-rw-r--r-- | engines/queen/queen.cpp | 2 | ||||
-rw-r--r-- | engines/saga/detection.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/detection.cpp | 2 | ||||
-rw-r--r-- | engines/sky/sky.cpp | 2 | ||||
-rw-r--r-- | engines/sword1/sword1.cpp | 2 | ||||
-rw-r--r-- | engines/sword2/sword2.cpp | 2 | ||||
-rw-r--r-- | engines/touche/detection.cpp | 4 | ||||
-rw-r--r-- | plugin.exp | 1 |
21 files changed, 53 insertions, 24 deletions
diff --git a/backends/plugins/dynamic-plugin.h b/backends/plugins/dynamic-plugin.h index 67d0b138c6..4b46c31ace 100644 --- a/backends/plugins/dynamic-plugin.h +++ b/backends/plugins/dynamic-plugin.h @@ -31,6 +31,7 @@ class DynamicPlugin : public Plugin { protected: + typedef int32 (*IntFunc)(); typedef void (*VoidFunc)(); typedef PluginObject *(*GetObjectFunc)(); @@ -38,6 +39,18 @@ protected: public: virtual bool loadPlugin() { + // Get the type of the plugin + IntFunc typeFunc = (IntFunc)findSymbol("PLUGIN_getType"); + if (!typeFunc) { + unloadPlugin(); + return false; + } + _type = (PluginType)typeFunc(); + if (_type >= PLUGIN_TYPE_MAX) { + unloadPlugin(); + return false; + } + // Get the plugin's instantiator object GetObjectFunc getObject = (GetObjectFunc)findSymbol("PLUGIN_getObject"); if (!getObject) { @@ -54,7 +67,7 @@ public: return true; } - + virtual void unloadPlugin() { delete _pluginObject; } diff --git a/base/plugins.cpp b/base/plugins.cpp index 3a53142438..bb4ef309ed 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -26,6 +26,9 @@ #include "base/plugins.h" #include "common/util.h" +PluginType Plugin::getType() const { + return _type; +} const char *Plugin::getName() const { return _pluginObject->getName(); @@ -59,9 +62,11 @@ SaveStateList Plugin::listSaves(const char *target) const { #ifndef DYNAMIC_MODULES class StaticPlugin : public Plugin { public: - StaticPlugin(PluginObject *pluginobject) { + StaticPlugin(PluginObject *pluginobject, PluginType type) { assert(pluginobject); + assert(type < PLUGIN_TYPE_MAX); _pluginObject = pluginobject; + _type = type; } ~StaticPlugin() { @@ -84,8 +89,9 @@ public: PluginList pl; #define LINK_PLUGIN(ID) \ + extern PluginType g_##ID##_type; \ extern PluginObject *g_##ID##_getObject(); \ - pl.push_back(new StaticPlugin(g_##ID##_getObject())); + pl.push_back(new StaticPlugin(g_##ID##_getObject(), g_##ID##_type)); // "Loader" for the static plugins. // Iterate over all registered (static) plugins and load them. diff --git a/base/plugins.h b/base/plugins.h index e91ed80aa4..f3022e7010 100644 --- a/base/plugins.h +++ b/base/plugins.h @@ -48,6 +48,12 @@ public: #include "engines/metaengine.h" +enum PluginType { + PLUGIN_TYPE_ENGINE = 0, + + PLUGIN_TYPE_MAX +}; + class Engine; class FSList; class OSystem; @@ -60,6 +66,7 @@ class OSystem; class Plugin { protected: PluginObject *_pluginObject; + PluginType _type; public: Plugin() : _pluginObject(0) {} @@ -72,6 +79,7 @@ public: virtual bool loadPlugin() = 0; // TODO: Rename to load() ? virtual void unloadPlugin() = 0; // TODO: Rename to unload() ? + PluginType getType() const; const char *getName() const; const char *getCopyright() const; @@ -95,14 +103,16 @@ public: */ #ifndef DYNAMIC_MODULES -#define REGISTER_PLUGIN(ID,PLUGINCLASS) \ +#define REGISTER_PLUGIN(ID,TYPE,PLUGINCLASS) \ + PluginType g_##ID##_type = TYPE; \ PluginObject *g_##ID##_getObject() { \ return new PLUGINCLASS(); \ } \ void dummyFuncToAllowTrailingSemicolon() #else -#define REGISTER_PLUGIN(ID,PLUGINCLASS) \ +#define REGISTER_PLUGIN(ID,TYPE,PLUGINCLASS) \ extern "C" { \ + PLUGIN_EXPORT int32 PLUGIN_getType() { return TYPE; } \ PLUGIN_EXPORT PluginObject *PLUGIN_getObject() { \ return new PLUGINCLASS(); \ } \ diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index 6a9479c7c5..55ccef7ea3 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -2284,5 +2284,4 @@ bool AgiMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common: return res; } -REGISTER_PLUGIN(AGI, AgiMetaEngine); - +REGISTER_PLUGIN(AGI, PLUGIN_TYPE_ENGINE, AgiMetaEngine); diff --git a/engines/agos/detection.cpp b/engines/agos/detection.cpp index 73106b65d5..03b3322555 100644 --- a/engines/agos/detection.cpp +++ b/engines/agos/detection.cpp @@ -151,7 +151,7 @@ bool AgosMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common return res; } -REGISTER_PLUGIN(AGOS, AgosMetaEngine); +REGISTER_PLUGIN(AGOS, PLUGIN_TYPE_ENGINE, AgosMetaEngine); namespace AGOS { diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp index af59a106f5..6c05c9a2e2 100644 --- a/engines/cine/detection.cpp +++ b/engines/cine/detection.cpp @@ -511,4 +511,4 @@ bool CineMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common return gd != 0; } -REGISTER_PLUGIN(CINE, CineMetaEngine); +REGISTER_PLUGIN(CINE, PLUGIN_TYPE_ENGINE, CineMetaEngine); diff --git a/engines/cruise/detection.cpp b/engines/cruise/detection.cpp index a6e3e909c2..568c131b31 100644 --- a/engines/cruise/detection.cpp +++ b/engines/cruise/detection.cpp @@ -146,4 +146,4 @@ bool CruiseMetaEngine::createInstance(OSystem *syst, Engine **engine, const Comm return gd != 0; } -REGISTER_PLUGIN(CRUISE, CruiseMetaEngine); +REGISTER_PLUGIN(CRUISE, PLUGIN_TYPE_ENGINE, CruiseMetaEngine); diff --git a/engines/drascula/detection.cpp b/engines/drascula/detection.cpp index 63fb6c92ad..e3b5b0dc44 100644 --- a/engines/drascula/detection.cpp +++ b/engines/drascula/detection.cpp @@ -186,4 +186,4 @@ bool DrasculaMetaEngine::createInstance(OSystem *syst, Engine **engine, const Co return gd != 0; } -REGISTER_PLUGIN(DRASCULA, DrasculaMetaEngine); +REGISTER_PLUGIN(DRASCULA, PLUGIN_TYPE_ENGINE, DrasculaMetaEngine); diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index b9ba12d224..34a65eb520 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -1779,7 +1779,7 @@ bool GobMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common: return gd != 0; } -REGISTER_PLUGIN(GOB, GobMetaEngine); +REGISTER_PLUGIN(GOB, PLUGIN_TYPE_ENGINE, GobMetaEngine); namespace Gob { diff --git a/engines/igor/detection.cpp b/engines/igor/detection.cpp index dcfc40bcd5..c86d027a91 100644 --- a/engines/igor/detection.cpp +++ b/engines/igor/detection.cpp @@ -134,4 +134,4 @@ bool IgorMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common return gd != 0; } -REGISTER_PLUGIN(IGOR, IgorMetaEngine); +REGISTER_PLUGIN(IGOR, PLUGIN_TYPE_ENGINE, IgorMetaEngine); diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp index a1556d6e26..f76a435b8a 100644 --- a/engines/kyra/detection.cpp +++ b/engines/kyra/detection.cpp @@ -484,4 +484,4 @@ bool KyraMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common return res; } -REGISTER_PLUGIN(KYRA, KyraMetaEngine); +REGISTER_PLUGIN(KYRA, PLUGIN_TYPE_ENGINE, KyraMetaEngine); diff --git a/engines/lure/detection.cpp b/engines/lure/detection.cpp index 66d0c329e8..6138bbc3a5 100644 --- a/engines/lure/detection.cpp +++ b/engines/lure/detection.cpp @@ -197,4 +197,4 @@ bool LureMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common return gd != 0; } -REGISTER_PLUGIN(LURE, LureMetaEngine); +REGISTER_PLUGIN(LURE, PLUGIN_TYPE_ENGINE, LureMetaEngine); diff --git a/engines/parallaction/detection.cpp b/engines/parallaction/detection.cpp index 90a46fdc0a..4d8b54085a 100644 --- a/engines/parallaction/detection.cpp +++ b/engines/parallaction/detection.cpp @@ -218,4 +218,4 @@ bool ParallactionMetaEngine::createInstance(OSystem *syst, Engine **engine, cons return res; } -REGISTER_PLUGIN(PARALLACTION, ParallactionMetaEngine); +REGISTER_PLUGIN(PARALLACTION, PLUGIN_TYPE_ENGINE, ParallactionMetaEngine); diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp index db8e9a94ce..ee71c18a62 100644 --- a/engines/queen/queen.cpp +++ b/engines/queen/queen.cpp @@ -127,7 +127,7 @@ PluginError QueenMetaEngine::createInstance(OSystem *syst, Engine **engine) cons return kNoError; } -REGISTER_PLUGIN(QUEEN, QueenMetaEngine); +REGISTER_PLUGIN(QUEEN, PLUGIN_TYPE_ENGINE, QueenMetaEngine); namespace Queen { diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp index 3838fd1d9e..1a04c7a001 100644 --- a/engines/saga/detection.cpp +++ b/engines/saga/detection.cpp @@ -164,7 +164,7 @@ bool SagaMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common return gd != 0; } -REGISTER_PLUGIN(SAGA, SagaMetaEngine); +REGISTER_PLUGIN(SAGA, PLUGIN_TYPE_ENGINE, SagaMetaEngine); namespace Saga { diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index 2b30780a6b..cfd0303302 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -964,4 +964,4 @@ SaveStateList ScummMetaEngine::listSaves(const char *target) const { return saveList; } -REGISTER_PLUGIN(SCUMM, ScummMetaEngine); +REGISTER_PLUGIN(SCUMM, PLUGIN_TYPE_ENGINE, ScummMetaEngine); diff --git a/engines/sky/sky.cpp b/engines/sky/sky.cpp index 6d8c4d36f7..1653d8b223 100644 --- a/engines/sky/sky.cpp +++ b/engines/sky/sky.cpp @@ -194,7 +194,7 @@ PluginError SkyMetaEngine::createInstance(OSystem *syst, Engine **engine) const return kNoError; } -REGISTER_PLUGIN(SKY, SkyMetaEngine); +REGISTER_PLUGIN(SKY, PLUGIN_TYPE_ENGINE, SkyMetaEngine); namespace Sky { diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp index 60559424c5..f446258fc9 100644 --- a/engines/sword1/sword1.cpp +++ b/engines/sword1/sword1.cpp @@ -187,7 +187,7 @@ PluginError SwordMetaEngine::createInstance(OSystem *syst, Engine **engine) cons return kNoError; } -REGISTER_PLUGIN(SWORD1, SwordMetaEngine); +REGISTER_PLUGIN(SWORD1, PLUGIN_TYPE_ENGINE, SwordMetaEngine); namespace Sword1 { diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp index 29530529e8..2634a96962 100644 --- a/engines/sword2/sword2.cpp +++ b/engines/sword2/sword2.cpp @@ -180,7 +180,7 @@ PluginError Sword2MetaEngine::createInstance(OSystem *syst, Engine **engine) con return kNoGameDataFoundError; } -REGISTER_PLUGIN(SWORD2, Sword2MetaEngine); +REGISTER_PLUGIN(SWORD2, PLUGIN_TYPE_ENGINE, Sword2MetaEngine); namespace Sword2 { diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp index 828fb43c6d..2b85f9f489 100644 --- a/engines/touche/detection.cpp +++ b/engines/touche/detection.cpp @@ -131,6 +131,7 @@ public: virtual const char *getName() const { return "Touche Engine"; } + virtual const char *getCopyright() const { return "Touche: The Adventures of the 5th Musketeer (C) Clipper Software"; } @@ -138,7 +139,6 @@ public: virtual bool createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) const; }; - bool ToucheMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) const { const Common::ADGameDescription *gd = encapsulatedDesc.realDesc; if (gd) { @@ -147,4 +147,4 @@ bool ToucheMetaEngine::createInstance(OSystem *syst, Engine **engine, const Comm return gd != 0; } -REGISTER_PLUGIN(TOUCHE, ToucheMetaEngine); +REGISTER_PLUGIN(TOUCHE, PLUGIN_TYPE_ENGINE, ToucheMetaEngine); diff --git a/plugin.exp b/plugin.exp index 253a22c331..890e46e473 100644 --- a/plugin.exp +++ b/plugin.exp @@ -1 +1,2 @@ +_PLUGIN_getType _PLUGIN_getObject |