Cleanup of C Interface, remove use of operator->, as it will throw when null.
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:
@@ -27,9 +27,6 @@ export uint8_t CreatureLib_AttackData_Construct(AttackData*& out, const char* na
|
||||
|
||||
export void CreatureLib_AttackData_Destruct(const AttackData* p) { delete p; }
|
||||
|
||||
#define SIMPLE_GET_FUNC(type, name, returnType) \
|
||||
export returnType CreatureLib_##type##_##name(const type* p) { return p->name(); }
|
||||
|
||||
export const char* CreatureLib_AttackData_GetName(const AttackData* p) { return p->GetName().c_str(); }
|
||||
SIMPLE_GET_FUNC(AttackData, GetType, uint8_t);
|
||||
SIMPLE_GET_FUNC(AttackData, GetCategory, AttackCategory);
|
||||
@@ -51,6 +48,4 @@ export const char* CreatureLib_AttackData_GetSecondaryEffectName(const AttackDat
|
||||
|
||||
export bool CreatureLib_AttackData_HasFlag(const AttackData* p, const char* key) {
|
||||
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
|
||||
}
|
||||
|
||||
#undef SIMPLE_GET_FUNC
|
||||
}
|
||||
@@ -18,23 +18,23 @@
|
||||
export bool simpleName##_TryGet(fullname* p, const char* name, const returnType*& out) { \
|
||||
ArbUt::BorrowedPtr<const returnType> o; \
|
||||
auto v = p->TryGet(ArbUt::StringView::CalculateHash(name), o); \
|
||||
out = o.operator->(); \
|
||||
out = o.GetRaw(); \
|
||||
return v; \
|
||||
} \
|
||||
\
|
||||
export bool simpleName##_TryGetWithHash(fullname* p, uint32_t hashedKey, const returnType*& out) { \
|
||||
ArbUt::BorrowedPtr<const returnType> o; \
|
||||
auto v = p->TryGet(hashedKey, o); \
|
||||
out = o.operator->(); \
|
||||
out = o.GetRaw(); \
|
||||
return v; \
|
||||
} \
|
||||
\
|
||||
export uint8_t simpleName##_Get(fullname* p, const char* name, const returnType*& out) { \
|
||||
Try(out = p->Get(ArbUt::StringView::CalculateHash(name)).operator->();) \
|
||||
Try(out = p->Get(ArbUt::StringView::CalculateHash(name)).GetRaw();) \
|
||||
} \
|
||||
\
|
||||
export uint8_t simpleName##_GetWithHash(fullname* p, uint32_t hashedKey, const returnType*& out) { \
|
||||
Try(out = p->Get(hashedKey).operator->();) \
|
||||
Try(out = p->Get(hashedKey).GetRaw();) \
|
||||
} \
|
||||
\
|
||||
export size_t simpleName##_GetCount(fullname* p) { return p->GetCount(); }
|
||||
|
||||
@@ -12,9 +12,6 @@ export uint8_t CreatureLib_CreatureSpecies_Construct(CreatureSpecies*& out, uint
|
||||
|
||||
export void CreatureLib_CreatureSpecies_Destruct(const CreatureSpecies* p) { delete p; }
|
||||
|
||||
#define SIMPLE_GET_FUNC(type, name, returnType) \
|
||||
export returnType CreatureLib_##type##_##name(const type* p) { return p->name(); }
|
||||
|
||||
SIMPLE_GET_FUNC(CreatureSpecies, GetId, uint16_t);
|
||||
SIMPLE_GET_FUNC(CreatureSpecies, GetGenderRate, float);
|
||||
SIMPLE_GET_FUNC(CreatureSpecies, GetCaptureRate, uint8_t);
|
||||
@@ -54,5 +51,3 @@ export uint8_t CreatureLib_CreatureSpecies_GetVariantWithHash(const SpeciesVaria
|
||||
export uint8_t CreatureLib_CreatureSpecies_SetVariant(CreatureSpecies* p, const char* name, SpeciesVariant* variant) {
|
||||
Try(p->SetVariant(ArbUt::StringView(name), variant);)
|
||||
}
|
||||
|
||||
#undef SIMPLE_GET_FUNC
|
||||
@@ -10,14 +10,9 @@ export uint8_t CreatureLib_DataLibrary_Construct(const DataLibrary*& out, Librar
|
||||
|
||||
export void CreatureLib_DataLibrary_Destruct(const DataLibrary* p) { delete p; }
|
||||
|
||||
#define SIMPLE_GET_FUNC(type, name, returnType) \
|
||||
export returnType CreatureLib_##type##_##name(const type* p) { return p->name().operator->(); }
|
||||
|
||||
SIMPLE_GET_FUNC(DataLibrary, GetSettings, const LibrarySettings*);
|
||||
SIMPLE_GET_FUNC(DataLibrary, GetSpeciesLibrary, const SpeciesLibrary*);
|
||||
SIMPLE_GET_FUNC(DataLibrary, GetAttackLibrary, const AttackLibrary*);
|
||||
SIMPLE_GET_FUNC(DataLibrary, GetItemLibrary, const ItemLibrary*);
|
||||
SIMPLE_GET_FUNC(DataLibrary, GetGrowthRates, const GrowthRateLibrary*);
|
||||
SIMPLE_GET_FUNC(DataLibrary, GetTypeLibrary, const TypeLibrary*);
|
||||
|
||||
#undef SIMPLE_GET_FUNC
|
||||
SMART_GET_FUNC(DataLibrary, GetSettings, const LibrarySettings*);
|
||||
SMART_GET_FUNC(DataLibrary, GetSpeciesLibrary, const SpeciesLibrary*);
|
||||
SMART_GET_FUNC(DataLibrary, GetAttackLibrary, const AttackLibrary*);
|
||||
SMART_GET_FUNC(DataLibrary, GetItemLibrary, const ItemLibrary*);
|
||||
SMART_GET_FUNC(DataLibrary, GetGrowthRates, const GrowthRateLibrary*);
|
||||
SMART_GET_FUNC(DataLibrary, GetTypeLibrary, const TypeLibrary*);
|
||||
@@ -14,9 +14,6 @@ export Item* CreatureLib_Item_Construct(const char* name, ItemCategory category,
|
||||
|
||||
export void CreatureLib_Item_Destruct(const Item* p) { delete p; }
|
||||
|
||||
#define SIMPLE_GET_FUNC(type, name, returnType) \
|
||||
export returnType CreatureLib_##type##_##name(const type* p) { return p->name(); }
|
||||
|
||||
export const char* CreatureLib_Item_GetName(const Item* p) { return p->GetName().c_str(); }
|
||||
SIMPLE_GET_FUNC(Item, GetCategory, ItemCategory);
|
||||
SIMPLE_GET_FUNC(Item, GetBattleCategory, BattleItemCategory);
|
||||
@@ -24,6 +21,4 @@ SIMPLE_GET_FUNC(Item, GetPrice, int32_t);
|
||||
|
||||
export bool CreatureLib_Item_HasFlag(const Item* p, const char* key) {
|
||||
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
|
||||
}
|
||||
|
||||
#undef SIMPLE_GET_FUNC
|
||||
}
|
||||
@@ -8,10 +8,5 @@ export const LibrarySettings* CreatureLib_LibrarySettings_Construct(uint8_t maxi
|
||||
|
||||
export void CreatureLib_LibrarySettings_Destruct(const LibrarySettings* p) { delete p; }
|
||||
|
||||
#define SIMPLE_GET_FUNC(type, name, returnType) \
|
||||
export returnType CreatureLib_##type##_##name(const CreatureLib::Library::type* p) { return p->name(); }
|
||||
|
||||
SIMPLE_GET_FUNC(LibrarySettings, GetMaximalLevel, uint8_t);
|
||||
SIMPLE_GET_FUNC(LibrarySettings, GetMaximalMoves, uint8_t);
|
||||
|
||||
#undef SIMPLE_GET_FUNC
|
||||
SIMPLE_GET_FUNC(LibrarySettings, GetMaximalMoves, uint8_t);
|
||||
@@ -27,9 +27,6 @@ export SpeciesVariant* CreatureLib_SpeciesVariant_Construct(
|
||||
|
||||
export void CreatureLib_SpeciesVariant_Destruct(SpeciesVariant* p) { delete p; }
|
||||
|
||||
#define SIMPLE_GET_FUNC(type, name, returnType) \
|
||||
export returnType CreatureLib_##type##_##name(const CreatureLib::Library::type* p) { return p->name(); }
|
||||
|
||||
export const char* CreatureLib_SpeciesVariant_GetName(SpeciesVariant* p) { return p->GetName().c_str(); }
|
||||
SIMPLE_GET_FUNC(SpeciesVariant, GetHeight, float);
|
||||
SIMPLE_GET_FUNC(SpeciesVariant, GetWeight, float);
|
||||
@@ -45,7 +42,5 @@ export uint8_t CreatureLib_SpeciesVariant_GetTalent(SpeciesVariant* p, bool secr
|
||||
Try(out = p->GetTalent(TalentIndex(secret, index)).c_str();)
|
||||
}
|
||||
export const LearnableAttacks* CreatureLib_SpeciesVariant_GetLearnableAttacks(SpeciesVariant* p) {
|
||||
return p->GetLearnableAttacks().operator->();
|
||||
return p->GetLearnableAttacks().GetRaw();
|
||||
}
|
||||
|
||||
#undef SIMPLE_GET_FUNC
|
||||
|
||||
Reference in New Issue
Block a user