Adds support for Angelscript debugger.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-10-22 15:11:52 +02:00
parent 0ebac13c14
commit af50f1cc74
9 changed files with 39 additions and 19 deletions

View File

@@ -121,7 +121,7 @@ void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg,
_engine->RegisterGlobalProperty("const StaticLibrary@ StaticLib", (void*)staticLib.get());
}
_contextPool = new ContextPool(_engine, _userData);
_contextPool = new ContextPool(this, _userData);
asPrepareMultithread();
}

View File

@@ -3,6 +3,7 @@
#include <CreatureLib/Battling/ScriptHandling/ScriptResolver.hpp>
#include <mutex>
#include "../../../extern/AngelscriptDebuggerServer/src/AngelscriptDebugger.hpp"
#include "../../../extern/angelscript_addons/scriptbuilder/scriptbuilder.h"
#include "../../Battling/Library/BattleLibrary.hpp"
#include "AngelScriptEvolutionScript.hpp"
@@ -24,6 +25,7 @@ private:
CScriptBuilder _builder = {};
std::string _sourceDirectory = {};
AngelscriptUserdata* _userData;
ArbUt::OptionalUniquePtr<AngelscriptDebugger> _debugger;
ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*>> _typeDatabase;
ArbUt::Dictionary<ArbUt::StringView, asITypeInfo*> _baseTypes;
@@ -106,6 +108,9 @@ public:
inline ContextPool* GetContextPool() const noexcept { return _contextPool; }
inline asIScriptEngine* GetEngine() const noexcept { return _engine; }
inline AngelscriptUserdata* GetUserdata() const noexcept { return _userData; }
inline ArbUt::OptionalBorrowedPtr<AngelscriptDebugger> GetDebugger() const noexcept { return _debugger.GetValue(); }
inline void SetDebugger(AngelscriptDebugger* debugger) noexcept { _debugger = debugger; }
};
#endif // PKMNLIB_ANGELSCRIPRESOLVER_HPP

View File

@@ -19,7 +19,7 @@ class ContextPool {
};
ArbUt::Dictionary<std::thread::id, CtxThreadedPoolStorage*> _pool;
asIScriptEngine* _engine;
AngelScriptResolver* _resolver;
AngelscriptUserdata* _userData;
CtxThreadedPoolStorage* GetThreadPool() {
@@ -32,7 +32,8 @@ class ContextPool {
}
public:
ContextPool(asIScriptEngine* engine, AngelscriptUserdata* userData) : _engine(engine), _userData(userData) {}
ContextPool(AngelScriptResolver* resolver, AngelscriptUserdata* userData)
: _resolver(resolver), _userData(userData) {}
~ContextPool() {
for (const auto& kv : _pool) {
@@ -49,9 +50,12 @@ public:
ctx = *pool->Pool.rbegin();
pool->Pool.pop_back();
} else {
ctx = _engine->CreateContext();
ctx = _resolver->GetEngine()->CreateContext();
ctx->SetUserData(_userData);
}
if (_resolver->GetDebugger().HasValue()) {
_resolver->GetDebugger().GetValue()->RegisterContext(ctx);
}
return ctx;
}