Implements handling of userdata collection items
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#define PORYGON_INTEGER_TYPE ((Porygon::ScriptType*)new Porygon::NumericScriptType(true, false))
|
||||
#define PORYGON_FLOAT_TYPE ((Porygon::ScriptType*)new Porygon::NumericScriptType(true, true))
|
||||
#define PORYGON_STRING_TYPE ((Porygon::ScriptType*)new Porygon::StringScriptType(false, 0))
|
||||
#define PORYGON_INDEXABLE_TYPE(keyType, valueType) \
|
||||
((Porygon::ScriptType*)Porygon::UserData::UserDataCollectionType::CreateIndexable(keyType, valueType))
|
||||
|
||||
#define PORYGON_FIELD(fieldName, fieldType, getterHelper, setterHelper) \
|
||||
{ \
|
||||
@@ -42,7 +44,7 @@
|
||||
{ \
|
||||
Porygon::Utilities::HashedString::ConstHash(#fieldName), \
|
||||
new Porygon::UserData::UserDataField(fieldType, \
|
||||
[](void* obj) -> Porygon::Evaluation::EvalValue* { return new getterHelper;}, \
|
||||
[](void* obj) -> const Porygon::Evaluation::EvalValue* { return new getterHelper;}, \
|
||||
nullptr \
|
||||
) \
|
||||
}, \
|
||||
@@ -63,6 +65,30 @@
|
||||
PORYGON_READONLY_FIELD(fieldName, PORYGON_FLOAT_TYPE, \
|
||||
Porygon::EvaluationFloatEvalValue(((T_USERDATA*)obj)->fieldName))
|
||||
|
||||
/*
|
||||
#define PORYGON_INDEXABLE_FIELD(fieldName, keyType, valueType) \
|
||||
PORYGON_FIELD(fieldName, PORYGON_INDEXABLE_TYPE(keyType, valueType), \
|
||||
const Porygon::Evaluation::IntegerEvalValue(((T_USERDATA*)obj)->fieldName), val->EvaluateInteger())
|
||||
*/
|
||||
|
||||
#define PORYGON_READONLY_VECTOR_FIELD(fieldName, valueType) \
|
||||
PORYGON_READONLY_FIELD(fieldName, PORYGON_INDEXABLE_TYPE(PORYGON_INTEGER_TYPE, valueType), \
|
||||
Porygon::UserData::UserDataCollectionValue( \
|
||||
PORYGON_INDEXABLE_TYPE(PORYGON_INTEGER_TYPE, valueType), \
|
||||
new UserDataCollectionHelper( \
|
||||
obj, \
|
||||
[](void* obj, const EvalValue* v) -> const EvalValue*{ \
|
||||
auto index = v->EvaluateInteger() - 1; \
|
||||
auto val = ((T_USERDATA*)obj)->fieldName;\
|
||||
return EvalValueHelper::Create(val[index]); \
|
||||
} \
|
||||
, [](void* obj, const EvalValue* key, const EvalValue* value){ \
|
||||
auto index = key->EvaluateInteger() - 1;\
|
||||
((T_USERDATA*)obj)->fieldName[index] = value->EvaluateInteger(); \
|
||||
}) \
|
||||
) \
|
||||
)
|
||||
|
||||
|
||||
#define PORYGON_FUNCTION(fieldName, returnType, ...) \
|
||||
{ \
|
||||
@@ -73,7 +99,8 @@
|
||||
\
|
||||
\
|
||||
[](void* obj) -> const Porygon::Evaluation::EvalValue* { \
|
||||
auto t = new Porygon::Evaluation::GenericFunctionEvalValue(make_shared<GenericFunctionScriptType>(), rand()); \
|
||||
auto t = new Porygon::Evaluation::GenericFunctionEvalValue(make_shared<GenericFunctionScriptType>(), \
|
||||
Porygon::Utilities::Random::Get()); \
|
||||
t->RegisterOption(new Porygon::UserData::UserDataFunction( \
|
||||
[](void* obj, const Porygon::Evaluation::EvalValue* par[], int parameterCount) \
|
||||
-> const Porygon::Evaluation::EvalValue*{return ((const T_USERDATA*)obj)->invoke__##fieldName(obj, par, parameterCount);}, \
|
||||
|
||||
Reference in New Issue
Block a user