[Scummvm-cvs-logs] SF.net SVN: scummvm: [30825] scummvm/trunk

jvprat at users.sourceforge.net jvprat at users.sourceforge.net
Fri Feb 8 01:02:23 CET 2008


Revision: 30825
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30825&view=rev
Author:   jvprat
Date:     2008-02-07 16:02:23 -0800 (Thu, 07 Feb 2008)

Log Message:
-----------
Initial support for plugin types

Modified Paths:
--------------
    scummvm/trunk/backends/plugins/dynamic-plugin.h
    scummvm/trunk/base/plugins.cpp
    scummvm/trunk/base/plugins.h
    scummvm/trunk/engines/agi/detection.cpp
    scummvm/trunk/engines/agos/detection.cpp
    scummvm/trunk/engines/cine/detection.cpp
    scummvm/trunk/engines/cruise/detection.cpp
    scummvm/trunk/engines/drascula/detection.cpp
    scummvm/trunk/engines/gob/detection.cpp
    scummvm/trunk/engines/igor/detection.cpp
    scummvm/trunk/engines/kyra/detection.cpp
    scummvm/trunk/engines/lure/detection.cpp
    scummvm/trunk/engines/parallaction/detection.cpp
    scummvm/trunk/engines/queen/queen.cpp
    scummvm/trunk/engines/saga/detection.cpp
    scummvm/trunk/engines/scumm/detection.cpp
    scummvm/trunk/engines/sky/sky.cpp
    scummvm/trunk/engines/sword1/sword1.cpp
    scummvm/trunk/engines/sword2/sword2.cpp
    scummvm/trunk/engines/touche/detection.cpp
    scummvm/trunk/plugin.exp

Modified: scummvm/trunk/backends/plugins/dynamic-plugin.h
===================================================================
--- scummvm/trunk/backends/plugins/dynamic-plugin.h	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/backends/plugins/dynamic-plugin.h	2008-02-08 00:02:23 UTC (rev 30825)
@@ -31,6 +31,7 @@
 
 class DynamicPlugin : public Plugin {
 protected:
+	typedef int32 (*IntFunc)();
 	typedef void (*VoidFunc)();
 	typedef PluginObject *(*GetObjectFunc)();
 
@@ -38,6 +39,18 @@
 
 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 @@
 
 		return true;
 	}
-	
+
 	virtual void unloadPlugin() {
 		delete _pluginObject;
 	}

Modified: scummvm/trunk/base/plugins.cpp
===================================================================
--- scummvm/trunk/base/plugins.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/base/plugins.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -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 @@
 #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 @@
 		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.

Modified: scummvm/trunk/base/plugins.h
===================================================================
--- scummvm/trunk/base/plugins.h	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/base/plugins.h	2008-02-08 00:02:23 UTC (rev 30825)
@@ -48,6 +48,12 @@
 
 #include "engines/metaengine.h"
 
+enum PluginType {
+	PLUGIN_TYPE_ENGINE = 0,
+
+	PLUGIN_TYPE_MAX
+};
+
 class Engine;
 class FSList;
 class OSystem;
@@ -60,6 +66,7 @@
 class Plugin {
 protected:
 	PluginObject *_pluginObject;
+	PluginType _type;
 
 public:
 	Plugin() : _pluginObject(0) {}
@@ -72,6 +79,7 @@
 	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 @@
  */
 
 #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(); \
 		} \

Modified: scummvm/trunk/engines/agi/detection.cpp
===================================================================
--- scummvm/trunk/engines/agi/detection.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/agi/detection.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -2284,5 +2284,4 @@
 	return res;
 }
 
-REGISTER_PLUGIN(AGI, AgiMetaEngine);
-
+REGISTER_PLUGIN(AGI, PLUGIN_TYPE_ENGINE, AgiMetaEngine);

Modified: scummvm/trunk/engines/agos/detection.cpp
===================================================================
--- scummvm/trunk/engines/agos/detection.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/agos/detection.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -151,7 +151,7 @@
 	return res;
 }
 
-REGISTER_PLUGIN(AGOS, AgosMetaEngine);
+REGISTER_PLUGIN(AGOS, PLUGIN_TYPE_ENGINE, AgosMetaEngine);
 
 namespace AGOS {
 

Modified: scummvm/trunk/engines/cine/detection.cpp
===================================================================
--- scummvm/trunk/engines/cine/detection.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/cine/detection.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -511,4 +511,4 @@
 	return gd != 0;
 }
 
-REGISTER_PLUGIN(CINE, CineMetaEngine);
+REGISTER_PLUGIN(CINE, PLUGIN_TYPE_ENGINE, CineMetaEngine);

Modified: scummvm/trunk/engines/cruise/detection.cpp
===================================================================
--- scummvm/trunk/engines/cruise/detection.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/cruise/detection.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -146,4 +146,4 @@
 	return gd != 0;
 }
 
-REGISTER_PLUGIN(CRUISE, CruiseMetaEngine);
+REGISTER_PLUGIN(CRUISE, PLUGIN_TYPE_ENGINE, CruiseMetaEngine);

Modified: scummvm/trunk/engines/drascula/detection.cpp
===================================================================
--- scummvm/trunk/engines/drascula/detection.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/drascula/detection.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -186,4 +186,4 @@
 	return gd != 0;
 }
 
-REGISTER_PLUGIN(DRASCULA, DrasculaMetaEngine);
+REGISTER_PLUGIN(DRASCULA, PLUGIN_TYPE_ENGINE, DrasculaMetaEngine);

Modified: scummvm/trunk/engines/gob/detection.cpp
===================================================================
--- scummvm/trunk/engines/gob/detection.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/gob/detection.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -1779,7 +1779,7 @@
 	return gd != 0;
 }
 
-REGISTER_PLUGIN(GOB, GobMetaEngine);
+REGISTER_PLUGIN(GOB, PLUGIN_TYPE_ENGINE, GobMetaEngine);
 
 namespace Gob {
 

Modified: scummvm/trunk/engines/igor/detection.cpp
===================================================================
--- scummvm/trunk/engines/igor/detection.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/igor/detection.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -134,4 +134,4 @@
 	return gd != 0;
 }
 
-REGISTER_PLUGIN(IGOR, IgorMetaEngine);
+REGISTER_PLUGIN(IGOR, PLUGIN_TYPE_ENGINE, IgorMetaEngine);

Modified: scummvm/trunk/engines/kyra/detection.cpp
===================================================================
--- scummvm/trunk/engines/kyra/detection.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/kyra/detection.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -484,4 +484,4 @@
 	return res;
 }
 
-REGISTER_PLUGIN(KYRA, KyraMetaEngine);
+REGISTER_PLUGIN(KYRA, PLUGIN_TYPE_ENGINE, KyraMetaEngine);

Modified: scummvm/trunk/engines/lure/detection.cpp
===================================================================
--- scummvm/trunk/engines/lure/detection.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/lure/detection.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -197,4 +197,4 @@
 	return gd != 0;
 }
 
-REGISTER_PLUGIN(LURE, LureMetaEngine);
+REGISTER_PLUGIN(LURE, PLUGIN_TYPE_ENGINE, LureMetaEngine);

Modified: scummvm/trunk/engines/parallaction/detection.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/detection.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/parallaction/detection.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -218,4 +218,4 @@
 	return res;
 }
 
-REGISTER_PLUGIN(PARALLACTION, ParallactionMetaEngine);
+REGISTER_PLUGIN(PARALLACTION, PLUGIN_TYPE_ENGINE, ParallactionMetaEngine);

Modified: scummvm/trunk/engines/queen/queen.cpp
===================================================================
--- scummvm/trunk/engines/queen/queen.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/queen/queen.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -127,7 +127,7 @@
 	return kNoError;
 }
 
-REGISTER_PLUGIN(QUEEN, QueenMetaEngine);
+REGISTER_PLUGIN(QUEEN, PLUGIN_TYPE_ENGINE, QueenMetaEngine);
 
 namespace Queen {
 

Modified: scummvm/trunk/engines/saga/detection.cpp
===================================================================
--- scummvm/trunk/engines/saga/detection.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/saga/detection.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -164,7 +164,7 @@
 	return gd != 0;
 }
 
-REGISTER_PLUGIN(SAGA, SagaMetaEngine);
+REGISTER_PLUGIN(SAGA, PLUGIN_TYPE_ENGINE, SagaMetaEngine);
 
 namespace Saga {
 

Modified: scummvm/trunk/engines/scumm/detection.cpp
===================================================================
--- scummvm/trunk/engines/scumm/detection.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/scumm/detection.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -964,4 +964,4 @@
 	return saveList;
 }
 
-REGISTER_PLUGIN(SCUMM, ScummMetaEngine);
+REGISTER_PLUGIN(SCUMM, PLUGIN_TYPE_ENGINE, ScummMetaEngine);

Modified: scummvm/trunk/engines/sky/sky.cpp
===================================================================
--- scummvm/trunk/engines/sky/sky.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/sky/sky.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -194,7 +194,7 @@
 	return kNoError;
 }
 
-REGISTER_PLUGIN(SKY, SkyMetaEngine);
+REGISTER_PLUGIN(SKY, PLUGIN_TYPE_ENGINE, SkyMetaEngine);
 
 namespace Sky {
 

Modified: scummvm/trunk/engines/sword1/sword1.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sword1.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/sword1/sword1.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -187,7 +187,7 @@
 	return kNoError;
 }
 
-REGISTER_PLUGIN(SWORD1, SwordMetaEngine);
+REGISTER_PLUGIN(SWORD1, PLUGIN_TYPE_ENGINE, SwordMetaEngine);
 
 namespace Sword1 {
 

Modified: scummvm/trunk/engines/sword2/sword2.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sword2.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/sword2/sword2.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -180,7 +180,7 @@
 	return kNoGameDataFoundError;
 }
 
-REGISTER_PLUGIN(SWORD2, Sword2MetaEngine);
+REGISTER_PLUGIN(SWORD2, PLUGIN_TYPE_ENGINE, Sword2MetaEngine);
 
 namespace Sword2 {
 

Modified: scummvm/trunk/engines/touche/detection.cpp
===================================================================
--- scummvm/trunk/engines/touche/detection.cpp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/engines/touche/detection.cpp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -131,6 +131,7 @@
 	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 @@
 	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 @@
 	return gd != 0;
 }
 
-REGISTER_PLUGIN(TOUCHE, ToucheMetaEngine);
+REGISTER_PLUGIN(TOUCHE, PLUGIN_TYPE_ENGINE, ToucheMetaEngine);

Modified: scummvm/trunk/plugin.exp
===================================================================
--- scummvm/trunk/plugin.exp	2008-02-07 23:38:17 UTC (rev 30824)
+++ scummvm/trunk/plugin.exp	2008-02-08 00:02:23 UTC (rev 30825)
@@ -1 +1,2 @@
+_PLUGIN_getType
 _PLUGIN_getObject


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list