From 9f34bb4ebe1e7d5b08b27acc7af216d3b27cd37e Mon Sep 17 00:00:00 2001 From: sheepandshepherd Date: Wed, 31 May 2017 00:03:50 +0200 Subject: [PATCH] Wrap copy constructor for some GDNative types --- modules/gdnative/godot/godot_array.cpp | 6 +++ modules/gdnative/godot/godot_array.h | 1 + modules/gdnative/godot/godot_dictionary.cpp | 6 +++ modules/gdnative/godot/godot_dictionary.h | 1 + modules/gdnative/godot/godot_pool_arrays.cpp | 42 ++++++++++++++++++++ modules/gdnative/godot/godot_pool_arrays.h | 7 ++++ 6 files changed, 63 insertions(+) diff --git a/modules/gdnative/godot/godot_array.cpp b/modules/gdnative/godot/godot_array.cpp index bf2ef359720..8cf6d1b8ef2 100644 --- a/modules/gdnative/godot/godot_array.cpp +++ b/modules/gdnative/godot/godot_array.cpp @@ -49,6 +49,12 @@ void GDAPI godot_array_new(godot_array *p_arr) { memnew_placement(a, Array); } +void GDAPI godot_array_new_copy(godot_array *p_dest, const godot_array *p_src) { + Array *dest = (Array *)p_dest; + const Array *src = (const Array *)p_src; + memnew_placement(dest, Array(*src)); +} + void GDAPI godot_array_new_pool_color_array(godot_array *p_arr, const godot_pool_color_array *p_pca) { Array *a = (Array *)p_arr; PoolVector *pca = (PoolVector *)p_pca; diff --git a/modules/gdnative/godot/godot_array.h b/modules/gdnative/godot/godot_array.h index f7150950fc8..5db0031b8ca 100644 --- a/modules/gdnative/godot/godot_array.h +++ b/modules/gdnative/godot/godot_array.h @@ -49,6 +49,7 @@ typedef struct godot_array { #include "../godot.h" void GDAPI godot_array_new(godot_array *p_arr); +void GDAPI godot_array_new_copy(godot_array *p_dest, const godot_array *p_src); void GDAPI godot_array_new_pool_color_array(godot_array *p_arr, const godot_pool_color_array *p_pca); void GDAPI godot_array_new_pool_vector3_array(godot_array *p_arr, const godot_pool_vector3_array *p_pv3a); void GDAPI godot_array_new_pool_vector2_array(godot_array *p_arr, const godot_pool_vector2_array *p_pv2a); diff --git a/modules/gdnative/godot/godot_dictionary.cpp b/modules/gdnative/godot/godot_dictionary.cpp index b98ee5b5c9a..deec5f8ffb8 100644 --- a/modules/gdnative/godot/godot_dictionary.cpp +++ b/modules/gdnative/godot/godot_dictionary.cpp @@ -44,6 +44,12 @@ void GDAPI godot_dictionary_new(godot_dictionary *r_dest) { memnew_placement(dest, Dictionary); } +void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *r_src) { + Dictionary *dest = (Dictionary *)r_dest; + const Dictionary *src = (const Dictionary *)r_src; + memnew_placement(dest, Dictionary(*src)); +} + void GDAPI godot_dictionary_destroy(godot_dictionary *p_self) { Dictionary *self = (Dictionary *)p_self; self->~Dictionary(); diff --git a/modules/gdnative/godot/godot_dictionary.h b/modules/gdnative/godot/godot_dictionary.h index 42f7f872a15..a89bd4bba1d 100644 --- a/modules/gdnative/godot/godot_dictionary.h +++ b/modules/gdnative/godot/godot_dictionary.h @@ -48,6 +48,7 @@ typedef struct godot_dictionary { #include "godot_variant.h" void GDAPI godot_dictionary_new(godot_dictionary *r_dest); +void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *r_src); void GDAPI godot_dictionary_destroy(godot_dictionary *p_self); godot_int GDAPI godot_dictionary_size(const godot_dictionary *p_self); diff --git a/modules/gdnative/godot/godot_pool_arrays.cpp b/modules/gdnative/godot/godot_pool_arrays.cpp index 10d5d6d9390..cb0b5d2f119 100644 --- a/modules/gdnative/godot/godot_pool_arrays.cpp +++ b/modules/gdnative/godot/godot_pool_arrays.cpp @@ -49,6 +49,12 @@ void GDAPI godot_pool_byte_array_new(godot_pool_byte_array *p_pba) { memnew_placement(pba, PoolVector); } +void GDAPI godot_pool_byte_array_new_copy(godot_pool_byte_array *p_dest, const godot_pool_byte_array *p_src) { + PoolVector *dest = (PoolVector *)p_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + void GDAPI godot_pool_byte_array_new_with_array(godot_pool_byte_array *p_pba, const godot_array *p_a) { PoolVector *pba = (PoolVector *)p_pba; Array *a = (Array *)p_a; @@ -122,6 +128,12 @@ void GDAPI godot_pool_int_array_new(godot_pool_int_array *p_pba) { memnew_placement(pba, PoolVector); } +void GDAPI godot_pool_int_array_new_copy(godot_pool_int_array *p_dest, const godot_pool_int_array *p_src) { + PoolVector *dest = (PoolVector *)p_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + void GDAPI godot_pool_int_array_new_with_array(godot_pool_int_array *p_pba, const godot_array *p_a) { PoolVector *pba = (PoolVector *)p_pba; Array *a = (Array *)p_a; @@ -195,6 +207,12 @@ void GDAPI godot_pool_real_array_new(godot_pool_real_array *p_pba) { memnew_placement(pba, PoolVector); } +void GDAPI godot_pool_real_array_new_copy(godot_pool_real_array *p_dest, const godot_pool_real_array *p_src) { + PoolVector *dest = (PoolVector *)p_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + void GDAPI godot_pool_real_array_new_with_array(godot_pool_real_array *p_pba, const godot_array *p_a) { PoolVector *pba = (PoolVector *)p_pba; Array *a = (Array *)p_a; @@ -268,6 +286,12 @@ void GDAPI godot_pool_string_array_new(godot_pool_string_array *p_pba) { memnew_placement(pba, PoolVector); } +void GDAPI godot_pool_string_array_new_copy(godot_pool_string_array *p_dest, const godot_pool_string_array *p_src) { + PoolVector *dest = (PoolVector *)p_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + void GDAPI godot_pool_string_array_new_with_array(godot_pool_string_array *p_pba, const godot_array *p_a) { PoolVector *pba = (PoolVector *)p_pba; Array *a = (Array *)p_a; @@ -349,6 +373,12 @@ void GDAPI godot_pool_vector2_array_new(godot_pool_vector2_array *p_pba) { memnew_placement(pba, PoolVector); } +void GDAPI godot_pool_vector2_array_new_copy(godot_pool_vector2_array *p_dest, const godot_pool_vector2_array *p_src) { + PoolVector *dest = (PoolVector *)p_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + void GDAPI godot_pool_vector2_array_new_with_array(godot_pool_vector2_array *p_pba, const godot_array *p_a) { PoolVector *pba = (PoolVector *)p_pba; Array *a = (Array *)p_a; @@ -429,6 +459,12 @@ void GDAPI godot_pool_vector3_array_new(godot_pool_vector3_array *p_pba) { memnew_placement(pba, PoolVector); } +void GDAPI godot_pool_vector3_array_new_copy(godot_pool_vector3_array *p_dest, const godot_pool_vector3_array *p_src) { + PoolVector *dest = (PoolVector *)p_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + void GDAPI godot_pool_vector3_array_new_with_array(godot_pool_vector3_array *p_pba, const godot_array *p_a) { PoolVector *pba = (PoolVector *)p_pba; Array *a = (Array *)p_a; @@ -509,6 +545,12 @@ void GDAPI godot_pool_color_array_new(godot_pool_color_array *p_pba) { memnew_placement(pba, PoolVector); } +void GDAPI godot_pool_color_array_new_copy(godot_pool_color_array *p_dest, const godot_pool_color_array *p_src) { + PoolVector *dest = (PoolVector *)p_dest; + const PoolVector *src = (const PoolVector *)p_src; + memnew_placement(dest, PoolVector(*src)); +} + void GDAPI godot_pool_color_array_new_with_array(godot_pool_color_array *p_pba, const godot_array *p_a) { PoolVector *pba = (PoolVector *)p_pba; Array *a = (Array *)p_a; diff --git a/modules/gdnative/godot/godot_pool_arrays.h b/modules/gdnative/godot/godot_pool_arrays.h index 015be65c3e0..8b0d0137fdd 100644 --- a/modules/gdnative/godot/godot_pool_arrays.h +++ b/modules/gdnative/godot/godot_pool_arrays.h @@ -102,6 +102,7 @@ typedef struct godot_pool_color_array { // byte void GDAPI godot_pool_byte_array_new(godot_pool_byte_array *p_pba); +void GDAPI godot_pool_byte_array_new_copy(godot_pool_byte_array *p_dest, const godot_pool_byte_array *p_src); void GDAPI godot_pool_byte_array_new_with_array(godot_pool_byte_array *p_pba, const godot_array *p_a); void GDAPI godot_pool_byte_array_append(godot_pool_byte_array *p_pba, const uint8_t p_data); @@ -128,6 +129,7 @@ void GDAPI godot_pool_byte_array_destroy(godot_pool_byte_array *p_pba); // int void GDAPI godot_pool_int_array_new(godot_pool_int_array *p_pia); +void GDAPI godot_pool_int_array_new_copy(godot_pool_int_array *p_dest, const godot_pool_int_array *p_src); void GDAPI godot_pool_int_array_new_with_array(godot_pool_int_array *p_pia, const godot_array *p_a); void GDAPI godot_pool_int_array_append(godot_pool_int_array *p_pia, const godot_int p_data); @@ -154,6 +156,7 @@ void GDAPI godot_pool_int_array_destroy(godot_pool_int_array *p_pia); // real void GDAPI godot_pool_real_array_new(godot_pool_real_array *p_pra); +void GDAPI godot_pool_real_array_new_copy(godot_pool_real_array *p_dest, const godot_pool_real_array *p_src); void GDAPI godot_pool_real_array_new_with_array(godot_pool_real_array *p_pra, const godot_array *p_a); void GDAPI godot_pool_real_array_append(godot_pool_real_array *p_pra, const godot_real p_data); @@ -180,6 +183,7 @@ void GDAPI godot_pool_real_array_destroy(godot_pool_real_array *p_pra); // string void GDAPI godot_pool_string_array_new(godot_pool_string_array *p_psa); +void GDAPI godot_pool_string_array_new_copy(godot_pool_string_array *p_dest, const godot_pool_string_array *p_src); void GDAPI godot_pool_string_array_new_with_array(godot_pool_string_array *p_psa, const godot_array *p_a); void GDAPI godot_pool_string_array_append(godot_pool_string_array *p_psa, const godot_string *p_data); @@ -206,6 +210,7 @@ void GDAPI godot_pool_string_array_destroy(godot_pool_string_array *p_psa); // vector2 void GDAPI godot_pool_vector2_array_new(godot_pool_vector2_array *p_pv2a); +void GDAPI godot_pool_vector2_array_new_copy(godot_pool_vector2_array *p_dest, const godot_pool_vector2_array *p_src); void GDAPI godot_pool_vector2_array_new_with_array(godot_pool_vector2_array *p_pv2a, const godot_array *p_a); void GDAPI godot_pool_vector2_array_append(godot_pool_vector2_array *p_pv2a, const godot_vector2 *p_data); @@ -232,6 +237,7 @@ void GDAPI godot_pool_vector2_array_destroy(godot_pool_vector2_array *p_pv2a); // vector3 void GDAPI godot_pool_vector3_array_new(godot_pool_vector3_array *p_pv3a); +void GDAPI godot_pool_vector3_array_new_copy(godot_pool_vector3_array *p_dest, const godot_pool_vector3_array *p_src); void GDAPI godot_pool_vector3_array_new_with_array(godot_pool_vector3_array *p_pv3a, const godot_array *p_a); void GDAPI godot_pool_vector3_array_append(godot_pool_vector3_array *p_pv3a, const godot_vector3 *p_data); @@ -258,6 +264,7 @@ void GDAPI godot_pool_vector3_array_destroy(godot_pool_vector3_array *p_pv3a); // color void GDAPI godot_pool_color_array_new(godot_pool_color_array *p_pca); +void GDAPI godot_pool_color_array_new_copy(godot_pool_color_array *p_dest, const godot_pool_color_array *p_src); void GDAPI godot_pool_color_array_new_with_array(godot_pool_color_array *p_pca, const godot_array *p_a); void GDAPI godot_pool_color_array_append(godot_pool_color_array *p_pca, const godot_color *p_data);