[Scummvm-cvs-logs] SF.net SVN: scummvm:[41173] scummvm/trunk/engines/sci

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Jun 4 22:51:09 CEST 2009


Revision: 41173
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41173&view=rev
Author:   fingolfin
Date:     2009-06-04 20:51:09 +0000 (Thu, 04 Jun 2009)

Log Message:
-----------
SCI: cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kernel.h
    scummvm/trunk/engines/sci/engine/kernel_types.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-06-04 20:50:51 UTC (rev 41172)
+++ scummvm/trunk/engines/sci/console.cpp	2009-06-04 20:51:09 UTC (rev 41173)
@@ -1646,7 +1646,7 @@
 		return true;
 	}
 
-	int t = determine_reg_type(g_EngineState, val, 1);
+	int t = determine_reg_type(g_EngineState, val, true);
 	int invalid = t & KSIG_INVALID;
 
 	switch (t & ~KSIG_INVALID) {

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-06-04 20:50:51 UTC (rev 41172)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-06-04 20:51:09 UTC (rev 41173)
@@ -298,16 +298,16 @@
 	/*0x88*/ "DbugStr"
 };
 
-enum KernelFunctionType {
+enum KernelFuncType {
 	KF_NEW = 1,
 	KF_NONE = -1, /**< No mapping, but name is known */
 	KF_TERMINATOR = -42 /**< terminates kfunct_mappers */
 };
 
 struct SciKernelFunction {
-	KernelFunctionType type;
+	KernelFuncType type;
 	const char *name;
-	kfunct *fun; /* The actual function */
+	KernelFunc *fun; /* The actual function */
 	const char *signature;  /* kfunct signature */
 };
 
@@ -469,7 +469,14 @@
 	{KF_TERMINATOR, NULL, NULL, NULL} // Terminator
 };
 
-static const char *argtype_description[] = { "Undetermined", "List", "Node", "Object", "Reference", "Arithmetic" };
+static const char *argtype_description[] = {
+	"Undetermined",
+	"List",
+	"Node",
+	"Object",
+	"Reference",
+	"Arithmetic"
+};
 
 Kernel::Kernel(ResourceManager *resmgr, bool isOldSci0) : _resmgr(resmgr) {
 	memset(&_selectorMap, 0, sizeof(_selectorMap));	// FIXME: Remove this once/if we C++ify selector_map_t
@@ -490,10 +497,6 @@
 }
 
 Kernel::~Kernel() {
-	_selectorNames.clear();
-	_opcodes.clear();
-	_kernelNames.clear();
-	_kfuncTable.clear();
 }
 
 bool Kernel::loadSelectorNames(bool isOldSci0) {
@@ -577,7 +580,7 @@
 	return 0;
 }
 
-void kernel_compile_signature(const char **s) {
+static void kernel_compile_signature(const char **s) {
 	const char *src = *s;
 	char *result;
 	int ellipsis = 0;
@@ -724,7 +727,7 @@
 	return;
 }
 
-int determine_reg_type(EngineState *s, reg_t reg, int allow_invalid) {
+int determine_reg_type(EngineState *s, reg_t reg, bool allow_invalid) {
 	MemObject *mobj;
 
 	if (!reg.segment) {
@@ -806,9 +809,10 @@
 	return argtype_description[sci_ffs(type)];
 }
 
-int kernel_matches_signature(EngineState *s, const char *sig, int argc, reg_t *argv) {
+bool kernel_matches_signature(EngineState *s, const char *sig, int argc, const reg_t *argv) {
+	// Always "match" if no signature is given
 	if (!sig)
-		return 1;
+		return true;
 
 	while (*sig && argc) {
 		if ((*sig & KSIG_ANY) != KSIG_ANY) {
@@ -816,17 +820,17 @@
 
 			if (!type) {
 				sciprintf("[KERN] Could not determine type of ref %04x:%04x; failing signature check\n", PRINT_REG(*argv));
-				return 0;
+				return false;
 			}
 
 			if (type & KSIG_INVALID) {
 				sciprintf("[KERN] ref %04x:%04x was determined to be a %s, but the reference itself is invalid\n",
 				          PRINT_REG(*argv), kernel_argtype_description(type));
-				return 0;
+				return false;
 			}
 
 			if (!(type & *sig))
-				return 0;
+				return false;
 
 		}
 		if (!(*sig & KSIG_ELLIPSIS))
@@ -836,7 +840,7 @@
 	}
 
 	if (argc)
-		return 0; // Too many arguments
+		return false; // Too many arguments
 	else
 		return (*sig == 0 || (*sig & KSIG_ELLIPSIS));
 }

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2009-06-04 20:50:51 UTC (rev 41172)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2009-06-04 20:51:09 UTC (rev 41173)
@@ -47,12 +47,12 @@
 };
 
 /* Generic description: */
-typedef reg_t kfunct(EngineState *s, int funct_nr, int argc, reg_t *argv);
+typedef reg_t KernelFunc(EngineState *s, int funct_nr, int argc, reg_t *argv);
 
-struct kfunct_sig_pair_t {
-	kfunct *fun; /* The actual function */
-	const char *signature;  /* kfunct signature */
-	Common::String orig_name; /* Original name, in case we couldn't map it */
+struct KernelFuncWithSignature {
+	KernelFunc *fun; /**< The actual function */
+	const char *signature;  /**< KernelFunc signature */
+	Common::String orig_name; /**< Original name, in case we couldn't map it */
 };
 
 class Kernel {
@@ -88,7 +88,7 @@
 	void dumpScriptClass(char *data, int seeker, int objsize);
 
 	selector_map_t _selectorMap; /**< Shortcut list for important selectors */
-	Common::Array<kfunct_sig_pair_t> _kfuncTable; /**< Table of kernel functions */
+	Common::Array<KernelFuncWithSignature> _kfuncTable; /**< Table of kernel functions */
 
 private:
 	/**

Modified: scummvm/trunk/engines/sci/engine/kernel_types.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel_types.h	2009-06-04 20:50:51 UTC (rev 41172)
+++ scummvm/trunk/engines/sci/engine/kernel_types.h	2009-06-04 20:51:09 UTC (rev 41173)
@@ -64,30 +64,36 @@
 #define KSIG_ALLOW_INV  0x20
 #define KSIG_INVALID	KSIG_ALLOW_INV
 
-int kernel_matches_signature(EngineState *s, const char *sig, int argc, reg_t *argv);
-/* Determines whether a list of registers matches a given signature
-** Parameters: (EngineState *) s: The state to operate on
-**             (char *) sig: The signature to test against
-**             (int) argc: Number of arguments to test
-**             (reg_t *) argv: Argument list
-** Returns   : (int) 0 iff the signature was not matched
-*/
+/**
+ * Determines whether a list of registers matches a given signature.
+ * If no signature is given (i.e., if sig is NULL), this is always
+ * treated as a match.
+ *
+ * @param s		state to operate on
+ * @param sig	signature to test against
+ * @param argc	number of arguments to test
+ * @param argv	argument list
+ * @return true if the signature was matched, false otherwise
+ */
+bool kernel_matches_signature(EngineState *s, const char *sig, int argc, const reg_t *argv);
 
-int determine_reg_type(EngineState *s, reg_t reg, int allow_invalid);
-/* Determines the type of the object indicated by reg
-** Parameters: (EngineState *) s: The state to operate on
-**             (reg_t) reg: The register to check
-**	       (int) allow_invalid: Allow invalid pointer values
-** Returns   : one of KSIG_* below KSIG_NULL.
-**	       KSIG_INVALID set if the type of reg can be determined, but is invalid.
-**	       0 on error.
-*/
+/**
+ * Determines the type of the object indicated by reg.
+ * @param s					state to operate on
+ * @param reg				register to check
+ * @param allow_invalid		determines whether invalid pointer (=offset) values are allowed
+ * @return one of KSIG_* below KSIG_NULL.
+ *	       KSIG_INVALID set if the type of reg can be determined, but is invalid.
+ *	       0 on error.
+ */
+int determine_reg_type(EngineState *s, reg_t reg, bool allow_invalid);
 
+/**
+ * Returns a textual description of the type of an object.
+ * @param type		type value to describe
+ * @return pointer to a (static) descriptive string
+ */
 const char *kernel_argtype_description(int type);
-/* Returns a textual description of the type of an object
-** Parameters: (int) type: The type value to describe
-** Returns: (const char *) Pointer to a (static) descriptive string
-*/
 
 } // End of namespace Sci
 


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