Fix issue with having two different libraries sharing the same CreatureLib Exception C Interface.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/Models/Battle.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export uint8_t CreatureLib_Battle_Construct(Battle*& out, const BattleLibrary* library, BattleParty* partyArr[],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/Library/BattleLibrary.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export uint8_t CreatureLib_BattleLibrary_Construct(const BattleLibrary*& out,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/Models/BattleParty.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
// Note that creatureIndices should be twice the size of numberOfIndices, and have index of side, index of creature on
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/Models/BattleRandom.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export BattleRandom* CreatureLib_BattleRandom_Construct() { return new BattleRandom(); }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/Models/BattleSide.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export BattleSide* CreatureLib_BattleSide_Construct(uint8_t index, Battle* battle, uint8_t creaturesPerSide) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/Library/BattleStatCalculator.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export const BattleStatCalculator* CreatureLib_BattleStatCalculator_Construct() { return new BattleStatCalculator(); }
|
||||
|
||||
5
CInterface/Battling/Core.cpp
Normal file
5
CInterface/Battling/Core.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "Core.hpp"
|
||||
|
||||
std::string ExceptionHandler::_creatureLibLastException = "";
|
||||
|
||||
export const char* CreatureLib_C_GetLastException() { return ExceptionHandler::GetLastException(); }
|
||||
41
CInterface/Battling/Core.hpp
Normal file
41
CInterface/Battling/Core.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef CREATURELIB_CORE_HPP
|
||||
#define CREATURELIB_CORE_HPP
|
||||
|
||||
#include <cstring>
|
||||
#include <exception>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#define export extern "C" [[maybe_unused]]
|
||||
|
||||
#define CreatureLibBattlingException 3;
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
||||
class ExceptionHandler {
|
||||
static std::string _creatureLibLastException;
|
||||
|
||||
public:
|
||||
static void SetLastException(std::string function, const std::exception& e) {
|
||||
std::stringstream ss;
|
||||
ss << "[" << function << "] " << e.what();
|
||||
_creatureLibLastException = ss.str();
|
||||
}
|
||||
static const char* GetLastException() { return _creatureLibLastException.c_str(); }
|
||||
};
|
||||
|
||||
#define Try(data) \
|
||||
try { \
|
||||
data; \
|
||||
return 0; \
|
||||
} catch (const std::exception& e) { \
|
||||
ExceptionHandler::SetLastException(__FUNCTION__, e); \
|
||||
return CreatureLibBattlingException; \
|
||||
}
|
||||
|
||||
#define SIMPLE_GET_FUNC(type, name, returnType) \
|
||||
export returnType CreatureLib_##type##_##name(const type* p) { return p->name(); }
|
||||
#define BORROWED_GET_FUNC(type, name, returnType) \
|
||||
export returnType CreatureLib_##type##_##name(const type* p) { return p->name().GetRaw(); }
|
||||
#define SMART_GET_FUNC(type, name, returnType) \
|
||||
export returnType CreatureLib_##type##_##name(const type* p) { return p->name().get(); }
|
||||
|
||||
#endif // CREATURELIB_CORE_HPP
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/Models/Creature.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export uint8_t CreatureLib_Creature_Construct(Creature*& out, const BattleLibrary* library,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/Models/CreatureParty.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export CreatureParty* CreatureLib_CreatureParty_ConstructWithSize(size_t size) { return new CreatureParty(size); }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/Library/DamageLibrary.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export const DamageLibrary* CreatureLib_DamageLibrary_Construct() { return new DamageLibrary(); }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/EventHooks/EventData.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export void CreatureLib_EventData_Destruct(const EventData* p) { delete p; }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/Models/ExecutingAttack.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export uint8_t CreatureLib_ExecutingAttack_Construct(ExecutingAttack*& out, Creature* const* targets,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/Library/ExperienceLibrary.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export const ExperienceLibrary* CreatureLib_ExperienceLibrary_Construct() { return new ExperienceLibrary(); }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/Models/LearnedAttack.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export uint8_t CreatureLib_LearnedAttack_Construct(LearnedAttack*& out, const CreatureLib::Library::AttackData* attack,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/Library/MiscLibrary.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export MiscLibrary* CreatureLib_MiscLibrary_Construct() { return new MiscLibrary(); }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/ScriptHandling/Script.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export void CreatureLib_Script_Destruct(Script* p) { delete p; }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../src/Battling/ScriptHandling/ScriptResolver.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export ScriptResolver* CreatureLib_ScriptResolver_Construct() { return new ScriptResolver(); }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "../../src/Battling/TurnChoices/FleeTurnChoice.hpp"
|
||||
#include "../../src/Battling/TurnChoices/PassTurnChoice.hpp"
|
||||
#include "../../src/Battling/TurnChoices/SwitchTurnChoice.hpp"
|
||||
#include "../Core.hpp"
|
||||
#include "Core.hpp"
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
export AttackTurnChoice* CreatureLib_AttackTurnChoice_Construct(Creature* user, LearnedAttack* attack,
|
||||
|
||||
Reference in New Issue
Block a user