Fixed issue where using operator->() function directly in Angelscript threw an exception if the pointer was null.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
665c47aa91
commit
45f80444b9
|
@ -89,7 +89,7 @@ void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg)
|
||||||
|
|
||||||
_contextPool = new ContextPool(_engine);
|
_contextPool = new ContextPool(_engine);
|
||||||
}
|
}
|
||||||
SMART_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, CreatureLib::Battling::Battle, GetBattle);
|
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, CreatureLib::Battling::Battle, GetBattle);
|
||||||
|
|
||||||
void AngelScriptResolver::RegisterTypes() {
|
void AngelScriptResolver::RegisterTypes() {
|
||||||
// Register static library types
|
// Register static library types
|
||||||
|
|
|
@ -43,7 +43,7 @@ void RegisterBattleClass::RegisterBattleRandom(asIScriptEngine* engine) {
|
||||||
Assert(r >= 0);
|
Assert(r >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMART_PTR_GETTER_FUNC(PkmnLib::Battling::Battle, CreatureLib::Battling::ChoiceQueue, GetCurrentTurnQueue);
|
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Battle, CreatureLib::Battling::ChoiceQueue, GetCurrentTurnQueue);
|
||||||
|
|
||||||
void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {
|
void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {
|
||||||
[[maybe_unused]] int r = engine->RegisterObjectType("Battle", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
[[maybe_unused]] int r = engine->RegisterObjectType("Battle", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
|
|
|
@ -7,8 +7,8 @@ void RegisterExecutingAttack::Register(asIScriptEngine* engine) {
|
||||||
RegisterHitData(engine);
|
RegisterHitData(engine);
|
||||||
RegisterExecutingAttackType(engine);
|
RegisterExecutingAttackType(engine);
|
||||||
}
|
}
|
||||||
SMART_PTR_GETTER_FUNC(CreatureLib::Battling::ExecutingAttack, CreatureLib::Battling::Creature, GetUser);
|
BORROWED_PTR_GETTER_FUNC(CreatureLib::Battling::ExecutingAttack, CreatureLib::Battling::Creature, GetUser);
|
||||||
SMART_PTR_GETTER_FUNC(CreatureLib::Battling::ExecutingAttack, CreatureLib::Battling::LearnedAttack, GetAttack);
|
BORROWED_PTR_GETTER_FUNC(CreatureLib::Battling::ExecutingAttack, CreatureLib::Battling::LearnedAttack, GetAttack);
|
||||||
|
|
||||||
void RegisterExecutingAttack::RegisterHitData(asIScriptEngine* engine) {
|
void RegisterExecutingAttack::RegisterHitData(asIScriptEngine* engine) {
|
||||||
[[maybe_unused]] int r = engine->RegisterObjectType("HitData", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
[[maybe_unused]] int r = engine->RegisterObjectType("HitData", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
|
|
|
@ -41,7 +41,7 @@ void RegisterPokemonClass::RegisterMoveLearnMethod(asIScriptEngine* engine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ENUM__SIZE_WRAPPER(LearnedMove_LearnMethodWrapper, CreatureLib::Battling::LearnedAttack, GetLearnMethod)
|
ENUM__SIZE_WRAPPER(LearnedMove_LearnMethodWrapper, CreatureLib::Battling::LearnedAttack, GetLearnMethod)
|
||||||
SMART_PTR_GETTER_FUNC(CreatureLib::Battling::LearnedAttack, const CreatureLib::Library::AttackData, GetAttack);
|
BORROWED_PTR_GETTER_FUNC(CreatureLib::Battling::LearnedAttack, const CreatureLib::Library::AttackData, GetAttack);
|
||||||
|
|
||||||
void RegisterPokemonClass::RegisterLearnedAttack(asIScriptEngine* engine) {
|
void RegisterPokemonClass::RegisterLearnedAttack(asIScriptEngine* engine) {
|
||||||
[[maybe_unused]] int r = engine->RegisterObjectType("LearnedMove", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
[[maybe_unused]] int r = engine->RegisterObjectType("LearnedMove", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
|
@ -82,9 +82,9 @@ static bool HasHeldItem(const PkmnLib::Battling::Pokemon* obj, const ArbUt::Stri
|
||||||
|
|
||||||
static std::string NicknameWrapper(const PkmnLib::Battling::Pokemon* obj) { return std::string(obj->GetNickname()); }
|
static std::string NicknameWrapper(const PkmnLib::Battling::Pokemon* obj) { return std::string(obj->GetNickname()); }
|
||||||
|
|
||||||
SMART_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::CreatureSpecies, GetSpecies);
|
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::CreatureSpecies, GetSpecies);
|
||||||
SMART_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const PkmnLib::Library::PokemonForme, GetForme);
|
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const PkmnLib::Library::PokemonForme, GetForme);
|
||||||
SMART_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::Item, GetHeldItem);
|
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::Item, GetHeldItem);
|
||||||
|
|
||||||
void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||||
[[maybe_unused]] int r = engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
[[maybe_unused]] int r = engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
#define SMART_PTR_GETTER_FUNC(o, returns, funcName) \
|
#define BORROWED_PTR_GETTER_FUNC(o, returns, funcName) \
|
||||||
static returns* funcName##Wrapper(o* obj) { return obj->funcName().operator->(); }
|
static returns* funcName##Wrapper(o* obj) { return obj->funcName().GetRaw(); }
|
||||||
|
#define UNIQUE_PTR_GETTER_FUNC(o, returns, funcName) \
|
||||||
|
static returns* funcName##Wrapper(o* obj) { return obj->funcName().get(); }
|
||||||
|
|
|
@ -47,7 +47,7 @@ static const PkmnLib::Library::PokemonForme* GetFormeWrapper(const std::string&
|
||||||
.As<const PkmnLib::Library::PokemonForme>()
|
.As<const PkmnLib::Library::PokemonForme>()
|
||||||
.GetRaw();
|
.GetRaw();
|
||||||
}
|
}
|
||||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonSpecies, const PkmnLib::Library::PokemonForme, GetDefaultForme);
|
BORROWED_PTR_GETTER_FUNC(PkmnLib::Library::PokemonSpecies, const PkmnLib::Library::PokemonForme, GetDefaultForme);
|
||||||
|
|
||||||
void RegisterSpeciesTypes::RegisterSpeciesType(asIScriptEngine* engine) {
|
void RegisterSpeciesTypes::RegisterSpeciesType(asIScriptEngine* engine) {
|
||||||
[[maybe_unused]] int r = engine->RegisterObjectType("Species", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
[[maybe_unused]] int r = engine->RegisterObjectType("Species", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
|
|
|
@ -21,12 +21,12 @@ void RegisterStaticLibraryTypes::RegisterLibrarySettingsType(asIScriptEngine* en
|
||||||
assert(r >= 0);
|
assert(r >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::LibrarySettings, GetSettings);
|
UNIQUE_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::LibrarySettings, GetSettings);
|
||||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::SpeciesLibrary, GetSpeciesLibrary);
|
UNIQUE_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::SpeciesLibrary, GetSpeciesLibrary);
|
||||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::MoveLibrary, GetMoveLibrary);
|
UNIQUE_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::MoveLibrary, GetMoveLibrary);
|
||||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::ItemLibrary, GetItemLibrary);
|
UNIQUE_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::ItemLibrary, GetItemLibrary);
|
||||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const CreatureLib::Library::GrowthRateLibrary, GetGrowthRates);
|
UNIQUE_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const CreatureLib::Library::GrowthRateLibrary, GetGrowthRates);
|
||||||
SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const CreatureLib::Library::TypeLibrary, GetTypeLibrary);
|
UNIQUE_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const CreatureLib::Library::TypeLibrary, GetTypeLibrary);
|
||||||
|
|
||||||
void RegisterStaticLibraryTypes::RegisterLibraryType(asIScriptEngine* engine) {
|
void RegisterStaticLibraryTypes::RegisterLibraryType(asIScriptEngine* engine) {
|
||||||
[[maybe_unused]] int r = engine->RegisterObjectType("StaticLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
[[maybe_unused]] int r = engine->RegisterObjectType("StaticLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
|
|
Loading…
Reference in New Issue