Update to new Arbutils memory model.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -70,10 +70,13 @@ public:
|
||||
}
|
||||
|
||||
asITypeInfo* GetBaseType(const ArbUt::StringView& name) {
|
||||
asITypeInfo* t = nullptr;
|
||||
if (!_baseTypes.TryGet(name, t)) {
|
||||
asITypeInfo* t;
|
||||
auto v = _baseTypes.TryGet(name);
|
||||
if (!v.has_value()) {
|
||||
t = this->_engine->GetTypeInfoByDecl(name.c_str());
|
||||
_baseTypes.Insert(name, t);
|
||||
} else {
|
||||
t = v.value();
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -42,11 +42,11 @@ public:
|
||||
const char* GetDecl() { return _type->GetName(); }
|
||||
|
||||
asIScriptFunction* GetFunction(const ArbUt::BasicStringView& functionName) {
|
||||
asIScriptFunction* func;
|
||||
if (_functions.TryGet(functionName, func)) {
|
||||
return func;
|
||||
auto v = _functions.TryGet(functionName);
|
||||
if (v.has_value()) {
|
||||
return v.value();
|
||||
}
|
||||
func = _type->GetMethodByName(functionName.c_str());
|
||||
auto func = _type->GetMethodByName(functionName.c_str());
|
||||
if (func != nullptr) {
|
||||
func->AddRef();
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ static std::string NicknameWrapper(const PkmnLib::Battling::Pokemon* obj) { retu
|
||||
|
||||
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::CreatureSpecies, GetSpecies);
|
||||
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const PkmnLib::Library::PokemonForme, GetForme);
|
||||
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::Item, GetHeldItem);
|
||||
OPTIONAL_BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::Item, GetHeldItem);
|
||||
|
||||
void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#define BORROWED_PTR_GETTER_FUNC(o, returns, funcName) \
|
||||
static returns* funcName##Wrapper(o* obj) { return obj->funcName().GetRaw(); }
|
||||
#define OPTIONAL_BORROWED_PTR_GETTER_FUNC(o, returns, funcName) \
|
||||
static returns* funcName##Wrapper(o* obj) { return obj->funcName().GetValue(); }
|
||||
#define UNIQUE_PTR_GETTER_FUNC(o, returns, funcName) \
|
||||
static returns* funcName##Wrapper(o* obj) { return obj->funcName().get(); }
|
||||
|
||||
Reference in New Issue
Block a user