diff --git a/gdnative/variant.cpp b/gdnative/variant.cpp index e4e4cc1..4ab8075 100644 --- a/gdnative/variant.cpp +++ b/gdnative/variant.cpp @@ -62,6 +62,44 @@ pandemonium_variant_type GDAPI pandemonium_variant_get_type(const pandemonium_va return (pandemonium_variant_type)self->get_type(); } +pandemonium_bool GDAPI pandemonium_variant_is_ref(const pandemonium_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->is_ref(); +} +pandemonium_bool GDAPI pandemonium_variant_is_num(const pandemonium_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->is_num(); +} +pandemonium_bool GDAPI pandemonium_variant_is_array(const pandemonium_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->is_array(); +} +pandemonium_bool GDAPI pandemonium_variant_is_null(const pandemonium_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->is_null(); +} +pandemonium_bool GDAPI pandemonium_variant_is_shared(const pandemonium_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->is_shared(); +} +pandemonium_bool GDAPI pandemonium_variant_is_zero(const pandemonium_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->is_zero(); +} +pandemonium_bool GDAPI pandemonium_variant_is_one(const pandemonium_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->is_one(); +} + +pandemonium_int GDAPI pandemonium_variant_get_object_instance_id(const pandemonium_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->get_object_instance_id(); +} +pandemonium_bool GDAPI pandemonium_variant_is_invalid_object(const pandemonium_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->is_invalid_object(); +} + void GDAPI pandemonium_variant_new_copy(pandemonium_variant *p_dest, const pandemonium_variant *p_src) { Variant *dest = (Variant *)p_dest; Variant *src = (Variant *)p_src; @@ -477,6 +515,17 @@ pandemonium_bool GDAPI pandemonium_variant_has_method(const pandemonium_variant return self->has_method(*method); } +pandemonium_bool GDAPI pandemonium_variant_deep_equal(const pandemonium_variant *p_self, const pandemonium_variant *p_variant) { + const Variant *self = (const Variant *)p_self; + const Variant *variant = (const Variant *)p_variant; + return self->deep_equal(*variant); +} +pandemonium_bool GDAPI pandemonium_variant_deep_equal_recursion_count(const pandemonium_variant *p_self, const pandemonium_variant *p_variant, pandemonium_int p_recursion_count) { + const Variant *self = (const Variant *)p_self; + const Variant *variant = (const Variant *)p_variant; + return self->deep_equal(*variant, p_recursion_count); +} + pandemonium_bool GDAPI pandemonium_variant_operator_equal(const pandemonium_variant *p_self, const pandemonium_variant *p_other) { const Variant *self = (const Variant *)p_self; const Variant *other = (const Variant *)p_other; @@ -489,6 +538,11 @@ pandemonium_bool GDAPI pandemonium_variant_operator_less(const pandemonium_varia return self->operator<(*other); } +pandemonium_int GDAPI pandemonium_variant_hash(const pandemonium_variant *p_self) { + const Variant *self = (const Variant *)p_self; + return self->hash(); +} + pandemonium_bool GDAPI pandemonium_variant_hash_compare(const pandemonium_variant *p_self, const pandemonium_variant *p_other) { const Variant *self = (const Variant *)p_self; const Variant *other = (const Variant *)p_other; @@ -523,6 +577,23 @@ void GDAPI pandemonium_variant_evaluate(pandemonium_variant_operator p_op, const Variant::evaluate(op, *a, *b, *ret, *r_valid); } +void GDAPI pandemonium_variant_zero(pandemonium_variant *p_self) { + Variant *self = (Variant *)p_self; + self->zero(); +} +pandemonium_variant GDAPI pandemonium_variant_duplicate(const pandemonium_variant *p_self) { + pandemonium_variant dest; + const Variant *self = (const Variant *)p_self; + *((Variant *)&dest) = self->duplicate(); + return dest; +} +pandemonium_variant GDAPI pandemonium_variant_duplicate_deep(const pandemonium_variant *p_self, pandemonium_bool deep) { + pandemonium_variant dest; + const Variant *self = (const Variant *)p_self; + *((Variant *)&dest) = self->duplicate(deep); + return dest; +} + #ifdef __cplusplus } #endif diff --git a/include/gdn/variant.h b/include/gdn/variant.h index dbe5a36..f756986 100644 --- a/include/gdn/variant.h +++ b/include/gdn/variant.h @@ -191,23 +191,25 @@ pandemonium_variant_type GDAPI pandemonium_variant_get_type(const pandemonium_va //static bool can_convert(Type p_type_from, Type p_type_to); //static bool can_convert_strict(Type p_type_from, Type p_type_to); -//bool is_ref() const; -//_FORCE_INLINE_ bool is_num() const { return type == INT || type == REAL; }; -//_FORCE_INLINE_ bool is_array() const { return type >= ARRAY; }; -//_FORCE_INLINE_ bool is_null() const { return type == NIL; }; -//bool is_shared() const; -//bool is_zero() const; -//bool is_one() const; +pandemonium_bool GDAPI pandemonium_variant_is_ref(const pandemonium_variant *p_self); +pandemonium_bool GDAPI pandemonium_variant_is_num(const pandemonium_variant *p_self); +pandemonium_bool GDAPI pandemonium_variant_is_array(const pandemonium_variant *p_self); +pandemonium_bool GDAPI pandemonium_variant_is_null(const pandemonium_variant *p_self); +pandemonium_bool GDAPI pandemonium_variant_is_shared(const pandemonium_variant *p_self); +pandemonium_bool GDAPI pandemonium_variant_is_zero(const pandemonium_variant *p_self); +pandemonium_bool GDAPI pandemonium_variant_is_one(const pandemonium_variant *p_self); -//ObjectID get_object_instance_id() const; -//bool is_invalid_object() const; +pandemonium_int GDAPI pandemonium_variant_get_object_instance_id(const pandemonium_variant *p_self); +pandemonium_bool GDAPI pandemonium_variant_is_invalid_object(const pandemonium_variant *p_self); pandemonium_string GDAPI pandemonium_variant_get_operator_name(pandemonium_variant_operator p_op); void GDAPI pandemonium_variant_evaluate(pandemonium_variant_operator p_op, const pandemonium_variant *p_a, const pandemonium_variant *p_b, pandemonium_variant *r_ret, pandemonium_bool *r_valid); -//static _FORCE_INLINE_ Variant evaluate(const Operator &p_op, const Variant &p_a, const Variant &p_b) { +//static _FORCE_INLINE_ Variant evaluate(const Operator &p_op, const Variant &p_a, const Variant &p_b); + +void GDAPI pandemonium_variant_zero(pandemonium_variant *p_self); +pandemonium_variant GDAPI pandemonium_variant_duplicate(const pandemonium_variant *p_self); +pandemonium_variant GDAPI pandemonium_variant_duplicate_deep(const pandemonium_variant *p_self, pandemonium_bool deep); -//void zero(); -//Variant duplicate(bool deep = false) const; //static void blend(const Variant &a, const Variant &b, float c, Variant &r_dst); //static void interpolate(const Variant &a, const Variant &b, float c, Variant &r_dst); //static void sub(const Variant &a, const Variant &b, Variant &r_dst); @@ -241,10 +243,11 @@ pandemonium_bool GDAPI pandemonium_variant_has_method(const pandemonium_variant //void get_property_list(List *p_list) const; -//bool deep_equal(const Variant &p_variant, int p_recursion_count = 0) const; +pandemonium_bool GDAPI pandemonium_variant_deep_equal(const pandemonium_variant *p_self, const pandemonium_variant *p_variant); +pandemonium_bool GDAPI pandemonium_variant_deep_equal_recursion_count(const pandemonium_variant *p_self, const pandemonium_variant *p_variant, pandemonium_int p_recursion_count); pandemonium_bool GDAPI pandemonium_variant_operator_equal(const pandemonium_variant *p_self, const pandemonium_variant *p_other); pandemonium_bool GDAPI pandemonium_variant_operator_less(const pandemonium_variant *p_self, const pandemonium_variant *p_other); -//uint32_t hash() const; +pandemonium_int GDAPI pandemonium_variant_hash(const pandemonium_variant *p_self); pandemonium_bool GDAPI pandemonium_variant_hash_compare(const pandemonium_variant *p_self, const pandemonium_variant *p_other); pandemonium_bool GDAPI pandemonium_variant_booleanize(const pandemonium_variant *p_self);