Fixed spelling error in AngelScriptResolver name.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
69
src/ScriptResolving/AngelScript/AngelScriptResolver.hpp
Normal file
69
src/ScriptResolving/AngelScript/AngelScriptResolver.hpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#ifndef PKMNLIB_ANGELSCRIPTRESOLVER_HPP
|
||||
#define PKMNLIB_ANGELSCRIPTRESOLVER_HPP
|
||||
|
||||
#include <CreatureLib/Battling/ScriptHandling/ScriptResolver.hpp>
|
||||
#include "../../../extern/angelscript_addons/scriptbuilder/scriptbuilder.h"
|
||||
#include "../../Battling/Library/BattleLibrary.hpp"
|
||||
|
||||
#define ANGELSCRIPT_DLL_LIBRARY_IMPORT
|
||||
#include <angelscript.h>
|
||||
#include <iostream>
|
||||
#include "AngelScriptScript.hpp"
|
||||
#include "AngelScriptTypeInfo.hpp"
|
||||
using namespace Arbutils::Collections;
|
||||
|
||||
class AngelScriptResolver : public CreatureLib::Battling::ScriptResolver {
|
||||
private:
|
||||
asIScriptEngine* _engine = nullptr;
|
||||
asIScriptModule* _mainModule = nullptr;
|
||||
ContextPool* _contextPool = nullptr;
|
||||
CScriptBuilder _builder;
|
||||
|
||||
static void MessageCallback(const asSMessageInfo* msg, void* param);
|
||||
static void Print(const std::string& str) { std::cout << str << std::endl; }
|
||||
Dictionary<ScriptCategory, Dictionary<ConstString, AngelScriptTypeInfo*>> _typeDatabase;
|
||||
Dictionary<ConstString, asITypeInfo*> _baseTypes;
|
||||
|
||||
void RegisterTypes();
|
||||
void InitializeByteCode(asIBinaryStream* stream,
|
||||
const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types);
|
||||
|
||||
public:
|
||||
~AngelScriptResolver() override {
|
||||
delete _contextPool;
|
||||
for (const auto& category : _typeDatabase) {
|
||||
for (const auto& type : category.second) {
|
||||
delete type.second;
|
||||
}
|
||||
}
|
||||
_engine->ShutDownAndRelease();
|
||||
}
|
||||
|
||||
void Initialize(CreatureLib::Battling::BattleLibrary* library) override;
|
||||
void CreateScript(const char* name, const char* script);
|
||||
|
||||
void FinalizeModule();
|
||||
|
||||
CreatureLib::Battling::Script* LoadScript(ScriptCategory category, const ConstString& scriptName) override;
|
||||
|
||||
void WriteByteCodeToFile(const char* file, bool stripDebugInfo = false);
|
||||
void LoadByteCodeFromFile(const char* file,
|
||||
const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types);
|
||||
uint8_t* WriteByteCodeToMemory(size_t& size, bool stripDebugInfo = false);
|
||||
void LoadByteCodeFromMemory(uint8_t*, size_t size,
|
||||
const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types);
|
||||
|
||||
const Dictionary<ScriptCategory, Dictionary<ConstString, AngelScriptTypeInfo*>>& GetTypeDatabase() const noexcept {
|
||||
return _typeDatabase;
|
||||
}
|
||||
|
||||
asITypeInfo* GetBaseType(const ConstString& name){
|
||||
asITypeInfo* t = nullptr;
|
||||
if (!_baseTypes.TryGet(name, t)){
|
||||
t = this->_engine->GetTypeInfoByDecl(name.c_str());
|
||||
_baseTypes.Insert(name, t);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
};
|
||||
#endif // PKMNLIB_ANGELSCRIPRESOLVER_HPP
|
||||
Reference in New Issue
Block a user