C interface for BattleLibrary.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-03-04 17:04:44 +01:00
parent 6bffea953d
commit ea8afcd0b3
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
4 changed files with 29 additions and 4 deletions

View File

@ -0,0 +1,25 @@
#include "../../src/Battling/Library/BattleLibrary.hpp"
#define export extern "C"
using namespace CreatureLib::Battling;
export const BattleLibrary* CreatureLib_BattleLibrary_Construct(const CreatureLib::Library::DataLibrary* staticLib,
BattleStatCalculator* statCalculator,
DamageLibrary* damageLibrary,
ExperienceLibrary* experienceLibrary,
ScriptResolver* scriptResolver,
MiscLibrary* miscLibrary) {
return new BattleLibrary(staticLib, statCalculator, damageLibrary, experienceLibrary, scriptResolver, miscLibrary);
}
export void CreatureLib_BattleLibrary_Destruct(const BattleLibrary* p) { delete p; }
#define SIMPLE_GET_FUNC(type, name, returnType) \
export returnType CreatureLib_##type##_##name(const type* p) { return p->name(); }
SIMPLE_GET_FUNC(BattleLibrary, GetStaticLib, const CreatureLib::Library::DataLibrary*);
SIMPLE_GET_FUNC(BattleLibrary, GetStatCalculator, const BattleStatCalculator*);
SIMPLE_GET_FUNC(BattleLibrary, GetDamageLibrary, const DamageLibrary*);
SIMPLE_GET_FUNC(BattleLibrary, GetMiscLibrary, const MiscLibrary*);
SIMPLE_GET_FUNC(BattleLibrary, GetExperienceLibrary, const ExperienceLibrary*);
#undef SIMPLE_GET_FUNC

View File

@ -32,7 +32,7 @@ if (WINDOWS)
endif (WINDOWS)
# Create Core library with files in src/Core
file(GLOB_RECURSE CORE_SRC_FILES "src/Core/*.cpp" "src/Core/*.hpp" "CInterface/Core/*.hpp")
file(GLOB_RECURSE CORE_SRC_FILES "src/Core/*.cpp" "src/Core/*.hpp" "CInterface/Core/*.cpp")
add_library(CreatureLibCore SHARED ${CORE_SRC_FILES})
set_target_properties(CreatureLibCore PROPERTIES LINKER_LANGUAGE CXX)
@ -41,7 +41,7 @@ file(GLOB_RECURSE LIBRARY_SRC_FILES "src/Library/*.cpp" "src/Library/*.hpp" "CIn
add_library(CreatureLibLibrary SHARED ${LIBRARY_SRC_FILES})
# Create Battling library with files in src/Battling
file(GLOB_RECURSE BATTLING_SRC_FILES "src/Battling/*.cpp" "src/Battling/*.hpp" "CInterface/Battling/*.hpp")
file(GLOB_RECURSE BATTLING_SRC_FILES "src/Battling/*.cpp" "src/Battling/*.hpp" "CInterface/Battling/*.cpp")
add_library(CreatureLibBattling SHARED ${BATTLING_SRC_FILES})
if (NOT DEFINED CONAN_EXPORTED)

View File

@ -3,7 +3,7 @@
using namespace CreatureLib::Battling;
BattleLibrary::BattleLibrary(CreatureLib::Library::DataLibrary* staticLib, BattleStatCalculator* statCalculator,
BattleLibrary::BattleLibrary(const CreatureLib::Library::DataLibrary* staticLib, BattleStatCalculator* statCalculator,
DamageLibrary* damageLibrary, ExperienceLibrary* experienceLibrary,
ScriptResolver* scriptResolver, MiscLibrary* miscLibrary)
: _staticLib(staticLib), _statCalculator(statCalculator), _damageLibrary(damageLibrary),

View File

@ -19,7 +19,7 @@ namespace CreatureLib::Battling {
MiscLibrary* _miscLibrary = nullptr;
public:
BattleLibrary(Library::DataLibrary* staticLib, BattleStatCalculator* statCalculator,
BattleLibrary(const Library::DataLibrary* staticLib, BattleStatCalculator* statCalculator,
DamageLibrary* damageLibrary, ExperienceLibrary* experienceLibrary,
ScriptResolver* scriptResolver, MiscLibrary* miscLibrary);
~BattleLibrary();