Fixed spelling error in AngelScriptResolver name.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-04-24 00:05:43 +02:00
parent 1d5c6d696e
commit 42ea76cf53
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
12 changed files with 61 additions and 61 deletions

View File

@ -1,4 +1,4 @@
#include "AngelScripResolver.hpp" #include "AngelScriptResolver.hpp"
#include <CreatureLib/Battling/Models/Creature.hpp> #include <CreatureLib/Battling/Models/Creature.hpp>
#include <cassert> #include <cassert>
#include <regex> #include <regex>
@ -24,7 +24,7 @@
#include "TypeRegistry/Library/RegisterTypeLibrary.hpp" #include "TypeRegistry/Library/RegisterTypeLibrary.hpp"
CreatureLib::Battling::ScriptResolver* PkmnLib::Battling::BattleLibrary::CreateScriptResolver() { CreatureLib::Battling::ScriptResolver* PkmnLib::Battling::BattleLibrary::CreateScriptResolver() {
return new AngelScripResolver(); return new AngelScriptResolver();
} }
static void TranslateException(asIScriptContext* ctx, void* /*userParam*/) { static void TranslateException(asIScriptContext* ctx, void* /*userParam*/) {
@ -40,7 +40,7 @@ static void TranslateException(asIScriptContext* ctx, void* /*userParam*/) {
} }
} }
void AngelScripResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg) { void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg) {
for (auto scriptCategory : ScriptCategoryHelper::GetValues()) { for (auto scriptCategory : ScriptCategoryHelper::GetValues()) {
_typeDatabase.Insert(scriptCategory, {}); _typeDatabase.Insert(scriptCategory, {});
} }
@ -88,7 +88,7 @@ void AngelScripResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg) {
_contextPool = new ContextPool(_engine); _contextPool = new ContextPool(_engine);
} }
void AngelScripResolver::RegisterTypes() { void AngelScriptResolver::RegisterTypes() {
// Register static library types // Register static library types
RegisterSpeciesTypes::Register(_engine); RegisterSpeciesTypes::Register(_engine);
RegisterItemTypes::Register(_engine); RegisterItemTypes::Register(_engine);
@ -113,7 +113,7 @@ void AngelScripResolver::RegisterTypes() {
BasicScriptClass::Register(_engine); BasicScriptClass::Register(_engine);
} }
void AngelScripResolver::MessageCallback(const asSMessageInfo* msg, void* param) { void AngelScriptResolver::MessageCallback(const asSMessageInfo* msg, void* param) {
const char* type = "ERR "; const char* type = "ERR ";
if (msg->type == asMSGTYPE_WARNING) if (msg->type == asMSGTYPE_WARNING)
type = "WARN"; type = "WARN";
@ -122,7 +122,7 @@ void AngelScripResolver::MessageCallback(const asSMessageInfo* msg, void* param)
printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message); printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message);
} }
CreatureLib::Battling::Script* AngelScripResolver::LoadScript(ScriptCategory category, const ConstString& scriptName) { CreatureLib::Battling::Script* AngelScriptResolver::LoadScript(ScriptCategory category, const ConstString& scriptName) {
Dictionary<ConstString, AngelScriptTypeInfo*> innerDb; Dictionary<ConstString, AngelScriptTypeInfo*> innerDb;
if (!_typeDatabase.TryGet(category, innerDb)) { if (!_typeDatabase.TryGet(category, innerDb)) {
_typeDatabase.Insert(category, innerDb); _typeDatabase.Insert(category, innerDb);
@ -141,7 +141,7 @@ CreatureLib::Battling::Script* AngelScripResolver::LoadScript(ScriptCategory cat
_contextPool->ReturnContextToPool(ctx); _contextPool->ReturnContextToPool(ctx);
return new AngelScriptScript(this, t, obj, _contextPool); return new AngelScriptScript(this, t, obj, _contextPool);
} }
void AngelScripResolver::FinalizeModule() { void AngelScriptResolver::FinalizeModule() {
int r = _builder.BuildModule(); int r = _builder.BuildModule();
if (r < 0) if (r < 0)
throw CreatureException("Building Script Module failed."); throw CreatureException("Building Script Module failed.");
@ -205,10 +205,10 @@ void AngelScripResolver::FinalizeModule() {
} }
} }
} }
void AngelScripResolver::CreateScript(const char* name, const char* script) { void AngelScriptResolver::CreateScript(const char* name, const char* script) {
_builder.AddSectionFromMemory(name, script); _builder.AddSectionFromMemory(name, script);
} }
void AngelScripResolver::WriteByteCodeToFile(const char* file, bool stripDebugInfo) { void AngelScriptResolver::WriteByteCodeToFile(const char* file, bool stripDebugInfo) {
FILE* wFile = nullptr; FILE* wFile = nullptr;
wFile = fopen(file, "wb"); wFile = fopen(file, "wb");
AssertNotNull(wFile); AssertNotNull(wFile);
@ -217,7 +217,7 @@ void AngelScripResolver::WriteByteCodeToFile(const char* file, bool stripDebugIn
Assert(fclose(wFile) == 0); Assert(fclose(wFile) == 0);
delete stream; delete stream;
} }
void AngelScripResolver::LoadByteCodeFromFile( void AngelScriptResolver::LoadByteCodeFromFile(
const char* file, const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types) { const char* file, const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types) {
FILE* rFile = nullptr; FILE* rFile = nullptr;
rFile = fopen(file, "rb"); rFile = fopen(file, "rb");
@ -227,7 +227,7 @@ void AngelScripResolver::LoadByteCodeFromFile(
Assert(fclose(rFile) == 0); Assert(fclose(rFile) == 0);
delete stream; delete stream;
} }
uint8_t* AngelScripResolver::WriteByteCodeToMemory(size_t& size, bool stripDebugInfo) { uint8_t* AngelScriptResolver::WriteByteCodeToMemory(size_t& size, bool stripDebugInfo) {
auto stream = new MemoryByteCodeStream(); auto stream = new MemoryByteCodeStream();
auto result = _mainModule->SaveByteCode(stream, stripDebugInfo); auto result = _mainModule->SaveByteCode(stream, stripDebugInfo);
Assert(result == asSUCCESS); Assert(result == asSUCCESS);
@ -237,13 +237,13 @@ uint8_t* AngelScripResolver::WriteByteCodeToMemory(size_t& size, bool stripDebug
delete stream; delete stream;
return arr; return arr;
} }
void AngelScripResolver::LoadByteCodeFromMemory( void AngelScriptResolver::LoadByteCodeFromMemory(
uint8_t* byte, size_t size, const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types) { uint8_t* byte, size_t size, const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types) {
auto stream = new MemoryByteCodeStream(byte, size); auto stream = new MemoryByteCodeStream(byte, size);
InitializeByteCode(stream, types); InitializeByteCode(stream, types);
delete stream; delete stream;
} }
void AngelScripResolver::InitializeByteCode( void AngelScriptResolver::InitializeByteCode(
asIBinaryStream* stream, const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types) { asIBinaryStream* stream, const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types) {
int result = _mainModule->LoadByteCode(stream); int result = _mainModule->LoadByteCode(stream);
Assert(result == asSUCCESS); Assert(result == asSUCCESS);

View File

@ -1,5 +1,5 @@
#ifndef PKMNLIB_ANGELSCRIPRESOLVER_HPP #ifndef PKMNLIB_ANGELSCRIPTRESOLVER_HPP
#define PKMNLIB_ANGELSCRIPRESOLVER_HPP #define PKMNLIB_ANGELSCRIPTRESOLVER_HPP
#include <CreatureLib/Battling/ScriptHandling/ScriptResolver.hpp> #include <CreatureLib/Battling/ScriptHandling/ScriptResolver.hpp>
#include "../../../extern/angelscript_addons/scriptbuilder/scriptbuilder.h" #include "../../../extern/angelscript_addons/scriptbuilder/scriptbuilder.h"
@ -12,7 +12,7 @@
#include "AngelScriptTypeInfo.hpp" #include "AngelScriptTypeInfo.hpp"
using namespace Arbutils::Collections; using namespace Arbutils::Collections;
class AngelScripResolver : public CreatureLib::Battling::ScriptResolver { class AngelScriptResolver : public CreatureLib::Battling::ScriptResolver {
private: private:
asIScriptEngine* _engine = nullptr; asIScriptEngine* _engine = nullptr;
asIScriptModule* _mainModule = nullptr; asIScriptModule* _mainModule = nullptr;
@ -29,7 +29,7 @@ private:
const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types); const Dictionary<ScriptCategory, Dictionary<ConstString, const char*>>& types);
public: public:
~AngelScripResolver() override { ~AngelScriptResolver() override {
delete _contextPool; delete _contextPool;
for (const auto& category : _typeDatabase) { for (const auto& category : _typeDatabase) {
for (const auto& type : category.second) { for (const auto& type : category.second) {

View File

@ -1,5 +1,5 @@
#include "AngelScriptScript.hpp" #include "AngelScriptScript.hpp"
#include "AngelScripResolver.hpp" #include "AngelScriptResolver.hpp"
#define CALL_HOOK(name, setup) \ #define CALL_HOOK(name, setup) \
auto s = _type->Get##name(); \ auto s = _type->Get##name(); \

View File

@ -10,17 +10,17 @@
#include "AngelScriptTypeInfo.hpp" #include "AngelScriptTypeInfo.hpp"
#include "ContextPool.hpp" #include "ContextPool.hpp"
class AngelScripResolver; class AngelScriptResolver;
class AngelScriptScript : public PkmnLib::Battling::PkmnScript { class AngelScriptScript : public PkmnLib::Battling::PkmnScript {
private: private:
AngelScripResolver* _resolver = nullptr; AngelScriptResolver* _resolver = nullptr;
AngelScriptTypeInfo* _type = nullptr; AngelScriptTypeInfo* _type = nullptr;
ContextPool* _ctxPool = nullptr; ContextPool* _ctxPool = nullptr;
asIScriptObject* _obj = nullptr; asIScriptObject* _obj = nullptr;
CScriptArray* GetEffectParameters(const List<CreatureLib::Library::EffectParameter*>& ls); CScriptArray* GetEffectParameters(const List<CreatureLib::Library::EffectParameter*>& ls);
public: public:
AngelScriptScript(AngelScripResolver* resolver, AngelScriptTypeInfo* type, asIScriptObject* obj, AngelScriptScript(AngelScriptResolver* resolver, AngelScriptTypeInfo* type, asIScriptObject* obj,
ContextPool* ctxPool) ContextPool* ctxPool)
: _resolver(resolver), _type(type), _ctxPool(ctxPool), _obj(obj) {} : _resolver(resolver), _type(type), _ctxPool(ctxPool), _obj(obj) {}

View File

@ -1,7 +1,7 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../extern/catch.hpp" #include "../../extern/catch.hpp"
#include "../../src/Battling/Pokemon/CreatePokemon.hpp" #include "../../src/Battling/Pokemon/CreatePokemon.hpp"
#include "../../src/ScriptResolving/AngelScript/AngelScripResolver.hpp" #include "../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../TestLibrary/TestLibrary.hpp" #include "../TestLibrary/TestLibrary.hpp"
#define AS_CLASS(name, contents) \ #define AS_CLASS(name, contents) \
@ -75,10 +75,10 @@ void StopBeforeAttack(ExecutingMove@ attack, bool& result) override{
}; };
static AngelScripResolver* _resolverCache = nullptr; static AngelScriptResolver* _resolverCache = nullptr;
static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib) { static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib) {
if (_resolverCache == nullptr) { if (_resolverCache == nullptr) {
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); _resolverCache = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
_resolverCache->Initialize(mainLib); _resolverCache->Initialize(mainLib);
for (auto kv : _scripts) { for (auto kv : _scripts) {
_resolverCache->CreateScript(kv.first, kv.second); _resolverCache->CreateScript(kv.first, kv.second);

View File

@ -1,6 +1,6 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../extern/catch.hpp" #include "../../extern/catch.hpp"
#include "../../src/ScriptResolving/AngelScript/AngelScripResolver.hpp" #include "../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../TestLibrary/TestLibrary.hpp" #include "../TestLibrary/TestLibrary.hpp"
static std::unordered_map<const char*, const char*> _scripts = static std::unordered_map<const char*, const char*> _scripts =
@ -28,7 +28,7 @@ TEST_CASE("Get a script resolver, initialize it, then delete it") {
} }
TEST_CASE("Get a script resolver, set script load function, load script, then build module") { TEST_CASE("Get a script resolver, set script load function, load script, then build module") {
auto lib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); auto lib = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
lib->Initialize(TestLibrary::GetLibrary()); lib->Initialize(TestLibrary::GetLibrary());
lib->CreateScript("testScript1", _scripts["testScript1"]); lib->CreateScript("testScript1", _scripts["testScript1"]);
lib->FinalizeModule(); lib->FinalizeModule();
@ -36,7 +36,7 @@ TEST_CASE("Get a script resolver, set script load function, load script, then bu
} }
TEST_CASE("Build script resolver, then create object") { TEST_CASE("Build script resolver, then create object") {
auto lib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); auto lib = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
lib->Initialize(TestLibrary::GetLibrary()); lib->Initialize(TestLibrary::GetLibrary());
lib->CreateScript("testScript1", _scripts["testScript1"]); lib->CreateScript("testScript1", _scripts["testScript1"]);
lib->FinalizeModule(); lib->FinalizeModule();
@ -48,7 +48,7 @@ TEST_CASE("Build script resolver, then create object") {
} }
TEST_CASE("Build script resolver, create object, invoke addition method") { TEST_CASE("Build script resolver, create object, invoke addition method") {
auto lib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); auto lib = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
lib->Initialize(TestLibrary::GetLibrary()); lib->Initialize(TestLibrary::GetLibrary());
lib->CreateScript("testScript1", _scripts["testScript1"]); lib->CreateScript("testScript1", _scripts["testScript1"]);
lib->FinalizeModule(); lib->FinalizeModule();
@ -79,7 +79,7 @@ TEST_CASE("Build script resolver, create object, invoke addition method") {
} }
TEST_CASE("Get a script resolver, save the byte code to memory, create new script resolver from it") { TEST_CASE("Get a script resolver, save the byte code to memory, create new script resolver from it") {
auto originLib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); auto originLib = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
originLib->Initialize(TestLibrary::GetLibrary()); originLib->Initialize(TestLibrary::GetLibrary());
originLib->CreateScript("testScript1", _scripts["testScript1"]); originLib->CreateScript("testScript1", _scripts["testScript1"]);
originLib->FinalizeModule(); originLib->FinalizeModule();
@ -97,7 +97,7 @@ TEST_CASE("Get a script resolver, save the byte code to memory, create new scrip
types.Insert(innerDb.first, newInnerDb); types.Insert(innerDb.first, newInnerDb);
} }
auto newLib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); auto newLib = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
newLib->Initialize(TestLibrary::GetLibrary()); newLib->Initialize(TestLibrary::GetLibrary());
newLib->LoadByteCodeFromMemory(byteCode, size, types); newLib->LoadByteCodeFromMemory(byteCode, size, types);
auto obj = dynamic_cast<AngelScriptScript*>(newLib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc)); auto obj = dynamic_cast<AngelScriptScript*>(newLib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc));

View File

@ -1,7 +1,7 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../../../extern/catch.hpp" #include "../../../../extern/catch.hpp"
#include "../../../../src/Battling/Pokemon/CreatePokemon.hpp" #include "../../../../src/Battling/Pokemon/CreatePokemon.hpp"
#include "../../../../src/ScriptResolving/AngelScript/AngelScripResolver.hpp" #include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../../../TestLibrary/TestLibrary.hpp" #include "../../../TestLibrary/TestLibrary.hpp"
static std::unordered_map<const char*, const char*> _scripts = static std::unordered_map<const char*, const char*> _scripts =
@ -32,7 +32,7 @@ class testScript1 {
struct ScriptData { struct ScriptData {
AngelScriptScript* Script = nullptr; AngelScriptScript* Script = nullptr;
AngelScripResolver* Resolver = nullptr; AngelScriptResolver* Resolver = nullptr;
asIScriptFunction* Func = nullptr; asIScriptFunction* Func = nullptr;
asIScriptContext* Context = nullptr; asIScriptContext* Context = nullptr;
@ -42,10 +42,10 @@ struct ScriptData {
} }
}; };
static AngelScripResolver* _resolverCache = nullptr; static AngelScriptResolver* _resolverCache = nullptr;
static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib) { static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib) {
if (_resolverCache == nullptr) { if (_resolverCache == nullptr) {
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); _resolverCache = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
_resolverCache->Initialize(mainLib); _resolverCache->Initialize(mainLib);
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]); _resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
_resolverCache->FinalizeModule(); _resolverCache->FinalizeModule();

View File

@ -1,6 +1,6 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../../../extern/catch.hpp" #include "../../../../extern/catch.hpp"
#include "../../../../src/ScriptResolving/AngelScript/AngelScripResolver.hpp" #include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../../../TestLibrary/TestLibrary.hpp" #include "../../../TestLibrary/TestLibrary.hpp"
static std::unordered_map<const char*, const char*> _scripts = static std::unordered_map<const char*, const char*> _scripts =
@ -21,7 +21,7 @@ class testScript1 {
struct ScriptData { struct ScriptData {
AngelScriptScript* Script = nullptr; AngelScriptScript* Script = nullptr;
AngelScripResolver* Resolver = nullptr; AngelScriptResolver* Resolver = nullptr;
asIScriptFunction* Func = nullptr; asIScriptFunction* Func = nullptr;
asIScriptContext* Context = nullptr; asIScriptContext* Context = nullptr;
@ -31,10 +31,10 @@ struct ScriptData {
} }
}; };
static AngelScripResolver* _resolverCache = nullptr; static AngelScriptResolver* _resolverCache = nullptr;
static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){
if (_resolverCache == nullptr){ if (_resolverCache == nullptr){
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); _resolverCache = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
_resolverCache->Initialize(mainLib); _resolverCache->Initialize(mainLib);
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]); _resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
_resolverCache->FinalizeModule(); _resolverCache->FinalizeModule();

View File

@ -1,6 +1,6 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../../../extern/catch.hpp" #include "../../../../extern/catch.hpp"
#include "../../../../src/ScriptResolving/AngelScript/AngelScripResolver.hpp" #include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../../../TestLibrary/TestLibrary.hpp" #include "../../../TestLibrary/TestLibrary.hpp"
static std::unordered_map<const char*, const char*> _scripts = static std::unordered_map<const char*, const char*> _scripts =
@ -17,7 +17,7 @@ class testScript1 {
struct ScriptData { struct ScriptData {
AngelScriptScript* Script = nullptr; AngelScriptScript* Script = nullptr;
AngelScripResolver* Resolver = nullptr; AngelScriptResolver* Resolver = nullptr;
asIScriptFunction* Func = nullptr; asIScriptFunction* Func = nullptr;
asIScriptContext* Context = nullptr; asIScriptContext* Context = nullptr;
@ -27,10 +27,10 @@ struct ScriptData {
} }
}; };
static AngelScripResolver* _resolverCache = nullptr; static AngelScriptResolver* _resolverCache = nullptr;
static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){
if (_resolverCache == nullptr){ if (_resolverCache == nullptr){
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); _resolverCache = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
_resolverCache->Initialize(mainLib); _resolverCache->Initialize(mainLib);
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]); _resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
_resolverCache->FinalizeModule(); _resolverCache->FinalizeModule();

View File

@ -1,6 +1,6 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../../../extern/catch.hpp" #include "../../../../extern/catch.hpp"
#include "../../../../src/ScriptResolving/AngelScript/AngelScripResolver.hpp" #include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../../../TestLibrary/TestLibrary.hpp" #include "../../../TestLibrary/TestLibrary.hpp"
static std::unordered_map<const char*, const char*> _scripts = static std::unordered_map<const char*, const char*> _scripts =
@ -21,7 +21,7 @@ class testScript1 {
struct ScriptData { struct ScriptData {
AngelScriptScript* Script = nullptr; AngelScriptScript* Script = nullptr;
AngelScripResolver* Resolver = nullptr; AngelScriptResolver* Resolver = nullptr;
asIScriptFunction* Func = nullptr; asIScriptFunction* Func = nullptr;
asIScriptContext* Context = nullptr; asIScriptContext* Context = nullptr;
@ -31,10 +31,10 @@ struct ScriptData {
} }
}; };
static AngelScripResolver* _resolverCache = nullptr; static AngelScriptResolver* _resolverCache = nullptr;
static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){
if (_resolverCache == nullptr){ if (_resolverCache == nullptr){
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); _resolverCache = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
_resolverCache->Initialize(mainLib); _resolverCache->Initialize(mainLib);
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]); _resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
_resolverCache->FinalizeModule(); _resolverCache->FinalizeModule();

View File

@ -1,6 +1,6 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../../../extern/catch.hpp" #include "../../../../extern/catch.hpp"
#include "../../../../src/ScriptResolving/AngelScript/AngelScripResolver.hpp" #include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../../../TestLibrary/TestLibrary.hpp" #include "../../../TestLibrary/TestLibrary.hpp"
static std::unordered_map<const char*, const char*> _scripts = static std::unordered_map<const char*, const char*> _scripts =
@ -19,7 +19,7 @@ class testScript1 {
struct ScriptData { struct ScriptData {
AngelScriptScript* Script; AngelScriptScript* Script;
AngelScripResolver* Resolver; AngelScriptResolver* Resolver;
asIScriptFunction* Func; asIScriptFunction* Func;
asIScriptContext* Context; asIScriptContext* Context;
@ -29,10 +29,10 @@ struct ScriptData {
} }
}; };
static AngelScripResolver* _resolverCache = nullptr; static AngelScriptResolver* _resolverCache = nullptr;
static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){
if (_resolverCache == nullptr){ if (_resolverCache == nullptr){
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); _resolverCache = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
_resolverCache->Initialize(mainLib); _resolverCache->Initialize(mainLib);
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]); _resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
_resolverCache->FinalizeModule(); _resolverCache->FinalizeModule();

View File

@ -1,6 +1,6 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../../../extern/catch.hpp" #include "../../../../extern/catch.hpp"
#include "../../../../src/ScriptResolving/AngelScript/AngelScripResolver.hpp" #include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../../../TestLibrary/TestLibrary.hpp" #include "../../../TestLibrary/TestLibrary.hpp"
static std::unordered_map<const char*, const char*> _scripts = static std::unordered_map<const char*, const char*> _scripts =
@ -20,7 +20,7 @@ class testScript1 {
struct ScriptData { struct ScriptData {
AngelScriptScript* Script; AngelScriptScript* Script;
AngelScripResolver* Resolver; AngelScriptResolver* Resolver;
asIScriptFunction* Func; asIScriptFunction* Func;
asIScriptContext* Context; asIScriptContext* Context;
@ -30,10 +30,10 @@ struct ScriptData {
} }
}; };
static AngelScripResolver* _resolverCache = nullptr; static AngelScriptResolver* _resolverCache = nullptr;
static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* mainLib){
if (_resolverCache == nullptr){ if (_resolverCache == nullptr){
_resolverCache = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); _resolverCache = dynamic_cast<AngelScriptResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
_resolverCache->Initialize(mainLib); _resolverCache->Initialize(mainLib);
_resolverCache->CreateScript("testScript1" , _scripts["testScript1"]); _resolverCache->CreateScript("testScript1" , _scripts["testScript1"]);
_resolverCache->FinalizeModule(); _resolverCache->FinalizeModule();