aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/base/scriptables
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-07-29 15:30:44 +0200
committerEinar Johan Trøan Sømåen2012-07-29 15:30:44 +0200
commitaa3467ddaa4b1df72398a1545c9d8b1c89dad6ad (patch)
treefebfbf4d0962bf64f6639039babb2bbc101e0c09 /engines/wintermute/base/scriptables
parent1f5288d8c17bb65d623e96ab66833ba548c26e70 (diff)
downloadscummvm-rg350-aa3467ddaa4b1df72398a1545c9d8b1c89dad6ad.tar.gz
scummvm-rg350-aa3467ddaa4b1df72398a1545c9d8b1c89dad6ad.tar.bz2
scummvm-rg350-aa3467ddaa4b1df72398a1545c9d8b1c89dad6ad.zip
WINTERMUTE: Remove the debugger.
Diffstat (limited to 'engines/wintermute/base/scriptables')
-rw-r--r--engines/wintermute/base/scriptables/script.cpp115
-rw-r--r--engines/wintermute/base/scriptables/script.h13
-rw-r--r--engines/wintermute/base/scriptables/script_engine.cpp181
-rw-r--r--engines/wintermute/base/scriptables/script_engine.h14
-rw-r--r--engines/wintermute/base/scriptables/script_value.cpp136
-rw-r--r--engines/wintermute/base/scriptables/script_value.h30
6 files changed, 3 insertions, 486 deletions
diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp
index 29185edce6..fb77225700 100644
--- a/engines/wintermute/base/scriptables/script.cpp
+++ b/engines/wintermute/base/scriptables/script.cpp
@@ -152,10 +152,6 @@ bool ScScript::initScript() {
_scriptStream->seek(_iP);
_currentLine = 0;
- // init breakpoints
- _engine->refreshScriptBreakpoints(this);
-
-
// ready to rumble...
_state = SCRIPT_RUNNING;
@@ -531,14 +527,8 @@ bool ScScript::executeInstruction() {
dw = getDWORD();
if (_scopeStack->_sP < 0) {
_globals->setProp(_symbols[dw], _operand);
- if (_gameRef->getDebugMgr()->_enabled) {
- _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]);
- }
} else {
_scopeStack->getTop()->setProp(_symbols[dw], _operand);
- if (_gameRef->getDebugMgr()->_enabled) {
- _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]);
- }
}
break;
@@ -551,26 +541,14 @@ bool ScScript::executeInstruction() {
if (!_engine->_globals->propExists(_symbols[dw])) {
_operand->setNULL();
_engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR);
-
- if (_gameRef->getDebugMgr()->_enabled) {
- _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]);
- }
}
break;
}
case II_RET:
if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) {
- _gameRef->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop());
-
_scopeStack->pop();
_iP = (uint32)_callStack->pop()->getInt();
-
- if (_scopeStack->_sP < 0) {
- _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL);
- } else {
- _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
- }
} else {
if (_thread) {
_state = SCRIPT_THREAD_FINISHED;
@@ -695,13 +673,6 @@ bool ScScript::executeInstruction() {
case II_SCOPE:
_operand->setNULL();
_scopeStack->push(_operand);
-
- if (_scopeStack->_sP < 0) {
- _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL);
- } else {
- _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
- }
-
break;
case II_CORRECT_STACK:
@@ -754,10 +725,6 @@ bool ScScript::executeInstruction() {
var->copy(val);
}
}
-
- if (_gameRef->getDebugMgr()->_enabled) {
- _gameRef->getDebugMgr()->onVariableChangeValue(var, val);
- }
}
break;
@@ -827,10 +794,6 @@ bool ScScript::executeInstruction() {
var->setProp(str, val);
}
- if (_gameRef->getDebugMgr()->_enabled) {
- _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL);
- }
-
break;
}
@@ -1117,21 +1080,6 @@ bool ScScript::executeInstruction() {
int newLine = getDWORD();
if (newLine != _currentLine) {
_currentLine = newLine;
- if (_gameRef->getDebugMgr()->_enabled) {
- _gameRef->getDebugMgr()->onScriptChangeLine(this, _currentLine);
- for (int i = 0; i < _breakpoints.getSize(); i++) {
- if (_breakpoints[i] == _currentLine) {
- _gameRef->getDebugMgr()->onScriptHitBreakpoint(this);
- sleep(0);
- break;
- }
- }
- if (_tracingMode) {
- _gameRef->getDebugMgr()->onScriptHitBreakpoint(this);
- sleep(0);
- break;
- }
- }
}
break;
@@ -1371,7 +1319,6 @@ ScScript *ScScript::invokeEventHandler(const Common::String &eventName, bool unb
if (DID_SUCCEED(ret)) {
thread->_unbreakable = unbreakable;
_engine->_scripts.add(thread);
- _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName.c_str());
return thread;
} else {
delete thread;
@@ -1497,68 +1444,6 @@ const char *ScScript::dbgGetFilename() {
return _filename;
}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScScript::dbgSendScript(IWmeDebugClient *client) {
- if (_methodThread) {
- client->onScriptMethodThreadInit(this, _parentScript, _threadEvent);
- } else if (_thread) {
- client->onScriptEventThreadInit(this, _parentScript, _threadEvent);
- } else {
- client->onScriptInit(this);
- }
-
- return dbgSendVariables(client);
- return STATUS_OK;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScScript::dbgSendVariables(IWmeDebugClient *client) {
- // send script globals
- _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0);
-
- // send scope variables
- if (_scopeStack->_sP >= 0) {
- for (int i = 0; i <= _scopeStack->_sP; i++) {
- // ScValue *Scope = _scopeStack->GetAt(i);
- //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope);
- }
- }
- return STATUS_OK;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-TScriptState ScScript::dbgGetState() {
- return _state;
-}
-
-//////////////////////////////////////////////////////////////////////////
-int ScScript::dbgGetNumBreakpoints() {
- return _breakpoints.getSize();
-}
-
-//////////////////////////////////////////////////////////////////////////
-int ScScript::dbgGetBreakpoint(int index) {
- if (index >= 0 && index < _breakpoints.getSize()) {
- return _breakpoints[index];
- } else {
- return -1;
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScScript::dbgSetTracingMode(bool isTracing) {
- _tracingMode = isTracing;
- return true;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScScript::dbgGetTracingMode() {
- return _tracingMode;
-}
-
-
//////////////////////////////////////////////////////////////////////////
void ScScript::afterLoad() {
if (_buffer == NULL) {
diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h
index 6b5fa1733b..1cd5c2dc1e 100644
--- a/engines/wintermute/base/scriptables/script.h
+++ b/engines/wintermute/base/scriptables/script.h
@@ -34,18 +34,13 @@
#include "engines/wintermute/dcscript.h" // Added by ClassView
#include "engines/wintermute/coll_templ.h"
-#include "engines/wintermute/wme_debugger.h"
-
namespace WinterMute {
class BaseScriptHolder;
class BaseObject;
class ScEngine;
class ScStack;
-class ScScript : public BaseClass, public IWmeDebugScript {
+class ScScript : public BaseClass {
public:
- bool dbgSendScript(IWmeDebugClient *client);
- bool dbgSendVariables(IWmeDebugClient *client);
-
BaseArray<int> _breakpoints;
bool _tracingMode;
@@ -172,12 +167,6 @@ private:
public:
virtual int dbgGetLine();
virtual const char *dbgGetFilename();
- virtual TScriptState dbgGetState();
- virtual int dbgGetNumBreakpoints();
- virtual int dbgGetBreakpoint(int Index);
-
- virtual bool dbgSetTracingMode(bool IsTracing);
- virtual bool dbgGetTracingMode();
};
} // end of namespace WinterMute
diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp
index 96250dbb90..06f584c9bb 100644
--- a/engines/wintermute/base/scriptables/script_engine.cpp
+++ b/engines/wintermute/base/scriptables/script_engine.cpp
@@ -88,17 +88,10 @@ ScEngine::ScEngine(BaseGame *inGame) : BaseClass(inGame) {
//////////////////////////////////////////////////////////////////////////
ScEngine::~ScEngine() {
_gameRef->LOG(0, "Shutting down scripting engine");
- saveBreakpoints();
disableProfiling();
cleanup();
-
- for (int i = 0; i < _breakpoints.getSize(); i++) {
- delete _breakpoints[i];
- _breakpoints[i] = NULL;
- }
- _breakpoints.clear();
}
@@ -174,7 +167,6 @@ ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) {
script->_globals->setProp("this", &val);
_scripts.add(script);
- _gameRef->getDebugMgr()->onScriptInit(script);
return script;
}
@@ -402,7 +394,7 @@ bool ScEngine::removeFinishedScripts() {
if (!_scripts[i]->_thread && _scripts[i]->_owner) {
_scripts[i]->_owner->removeScript(_scripts[i]);
}
- _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]);
+
delete _scripts[i];
_scripts.remove_at(i);
i--;
@@ -557,177 +549,6 @@ bool ScEngine::clearGlobals(bool includingNatives) {
}
//////////////////////////////////////////////////////////////////////////
-bool ScEngine::dbgSendScripts(IWmeDebugClient *client) {
- // send global variables
- _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0);
-
- // process normal scripts first
- for (int i = 0; i < _scripts.getSize(); i++) {
- if (_scripts[i]->_thread || _scripts[i]->_methodThread) {
- continue;
- }
- _scripts[i]->dbgSendScript(client);
- }
-
- // and threads later
- for (int i = 0; i < _scripts.getSize(); i++) {
- if (_scripts[i]->_thread || _scripts[i]->_methodThread) {
- _scripts[i]->dbgSendScript(client);
- }
- }
-
- return STATUS_OK;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScEngine::addBreakpoint(const char *scriptFilename, int line) {
- if (!_gameRef->getDebugMgr()->_enabled) {
- return STATUS_OK;
- }
-
- CScBreakpoint *bp = NULL;
- for (int i = 0; i < _breakpoints.getSize(); i++) {
- if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) {
- bp = _breakpoints[i];
- break;
- }
- }
- if (bp == NULL) {
- bp = new CScBreakpoint(scriptFilename);
- _breakpoints.add(bp);
- }
-
- for (int i = 0; i < bp->_lines.getSize(); i++) {
- if (bp->_lines[i] == line) {
- return STATUS_OK;
- }
- }
- bp->_lines.add(line);
-
- // refresh changes
- refreshScriptBreakpoints();
-
- return STATUS_OK;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) {
- if (!_gameRef->getDebugMgr()->_enabled) {
- return STATUS_OK;
- }
-
- for (int i = 0; i < _breakpoints.getSize(); i++) {
- if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) {
- for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) {
- if (_breakpoints[i]->_lines[j] == line) {
- _breakpoints[i]->_lines.remove_at(j);
- if (_breakpoints[i]->_lines.getSize() == 0) {
- delete _breakpoints[i];
- _breakpoints.remove_at(i);
- }
- // refresh changes
- refreshScriptBreakpoints();
-
- return STATUS_OK;
- }
- }
- break;
- }
- }
- return STATUS_FAILED;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScEngine::refreshScriptBreakpoints() {
- if (!_gameRef->getDebugMgr()->_enabled) {
- return STATUS_OK;
- }
-
- for (int i = 0; i < _scripts.getSize(); i++) {
- refreshScriptBreakpoints(_scripts[i]);
- }
- return STATUS_OK;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScEngine::refreshScriptBreakpoints(ScScript *script) {
- if (!_gameRef->getDebugMgr()->_enabled) {
- return STATUS_OK;
- }
-
- if (!script || !script->_filename) {
- return STATUS_FAILED;
- }
-
- for (int i = 0; i < _breakpoints.getSize(); i++) {
- if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) {
- script->_breakpoints.copy(_breakpoints[i]->_lines);
- return STATUS_OK;
- }
- }
- if (script->_breakpoints.getSize() > 0) {
- script->_breakpoints.clear();
- }
-
- return STATUS_OK;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScEngine::saveBreakpoints() {
- if (!_gameRef->getDebugMgr()->_enabled) {
- return STATUS_OK;
- }
-
-
- char text[512];
- char key[100];
-
- int count = 0;
- for (int i = 0; i < _breakpoints.getSize(); i++) {
- for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) {
- count++;
- sprintf(key, "Breakpoint%d", count);
- sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]);
-
- BaseEngine::instance().getRegistry()->writeString("Debug", key, text);
- }
- }
- BaseEngine::instance().getRegistry()->writeInt("Debug", "NumBreakpoints", count);
-
- return STATUS_OK;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScEngine::loadBreakpoints() {
- if (!_gameRef->getDebugMgr()->_enabled) {
- return STATUS_OK;
- }
-
- char key[100];
-
- int count = BaseEngine::instance().getRegistry()->readInt("Debug", "NumBreakpoints", 0);
- for (int i = 1; i <= count; i++) {
- /* uint32 bufSize = 512; */
- sprintf(key, "Breakpoint%d", i);
- AnsiString breakpoint = BaseEngine::instance().getRegistry()->readString("Debug", key, "");
-
- char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':');
- char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':');
-
- if (path != NULL && line != NULL) {
- addBreakpoint(path, atoi(line));
- }
- delete[] path;
- delete[] line;
- path = NULL;
- line = NULL;
- }
-
- return STATUS_OK;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
void ScEngine::addScriptTime(const char *filename, uint32 time) {
if (!_isProfiling) {
return;
diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h
index fcfaa51971..9aae8be85b 100644
--- a/engines/wintermute/base/scriptables/script_engine.h
+++ b/engines/wintermute/base/scriptables/script_engine.h
@@ -32,7 +32,6 @@
#include "engines/wintermute/persistent.h"
#include "engines/wintermute/coll_templ.h"
#include "engines/wintermute/base/base.h"
-#include "engines/wintermute/wme_debugger.h"
namespace WinterMute {
@@ -81,20 +80,7 @@ public:
BaseArray<int> _lines;
};
-
-
-
public:
- bool dbgSendScripts(IWmeDebugClient *client);
-
- BaseArray<CScBreakpoint *> _breakpoints;
- bool addBreakpoint(const char *scriptFilename, int line);
- bool removeBreakpoint(const char *scriptFilename, int line);
- bool refreshScriptBreakpoints();
- bool refreshScriptBreakpoints(ScScript *script);
- bool saveBreakpoints();
- bool loadBreakpoints();
-
bool clearGlobals(bool includingNatives = false);
bool tickUnbreakable();
bool removeFinishedScripts();
diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp
index 456f93507e..d35f85f9a1 100644
--- a/engines/wintermute/base/scriptables/script_value.cpp
+++ b/engines/wintermute/base/scriptables/script_value.cpp
@@ -950,18 +950,6 @@ int ScValue::compareStrict(ScValue *val1, ScValue *val2) {
}
}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, ScScript *script, unsigned int scopeID) {
- _valIter = _valObject.begin();
- while (_valIter != _valObject.end()) {
- client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str());
- _valIter++;
- }
- return STATUS_OK;
-}
-
-
//////////////////////////////////////////////////////////////////////////
bool ScValue::setProperty(const char *propName, int value) {
ScValue *val = new ScValue(_gameRef, value);
@@ -1004,128 +992,4 @@ bool ScValue::setProperty(const char *propName) {
return ret;
}
-
-//////////////////////////////////////////////////////////////////////////
-// IWmeDebugProp
-//////////////////////////////////////////////////////////////////////////
-EWmeDebuggerPropType ScValue::dbgGetType() {
- switch (getType()) {
- case VAL_NULL:
- return WME_DBGPROP_NULL;
- case VAL_STRING:
- return WME_DBGPROP_STRING;
- case VAL_INT:
- return WME_DBGPROP_INT;
- case VAL_BOOL:
- return WME_DBGPROP_BOOL;
- case VAL_FLOAT:
- return WME_DBGPROP_FLOAT;
- case VAL_OBJECT:
- return WME_DBGPROP_OBJECT;
- case VAL_NATIVE:
- return WME_DBGPROP_NATIVE;
- default:
- return WME_DBGPROP_UNKNOWN;
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-int ScValue::dbgGetValInt() {
- return getInt();
-}
-
-//////////////////////////////////////////////////////////////////////////
-double ScValue::dbgGetValFloat() {
- return getFloat();
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScValue::dbgGetValBool() {
- return getBool();
-}
-
-//////////////////////////////////////////////////////////////////////////
-const char *ScValue::dbgGetValString() {
- return getString();
-}
-
-//////////////////////////////////////////////////////////////////////////
-IWmeDebugObject *ScValue::dbgGetValNative() {
- return getNative();
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScValue::dbgSetVal(int value) {
- setInt(value);
- return true;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScValue::dbgSetVal(double value) {
- setFloat(value);
- return true;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScValue::dbgSetVal(bool value) {
- setBool(value);
- return true;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScValue::dbgSetVal(const char *value) {
- setString(value);
- return true;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScValue::dbgSetVal() {
- setNULL();
- return true;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-int ScValue::dbgGetNumProperties() {
- if (_valNative && _valNative->_scProp) {
- return _valNative->_scProp->dbgGetNumProperties();
- } else {
- return _valObject.size();
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) {
- if (_valNative && _valNative->_scProp) {
- return _valNative->_scProp->dbgGetProperty(index, name, value);
- } else {
- int count = 0;
- _valIter = _valObject.begin();
- while (_valIter != _valObject.end()) {
- if (count == index) {
- *name = _valIter->_key.c_str();
- *value = _valIter->_value;
- return true;
- }
- _valIter++;
- count++;
- }
- return false;
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool ScValue::dbgGetDescription(char *buf, int bufSize) {
- if (_type == VAL_VARIABLE_REF) {
- return _valRef->dbgGetDescription(buf, bufSize);
- }
-
- if (_type == VAL_NATIVE) {
- _valNative->scDebuggerDesc(buf, bufSize);
- } else {
- strncpy(buf, getString(), bufSize);
- }
- return true;
-}
-
} // end of namespace WinterMute
diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h
index 069c36bd47..8fced06972 100644
--- a/engines/wintermute/base/scriptables/script_value.h
+++ b/engines/wintermute/base/scriptables/script_value.h
@@ -33,7 +33,6 @@
#include "engines/wintermute/base/base.h"
#include "engines/wintermute/persistent.h"
#include "engines/wintermute/dcscript.h" // Added by ClassView
-#include "engines/wintermute/wme_debugger.h"
#include "common/str.h"
namespace WinterMute {
@@ -41,10 +40,8 @@ namespace WinterMute {
class ScScript;
class BaseScriptable;
-class ScValue : public BaseClass, public IWmeDebugProp {
+class ScValue : public BaseClass {
public:
- bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, ScScript *script, unsigned int scopeID);
-
static int compare(ScValue *val1, ScValue *val2);
static int compareStrict(ScValue *val1, ScValue *val2);
TValType getTypeTolerant();
@@ -109,31 +106,6 @@ public:
bool setProperty(const char *propName, double value);
bool setProperty(const char *propName, bool value);
bool setProperty(const char *propName);
-
-
-// IWmeDebugProp interface implementation
-public:
- virtual EWmeDebuggerPropType dbgGetType();
-
- // getters
- virtual int dbgGetValInt();
- virtual double dbgGetValFloat();
- virtual bool dbgGetValBool();
- virtual const char *dbgGetValString();
- virtual IWmeDebugObject *dbgGetValNative();
-
- // setters
- virtual bool dbgSetVal(int value);
- virtual bool dbgSetVal(double value);
- virtual bool dbgSetVal(bool value);
- virtual bool dbgSetVal(const char *value);
- virtual bool dbgSetVal();
-
- // properties
- virtual int dbgGetNumProperties();
- virtual bool dbgGetProperty(int index, const char **mame, IWmeDebugProp **value);
-
- virtual bool dbgGetDescription(char *buf, int bufSize);
};
} // end of namespace WinterMute