From ea4ca1895cd2d3f2b138e41bb41664a97e93984a Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 31 May 2023 01:39:00 +0200 Subject: [PATCH] Added the new PoolVector variants to Variant. --- gdnative/variant.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++ include/gdn/variant.h | 10 ++++++-- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/gdnative/variant.cpp b/gdnative/variant.cpp index 4ab8075..b3fbe1e 100644 --- a/gdnative/variant.cpp +++ b/gdnative/variant.cpp @@ -271,12 +271,36 @@ void GDAPI pandemonium_variant_new_pool_vector2_array(pandemonium_variant *r_des memnew_placement_custom(dest, Variant, Variant(*pv2a)); } +void GDAPI pandemonium_variant_new_pool_vector2i_array(pandemonium_variant *r_dest, const pandemonium_pool_vector2i_array *p_pv2ia) { + Variant *dest = (Variant *)r_dest; + PoolVector2iArray *pv2ia = (PoolVector2iArray *)p_pv2ia; + memnew_placement_custom(dest, Variant, Variant(*pv2ia)); +} + void GDAPI pandemonium_variant_new_pool_vector3_array(pandemonium_variant *r_dest, const pandemonium_pool_vector3_array *p_pv3a) { Variant *dest = (Variant *)r_dest; PoolVector3Array *pv3a = (PoolVector3Array *)p_pv3a; memnew_placement_custom(dest, Variant, Variant(*pv3a)); } +void GDAPI pandemonium_variant_new_pool_vector3i_array(pandemonium_variant *r_dest, const pandemonium_pool_vector3i_array *p_pv3ia) { + Variant *dest = (Variant *)r_dest; + PoolVector3iArray *pv3ia = (PoolVector3iArray *)p_pv3ia; + memnew_placement_custom(dest, Variant, Variant(*pv3ia)); +} + +void GDAPI pandemonium_variant_new_pool_vector4_array(pandemonium_variant *r_dest, const pandemonium_pool_vector4_array *p_pv4a) { + Variant *dest = (Variant *)r_dest; + PoolVector4Array *pv4a = (PoolVector4Array *)p_pv4a; + memnew_placement_custom(dest, Variant, Variant(*pv4a)); +} + +void GDAPI pandemonium_variant_new_pool_vector4i_array(pandemonium_variant *r_dest, const pandemonium_pool_vector4i_array *p_pv4ia) { + Variant *dest = (Variant *)r_dest; + PoolVector4iArray *pv4ia = (PoolVector4iArray *)p_pv4ia; + memnew_placement_custom(dest, Variant, Variant(*pv4ia)); +} + void GDAPI pandemonium_variant_new_pool_color_array(pandemonium_variant *r_dest, const pandemonium_pool_color_array *p_pca) { Variant *dest = (Variant *)r_dest; PoolColorArray *pca = (PoolColorArray *)p_pca; @@ -475,6 +499,15 @@ pandemonium_pool_vector2_array GDAPI pandemonium_variant_as_pool_vector2_array(c return raw_dest; } +pandemonium_pool_vector2i_array GDAPI pandemonium_variant_as_pool_vector2i_array(const pandemonium_variant *p_self) { + pandemonium_pool_vector2i_array raw_dest; + const Variant *self = (const Variant *)p_self; + PoolVector2iArray *dest = (PoolVector2iArray *)&raw_dest; + memnew_placement(dest, PoolVector2iArray(self->operator PoolVector2iArray())); // operator = is overloaded by PoolVector2Array + *dest = *self; + return raw_dest; +} + pandemonium_pool_vector3_array GDAPI pandemonium_variant_as_pool_vector3_array(const pandemonium_variant *p_self) { pandemonium_pool_vector3_array raw_dest; const Variant *self = (const Variant *)p_self; @@ -484,6 +517,33 @@ pandemonium_pool_vector3_array GDAPI pandemonium_variant_as_pool_vector3_array(c return raw_dest; } +pandemonium_pool_vector3i_array GDAPI pandemonium_variant_as_pool_vector3i_array(const pandemonium_variant *p_self) { + pandemonium_pool_vector3i_array raw_dest; + const Variant *self = (const Variant *)p_self; + PoolVector3iArray *dest = (PoolVector3iArray *)&raw_dest; + memnew_placement(dest, PoolVector3iArray(self->operator PoolVector3iArray())); // operator = is overloaded by PoolVector3Array + *dest = *self; + return raw_dest; +} + +pandemonium_pool_vector4_array GDAPI pandemonium_variant_as_pool_vector4_array(const pandemonium_variant *p_self) { + pandemonium_pool_vector4_array raw_dest; + const Variant *self = (const Variant *)p_self; + PoolVector4Array *dest = (PoolVector4Array *)&raw_dest; + memnew_placement(dest, PoolVector4Array(self->operator PoolVector4Array())); // operator = is overloaded by PoolVector3Array + *dest = *self; + return raw_dest; +} + +pandemonium_pool_vector4i_array GDAPI pandemonium_variant_as_pool_vector4i_array(const pandemonium_variant *p_self) { + pandemonium_pool_vector4i_array raw_dest; + const Variant *self = (const Variant *)p_self; + PoolVector4iArray *dest = (PoolVector4iArray *)&raw_dest; + memnew_placement(dest, PoolVector4iArray(self->operator PoolVector4iArray())); // operator = is overloaded by PoolVector3Array + *dest = *self; + return raw_dest; +} + pandemonium_pool_color_array GDAPI pandemonium_variant_as_pool_color_array(const pandemonium_variant *p_self) { pandemonium_pool_color_array raw_dest; const Variant *self = (const Variant *)p_self; diff --git a/include/gdn/variant.h b/include/gdn/variant.h index f756986..df0bf6f 100644 --- a/include/gdn/variant.h +++ b/include/gdn/variant.h @@ -287,9 +287,12 @@ pandemonium_pool_int_array GDAPI pandemonium_variant_as_pool_int_array(const pan pandemonium_pool_real_array GDAPI pandemonium_variant_as_pool_real_array(const pandemonium_variant *p_self); pandemonium_pool_string_array GDAPI pandemonium_variant_as_pool_string_array(const pandemonium_variant *p_self); pandemonium_pool_vector2_array GDAPI pandemonium_variant_as_pool_vector2_array(const pandemonium_variant *p_self); +pandemonium_pool_vector2i_array GDAPI pandemonium_variant_as_pool_vector2i_array(const pandemonium_variant *p_self); pandemonium_pool_vector3_array GDAPI pandemonium_variant_as_pool_vector3_array(const pandemonium_variant *p_self); +pandemonium_pool_vector3i_array GDAPI pandemonium_variant_as_pool_vector3i_array(const pandemonium_variant *p_self); +pandemonium_pool_vector4_array GDAPI pandemonium_variant_as_pool_vector4_array(const pandemonium_variant *p_self); +pandemonium_pool_vector4i_array GDAPI pandemonium_variant_as_pool_vector4i_array(const pandemonium_variant *p_self); pandemonium_pool_color_array GDAPI pandemonium_variant_as_pool_color_array(const pandemonium_variant *p_self); -//add the new ones void GDAPI pandemonium_variant_new_copy(pandemonium_variant *r_dest, const pandemonium_variant *p_src); @@ -319,9 +322,12 @@ void GDAPI pandemonium_variant_new_pool_int_array(pandemonium_variant *r_dest, c void GDAPI pandemonium_variant_new_pool_real_array(pandemonium_variant *r_dest, const pandemonium_pool_real_array *p_pra); void GDAPI pandemonium_variant_new_pool_string_array(pandemonium_variant *r_dest, const pandemonium_pool_string_array *p_psa); void GDAPI pandemonium_variant_new_pool_vector2_array(pandemonium_variant *r_dest, const pandemonium_pool_vector2_array *p_pv2a); +void GDAPI pandemonium_variant_new_pool_vector2i_array(pandemonium_variant *r_dest, const pandemonium_pool_vector2i_array *p_pv2ia); void GDAPI pandemonium_variant_new_pool_vector3_array(pandemonium_variant *r_dest, const pandemonium_pool_vector3_array *p_pv3a); +void GDAPI pandemonium_variant_new_pool_vector3i_array(pandemonium_variant *r_dest, const pandemonium_pool_vector3i_array *p_pv3ia); +void GDAPI pandemonium_variant_new_pool_vector4_array(pandemonium_variant *r_dest, const pandemonium_pool_vector4_array *p_pv4a); +void GDAPI pandemonium_variant_new_pool_vector4i_array(pandemonium_variant *r_dest, const pandemonium_pool_vector4i_array *p_pv4ia); void GDAPI pandemonium_variant_new_pool_color_array(pandemonium_variant *r_dest, const pandemonium_pool_color_array *p_pca); -//add the new ones void GDAPI pandemonium_variant_destroy(pandemonium_variant *p_self);