diff options
author | Max Horn | 2009-06-04 20:51:09 +0000 |
---|---|---|
committer | Max Horn | 2009-06-04 20:51:09 +0000 |
commit | ae3c6c30531aa1def49939baf5a15c2e227365ae (patch) | |
tree | 8c6d721bacac8a1a78a9c4cfb96ab181f7372443 /engines/sci/engine | |
parent | 3091de6735aecac10cd18c7807bf74c7037cef91 (diff) | |
download | scummvm-rg350-ae3c6c30531aa1def49939baf5a15c2e227365ae.tar.gz scummvm-rg350-ae3c6c30531aa1def49939baf5a15c2e227365ae.tar.bz2 scummvm-rg350-ae3c6c30531aa1def49939baf5a15c2e227365ae.zip |
SCI: cleanup
svn-id: r41173
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/kernel.cpp | 36 | ||||
-rw-r--r-- | engines/sci/engine/kernel.h | 12 | ||||
-rw-r--r-- | engines/sci/engine/kernel_types.h | 48 |
3 files changed, 53 insertions, 43 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 719ff16334..40c7be207d 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -298,16 +298,16 @@ static const char *sci1_default_knames[SCI1_KNAMES_DEFAULT_ENTRIES_NR] = { /*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 @@ SciKernelFunction kfunct_mappers[] = { {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(ResourceManager *resmgr, bool isOldSci0) : _resmgr(resmgr) { } Kernel::~Kernel() { - _selectorNames.clear(); - _opcodes.clear(); - _kernelNames.clear(); - _kfuncTable.clear(); } bool Kernel::loadSelectorNames(bool isOldSci0) { @@ -577,7 +580,7 @@ int kfree(EngineState *s, reg_t handle) { 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 @@ void Kernel::mapFunctions() { 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 @@ const char *kernel_argtype_description(int type) { 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 @@ int kernel_matches_signature(EngineState *s, const char *sig, int argc, reg_t *a 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 @@ int kernel_matches_signature(EngineState *s, const char *sig, int argc, reg_t *a } if (argc) - return 0; // Too many arguments + return false; // Too many arguments else return (*sig == 0 || (*sig & KSIG_ELLIPSIS)); } diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 0db5b9205b..1fc9cd4b25 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -47,12 +47,12 @@ struct opcode { }; /* 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 @@ public: 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: /** diff --git a/engines/sci/engine/kernel_types.h b/engines/sci/engine/kernel_types.h index 24478c9119..8927586a8e 100644 --- a/engines/sci/engine/kernel_types.h +++ b/engines/sci/engine/kernel_types.h @@ -64,30 +64,36 @@ namespace Sci { #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 |