aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorJohannes Schickel2008-04-20 15:47:11 +0000
committerJohannes Schickel2008-04-20 15:47:11 +0000
commitf173041811398817ffce870d30ef3b87d1302736 (patch)
tree78e43d204662641a5d687cbc184ac60913ac870d /gui
parent38319954d1035a7ec8df335c88d455a4042a94fc (diff)
downloadscummvm-rg350-f173041811398817ffce870d30ef3b87d1302736.tar.gz
scummvm-rg350-f173041811398817ffce870d30ef3b87d1302736.tar.bz2
scummvm-rg350-f173041811398817ffce870d30ef3b87d1302736.zip
- moved kyra functor code to common/func.h
- adapted debugger code to use functor code from common/func.h - adapted kyra engine to use functor code from common/func.h svn-id: r31614
Diffstat (limited to 'gui')
-rw-r--r--gui/debugger.cpp1
-rw-r--r--gui/debugger.h26
2 files changed, 5 insertions, 22 deletions
diff --git a/gui/debugger.cpp b/gui/debugger.cpp
index 81a00d717c..99aebe9b62 100644
--- a/gui/debugger.cpp
+++ b/gui/debugger.cpp
@@ -347,6 +347,7 @@ void Debugger::DVar_Register(const char *varname, void *pointer, int type, int o
// Command registration function
void Debugger::DCmd_Register(const char *cmdname, Debuglet *debuglet) {
+ assert(debuglet->isValid());
assert(_dcmd_count < ARRAYSIZE(_dcmds));
strcpy(_dcmds[_dcmd_count].name, cmdname);
_dcmds[_dcmd_count].debuglet = debuglet;
diff --git a/gui/debugger.h b/gui/debugger.h
index ac6ae62e03..0e48f384de 100644
--- a/gui/debugger.h
+++ b/gui/debugger.h
@@ -25,6 +25,8 @@
#ifndef GUI_DEBUGGER_H
#define GUI_DEBUGGER_H
+#include "common/func.h"
+
namespace GUI {
// Choose between text console or ScummConsole
@@ -47,32 +49,12 @@ public:
bool isAttached() const { return _isAttached; }
protected:
- class Debuglet {
- public:
- virtual ~Debuglet() {}
- virtual bool operator()(int argc, const char **argv) = 0;
- };
-
- template <class T>
- class DelegateDebuglet : public Debuglet {
- typedef bool (T::*Method)(int argc, const char **argv);
-
- T *_delegate;
- const Method _method;
- public:
- DelegateDebuglet(T *delegate, Method method)
- : _delegate(delegate), _method(method) {
- assert(delegate != 0);
- }
- virtual bool operator()(int argc, const char **argv) {
- return (_delegate->*_method)(argc, argv);
- };
- };
+ typedef Common::Functor2<int, const char **, bool> Debuglet;
// Convenicence macro for registering a method of a debugger class
// as the current command.
#define WRAP_METHOD(cls, method) \
- new DelegateDebuglet<cls>(this, &cls::method)
+ new Common::Functor2Mem<int, const char **, bool, cls>(this, &cls::method)
enum {
DVAR_BYTE,