More Item tests
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-01-22 11:29:14 +01:00
parent 22648e8617
commit 47db8464a2
2 changed files with 51 additions and 2 deletions

View File

@@ -46,6 +46,13 @@ void RegisterItemTypes::RegisterBattleItemCategoryEnum(asIScriptEngine* engine)
assert(r >= 0);
}
// Hack to handle AngelScript not recognizing different sized enums on fields, and returning invalid values due to it.
#define ENUM__SIZE_WRAPPER(name, type, func) \
int32_t name(type* obj) { return static_cast<int32_t>(obj->func()); }
ENUM__SIZE_WRAPPER(Move_CategoryWrapper, PkmnLib::Library::Item, GetCategory)
ENUM__SIZE_WRAPPER(Move_BattleCategoryWrapper, PkmnLib::Library::Item, GetBattleCategory)
void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("Item", 0, asOBJ_REF | asOBJ_NOCOUNT);
assert(r >= 0);
@@ -53,10 +60,10 @@ void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) {
asMETHOD(PkmnLib::Library::Item, GetName), asCALL_THISCALL);
assert(r >= 0);
r = engine->RegisterObjectMethod("Item", "ItemCategory get_Category() const property",
asMETHOD(PkmnLib::Library::Item, GetCategory), asCALL_THISCALL);
asFUNCTION(Move_CategoryWrapper), asCALL_CDECL_OBJLAST);
assert(r >= 0);
r = engine->RegisterObjectMethod("Item", "BattleItemCategory get_BattleCategory() const property",
asMETHOD(PkmnLib::Library::Item, GetBattleCategory), asCALL_THISCALL);
asFUNCTION(Move_BattleCategoryWrapper), asCALL_CDECL_OBJLAST);
assert(r >= 0);
r = engine->RegisterObjectMethod("Item", "int get_Price() const property",
asMETHOD(PkmnLib::Library::Item, GetPrice), asCALL_THISCALL);