Update to new Arbutils memory model.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2020-12-12 14:25:27 +01:00
parent b6a5e41b51
commit 53bd6e7a94
19 changed files with 87 additions and 74 deletions

View File

@@ -91,7 +91,7 @@ void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg,
_contextPool = new ContextPool(_engine);
}
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, CreatureLib::Battling::Battle, GetBattle);
OPTIONAL_BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, CreatureLib::Battling::Battle, GetBattle);
void AngelScriptResolver::RegisterTypes() {
// Register static library types
@@ -129,23 +129,26 @@ void AngelScriptResolver::MessageCallback(const asSMessageInfo* msg, void*) {
CreatureLib::Battling::Script* AngelScriptResolver::LoadScript(ScriptCategory category,
const ArbUt::StringView& scriptName) {
ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo*> innerDb;
if (!_typeDatabase.TryGet(category, innerDb)) {
auto v = _typeDatabase.TryGet(category);
if (!v.has_value()) {
innerDb.Insert(scriptName, nullptr);
_typeDatabase.Insert(category, innerDb);
return nullptr;
} else {
innerDb = v.value();
}
AngelScriptTypeInfo* t;
if (!innerDb.TryGet(scriptName, t)) {
auto t = innerDb.TryGet(scriptName);
if (!t.has_value()) {
innerDb.Insert(scriptName, nullptr);
return nullptr;
}
if (t == nullptr) {
if (!t.has_value()) {
return nullptr;
}
auto ctx = _contextPool->RequestContext();
auto obj = t->Instantiate(ctx);
auto obj = const_cast<AngelScriptTypeInfo*>(t.value().get())->Instantiate(ctx);
_contextPool->ReturnContextToPool(ctx);
return new AngelScriptScript(this, t, obj, _contextPool);
return new AngelScriptScript(this, t.value(), obj, _contextPool);
}
void AngelScriptResolver::FinalizeModule() {
int r = _builder.BuildModule();