From 835233fb7128db46389262a8bb23b623b9359ee4 Mon Sep 17 00:00:00 2001 From: Marc Gilleron Date: Wed, 17 Jan 2018 23:58:28 +0100 Subject: [PATCH] Added missing copy constructors and assign operators to PoolVectors --- include/core/PoolArrays.hpp | 14 +++++++ src/core/PoolArrays.cpp | 84 +++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/include/core/PoolArrays.hpp b/include/core/PoolArrays.hpp index 17f08a62..b1c8fec2 100644 --- a/include/core/PoolArrays.hpp +++ b/include/core/PoolArrays.hpp @@ -64,6 +64,8 @@ public: }; PoolByteArray(); + PoolByteArray(const PoolByteArray &p_other); + PoolByteArray &operator=(const PoolByteArray & p_other); PoolByteArray(const Array& array); @@ -143,6 +145,8 @@ public: }; PoolIntArray(); + PoolIntArray(const PoolIntArray &p_other); + PoolIntArray &operator=(const PoolIntArray &p_other); PoolIntArray(const Array& array); @@ -222,6 +226,8 @@ public: }; PoolRealArray(); + PoolRealArray(const PoolRealArray &p_other); + PoolRealArray &operator=(const PoolRealArray &p_other); PoolRealArray(const Array& array); @@ -301,6 +307,8 @@ public: }; PoolStringArray(); + PoolStringArray(const PoolStringArray &p_other); + PoolStringArray &operator=(const PoolStringArray &p_other); PoolStringArray(const Array& array); @@ -381,6 +389,8 @@ public: }; PoolVector2Array(); + PoolVector2Array(const PoolVector2Array &p_other); + PoolVector2Array &operator=(const PoolVector2Array &p_other); PoolVector2Array(const Array& array); @@ -460,6 +470,8 @@ public: }; PoolVector3Array(); + PoolVector3Array(const PoolVector3Array &p_other); + PoolVector3Array &operator=(const PoolVector3Array &p_other); PoolVector3Array(const Array& array); @@ -539,6 +551,8 @@ public: }; PoolColorArray(); + PoolColorArray(const PoolColorArray &p_other); + PoolColorArray &operator=(const PoolColorArray &p_other); PoolColorArray(const Array& array); diff --git a/src/core/PoolArrays.cpp b/src/core/PoolArrays.cpp index 40385746..0ea493fb 100644 --- a/src/core/PoolArrays.cpp +++ b/src/core/PoolArrays.cpp @@ -15,6 +15,18 @@ PoolByteArray::PoolByteArray() godot::api->godot_pool_byte_array_new(&_godot_array); } +PoolByteArray::PoolByteArray(const PoolByteArray &p_other) +{ + godot::api->godot_pool_byte_array_new_copy(&_godot_array, &p_other._godot_array); +} + +PoolByteArray &PoolByteArray::operator=(const PoolByteArray & p_other) +{ + godot::api->godot_pool_byte_array_destroy(&_godot_array); + godot::api->godot_pool_byte_array_new_copy(&_godot_array, &p_other._godot_array); + return *this; +} + PoolByteArray::PoolByteArray(const Array& array) { godot::api->godot_pool_byte_array_new_with_array(&_godot_array, (godot_array *) &array); @@ -97,6 +109,18 @@ PoolIntArray::PoolIntArray() godot::api->godot_pool_int_array_new(&_godot_array); } +PoolIntArray::PoolIntArray(const PoolIntArray &p_other) +{ + godot::api->godot_pool_int_array_new_copy(&_godot_array, &p_other._godot_array); +} + +PoolIntArray &PoolIntArray::operator=(const PoolIntArray &p_other) +{ + godot::api->godot_pool_int_array_destroy(&_godot_array); + godot::api->godot_pool_int_array_new_copy(&_godot_array, &p_other._godot_array); + return *this; +} + PoolIntArray::PoolIntArray(const Array& array) { godot::api->godot_pool_int_array_new_with_array(&_godot_array, (godot_array *) &array); @@ -178,6 +202,18 @@ PoolRealArray::PoolRealArray() godot::api->godot_pool_real_array_new(&_godot_array); } +PoolRealArray::PoolRealArray(const PoolRealArray &p_other) +{ + godot::api->godot_pool_real_array_new_copy(&_godot_array, &p_other._godot_array); +} + +PoolRealArray &PoolRealArray::operator=(const PoolRealArray &p_other) +{ + godot::api->godot_pool_real_array_destroy(&_godot_array); + godot::api->godot_pool_real_array_new_copy(&_godot_array, &p_other._godot_array); + return *this; +} + PoolRealArray::Read PoolRealArray::read() const { Read read; @@ -260,6 +296,18 @@ PoolStringArray::PoolStringArray() godot::api->godot_pool_string_array_new(&_godot_array); } +PoolStringArray::PoolStringArray(const PoolStringArray &p_other) +{ + godot::api->godot_pool_string_array_new_copy(&_godot_array, &p_other._godot_array); +} + +PoolStringArray &PoolStringArray::operator=(const PoolStringArray &p_other) +{ + godot::api->godot_pool_string_array_destroy(&_godot_array); + godot::api->godot_pool_string_array_new_copy(&_godot_array, &p_other._godot_array); + return *this; +} + PoolStringArray::PoolStringArray(const Array& array) { godot::api->godot_pool_string_array_new_with_array(&_godot_array, (godot_array *) &array); @@ -346,6 +394,18 @@ PoolVector2Array::PoolVector2Array() godot::api->godot_pool_vector2_array_new(&_godot_array); } +PoolVector2Array::PoolVector2Array(const PoolVector2Array &p_other) +{ + godot::api->godot_pool_vector2_array_new_copy(&_godot_array, &p_other._godot_array); +} + +PoolVector2Array &PoolVector2Array::operator=(const PoolVector2Array &p_other) +{ + godot::api->godot_pool_vector2_array_destroy(&_godot_array); + godot::api->godot_pool_vector2_array_new_copy(&_godot_array, &p_other._godot_array); + return *this; +} + PoolVector2Array::PoolVector2Array(const Array& array) { godot::api->godot_pool_vector2_array_new_with_array(&_godot_array, (godot_array *) &array); @@ -430,6 +490,18 @@ PoolVector3Array::PoolVector3Array() godot::api->godot_pool_vector3_array_new(&_godot_array); } +PoolVector3Array::PoolVector3Array(const PoolVector3Array &p_other) +{ + godot::api->godot_pool_vector3_array_new_copy(&_godot_array, &p_other._godot_array); +} + +PoolVector3Array &PoolVector3Array::operator=(const PoolVector3Array &p_other) +{ + godot::api->godot_pool_vector3_array_destroy(&_godot_array); + godot::api->godot_pool_vector3_array_new_copy(&_godot_array, &p_other._godot_array); + return *this; +} + PoolVector3Array::PoolVector3Array(const Array& array) { godot::api->godot_pool_vector3_array_new_with_array(&_godot_array, (godot_array *) &array); @@ -513,6 +585,18 @@ PoolColorArray::PoolColorArray() godot::api->godot_pool_color_array_new(&_godot_array); } +PoolColorArray::PoolColorArray(const PoolColorArray &p_other) +{ + godot::api->godot_pool_color_array_new_copy(&_godot_array, &p_other._godot_array); +} + +PoolColorArray &PoolColorArray::operator=(const PoolColorArray &p_other) +{ + godot::api->godot_pool_color_array_destroy(&_godot_array); + godot::api->godot_pool_color_array_new_copy(&_godot_array, &p_other._godot_array); + return *this; +} + PoolColorArray::PoolColorArray(const Array& array) { godot::api->godot_pool_color_array_new_with_array(&_godot_array, (godot_array *) &array);