feat: added debugger - untested

This commit is contained in:
2025-11-06 15:51:47 +13:00
parent ea7c45ae01
commit 2e958fa1ec
4 changed files with 39 additions and 3 deletions
+19
View File
@@ -22,6 +22,9 @@ bool ScriptEngine::Initialize() {
return false;
}
debugger = new CDebugger();
debugger->SetEngine(engine);
// Register std::string
RegisterStdString(engine);
@@ -40,6 +43,11 @@ bool ScriptEngine::Initialize() {
void ScriptEngine::Shutdown() {
ClearCachedFunctions();
if (debugger) {
debugger->SetEngine(nullptr);
delete debugger;
debugger = nullptr;
}
if (engine) {
engine->ShutDownAndRelease();
engine = nullptr;
@@ -120,6 +128,10 @@ void ScriptEngine::CallScriptFunction(asIScriptFunction* func, float dt) {
asIScriptContext* ctx = engine->CreateContext();
if (!ctx) return;
if (debugger) {
ctx->SetLineCallback(asMETHOD(CDebugger, LineCallback), debugger, asCALL_THISCALL);
}
int r = ctx->Prepare(func);
if (r < 0) {
ctx->Release();
@@ -152,6 +164,13 @@ void ScriptEngine::GarbageCollect() {
}
}
void ScriptEngine::AddFileBreakPoint(const std::string &file, int line) {
if (debugger) debugger->AddFileBreakPoint(file, line);
}
void ScriptEngine::AddFuncBreakPoint(const std::string &func) {
if (debugger) debugger->AddFuncBreakPoint(func);
}
void ScriptEngine::MessageCallback(const asSMessageInfo* msg, void*) {
// Map AngelScript message types to log levels
if (msg->type == asMSGTYPE_ERROR) {