[Scummvm-cvs-logs] SF.net SVN: scummvm:[53607] scummvm/trunk/engines/sword25/kernel
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Tue Oct 19 11:43:53 CEST 2010
Revision: 53607
http://scummvm.svn.sourceforge.net/scummvm/?rev=53607&view=rev
Author: fingolfin
Date: 2010-10-19 09:43:53 +0000 (Tue, 19 Oct 2010)
Log Message:
-----------
SWORD25: Move BS_ServiceInfo to service_ids.h and turn it into a POD struct
Modified Paths:
--------------
scummvm/trunk/engines/sword25/kernel/kernel.cpp
scummvm/trunk/engines/sword25/kernel/kernel.h
scummvm/trunk/engines/sword25/kernel/service_ids.h
Modified: scummvm/trunk/engines/sword25/kernel/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sword25/kernel/kernel.cpp 2010-10-19 09:43:31 UTC (rev 53606)
+++ scummvm/trunk/engines/sword25/kernel/kernel.cpp 2010-10-19 09:43:53 UTC (rev 53607)
@@ -49,6 +49,7 @@
#define BS_LOG_PREFIX "KERNEL"
+
Kernel *Kernel::_Instance = 0;
Kernel::Kernel() :
@@ -61,7 +62,7 @@
BS_LOGLN("created.");
// Read the BS_SERVICE_TABLE and prepare kernel structures
- for (uint i = 0; i < BS_SERVICE_COUNT; i++) {
+ for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++) {
// Is the superclass already registered?
Superclass *pCurSuperclass = NULL;
Common::Array<Superclass *>::iterator Iter;
@@ -136,7 +137,7 @@
_Identifier(Identifier),
_ServiceCount(0),
_ActiveService(NULL) {
- for (uint i = 0; i < BS_SERVICE_COUNT; i++)
+ for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++)
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier)
_ServiceCount++;
}
@@ -158,7 +159,7 @@
if (Number > _ServiceCount) return NULL;
uint CurServiceOrd = 0;
- for (uint i = 0; i < BS_SERVICE_COUNT; i++) {
+ for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++) {
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier) {
if (Number == CurServiceOrd)
return BS_SERVICE_TABLE[i].ServiceIdentifier;
@@ -180,7 +181,7 @@
* For the superclass "sfx" an example could be "Fmod" or "directsound"
*/
Service *Kernel::Superclass::NewService(const Common::String &ServiceIdentifier) {
- for (uint i = 0; i < BS_SERVICE_COUNT; i++)
+ for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++)
if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier &&
BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier) {
Service *NewService_ = BS_SERVICE_TABLE[i].CreateMethod(_pKernel);
Modified: scummvm/trunk/engines/sword25/kernel/kernel.h
===================================================================
--- scummvm/trunk/engines/sword25/kernel/kernel.h 2010-10-19 09:43:31 UTC (rev 53606)
+++ scummvm/trunk/engines/sword25/kernel/kernel.h 2010-10-19 09:43:53 UTC (rev 53607)
@@ -331,24 +331,6 @@
bool _RegisterScriptBindings();
};
-/**
- * This is only a small class that manages the data of a service. It is a little ugly, I know,
- * but with Common::String a simple struct could not be used.
- */
-class BS_ServiceInfo {
-public:
- BS_ServiceInfo(const Common::String &SuperclassIdentifier_, const Common::String &ServiceIdentifier_,
- Service*(*CreateMethod_)(Kernel *)) {
- this->SuperclassIdentifier = SuperclassIdentifier_;
- this->ServiceIdentifier = ServiceIdentifier_;
- this->CreateMethod = CreateMethod_;
- }
-
- Common::String SuperclassIdentifier;
- Common::String ServiceIdentifier;
- Service*(*CreateMethod)(Kernel *);
-};
-
} // End of namespace Sword25
#endif
Modified: scummvm/trunk/engines/sword25/kernel/service_ids.h
===================================================================
--- scummvm/trunk/engines/sword25/kernel/service_ids.h 2010-10-19 09:43:31 UTC (rev 53606)
+++ scummvm/trunk/engines/sword25/kernel/service_ids.h 2010-10-19 09:43:53 UTC (rev 53607)
@@ -61,23 +61,30 @@
Service *OggTheora_CreateObject(Kernel *pKernel) { return NULL; }
#endif
+
+/**
+ * This is only a small struct that manages the data of a service.
+ */
+struct BS_ServiceInfo {
+ const char *SuperclassIdentifier;
+ const char *ServiceIdentifier;
+ Service *(*CreateMethod)(Kernel *);
+};
+
// Services are recorded in this table
const BS_ServiceInfo BS_SERVICE_TABLE[] = {
- // The first two parameters are the name of the superclass and service
- // The third parameter is the static method of the class that creates an object
- // of the class and returns it
- // Example:
- // BS_ServiceInfo("Superclass", "Service", CreateMethod)
- BS_ServiceInfo("gfx", "opengl", GraphicEngine_CreateObject),
- BS_ServiceInfo("package", "archiveFS", PackageManager_CreateObject),
- BS_ServiceInfo("input", "winapi", InputEngine_CreateObject),
- BS_ServiceInfo("sfx", "fmodex", SoundEngine_CreateObject),
- BS_ServiceInfo("script", "lua", LuaScriptEngine_CreateObject),
- BS_ServiceInfo("geometry", "std", Geometry_CreateObject),
- BS_ServiceInfo("fmv", "oggtheora", OggTheora_CreateObject),
+ // The first two values are the name of the superclass and service.
+ // The third value is the static method of the class that creates an object
+ // of the class and returns it.
+ { "gfx", "opengl", GraphicEngine_CreateObject },
+ { "package", "archiveFS", PackageManager_CreateObject },
+ { "input", "winapi", InputEngine_CreateObject },
+ { "sfx", "fmodex", SoundEngine_CreateObject },
+ { "script", "lua", LuaScriptEngine_CreateObject },
+ { "geometry", "std", Geometry_CreateObject },
+ { "fmv", "oggtheora", OggTheora_CreateObject }
};
-const uint BS_SERVICE_COUNT = sizeof(BS_SERVICE_TABLE) / sizeof(BS_ServiceInfo);
} // End of namespace Sword25
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