diff --git a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp index b0c9f49..681d1b9 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp @@ -89,7 +89,7 @@ void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg) _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() { // Register static library types diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp index 7a109ff..bcb5587 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp @@ -43,7 +43,7 @@ void RegisterBattleClass::RegisterBattleRandom(asIScriptEngine* engine) { 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) { [[maybe_unused]] int r = engine->RegisterObjectType("Battle", 0, asOBJ_REF | asOBJ_NOCOUNT); diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp index 9c41eba..0da6df4 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp @@ -7,8 +7,8 @@ void RegisterExecutingAttack::Register(asIScriptEngine* engine) { RegisterHitData(engine); RegisterExecutingAttackType(engine); } -SMART_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::Creature, GetUser); +BORROWED_PTR_GETTER_FUNC(CreatureLib::Battling::ExecutingAttack, CreatureLib::Battling::LearnedAttack, GetAttack); void RegisterExecutingAttack::RegisterHitData(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("HitData", 0, asOBJ_REF | asOBJ_NOCOUNT); diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp index 463fbd9..718b2c1 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp @@ -41,7 +41,7 @@ void RegisterPokemonClass::RegisterMoveLearnMethod(asIScriptEngine* engine) { } 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) { [[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()); } -SMART_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::CreatureSpecies, GetSpecies); -SMART_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::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); void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT); diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/HelperFile.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/HelperFile.hpp index 230138f..83d0ac7 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/HelperFile.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/HelperFile.hpp @@ -1,2 +1,4 @@ -#define SMART_PTR_GETTER_FUNC(o, returns, funcName) \ - static returns* funcName##Wrapper(o* obj) { return obj->funcName().operator->(); } +#define BORROWED_PTR_GETTER_FUNC(o, returns, funcName) \ + 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(); } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp index 9b04740..336595d 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp @@ -47,7 +47,7 @@ static const PkmnLib::Library::PokemonForme* GetFormeWrapper(const std::string& .As() .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) { [[maybe_unused]] int r = engine->RegisterObjectType("Species", 0, asOBJ_REF | asOBJ_NOCOUNT); diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterStaticLibraryTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterStaticLibraryTypes.cpp index 571a26c..a407549 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterStaticLibraryTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterStaticLibraryTypes.cpp @@ -21,12 +21,12 @@ void RegisterStaticLibraryTypes::RegisterLibrarySettingsType(asIScriptEngine* en assert(r >= 0); } -SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::LibrarySettings, GetSettings); -SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::SpeciesLibrary, GetSpeciesLibrary); -SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::MoveLibrary, GetMoveLibrary); -SMART_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::ItemLibrary, GetItemLibrary); -SMART_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 PkmnLib::Library::LibrarySettings, GetSettings); +UNIQUE_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::SpeciesLibrary, GetSpeciesLibrary); +UNIQUE_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::MoveLibrary, GetMoveLibrary); +UNIQUE_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const PkmnLib::Library::ItemLibrary, GetItemLibrary); +UNIQUE_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const CreatureLib::Library::GrowthRateLibrary, GetGrowthRates); +UNIQUE_PTR_GETTER_FUNC(PkmnLib::Library::PokemonLibrary, const CreatureLib::Library::TypeLibrary, GetTypeLibrary); void RegisterStaticLibraryTypes::RegisterLibraryType(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("StaticLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);