From a19965c1c327941d5564dc5cdf679d77e5355590 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Mon, 4 May 2020 18:07:39 +0200 Subject: [PATCH] C Interface for PokemonLibrary. --- CInterface/Library/PokemonLibrary.cpp | 16 ++++++++++++++++ CMakeLists.txt | 4 ++-- conanfile.py | 2 +- src/Library/PokemonLibrary.hpp | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 CInterface/Library/PokemonLibrary.cpp diff --git a/CInterface/Library/PokemonLibrary.cpp b/CInterface/Library/PokemonLibrary.cpp new file mode 100644 index 0000000..3ac6f34 --- /dev/null +++ b/CInterface/Library/PokemonLibrary.cpp @@ -0,0 +1,16 @@ +#include "../../src/Library/PokemonLibrary.hpp" +#include "../Core.hpp" +using namespace PkmnLib::Library; + +export uint8_t PkmnLib_PokemonLibrary_Construct(PokemonLibrary*& out, PkmnLib::Library::LibrarySettings* settings, + SpeciesLibrary* species, MoveLibrary* moves, ItemLibrary* items, + CreatureLib::Library::GrowthRateLibrary* growthRates, + CreatureLib::Library::TypeLibrary* typeLibrary, + NatureLibrary* natures) { + Try(out = new PokemonLibrary(settings, species, moves, items, growthRates, typeLibrary, natures)); +} + +export void PkmnLib_PokemonLibrary_Destruct(const PokemonLibrary* p) { delete p; } +export const NatureLibrary* PkmnLib_PokemonLibrary_GetNatureLibrary(const PokemonLibrary* p) { + return p->GetNatureLibrary(); +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index bc0c5a5..985569d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,10 +41,10 @@ if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) if (NOT WINDOWS) execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated - -s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -o *:staticC=${CONAN_STATIC_C}) + -s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -o *:staticC=${CONAN_STATIC_C} -o AngelScript:link_std_statically=True) else () execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated - -s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s os=Windows -o *:staticC=${CONAN_STATIC_C}) + -s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s os=Windows -o *:staticC=${CONAN_STATIC_C} -o AngelScript:link_std_statically=True) endif () endif () include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) diff --git a/conanfile.py b/conanfile.py index 4d85a02..d1d2511 100644 --- a/conanfile.py +++ b/conanfile.py @@ -43,7 +43,7 @@ class PkmnLibConan(ConanFile): def configure(self): if self.options.script_handler == "angelscript": self.options["AngelScript"].shared = True - if self.settings.os == "Windows": + if self.options.staticC: self.options["AngelScript"].link_std_statically = True def requirements(self): diff --git a/src/Library/PokemonLibrary.hpp b/src/Library/PokemonLibrary.hpp index a62f58b..6a3f6a7 100644 --- a/src/Library/PokemonLibrary.hpp +++ b/src/Library/PokemonLibrary.hpp @@ -37,7 +37,7 @@ namespace PkmnLib::Library { return (const ItemLibrary*)(CreatureLib::Library::DataLibrary::GetItemLibrary()); } - [[nodiscard]] const NatureLibrary* GetNatureLibrary() const { return _natures; } + [[nodiscard]] const NatureLibrary* GetNatureLibrary() const noexcept { return _natures; } }; }