diff --git a/include/core/Array.hpp b/include/core/Array.hpp index 2005740..2320568 100644 --- a/include/core/Array.hpp +++ b/include/core/Array.hpp @@ -22,6 +22,8 @@ class Array { godot_array _godot_array; public: Array(); + Array(const Array & other); + Array & operator=(const Array & other); Array(const PoolByteArray& a); diff --git a/include/core/Dictionary.hpp b/include/core/Dictionary.hpp index 238724d..ec496af 100644 --- a/include/core/Dictionary.hpp +++ b/include/core/Dictionary.hpp @@ -13,6 +13,8 @@ class Dictionary { godot_dictionary _godot_dictionary; public: Dictionary(); + Dictionary(const Dictionary & other); + Dictionary & operator=(const Dictionary & other); void clear(); diff --git a/src/core/Array.cpp b/src/core/Array.cpp index c3de16c..0350547 100644 --- a/src/core/Array.cpp +++ b/src/core/Array.cpp @@ -13,6 +13,18 @@ Array::Array() godot::api->godot_array_new(&_godot_array); } +Array::Array(const Array & other) +{ + godot::api->godot_array_new_copy(&_godot_array, &other._godot_array); +} + +Array & Array::operator=(const Array & other) +{ + godot::api->godot_array_destroy(&_godot_array); + godot::api->godot_array_new_copy(&_godot_array, &other._godot_array); + return *this; +} + Array::Array(const PoolByteArray& a) { godot::api->godot_array_new_pool_byte_array(&_godot_array, (godot_pool_byte_array *) &a); diff --git a/src/core/Dictionary.cpp b/src/core/Dictionary.cpp index aba226c..bb40017 100644 --- a/src/core/Dictionary.cpp +++ b/src/core/Dictionary.cpp @@ -10,6 +10,18 @@ Dictionary::Dictionary() godot::api->godot_dictionary_new(&_godot_dictionary); } +Dictionary::Dictionary(const Dictionary & other) +{ + godot::api->godot_dictionary_new_copy(&_godot_dictionary, &other._godot_dictionary); +} + +Dictionary & Dictionary::operator=(const Dictionary & other) +{ + godot::api->godot_dictionary_destroy(&_godot_dictionary); + godot::api->godot_dictionary_new_copy(&_godot_dictionary, &other._godot_dictionary); + return *this; +} + void Dictionary::clear() { godot::api->godot_dictionary_clear(&_godot_dictionary);