From d50926afba0f33bd22131b3b2730ee8453565fe2 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Tue, 7 Jul 2020 15:54:25 +0200 Subject: [PATCH] Cleanup of CInterface, removed operator-> on BorrowedPtr, as it throws when null. --- CInterface/Battling/Pokemon.cpp | 10 +--------- CInterface/Core.hpp | 5 +++++ CInterface/Library/Item.cpp | 7 +------ CInterface/Library/LibrarySettings.cpp | 7 +------ CInterface/Library/Nature.cpp | 5 ----- CInterface/Library/PokemonSpecies.cpp | 6 ------ 6 files changed, 8 insertions(+), 32 deletions(-) diff --git a/CInterface/Battling/Pokemon.cpp b/CInterface/Battling/Pokemon.cpp index fd1c293..30a8c53 100644 --- a/CInterface/Battling/Pokemon.cpp +++ b/CInterface/Battling/Pokemon.cpp @@ -22,11 +22,6 @@ export Pokemon* PkmnLib_Pokemon_Construct(const BattleLibrary* library, const Pk export void PkmnLib_Pokemon_Destruct(const Pokemon* p) { delete p; } -#define SIMPLE_GET_FUNC(type, name, returnType) \ - export returnType PkmnLib_##type##_##name(const PkmnLib::Battling::type* p) { return p->name(); } -#define SIMPLE_GET_FUNC_SMART_PTR(type, name, returnType) \ - export returnType PkmnLib_##type##_##name(const PkmnLib::Battling::type* p) { return p->name().operator->(); } - SIMPLE_GET_FUNC(Pokemon, IsShiny, bool) SIMPLE_GET_FUNC_SMART_PTR(Pokemon, GetNature, const PkmnLib::Library::Nature*) @@ -37,7 +32,4 @@ export uint8_t PkmnLib_Pokemon_GetIndividualValue(const Pokemon* p, CreatureLib: } export uint8_t PkmnLib_Pokemon_GetEffortValue(const Pokemon* p, CreatureLib::Library::Statistic stat) { return p->GetEffortValue(stat); -} - -#undef SIMPLE_GET_FUNC -#undef SIMPLE_GET_FUNC_SMART_PTR \ No newline at end of file +} \ No newline at end of file diff --git a/CInterface/Core.hpp b/CInterface/Core.hpp index ee85466..780c678 100644 --- a/CInterface/Core.hpp +++ b/CInterface/Core.hpp @@ -26,4 +26,9 @@ public: return PkmnLibException; \ } +#define SIMPLE_GET_FUNC(type, name, returnType) \ + export returnType PkmnLib_##type##_##name(const type* p) { return p->name(); } +#define SIMPLE_GET_FUNC_SMART_PTR(type, name, returnType) \ + export returnType PkmnLib_##type##_##name(const type* p) { return p->name().GetRaw(); } + #endif // PKMNLIB_CORE_HPP diff --git a/CInterface/Library/Item.cpp b/CInterface/Library/Item.cpp index cc11304..d397c8a 100644 --- a/CInterface/Library/Item.cpp +++ b/CInterface/Library/Item.cpp @@ -16,9 +16,4 @@ export Item* PkmnLib_Item_Construct(const char* name, CreatureLib::Library::Item export void PkmnLib_Item_Destruct(const Item* p) { delete p; } -#define SIMPLE_GET_FUNC(type, name, returnType) \ - export returnType PkmnLib_##type##_##name(const PkmnLib::Library::type* p) { return p->name(); } - -SIMPLE_GET_FUNC(Item, GetFlingPower, uint8_t) - -#undef SIMPLE_GET_FUNC +SIMPLE_GET_FUNC(Item, GetFlingPower, uint8_t) \ No newline at end of file diff --git a/CInterface/Library/LibrarySettings.cpp b/CInterface/Library/LibrarySettings.cpp index 3ffb1f7..9dafa48 100644 --- a/CInterface/Library/LibrarySettings.cpp +++ b/CInterface/Library/LibrarySettings.cpp @@ -9,9 +9,4 @@ export const LibrarySettings* PkmnLib_LibrarySettings_Construct(uint8_t maximalL export void PkmnLib_LibrarySettings_Destruct(const LibrarySettings* p) { delete p; } -#define SIMPLE_GET_FUNC(type, name, returnType) \ - export returnType PkmnLib_##type##_##name(const PkmnLib::Library::type* p) { return p->name(); } - -SIMPLE_GET_FUNC(LibrarySettings, GetShinyRate, uint16_t); - -#undef SIMPLE_GET_FUNC \ No newline at end of file +SIMPLE_GET_FUNC(LibrarySettings, GetShinyRate, uint16_t); \ No newline at end of file diff --git a/CInterface/Library/Nature.cpp b/CInterface/Library/Nature.cpp index 2f64ed3..cd71aca 100644 --- a/CInterface/Library/Nature.cpp +++ b/CInterface/Library/Nature.cpp @@ -9,16 +9,11 @@ export Nature* PkmnLib_Nature_Construct(CreatureLib::Library::Statistic increase } export void PkmnLib_Nature_Destruct(const Nature* p) { delete p; } -#define SIMPLE_GET_FUNC(type, name, returnType) \ - export returnType PkmnLib_##type##_##name(const PkmnLib::Library::type* p) { return p->name(); } - SIMPLE_GET_FUNC(Nature, GetIncreaseModifier, float) SIMPLE_GET_FUNC(Nature, GetDecreaseModifier, float) SIMPLE_GET_FUNC(Nature, GetIncreasedStat, CreatureLib::Library::Statistic) SIMPLE_GET_FUNC(Nature, GetDecreasedStat, CreatureLib::Library::Statistic) -#undef SIMPLE_GET_FUNC - export float PkmnLib_Nature_GetStatModifier(const PkmnLib::Library::Nature* nature, CreatureLib::Library::Statistic stat) { return nature->GetStatModifier(stat); diff --git a/CInterface/Library/PokemonSpecies.cpp b/CInterface/Library/PokemonSpecies.cpp index b14c7eb..94ed981 100644 --- a/CInterface/Library/PokemonSpecies.cpp +++ b/CInterface/Library/PokemonSpecies.cpp @@ -11,13 +11,7 @@ export uint8_t PkmnLib_PokemonSpecies_Construct(const PokemonSpecies*& out, uint export void PkmnLib_PokemonSpecies_Destruct(const PokemonSpecies* p) { delete p; } -#define SIMPLE_GET_FUNC(type, name, returnType) \ - export returnType PkmnLib_##type##_##name(const PkmnLib::Library::type* p) { return p->name(); } - SIMPLE_GET_FUNC(PokemonSpecies, GetBaseHappiness, uint8_t); - -#undef SIMPLE_GET_FUNC - export void PkmnLib_PokemonSpecies_AddEvolution(PokemonSpecies* p, EvolutionData* evo) { p->AddEvolution(evo); } export size_t PkmnLib_PokemonSpecies_GetEvolutionCount(const PokemonSpecies* p) { return p->GetEvolutions().Count(); }