Make the last couple classes use smart pointers.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-06-02 18:30:37 +02:00
parent 7262ae9e8b
commit 657d646fda
10 changed files with 33 additions and 25 deletions

View File

@@ -6,18 +6,23 @@ export void CreatureLib_EventData_Destruct(const EventData* p) { delete p; }
#define SIMPLE_GET_FUNC(type, name, returnType) \
export returnType CreatureLib_##type##_##name(const type* p) { return p->name(); }
#define SIMPLE_GET_FUNC_SMART_PTR(type, name, returnType) \
export returnType CreatureLib_##type##_##name(const type* p) { return p->name().operator->(); }
SIMPLE_GET_FUNC(EventData, GetKind, EventDataKind);
SIMPLE_GET_FUNC(DamageEvent, GetCreature, Creature*);
SIMPLE_GET_FUNC_SMART_PTR(DamageEvent, GetCreature, Creature*);
SIMPLE_GET_FUNC(DamageEvent, GetDamageSource, DamageSource);
SIMPLE_GET_FUNC(DamageEvent, GetOriginalHealth, uint32_t);
SIMPLE_GET_FUNC(DamageEvent, GetNewHealth, uint32_t);
SIMPLE_GET_FUNC(HealEvent, GetCreature, Creature*);
SIMPLE_GET_FUNC_SMART_PTR(HealEvent, GetCreature, Creature*);
SIMPLE_GET_FUNC(HealEvent, GetOriginalHealth, uint32_t);
SIMPLE_GET_FUNC(HealEvent, GetNewHealth, uint32_t);
SIMPLE_GET_FUNC(FaintEvent, GetCreature, Creature*);
SIMPLE_GET_FUNC_SMART_PTR(FaintEvent, GetCreature, Creature*);
export const char* CreatureLib_DisplayTextEvent_GetText(const DisplayTextEvent* p) { return p->GetText().c_str(); }
#undef SIMPLE_GET_FUNC
#undef SIMPLE_GET_FUNC_SMART_PTR

View File

@@ -23,7 +23,7 @@ export void CreatureLib_BaseTurnChoice_Destruct(const BaseTurnChoice* p) { delet
export returnType CreatureLib_##type##_##name(const type* p) { return p->name().operator->(); }
SIMPLE_GET_FUNC(BaseTurnChoice, GetKind, TurnChoiceKind)
SIMPLE_GET_FUNC(BaseTurnChoice, GetUser, Creature*)
SIMPLE_GET_FUNC_SMART_PTR(BaseTurnChoice, GetUser, Creature*)
SIMPLE_GET_FUNC_SMART_PTR(AttackTurnChoice, GetAttack, LearnedAttack*)
SIMPLE_GET_FUNC(AttackTurnChoice, GetKind, TurnChoiceKind)
@@ -38,7 +38,7 @@ export uint8_t CreatureLib_BaseTurnChoice_GetTargetCreatureIndex(const AttackTur
return p->GetTarget().GetCreatureIndex();
}
SIMPLE_GET_FUNC(SwitchTurnChoice, GetNewCreature, Creature*)
SIMPLE_GET_FUNC_SMART_PTR(SwitchTurnChoice, GetNewCreature, Creature*)
#undef SIMPLE_GET_FUNC
#undef SIMPLE_GET_FUNC_SMART_PTR