diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdnative/gdnative/variant.cpp | 18 | ||||
-rw-r--r-- | modules/gdnative/gdnative_api.json | 18 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/variant.h | 44 |
3 files changed, 80 insertions, 0 deletions
diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp index 423f3312e1..fd6babfc3a 100644 --- a/modules/gdnative/gdnative/variant.cpp +++ b/modules/gdnative/gdnative/variant.cpp @@ -489,6 +489,24 @@ void GDAPI godot_variant_destroy(godot_variant *p_self) { self->~Variant(); } +// GDNative core 1.1 + +godot_string GDAPI godot_variant_get_operator_name(godot_variant_operator p_op) { + Variant::Operator op = (Variant::Operator)p_op; + godot_string raw_dest; + String *dest = (String *)&raw_dest; + memnew_placement(dest, String(Variant::get_operator_name(op))); // operator = is overloaded by String + return raw_dest; +} + +void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_ret, godot_bool *r_valid) { + Variant::Operator op = (Variant::Operator)p_op; + const Variant *a = (const Variant *)p_a; + const Variant *b = (const Variant *)p_b; + Variant *ret = (Variant *)r_ret; + Variant::evaluate(op, a, b, *ret, *r_valid); +} + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index dce3d7e96b..16a34a9a33 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -94,6 +94,24 @@ ["godot_transform *", "r_dest"], ["const godot_quat *", "p_quat"] ] + }, + { + "name": "godot_variant_get_operator_name", + "return_type": "godot_string", + "arguments": [ + ["godot_variant_operator", "p_op"] + ] + }, + { + "name": "godot_variant_evaluate", + "return_type": "void", + "arguments": [ + ["godot_variant_operator", "p_op"], + ["const godot_variant *", "p_a"], + ["const godot_variant *", "p_b"], + ["godot_variant *", "r_ret"], + ["godot_bool *", "r_valid"] + ] } ] }, diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h index 6779dc4092..5e71aa9f11 100644 --- a/modules/gdnative/include/gdnative/variant.h +++ b/modules/gdnative/include/gdnative/variant.h @@ -100,6 +100,45 @@ typedef struct godot_variant_call_error { godot_variant_type expected; } godot_variant_call_error; +typedef enum godot_variant_operator { + // comparison + GODOT_VARIANT_OP_EQUAL, + GODOT_VARIANT_OP_NOT_EQUAL, + GODOT_VARIANT_OP_LESS, + GODOT_VARIANT_OP_LESS_EQUAL, + GODOT_VARIANT_OP_GREATER, + GODOT_VARIANT_OP_GREATER_EQUAL, + + // mathematic + GODOT_VARIANT_OP_ADD, + GODOT_VARIANT_OP_SUBTRACT, + GODOT_VARIANT_OP_MULTIPLY, + GODOT_VARIANT_OP_DIVIDE, + GODOT_VARIANT_OP_NEGATE, + GODOT_VARIANT_OP_POSITIVE, + GODOT_VARIANT_OP_MODULE, + GODOT_VARIANT_OP_STRING_CONCAT, + + // bitwise + GODOT_VARIANT_OP_SHIFT_LEFT, + GODOT_VARIANT_OP_SHIFT_RIGHT, + GODOT_VARIANT_OP_BIT_AND, + GODOT_VARIANT_OP_BIT_OR, + GODOT_VARIANT_OP_BIT_XOR, + GODOT_VARIANT_OP_BIT_NEGATE, + + // logic + GODOT_VARIANT_OP_AND, + GODOT_VARIANT_OP_OR, + GODOT_VARIANT_OP_XOR, + GODOT_VARIANT_OP_NOT, + + // containment + GODOT_VARIANT_OP_IN, + + GODOT_VARIANT_OP_MAX, +} godot_variant_operator; + // reduce extern "C" nesting for VS2013 #ifdef __cplusplus } @@ -204,6 +243,11 @@ godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self); void GDAPI godot_variant_destroy(godot_variant *p_self); +// GDNative core 1.1 + +godot_string GDAPI godot_variant_get_operator_name(godot_variant_operator p_op); +void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_ret, godot_bool *r_valid); + #ifdef __cplusplus } #endif |