Enable pedantic errors
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2022-04-02 13:03:11 +02:00
parent 3739b0bb66
commit a6b1c8a8ec
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
28 changed files with 122 additions and 116 deletions

View File

@ -1,56 +1,56 @@
#include "../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp" #include "../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../Core.hpp" #include "../Core.hpp"
export AngelScriptResolver* PkmnLib_AngelScriptResolver_Construct() { return new AngelScriptResolver(); } export_func AngelScriptResolver* PkmnLib_AngelScriptResolver_Construct() { return new AngelScriptResolver(); }
export uint8_t PkmnLib_AngelScriptResolver_Destruct(AngelScriptResolver* p) { Try(delete p;) } export_func uint8_t PkmnLib_AngelScriptResolver_Destruct(AngelScriptResolver* p) { Try(delete p;) }
export uint8_t PkmnLib_AngelScriptResolver_Initialize(AngelScriptResolver* p, export_func uint8_t PkmnLib_AngelScriptResolver_Initialize(AngelScriptResolver* p,
CreatureLib::Battling::BattleLibrary* lib) { CreatureLib::Battling::BattleLibrary* lib) {
Try(p->Initialize(lib);) Try(p->Initialize(lib);)
} }
export uint8_t PkmnLib_AngelScriptResolver_CreateScript(AngelScriptResolver* p, const char* name, const char* script) { export_func uint8_t PkmnLib_AngelScriptResolver_CreateScript(AngelScriptResolver* p, const char* name, const char* script) {
Try(p->CreateScript(name, script);) Try(p->CreateScript(name, script);)
} }
export uint8_t PkmnLib_AngelScriptResolver_FinalizeModule(AngelScriptResolver* p) { Try(p->FinalizeModule();) } export_func uint8_t PkmnLib_AngelScriptResolver_FinalizeModule(AngelScriptResolver* p) { Try(p->FinalizeModule();) }
export uint8_t PkmnLib_AngelScriptResolver_LoadScript(CreatureLib::Battling::BattleScript*& out, AngelScriptResolver* p, export_func uint8_t PkmnLib_AngelScriptResolver_LoadScript(CreatureLib::Battling::BattleScript*& out, AngelScriptResolver* p,
void* owner, ScriptCategory category, const char* scriptName) { void* owner, ScriptCategory category, const char* scriptName) {
Try(out = p->LoadScript(owner, category, ArbUt::StringView(scriptName));) Try(out = p->LoadScript(owner, category, ArbUt::StringView(scriptName));)
} }
export uint8_t PkmnLib_AngelScriptResolver_LoadEvolutionScript(PkmnLib::Battling::EvolutionScript const*& out, export_func uint8_t PkmnLib_AngelScriptResolver_LoadEvolutionScript(PkmnLib::Battling::EvolutionScript const*& out,
AngelScriptResolver* p, const char* scriptName) { AngelScriptResolver* p, const char* scriptName) {
Try( Try(
auto s = p->LoadEvolutionScript(ArbUt::StringView(scriptName)); auto s = p->LoadEvolutionScript(ArbUt::StringView(scriptName));
if (!s.HasValue()) { out = nullptr; } else { out = s.GetValue(); }) if (!s.HasValue()) { out = nullptr; } else { out = s.GetValue(); })
} }
export uint8_t PkmnLib_AngelScriptResolver_WriteByteCodeToFile(AngelScriptResolver* p, const char* file, export_func uint8_t PkmnLib_AngelScriptResolver_WriteByteCodeToFile(AngelScriptResolver* p, const char* file,
bool stripDebugInfo) { bool stripDebugInfo) {
Try(p->WriteByteCodeToFile(file, stripDebugInfo);) Try(p->WriteByteCodeToFile(file, stripDebugInfo);)
} }
export uint8_t PkmnLib_AngelScriptResolver_LoadByteCodeFromFile(AngelScriptResolver* p, const char* file) { export_func uint8_t PkmnLib_AngelScriptResolver_LoadByteCodeFromFile(AngelScriptResolver* p, const char* file) {
Try(p->LoadByteCodeFromFile(file);) Try(p->LoadByteCodeFromFile(file);)
} }
export uint8_t PkmnLib_AngelScriptResolver_WriteByteCodeToMemory(AngelScriptResolver* p, bool stripDebugInfo, export_func uint8_t PkmnLib_AngelScriptResolver_WriteByteCodeToMemory(AngelScriptResolver* p, bool stripDebugInfo,
size_t& size, uint8_t*& out) { size_t& size, uint8_t*& out) {
Try(out = p->WriteByteCodeToMemory(size, stripDebugInfo);) Try(out = p->WriteByteCodeToMemory(size, stripDebugInfo);)
} }
export uint8_t PkmnLib_AngelScriptResolver_LoadByteCodeFromMemory(AngelScriptResolver* p, uint8_t* memory, export_func uint8_t PkmnLib_AngelScriptResolver_LoadByteCodeFromMemory(AngelScriptResolver* p, uint8_t* memory,
size_t size) { size_t size) {
Try(p->LoadByteCodeFromMemory(memory, size);) Try(p->LoadByteCodeFromMemory(memory, size);)
} }
export uint8_t PkmnLib_AngelScriptResolver_RegisterType(AngelScriptResolver* p, const char* typeName) { export_func uint8_t PkmnLib_AngelScriptResolver_RegisterType(AngelScriptResolver* p, const char* typeName) {
Try(p->RegisterType(typeName);) Try(p->RegisterType(typeName);)
} }
export uint8_t PkmnLib_AngelScriptResolver_RegisterTypeMethod(AngelScriptResolver* p, const char* typeName, export_func uint8_t PkmnLib_AngelScriptResolver_RegisterTypeMethod(AngelScriptResolver* p, const char* typeName,
const char* decl, void*(func)(void*)) { const char* decl, void*(func)(void*)) {
Try(p->RegisterTypeMethod(typeName, decl, func);) Try(p->RegisterTypeMethod(typeName, decl, func);)
} }
export uint8_t PkmnLib_AngelScriptResolver_RegisterGlobalMethod(AngelScriptResolver* p, const char* decl, export_func uint8_t PkmnLib_AngelScriptResolver_RegisterGlobalMethod(AngelScriptResolver* p, const char* decl,
void*(func)(void*)) { void*(func)(void*)) {
Try(p->RegisterGlobalMethod(decl, func);) Try(p->RegisterGlobalMethod(decl, func);)
} }
export void PkmnLib_AngelScriptResolver_DefineWord(AngelScriptResolver* p, const char* word) { p->DefineWord(word); } export_func void PkmnLib_AngelScriptResolver_DefineWord(AngelScriptResolver* p, const char* word) { p->DefineWord(word); }
#ifdef ANGELSCRIPT_DEBUGGER #ifdef ANGELSCRIPT_DEBUGGER
export void PkmnLib_AngelScriptResolver_AddDebugger(AngelScriptResolver* p, u16 port) { export void PkmnLib_AngelScriptResolver_AddDebugger(AngelScriptResolver* p, u16 port) {

View File

@ -1,4 +1,4 @@
#include "../../src/ScriptResolving/AngelScript/AngelScriptScript.hpp" #include "../../src/ScriptResolving/AngelScript/AngelScriptScript.hpp"
#include "../Core.hpp" #include "../Core.hpp"
export uint8_t PkmnLib_AngelscriptScript_Destruct(AngelScriptScript* p) { Try(delete p;) } export_func uint8_t PkmnLib_AngelscriptScript_Destruct(AngelScriptScript* p) { Try(delete p;) }

View File

@ -2,7 +2,7 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Battling; using namespace PkmnLib::Battling;
export uint8_t PkmnLib_Battle_Construct(Battle*& out, const BattleLibrary* library, export_func uint8_t PkmnLib_Battle_Construct(Battle*& out, const BattleLibrary* library,
CreatureLib::Battling::BattleParty* const* parties, size_t partiesCount, CreatureLib::Battling::BattleParty* const* parties, size_t partiesCount,
bool canFlee, uint8_t numberOfSides, uint8_t creaturesPerSide, bool canFlee, uint8_t numberOfSides, uint8_t creaturesPerSide,
uint_fast32_t randomSeed) { uint_fast32_t randomSeed) {
@ -10,7 +10,7 @@ export uint8_t PkmnLib_Battle_Construct(Battle*& out, const BattleLibrary* libra
Try(out = new Battle(library, partiesList, canFlee, numberOfSides, creaturesPerSide, randomSeed)); Try(out = new Battle(library, partiesList, canFlee, numberOfSides, creaturesPerSide, randomSeed));
} }
export void PkmnLib_Battle_Destruct(Battle* p) { p->~Battle(); } export_func void PkmnLib_Battle_Destruct(Battle* p) { p->~Battle(); }
export uint8_t PkmnLib_Battle_SetWeather(Battle* p, const char* name) { Try(p->SetWeather(ArbUt::StringView(name))); }; export_func uint8_t PkmnLib_Battle_SetWeather(Battle* p, const char* name) { Try(p->SetWeather(ArbUt::StringView(name))); };
export uint8_t PkmnLib_Battle_ClearWeather(Battle* p) { Try(p->ClearWeather()); }; export_func uint8_t PkmnLib_Battle_ClearWeather(Battle* p) { Try(p->ClearWeather()); };
export const char* PkmnLib_Battle_GetWeatherName(Battle* p) { return p->GetWeatherName().c_str(); } export_func const char* PkmnLib_Battle_GetWeatherName(Battle* p) { return p->GetWeatherName().c_str(); }

View File

@ -2,7 +2,7 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Battling; using namespace PkmnLib::Battling;
export uint8_t PkmnLib_BattleLibrary_Construct(BattleLibrary*& out, PkmnLib::Library::PokemonLibrary* staticLib, export_func uint8_t PkmnLib_BattleLibrary_Construct(BattleLibrary*& out, PkmnLib::Library::PokemonLibrary* staticLib,
StatCalculator* statCalculator, DamageLibrary* damageLibrary, StatCalculator* statCalculator, DamageLibrary* damageLibrary,
ExperienceLibrary* experienceLibrary, ExperienceLibrary* experienceLibrary,
PkmnLib::Battling::ScriptResolver* scriptResolver, PkmnLib::Battling::ScriptResolver* scriptResolver,
@ -11,7 +11,7 @@ export uint8_t PkmnLib_BattleLibrary_Construct(BattleLibrary*& out, PkmnLib::Lib
miscLibrary, captureLibrary)); miscLibrary, captureLibrary));
} }
export void PkmnLib_BattleLibrary_Destruct(BattleLibrary* p) { delete p; } export_func void PkmnLib_BattleLibrary_Destruct(BattleLibrary* p) { delete p; }
export uint8_t PkmnLib_CaptureLibrary_Construct(CaptureLibrary*& out) { Try(out = new CaptureLibrary()); } export_func uint8_t PkmnLib_CaptureLibrary_Construct(CaptureLibrary*& out) { Try(out = new CaptureLibrary()); }
export void PkmnLib_CaptureLibrary_Destruct(CaptureLibrary* p) { delete p; } export_func void PkmnLib_CaptureLibrary_Destruct(CaptureLibrary* p) { delete p; }

View File

@ -2,6 +2,6 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Battling; using namespace PkmnLib::Battling;
export DamageLibrary* PkmnLib_DamageLibrary_Construct() { return new DamageLibrary(); } export_func DamageLibrary* PkmnLib_DamageLibrary_Construct() { return new DamageLibrary(); }
export void PkmnLib_DamageLibrary_Destruct(DamageLibrary* p) { delete p; } export_func void PkmnLib_DamageLibrary_Destruct(DamageLibrary* p) { delete p; }

View File

@ -3,16 +3,16 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Battling; using namespace PkmnLib::Battling;
export void PkmnLib_WeatherChangeEvent_Destruct(WeatherChangeEvent* p) { delete p; } export_func void PkmnLib_WeatherChangeEvent_Destruct(WeatherChangeEvent* p) { delete p; }
export const char* PkmnLib_WeatherChangeEvent_GetWeatherName(WeatherChangeEvent* p) { export_func const char* PkmnLib_WeatherChangeEvent_GetWeatherName(WeatherChangeEvent* p) {
return p->GetWeatherName().c_str(); return p->GetWeatherName().c_str();
} }
export void PkmnLib_CaptureAttemptEvent_Destruct(CaptureAttemptEvent* p) { delete p; } export_func void PkmnLib_CaptureAttemptEvent_Destruct(CaptureAttemptEvent* p) { delete p; }
export const PkmnLib::Battling::Pokemon* PkmnLib_CaptureAttemptEvent_GetPokemon(CaptureAttemptEvent* p) { export_func const PkmnLib::Battling::Pokemon* PkmnLib_CaptureAttemptEvent_GetPokemon(CaptureAttemptEvent* p) {
return p->GetPokemon(); return p->GetPokemon();
} }
export const PkmnLib::Battling::CaptureLibrary::CaptureResult export_func const PkmnLib::Battling::CaptureLibrary::CaptureResult
PkmnLib_CaptureAttemptEvent_GetResult(CaptureAttemptEvent* p) { PkmnLib_CaptureAttemptEvent_GetResult(CaptureAttemptEvent* p) {
return p->GetResult(); return p->GetResult();
} }

View File

@ -2,9 +2,9 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Battling; using namespace PkmnLib::Battling;
export ExperienceLibrary* PkmnLib_ExperienceLibrary_Construct() { return new ExperienceLibrary(); } export_func ExperienceLibrary* PkmnLib_ExperienceLibrary_Construct() { return new ExperienceLibrary(); }
export uint8_t PkmnLib_ExperienceLibrary_HandleExperienceGain(ExperienceLibrary* p, export_func uint8_t PkmnLib_ExperienceLibrary_HandleExperienceGain(ExperienceLibrary* p,
CreatureLib::Battling::Creature* faintedMon, CreatureLib::Battling::Creature* faintedMon,
CreatureLib::Battling::Creature* const* opponents, CreatureLib::Battling::Creature* const* opponents,
size_t numberOfOpponents) { size_t numberOfOpponents) {
@ -12,4 +12,4 @@ export uint8_t PkmnLib_ExperienceLibrary_HandleExperienceGain(ExperienceLibrary*
opponents, opponents + numberOfOpponents));) opponents, opponents + numberOfOpponents));)
} }
export void PkmnLib_ExperienceLibrary_Destruct(ExperienceLibrary* p) { delete p; } export_func void PkmnLib_ExperienceLibrary_Destruct(ExperienceLibrary* p) { delete p; }

View File

@ -2,13 +2,13 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Battling; using namespace PkmnLib::Battling;
export MiscLibrary* PkmnLib_MiscLibrary_Construct(PkmnLib::Library::TimeOfDay (*getTime)()) { export_func MiscLibrary* PkmnLib_MiscLibrary_Construct(PkmnLib::Library::TimeOfDay (*getTime)()) {
return new MiscLibrary(getTime); return new MiscLibrary(getTime);
} }
export void PkmnLib_MiscLibrary_Destruct(MiscLibrary* p) { delete p; } export_func void PkmnLib_MiscLibrary_Destruct(MiscLibrary* p) { delete p; }
export u8 PkmnLib_MiscLibrary_CanEvolveFromLevelUp(bool& out, MiscLibrary* p, export_func u8 PkmnLib_MiscLibrary_CanEvolveFromLevelUp(bool& out, MiscLibrary* p,
const PkmnLib::Library::EvolutionData* evoData, const PkmnLib::Library::EvolutionData* evoData,
const Pokemon* pokemon) { const Pokemon* pokemon) {
Try(out = p->CanEvolveFromLevelUp(evoData, pokemon)) Try(out = p->CanEvolveFromLevelUp(evoData, pokemon))

View File

@ -4,14 +4,14 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Battling; using namespace PkmnLib::Battling;
export uint8_t PkmnLib_PkmnScript_ModifyCriticalStage(PkmnScript* script, export_func uint8_t PkmnLib_PkmnScript_ModifyCriticalStage(PkmnScript* script,
CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::ExecutingAttack* attack,
CreatureLib::Battling::Creature* target, uint8_t hit, CreatureLib::Battling::Creature* target, uint8_t hit,
uint8_t* critStage) { uint8_t* critStage) {
Try(script->ModifyCriticalStage(attack, target, hit, critStage);) Try(script->ModifyCriticalStage(attack, target, hit, critStage);)
} }
export u8 PkmnLib_EvolutionScript_DoesEvolveFromLevelUp(EvolutionScript* script, export_func u8 PkmnLib_EvolutionScript_DoesEvolveFromLevelUp(EvolutionScript* script,
const PkmnLib::Library::EvolutionData* evoData, const PkmnLib::Library::EvolutionData* evoData,
const Pokemon* pokemon, bool* out) { const Pokemon* pokemon, bool* out) {
Try(script->DoesEvolveFromLevelUp(evoData, pokemon, out)); Try(script->DoesEvolveFromLevelUp(evoData, pokemon, out));

View File

@ -2,7 +2,7 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Battling; using namespace PkmnLib::Battling;
export uint8_t export_func uint8_t
PkmnLib_Pokemon_Construct(Pokemon*& out, const BattleLibrary* library, const PkmnLib::Library::PokemonSpecies* species, PkmnLib_Pokemon_Construct(Pokemon*& out, const BattleLibrary* library, const PkmnLib::Library::PokemonSpecies* species,
const PkmnLib::Library::PokemonForme* forme, uint8_t level, uint32_t experience, uint32_t uid, const PkmnLib::Library::PokemonForme* forme, uint8_t level, uint32_t experience, uint32_t uid,
CreatureLib::Library::Gender gender, uint8_t coloring, const PkmnLib::Library::Item* heldItem, CreatureLib::Library::Gender gender, uint8_t coloring, const PkmnLib::Library::Item* heldItem,
@ -27,37 +27,37 @@ PkmnLib_Pokemon_Construct(Pokemon*& out, const BattleLibrary* library, const Pkm
}) })
}; };
export void PkmnLib_Pokemon_Destruct(const Pokemon* p) { delete p; } export_func void PkmnLib_Pokemon_Destruct(const Pokemon* p) { delete p; }
SIMPLE_GET_FUNC(Pokemon, IsShiny, bool) SIMPLE_GET_FUNC(Pokemon, IsShiny, bool)
SIMPLE_GET_FUNC(Pokemon, WasCaught, bool) SIMPLE_GET_FUNC(Pokemon, WasCaught, bool)
SIMPLE_GET_FUNC_SMART_PTR(Pokemon, GetNature, const PkmnLib::Library::Nature*) SIMPLE_GET_FUNC_SMART_PTR(Pokemon, GetNature, const PkmnLib::Library::Nature*)
export u8 PkmnLib_Pokemon_GetIndividualValue(const Pokemon* p, CreatureLib::Library::Statistic stat) { export_func u8 PkmnLib_Pokemon_GetIndividualValue(const Pokemon* p, CreatureLib::Library::Statistic stat) {
return p->GetIndividualValue(stat); return p->GetIndividualValue(stat);
} }
export void PkmnLib_Pokemon_SetIndividualValue(Pokemon* p, CreatureLib::Library::Statistic stat, uint8_t value) { export_func void PkmnLib_Pokemon_SetIndividualValue(Pokemon* p, CreatureLib::Library::Statistic stat, uint8_t value) {
p->SetIndividualValue(stat, value); p->SetIndividualValue(stat, value);
} }
export u8 PkmnLib_Pokemon_GetEffortValue(const Pokemon* p, CreatureLib::Library::Statistic stat) { export_func u8 PkmnLib_Pokemon_GetEffortValue(const Pokemon* p, CreatureLib::Library::Statistic stat) {
return p->GetEffortValue(stat); return p->GetEffortValue(stat);
} }
export void PkmnLib_Pokemon_SetEffortValue(Pokemon* p, CreatureLib::Library::Statistic stat, uint8_t value) { export_func void PkmnLib_Pokemon_SetEffortValue(Pokemon* p, CreatureLib::Library::Statistic stat, uint8_t value) {
p->SetEffortValue(stat, value); p->SetEffortValue(stat, value);
} }
SIMPLE_GET_FUNC(Pokemon, GetFriendship, uint8_t) SIMPLE_GET_FUNC(Pokemon, GetFriendship, uint8_t)
export void PkmnLib_Pokemon_SetFriendship(Pokemon* p, u8 value) { p->SetFriendship(value); } export_func void PkmnLib_Pokemon_SetFriendship(Pokemon* p, u8 value) { p->SetFriendship(value); }
export void PkmnLib_Pokemon_ChangeFriendship(Pokemon* p, i8 amount) { p->ChangeFriendship(amount); } export_func void PkmnLib_Pokemon_ChangeFriendship(Pokemon* p, i8 amount) { p->ChangeFriendship(amount); }
SIMPLE_GET_FUNC(Pokemon, IsEgg, bool) SIMPLE_GET_FUNC(Pokemon, IsEgg, bool)
export void PkmnLib_Pokemon_SetIsEgg(Pokemon* p, bool value) { p->SetIsEgg(value); } export_func void PkmnLib_Pokemon_SetIsEgg(Pokemon* p, bool value) { p->SetIsEgg(value); }
export u8 PkmnLib_Pokemon_Evolve(Pokemon* p, const PkmnLib::Library::PokemonSpecies* species, export_func u8 PkmnLib_Pokemon_Evolve(Pokemon* p, const PkmnLib::Library::PokemonSpecies* species,
const PkmnLib::Library::PokemonForme* forme) { const PkmnLib::Library::PokemonForme* forme) {
Try(p->Evolve(species, forme);) Try(p->Evolve(species, forme);)
} }
export u8 PkmnLib_Pokemon_AttemptCapture(Pokemon* p, PkmnLib::Library::Item* non_null catchItem) { export_func u8 PkmnLib_Pokemon_AttemptCapture(Pokemon* p, PkmnLib::Library::Item* non_null catchItem) {
Try(p->AttemptCapture(catchItem);) Try(p->AttemptCapture(catchItem);)
} }

View File

@ -2,6 +2,6 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Battling; using namespace PkmnLib::Battling;
export StatCalculator* PkmnLib_StatCalculator_Construct() { return new StatCalculator(); } export_func StatCalculator* PkmnLib_StatCalculator_Construct() { return new StatCalculator(); }
export void PkmnLib_StatCalculator_Destruct(StatCalculator* p) { delete p; } export_func void PkmnLib_StatCalculator_Destruct(StatCalculator* p) { delete p; }

View File

@ -3,5 +3,5 @@
std::string ExceptionHandler::_pkmnLibLastException = ""; std::string ExceptionHandler::_pkmnLibLastException = "";
std::string ExceptionHandler::_pkmnLibLastExceptionStacktrace = "Unset"; std::string ExceptionHandler::_pkmnLibLastExceptionStacktrace = "Unset";
export const char* PkmnLib_C_GetLastException() { return ExceptionHandler::GetLastException(); } export_func const char* PkmnLib_C_GetLastException() { return ExceptionHandler::GetLastException(); }
export const char* PkmnLib_C_GetLastExceptionStacktrace() { return ExceptionHandler::GetLastExceptionStacktrace(); } export_func const char* PkmnLib_C_GetLastExceptionStacktrace() { return ExceptionHandler::GetLastExceptionStacktrace(); }

View File

@ -6,7 +6,7 @@
#include <exception> #include <exception>
#include <sstream> #include <sstream>
#include <string> #include <string>
#define export extern "C" [[maybe_unused]] #define export_func extern "C" [[maybe_unused]]
#define PkmnLibException 4 #define PkmnLibException 4
@ -46,10 +46,10 @@ public:
} }
#define SIMPLE_GET_FUNC(type, name, returnType) \ #define SIMPLE_GET_FUNC(type, name, returnType) \
export returnType PkmnLib_##type##_##name(const type* p) { return p->name(); } export_func returnType PkmnLib_##type##_##name(const type* p) { return p->name(); }
#define SIMPLE_GET_FUNC_SMART_PTR(type, name, returnType) \ #define SIMPLE_GET_FUNC_SMART_PTR(type, name, returnType) \
export returnType PkmnLib_##type##_##name(const type* p) { return p->name().GetRaw(); } export_func returnType PkmnLib_##type##_##name(const type* p) { return p->name().GetRaw(); }
#define DESTRUCTOR(type) \ #define DESTRUCTOR(type) \
export void PkmnLib_##type##_Destruct(const type* p) { delete p; } export_func void PkmnLib_##type##_Destruct(const type* p) { delete p; }
#endif // PKMNLIB_CORE_HPP #endif // PKMNLIB_CORE_HPP

View File

@ -2,78 +2,78 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Library; using namespace PkmnLib::Library;
export const EvolutionData* PkmnLib_EvolutionData_CreateLevelEvolution(uint8_t level, const PokemonSpecies* into) { export_func const EvolutionData* PkmnLib_EvolutionData_CreateLevelEvolution(uint8_t level, const PokemonSpecies* into) {
return EvolutionData::CreateLevelEvolution(level, into); return EvolutionData::CreateLevelEvolution(level, into);
} }
export const EvolutionData* PkmnLib_EvolutionData_CreateFriendshipEvolution(uint8_t friendship, export_func const EvolutionData* PkmnLib_EvolutionData_CreateFriendshipEvolution(uint8_t friendship,
const PokemonSpecies* into) { const PokemonSpecies* into) {
return EvolutionData::CreateFriendshipEvolution(friendship, into); return EvolutionData::CreateFriendshipEvolution(friendship, into);
} }
export const EvolutionData* PkmnLib_EvolutionData_CreateFriendshipTimeEvolution(uint8_t friendship, TimeOfDay startTime, export_func const EvolutionData* PkmnLib_EvolutionData_CreateFriendshipTimeEvolution(uint8_t friendship, TimeOfDay startTime,
TimeOfDay endTime, TimeOfDay endTime,
const PokemonSpecies* into) { const PokemonSpecies* into) {
return EvolutionData::CreateFriendshipTimeEvolution(friendship, startTime, endTime, into); return EvolutionData::CreateFriendshipTimeEvolution(friendship, startTime, endTime, into);
} }
export const EvolutionData* PkmnLib_EvolutionData_CreateKnownMoveEvolution(const MoveData* move, export_func const EvolutionData* PkmnLib_EvolutionData_CreateKnownMoveEvolution(const MoveData* move,
const PokemonSpecies* into) { const PokemonSpecies* into) {
return EvolutionData::CreateKnownMoveEvolution(move, into); return EvolutionData::CreateKnownMoveEvolution(move, into);
} }
export const EvolutionData* PkmnLib_EvolutionData_CreateLocationEvolution(const char* location, export_func const EvolutionData* PkmnLib_EvolutionData_CreateLocationEvolution(const char* location,
const PokemonSpecies* into) { const PokemonSpecies* into) {
return EvolutionData::CreateLocationEvolution(ArbUt::StringView(location), into); return EvolutionData::CreateLocationEvolution(ArbUt::StringView(location), into);
} }
export const EvolutionData* PkmnLib_EvolutionData_CreateTimeEvolution(TimeOfDay startTime, TimeOfDay endTime, export_func const EvolutionData* PkmnLib_EvolutionData_CreateTimeEvolution(TimeOfDay startTime, TimeOfDay endTime,
const PokemonSpecies* into) { const PokemonSpecies* into) {
return EvolutionData::CreateTimeEvolution(startTime, endTime, into); return EvolutionData::CreateTimeEvolution(startTime, endTime, into);
} }
export const EvolutionData* PkmnLib_EvolutionData_CreateHeldItemEvolution(const Item* item, export_func const EvolutionData* PkmnLib_EvolutionData_CreateHeldItemEvolution(const Item* item,
const PokemonSpecies* into) { const PokemonSpecies* into) {
return EvolutionData::CreateHeldItemEvolution(item, into); return EvolutionData::CreateHeldItemEvolution(item, into);
} }
export const EvolutionData* PkmnLib_EvolutionData_CreateHeldItemTimeEvolution(const Item* item, TimeOfDay startTime, export_func const EvolutionData* PkmnLib_EvolutionData_CreateHeldItemTimeEvolution(const Item* item, TimeOfDay startTime,
TimeOfDay endTime, TimeOfDay endTime,
const PokemonSpecies* into) { const PokemonSpecies* into) {
return EvolutionData::CreateHeldItemTimeEvolution(item, startTime, endTime, into); return EvolutionData::CreateHeldItemTimeEvolution(item, startTime, endTime, into);
} }
export const EvolutionData* PkmnLib_EvolutionData_CreateGenderBasedEvolution(CreatureLib::Library::Gender gender, export_func const EvolutionData* PkmnLib_EvolutionData_CreateGenderBasedEvolution(CreatureLib::Library::Gender gender,
uint8_t level, uint8_t level,
const PokemonSpecies* into) { const PokemonSpecies* into) {
return EvolutionData::CreateGenderBasedEvolution(gender, level, into); return EvolutionData::CreateGenderBasedEvolution(gender, level, into);
} }
export const EvolutionData* PkmnLib_EvolutionData_CreateItemUseEvolution(const Item* item, const PokemonSpecies* into) { export_func const EvolutionData* PkmnLib_EvolutionData_CreateItemUseEvolution(const Item* item, const PokemonSpecies* into) {
return EvolutionData::CreateItemUseEvolution(item, into); return EvolutionData::CreateItemUseEvolution(item, into);
} }
export const EvolutionData* PkmnLib_EvolutionData_CreateItemUseWithGenderEvolution(const Item* item, export_func const EvolutionData* PkmnLib_EvolutionData_CreateItemUseWithGenderEvolution(const Item* item,
CreatureLib::Library::Gender gender, CreatureLib::Library::Gender gender,
const PokemonSpecies* into) { const PokemonSpecies* into) {
return EvolutionData::CreateItemUseWithGenderEvolution(item, gender, into); return EvolutionData::CreateItemUseWithGenderEvolution(item, gender, into);
} }
export const EvolutionData* PkmnLib_EvolutionData_CreateTradeEvolution(const PokemonSpecies* into) { export_func const EvolutionData* PkmnLib_EvolutionData_CreateTradeEvolution(const PokemonSpecies* into) {
return EvolutionData::CreateTradeEvolution(into); return EvolutionData::CreateTradeEvolution(into);
} }
export const EvolutionData* PkmnLib_EvolutionData_CreateTradeWithItemEvolution(const Item* item, export_func const EvolutionData* PkmnLib_EvolutionData_CreateTradeWithItemEvolution(const Item* item,
const PokemonSpecies* into) { const PokemonSpecies* into) {
return EvolutionData::CreateTradeWithItemEvolution(item, into); return EvolutionData::CreateTradeWithItemEvolution(item, into);
} }
export const EvolutionData* PkmnLib_EvolutionData_CreateTradeWithSpeciesEvolution(const PokemonSpecies* traded, export_func const EvolutionData* PkmnLib_EvolutionData_CreateTradeWithSpeciesEvolution(const PokemonSpecies* traded,
const PokemonSpecies* into) { const PokemonSpecies* into) {
return EvolutionData::CreateTradeWithSpeciesEvolution(traded, into); return EvolutionData::CreateTradeWithSpeciesEvolution(traded, into);
} }
export const EvolutionData* export_func const EvolutionData*
PkmnLib_EvolutionData_CreateCustomEvolution(const CreatureLib::Library::EffectParameter** data, size_t dataLength, PkmnLib_EvolutionData_CreateCustomEvolution(const CreatureLib::Library::EffectParameter** data, size_t dataLength,
const PokemonSpecies* into) { const PokemonSpecies* into) {
auto list = std::vector<const CreatureLib::Library::EffectParameter*>(data, data + dataLength); auto list = std::vector<const CreatureLib::Library::EffectParameter*>(data, data + dataLength);
return EvolutionData::CreateCustomEvolution(list, into); return EvolutionData::CreateCustomEvolution(list, into);
} }
export EvolutionMethod PkmnLib_EvolutionData_GetMethod(const EvolutionData* data) { return data->GetMethod(); } export_func EvolutionMethod PkmnLib_EvolutionData_GetMethod(const EvolutionData* data) { return data->GetMethod(); }
export const PokemonSpecies* PkmnLib_EvolutionData_GetNewSpecies(const EvolutionData* data) { export_func const PokemonSpecies* PkmnLib_EvolutionData_GetNewSpecies(const EvolutionData* data) {
return data->GetNewSpecies().GetRaw(); return data->GetNewSpecies().GetRaw();
} }
export size_t PkmnLib_EvolutionData_GetDataCount(const EvolutionData* data) { return data->GetDataCount(); } export_func size_t PkmnLib_EvolutionData_GetDataCount(const EvolutionData* data) { return data->GetDataCount(); }
export uint8_t PkmnLib_EvolutionData_GetDataAt(const EvolutionData* data, size_t index, export_func uint8_t PkmnLib_EvolutionData_GetDataAt(const EvolutionData* data, size_t index,
const CreatureLib::Library::EffectParameter*& out) { const CreatureLib::Library::EffectParameter*& out) {
Try(out = data->GetDataAt(index).GetRaw()); Try(out = data->GetDataAt(index).GetRaw());
} }

View File

@ -3,7 +3,7 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Library; using namespace PkmnLib::Library;
export Item* PkmnLib_Item_Construct(const char* name, CreatureLib::Library::ItemCategory category, export_func Item* PkmnLib_Item_Construct(const char* name, CreatureLib::Library::ItemCategory category,
CreatureLib::Library::BattleItemCategory battleCategory, int32_t price, CreatureLib::Library::BattleItemCategory battleCategory, int32_t price,
const char* effectName, CreatureLib::Library::EffectParameter* effectParameters[], const char* effectName, CreatureLib::Library::EffectParameter* effectParameters[],
size_t effectParameterCount, const char* battleTriggerEffectName, size_t effectParameterCount, const char* battleTriggerEffectName,
@ -28,6 +28,6 @@ export Item* PkmnLib_Item_Construct(const char* name, CreatureLib::Library::Item
conversedFlags, flingPower); conversedFlags, flingPower);
}; };
export void PkmnLib_Item_Destruct(const Item* p) { delete p; } export_func void PkmnLib_Item_Destruct(const Item* p) { delete p; }
SIMPLE_GET_FUNC(Item, GetFlingPower, uint8_t) SIMPLE_GET_FUNC(Item, GetFlingPower, uint8_t)

View File

@ -2,13 +2,13 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Library; using namespace PkmnLib::Library;
export uint8_t PkmnLib_LearnableMoves_Construct(LearnableMoves*& out, size_t levelAttackCapacity) { export_func uint8_t PkmnLib_LearnableMoves_Construct(LearnableMoves*& out, size_t levelAttackCapacity) {
Try(out = new LearnableMoves(levelAttackCapacity)); Try(out = new LearnableMoves(levelAttackCapacity));
} }
DESTRUCTOR(LearnableMoves) DESTRUCTOR(LearnableMoves)
export void PkmnLib_LearnableMoves_AddEggMove(LearnableMoves* p, MoveData* move) { p->AddEggMove(move); } export_func void PkmnLib_LearnableMoves_AddEggMove(LearnableMoves* p, MoveData* move) { p->AddEggMove(move); }
export size_t PkmnLib_LearnableMoves_GetEggMovesCount(LearnableMoves* p) { return p->GetEggMoves().Count(); } export_func size_t PkmnLib_LearnableMoves_GetEggMovesCount(LearnableMoves* p) { return p->GetEggMoves().Count(); }
export const MoveData* const* PkmnLib_LearnableMoves_GetEggMoves(LearnableMoves* p) { export_func const MoveData* const* PkmnLib_LearnableMoves_GetEggMoves(LearnableMoves* p) {
return reinterpret_cast<const MoveData* const*>(p->GetEggMoves().RawData()); return reinterpret_cast<const MoveData* const*>(p->GetEggMoves().RawData());
} }

View File

@ -2,11 +2,11 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Library; using namespace PkmnLib::Library;
export const LibrarySettings* PkmnLib_LibrarySettings_Construct(uint8_t maximalLevel, uint8_t maximalMoves, export_func const LibrarySettings* PkmnLib_LibrarySettings_Construct(uint8_t maximalLevel, uint8_t maximalMoves,
uint16_t shinyRate) { uint16_t shinyRate) {
return new LibrarySettings(maximalLevel, maximalMoves, shinyRate); return new LibrarySettings(maximalLevel, maximalMoves, shinyRate);
} }
export void PkmnLib_LibrarySettings_Destruct(const LibrarySettings* p) { delete p; } export_func void PkmnLib_LibrarySettings_Destruct(const LibrarySettings* p) { delete p; }
SIMPLE_GET_FUNC(LibrarySettings, GetShinyRate, uint16_t); SIMPLE_GET_FUNC(LibrarySettings, GetShinyRate, uint16_t);

View File

@ -2,19 +2,19 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Library; using namespace PkmnLib::Library;
export Nature* PkmnLib_Nature_Construct(CreatureLib::Library::Statistic increasedStat, export_func Nature* PkmnLib_Nature_Construct(CreatureLib::Library::Statistic increasedStat,
CreatureLib::Library::Statistic decreasedStat, float increasedModifier, CreatureLib::Library::Statistic decreasedStat, float increasedModifier,
float decreasedModifier) { float decreasedModifier) {
return new Nature(increasedStat, decreasedStat, increasedModifier, decreasedModifier); return new Nature(increasedStat, decreasedStat, increasedModifier, decreasedModifier);
} }
export void PkmnLib_Nature_Destruct(const Nature* p) { delete p; } export_func void PkmnLib_Nature_Destruct(const Nature* p) { delete p; }
SIMPLE_GET_FUNC(Nature, GetIncreaseModifier, float) SIMPLE_GET_FUNC(Nature, GetIncreaseModifier, float)
SIMPLE_GET_FUNC(Nature, GetDecreaseModifier, float) SIMPLE_GET_FUNC(Nature, GetDecreaseModifier, float)
SIMPLE_GET_FUNC(Nature, GetIncreasedStat, CreatureLib::Library::Statistic) SIMPLE_GET_FUNC(Nature, GetIncreasedStat, CreatureLib::Library::Statistic)
SIMPLE_GET_FUNC(Nature, GetDecreasedStat, CreatureLib::Library::Statistic) SIMPLE_GET_FUNC(Nature, GetDecreasedStat, CreatureLib::Library::Statistic)
export float PkmnLib_Nature_GetStatModifier(const PkmnLib::Library::Nature* nature, export_func float PkmnLib_Nature_GetStatModifier(const PkmnLib::Library::Nature* nature,
CreatureLib::Library::Statistic stat) { CreatureLib::Library::Statistic stat) {
return nature->GetStatModifier(stat); return nature->GetStatModifier(stat);
} }

View File

@ -2,27 +2,27 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Library; using namespace PkmnLib::Library;
export NatureLibrary* PkmnLib_NatureLibrary_Construct(size_t initialCapacity) { export_func NatureLibrary* PkmnLib_NatureLibrary_Construct(size_t initialCapacity) {
return new NatureLibrary(initialCapacity); return new NatureLibrary(initialCapacity);
} }
export void PkmnLib_NatureLibrary_Destruct(const NatureLibrary* p) { delete p; } export_func void PkmnLib_NatureLibrary_Destruct(const NatureLibrary* p) { delete p; }
export uint8_t PkmnLib_NatureLibrary_LoadNature(NatureLibrary* p, const char* name, const Nature* nature) { export_func uint8_t PkmnLib_NatureLibrary_LoadNature(NatureLibrary* p, const char* name, const Nature* nature) {
Try(p->LoadNature(ArbUt::StringView(name), nature);) Try(p->LoadNature(ArbUt::StringView(name), nature);)
} }
export uint8_t PkmnLib_NatureLibrary_GetNatureByName(NatureLibrary* p, const char* name, const Nature*& out) { export_func uint8_t PkmnLib_NatureLibrary_GetNatureByName(NatureLibrary* p, const char* name, const Nature*& out) {
Try(out = p->GetNatureByName(ArbUt::StringView(name)).GetRaw()); Try(out = p->GetNatureByName(ArbUt::StringView(name)).GetRaw());
} }
export uint8_t PkmnLib_NatureLibrary_GetRandomNatureName(NatureLibrary* p, ArbUt::Random* rand, const char*& out) { export_func uint8_t PkmnLib_NatureLibrary_GetRandomNatureName(NatureLibrary* p, ArbUt::Random* rand, const char*& out) {
Try(out = p->GetRandomNatureName(*rand).c_str();) Try(out = p->GetRandomNatureName(*rand).c_str();)
} }
export uint8_t PkmnLib_NatureLibrary_GetNatureName(NatureLibrary* p, const Nature* nature, const char*& out) { export_func uint8_t PkmnLib_NatureLibrary_GetNatureName(NatureLibrary* p, const Nature* nature, const char*& out) {
Try(out = p->GetNatureName(nature).c_str()); Try(out = p->GetNatureName(nature).c_str());
} }
SIMPLE_GET_FUNC(NatureLibrary, GetNatureCount, size_t) SIMPLE_GET_FUNC(NatureLibrary, GetNatureCount, size_t)
export uint8_t PkmnLib_NatureLibrary_GetNatureByIndex(NatureLibrary* p, size_t index, const char*& out) { export_func uint8_t PkmnLib_NatureLibrary_GetNatureByIndex(NatureLibrary* p, size_t index, const char*& out) {
Try(out = p->GetNatureFromIndex(index).c_str();) Try(out = p->GetNatureFromIndex(index).c_str();)
} }

View File

@ -3,7 +3,7 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Library; using namespace PkmnLib::Library;
export PokemonForme* export_func PokemonForme*
PkmnLib_PokemonForme_Construct(const char* name, float height, float weight, uint32_t baseExperience, uint8_t types[], PkmnLib_PokemonForme_Construct(const char* name, float height, float weight, uint32_t baseExperience, uint8_t types[],
size_t typeLength, uint16_t baseHealth, uint16_t baseAttack, uint16_t baseDefense, size_t typeLength, uint16_t baseHealth, uint16_t baseAttack, uint16_t baseDefense,
uint16_t baseMagicalAttack, uint16_t baseMagicalDefense, uint16_t baseSpeed, uint16_t baseMagicalAttack, uint16_t baseMagicalDefense, uint16_t baseSpeed,

View File

@ -2,7 +2,7 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Library; using namespace PkmnLib::Library;
export uint8_t PkmnLib_PokemonLibrary_Construct(PokemonLibrary*& out, PkmnLib::Library::LibrarySettings* settings, export_func uint8_t PkmnLib_PokemonLibrary_Construct(PokemonLibrary*& out, PkmnLib::Library::LibrarySettings* settings,
SpeciesLibrary* species, MoveLibrary* moves, ItemLibrary* items, SpeciesLibrary* species, MoveLibrary* moves, ItemLibrary* items,
CreatureLib::Library::GrowthRateLibrary* growthRates, CreatureLib::Library::GrowthRateLibrary* growthRates,
CreatureLib::Library::TypeLibrary* typeLibrary, CreatureLib::Library::TypeLibrary* typeLibrary,
@ -11,7 +11,7 @@ export uint8_t PkmnLib_PokemonLibrary_Construct(PokemonLibrary*& out, PkmnLib::L
Try(out = new PokemonLibrary(settings, species, moves, items, growthRates, typeLibrary, talentLibrary, natures)); Try(out = new PokemonLibrary(settings, species, moves, items, growthRates, typeLibrary, talentLibrary, natures));
} }
export void PkmnLib_PokemonLibrary_Destruct(const PokemonLibrary* p) { delete p; } export_func void PkmnLib_PokemonLibrary_Destruct(const PokemonLibrary* p) { delete p; }
export const NatureLibrary* PkmnLib_PokemonLibrary_GetNatureLibrary(const PokemonLibrary* p) { export_func const NatureLibrary* PkmnLib_PokemonLibrary_GetNatureLibrary(const PokemonLibrary* p) {
return p->GetNatureLibrary().GetRaw(); return p->GetNatureLibrary().GetRaw();
} }

View File

@ -2,7 +2,7 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Library; using namespace PkmnLib::Library;
export uint8_t PkmnLib_PokemonSpecies_Construct(const PokemonSpecies*& out, uint16_t id, const char* name, export_func uint8_t PkmnLib_PokemonSpecies_Construct(const PokemonSpecies*& out, uint16_t id, const char* name,
const PokemonForme* defaultForme, float genderRatio, const PokemonForme* defaultForme, float genderRatio,
const char* growthRate, uint8_t captureRate, uint8_t baseHappiness, const char* growthRate, uint8_t captureRate, uint8_t baseHappiness,
const char* const* eggGroupsRaw, size_t eggGroupsLength, const char* const* eggGroupsRaw, size_t eggGroupsLength,
@ -20,22 +20,22 @@ export uint8_t PkmnLib_PokemonSpecies_Construct(const PokemonSpecies*& out, uint
eggGroups, conversedFlags);) eggGroups, conversedFlags);)
} }
export void PkmnLib_PokemonSpecies_Destruct(const PokemonSpecies* p) { delete p; } export_func void PkmnLib_PokemonSpecies_Destruct(const PokemonSpecies* p) { delete p; }
SIMPLE_GET_FUNC(PokemonSpecies, GetBaseHappiness, uint8_t); SIMPLE_GET_FUNC(PokemonSpecies, GetBaseHappiness, uint8_t);
export void PkmnLib_PokemonSpecies_AddEvolution(PokemonSpecies* p, EvolutionData* evo) { p->AddEvolution(evo); } export_func void PkmnLib_PokemonSpecies_AddEvolution(PokemonSpecies* p, EvolutionData* evo) { p->AddEvolution(evo); }
export size_t PkmnLib_PokemonSpecies_GetEvolutionCount(const PokemonSpecies* p) { return p->GetEvolutions().Count(); } export_func size_t PkmnLib_PokemonSpecies_GetEvolutionCount(const PokemonSpecies* p) { return p->GetEvolutions().Count(); }
export uint8_t PkmnLib_PokemonSpecies_GetEvolution(const PokemonSpecies* p, size_t index, const EvolutionData*& out) { export_func uint8_t PkmnLib_PokemonSpecies_GetEvolution(const PokemonSpecies* p, size_t index, const EvolutionData*& out) {
Try(out = p->GetEvolutions().At(index).GetRaw()); Try(out = p->GetEvolutions().At(index).GetRaw());
} }
export uint8_t PkmnLib_PokemonSpecies_GetEvolutions(const PokemonSpecies* p, const EvolutionData* const*& out) { export_func uint8_t PkmnLib_PokemonSpecies_GetEvolutions(const PokemonSpecies* p, const EvolutionData* const*& out) {
Try(out = p->GetEvolutions().RawData()); Try(out = p->GetEvolutions().RawData());
} }
export size_t PkmnLib_PokemonSpecies_GetEggGroupCount(const PokemonSpecies* p) { return p->GetEggGroups().Count(); } export_func size_t PkmnLib_PokemonSpecies_GetEggGroupCount(const PokemonSpecies* p) { return p->GetEggGroups().Count(); }
export const char* PkmnLib_PokemonSpecies_GetEggGroup(const PokemonSpecies* p, size_t index) { export_func const char* PkmnLib_PokemonSpecies_GetEggGroup(const PokemonSpecies* p, size_t index) {
return p->GetEggGroups()[index].c_str(); return p->GetEggGroups()[index].c_str();
} }

View File

@ -2,11 +2,11 @@
#include "../Core.hpp" #include "../Core.hpp"
using namespace PkmnLib::Library; using namespace PkmnLib::Library;
export const SpeciesLibrary* PkmnLib_SpeciesLibrary_Construct(size_t initialCapacity) { export_func const SpeciesLibrary* PkmnLib_SpeciesLibrary_Construct(size_t initialCapacity) {
return new SpeciesLibrary(initialCapacity); return new SpeciesLibrary(initialCapacity);
}; };
export u8 PkmnLib_SpeciesLibrary_FindPreEvolution(const PokemonSpecies*& out, const SpeciesLibrary* p, export_func u8 PkmnLib_SpeciesLibrary_FindPreEvolution(const PokemonSpecies*& out, const SpeciesLibrary* p,
const PokemonSpecies* species) { const PokemonSpecies* species) {
Try( Try(
auto v = p->FindPreEvolution(species); auto v = p->FindPreEvolution(species);

View File

@ -23,6 +23,12 @@ endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_link_options(-fuse-ld=lld) add_link_options(-fuse-ld=lld)
# Only warn for unknown sanitizers. This error is not major enough to error on.
add_compile_options(-Wno-error=unknown-sanitizers)
# Ignore pedantic nullability extension warning, as we only use this for clang specifically
add_compile_options(-Wno-nullability-extension)
# As far as I can tell this is an invalid pedantic warning since C++ 20. Empty variadic macro arguments is completely legal.
add_compile_options(-Wno-gnu-zero-variadic-macro-arguments)
endif () endif ()
execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/include) execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/include)
@ -159,7 +165,7 @@ endif ()
file(GLOB_RECURSE CORE_SRC_FILES ${FILE_SOURCE}) file(GLOB_RECURSE CORE_SRC_FILES ${FILE_SOURCE})
add_library(pkmnLib ${LIBTYPE} ${CORE_SRC_FILES}) add_library(pkmnLib ${LIBTYPE} ${CORE_SRC_FILES})
# Enable all warnings, and make them error when occurring. # Enable all warnings, and make them error when occurring.
target_compile_options(pkmnLib PRIVATE -Wall -Wextra -Werror) target_compile_options(pkmnLib PRIVATE -Wall -Wextra -Werror -pedantic-errors)
target_link_directories(pkmnLib PUBLIC ${Angelscript_BINARY_DIR}) target_link_directories(pkmnLib PUBLIC ${Angelscript_BINARY_DIR})
# If interprocedural optimization is available, apply it # If interprocedural optimization is available, apply it
@ -218,7 +224,7 @@ if (PKMNLIB_TESTS)
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp") file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
add_executable(pkmnLibTests ${TEST_FILES}) add_executable(pkmnLibTests ${TEST_FILES})
# Enable all warnings, and make them error when occurring. # Enable all warnings, and make them error when occurring.
target_compile_options(pkmnLibTests PRIVATE -Wall -Wextra -Werror) target_compile_options(pkmnLibTests PRIVATE -Wall -Wextra -Werror -pedantic-errors)
message(STATUS "${_TESTLINKS}") message(STATUS "${_TESTLINKS}")
target_link_libraries(pkmnLibTests PUBLIC ${_TESTLINKS}) target_link_libraries(pkmnLibTests PUBLIC ${_TESTLINKS})

View File

@ -14,7 +14,7 @@ namespace PkmnLib::Battling {
"struggle"_cnc, 0, PkmnLib::Library::MoveCategory::Physical, 50, 255, 10, "struggle"_cnc, 0, PkmnLib::Library::MoveCategory::Physical, 50, 255, 10,
CreatureLib::Library::AttackTarget::Any, 0, CreatureLib::Library::AttackTarget::Any, 0,
new CreatureLib::Library::SecondaryEffect(-1, "struggle"_cnc, {}), std::unordered_set<uint32_t>()); new CreatureLib::Library::SecondaryEffect(-1, "struggle"_cnc, {}), std::unordered_set<uint32_t>());
;
std::unique_ptr<CreatureLib::Battling::LearnedAttack> _struggle = std::unique_ptr<CreatureLib::Battling::LearnedAttack> _struggle =
std::make_unique<PkmnLib::Battling::LearnedMove>(_struggleData, std::make_unique<PkmnLib::Battling::LearnedMove>(_struggleData,
CreatureLib::Battling::AttackLearnMethod::Unknown); CreatureLib::Battling::AttackLearnMethod::Unknown);

View File

@ -15,7 +15,7 @@ class AngelScriptEvolutionScript final : public PkmnLib::Battling::EvolutionScri
asIScriptFunction* nullable Function = nullptr; asIScriptFunction* nullable Function = nullptr;
}; };
#define EVO_SCRIPT_HOOK_FUNCTION(name, decl) FunctionInfo __##name = Initialize(decl); #define EVO_SCRIPT_HOOK_FUNCTION(name, decl) FunctionInfo __##name = Initialize(decl)
FunctionInfo Initialize(const std::string& decl) { FunctionInfo Initialize(const std::string& decl) {
auto val = _scriptObject->GetObjectType()->GetMethodByDecl(decl.c_str(), false); auto val = _scriptObject->GetObjectType()->GetMethodByDecl(decl.c_str(), false);

View File

@ -70,7 +70,7 @@ private:
FunctionInfo __GetOwner = InitializeGetOwner(); FunctionInfo __GetOwner = InitializeGetOwner();
FunctionInfo __SetOwner = InitializeSetOwner(); FunctionInfo __SetOwner = InitializeSetOwner();
#define ITEM_USE_SCRIPT_HOOK_FUNCTION(name, decl) FunctionInfo __##name = Initialize(decl); #define ITEM_USE_SCRIPT_HOOK_FUNCTION(name, decl) FunctionInfo __##name = Initialize(decl)
ITEM_USE_SCRIPT_HOOK_FUNCTION( ITEM_USE_SCRIPT_HOOK_FUNCTION(
OnInitialize, "void OnInitialize(const BattleLibrary@ library, const narray<EffectParameter@>@ parameters)"); OnInitialize, "void OnInitialize(const BattleLibrary@ library, const narray<EffectParameter@>@ parameters)");

View File

@ -17,7 +17,7 @@ static std::string ImplConstStringStringConv(const ArbUt::StringView& s) { retur
void ConstStringRegister::Register(asIScriptEngine* engine) { void ConstStringRegister::Register(asIScriptEngine* engine) {
auto r = engine->RegisterObjectType("constString", sizeof(ArbUt::StringView), auto r = engine->RegisterObjectType("constString", sizeof(ArbUt::StringView),
asOBJ_VALUE | asGetTypeTraits<ArbUt::StringView>()); asOBJ_VALUE | asGetTypeTraits<ArbUt::StringView>() | asOBJ_APP_CLASS_ALIGN8);
Ensure(r >= 0); Ensure(r >= 0);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructConstString), r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructConstString),