diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-11-10 13:53:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-10 13:53:58 +0100 |
commit | 03ae26bb74c0b713fe2132c5b003ae41e366746c (patch) | |
tree | 89eb2288855ead545309069fb9c570c43495f469 /core/variant | |
parent | 0efe6dff5f1f973393fcd453d38336f83542786f (diff) | |
parent | 9f23a94b8adbdae83648080a73f9201c03ba4e0d (diff) |
Merge pull request #43398 from KoBeWi/add_an_array_to_another_array_but_with_a_method
Add append_array() method to Array class
Diffstat (limited to 'core/variant')
-rw-r--r-- | core/variant/array.cpp | 5 | ||||
-rw-r--r-- | core/variant/array.h | 1 | ||||
-rw-r--r-- | core/variant/variant_call.cpp | 1 |
3 files changed, 7 insertions, 0 deletions
diff --git a/core/variant/array.cpp b/core/variant/array.cpp index 04ee47efff..79bc01b89c 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -192,6 +192,11 @@ void Array::push_back(const Variant &p_value) { _p->array.push_back(p_value); } +void Array::append_array(const Array &p_array) { + ERR_FAIL_COND(!_p->typed.validate(p_array, "append_array")); + _p->array.append_array(p_array._p->array); +} + Error Array::resize(int p_new_size) { return _p->array.resize(p_new_size); } diff --git a/core/variant/array.h b/core/variant/array.h index b37d600abd..e01ac13168 100644 --- a/core/variant/array.h +++ b/core/variant/array.h @@ -68,6 +68,7 @@ public: void push_back(const Variant &p_value); _FORCE_INLINE_ void append(const Variant &p_value) { push_back(p_value); } //for python compatibility + void append_array(const Array &p_array); Error resize(int p_new_size); void insert(int p_pos, const Variant &p_value); diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 929a8e2cc8..06bf61720a 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1356,6 +1356,7 @@ void Variant::_register_variant_methods() { bind_method(Array, push_back, sarray("value"), varray()); bind_method(Array, push_front, sarray("value"), varray()); bind_method(Array, append, sarray("value"), varray()); + bind_method(Array, append_array, sarray("array"), varray()); bind_method(Array, resize, sarray("size"), varray()); bind_method(Array, insert, sarray("position", "value"), varray()); bind_method(Array, remove, sarray("position"), varray()); |