diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-04-28 16:52:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-28 16:52:31 +0200 |
commit | 9e9ac9f6ad470be968233a021f54744ad4735c54 (patch) | |
tree | d3d13d411e24a280fde7e6c3b0b818134891c41d /core/variant | |
parent | f505a2679808ddb95a552d9ad8ce9a0f9aa3b285 (diff) | |
parent | efd27a63c138ceef89d4ed2586651ea61898f5c7 (diff) |
Merge pull request #46476 from DarknessCatt/master
Add fill method to Arrays and PackedArrays
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 | 10 |
3 files changed, 16 insertions, 0 deletions
diff --git a/core/variant/array.cpp b/core/variant/array.cpp index 2ad728ec5e..2fb2dd4a30 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -208,6 +208,11 @@ void Array::insert(int p_pos, const Variant &p_value) { _p->array.insert(p_pos, p_value); } +void Array::fill(const Variant &p_value) { + ERR_FAIL_COND(!_p->typed.validate(p_value, "fill")); + _p->array.fill(p_value); +} + void Array::erase(const Variant &p_value) { ERR_FAIL_COND(!_p->typed.validate(p_value, "erase")); _p->array.erase(p_value); diff --git a/core/variant/array.h b/core/variant/array.h index 6b58ed12cb..5ce977ee4b 100644 --- a/core/variant/array.h +++ b/core/variant/array.h @@ -74,6 +74,7 @@ public: void insert(int p_pos, const Variant &p_value); void remove(int p_pos); + void fill(const Variant &p_value); Variant front() const; Variant back() const; diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index c8d26f02cb..deaccc6304 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1647,6 +1647,7 @@ static void _register_variant_builtin_methods() { bind_method(Array, resize, sarray("size"), varray()); bind_method(Array, insert, sarray("position", "value"), varray()); bind_method(Array, remove, sarray("position"), varray()); + bind_method(Array, fill, sarray("value"), varray()); bind_method(Array, erase, sarray("value"), varray()); bind_method(Array, front, sarray(), varray()); bind_method(Array, back, sarray(), varray()); @@ -1677,6 +1678,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedByteArray, append_array, sarray("array"), varray()); bind_method(PackedByteArray, remove, sarray("index"), varray()); bind_method(PackedByteArray, insert, sarray("at_index", "value"), varray()); + bind_method(PackedByteArray, fill, sarray("value"), varray()); bind_method(PackedByteArray, resize, sarray("new_size"), varray()); bind_method(PackedByteArray, has, sarray("value"), varray()); bind_method(PackedByteArray, reverse, sarray(), varray()); @@ -1731,6 +1733,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedInt32Array, append_array, sarray("array"), varray()); bind_method(PackedInt32Array, remove, sarray("index"), varray()); bind_method(PackedInt32Array, insert, sarray("at_index", "value"), varray()); + bind_method(PackedInt32Array, fill, sarray("value"), varray()); bind_method(PackedInt32Array, resize, sarray("new_size"), varray()); bind_method(PackedInt32Array, has, sarray("value"), varray()); bind_method(PackedInt32Array, reverse, sarray(), varray()); @@ -1749,6 +1752,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedInt64Array, append_array, sarray("array"), varray()); bind_method(PackedInt64Array, remove, sarray("index"), varray()); bind_method(PackedInt64Array, insert, sarray("at_index", "value"), varray()); + bind_method(PackedInt64Array, fill, sarray("value"), varray()); bind_method(PackedInt64Array, resize, sarray("new_size"), varray()); bind_method(PackedInt64Array, has, sarray("value"), varray()); bind_method(PackedInt64Array, reverse, sarray(), varray()); @@ -1767,6 +1771,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedFloat32Array, append_array, sarray("array"), varray()); bind_method(PackedFloat32Array, remove, sarray("index"), varray()); bind_method(PackedFloat32Array, insert, sarray("at_index", "value"), varray()); + bind_method(PackedFloat32Array, fill, sarray("value"), varray()); bind_method(PackedFloat32Array, resize, sarray("new_size"), varray()); bind_method(PackedFloat32Array, has, sarray("value"), varray()); bind_method(PackedFloat32Array, reverse, sarray(), varray()); @@ -1785,6 +1790,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedFloat64Array, append_array, sarray("array"), varray()); bind_method(PackedFloat64Array, remove, sarray("index"), varray()); bind_method(PackedFloat64Array, insert, sarray("at_index", "value"), varray()); + bind_method(PackedFloat64Array, fill, sarray("value"), varray()); bind_method(PackedFloat64Array, resize, sarray("new_size"), varray()); bind_method(PackedFloat64Array, has, sarray("value"), varray()); bind_method(PackedFloat64Array, reverse, sarray(), varray()); @@ -1803,6 +1809,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedStringArray, append_array, sarray("array"), varray()); bind_method(PackedStringArray, remove, sarray("index"), varray()); bind_method(PackedStringArray, insert, sarray("at_index", "value"), varray()); + bind_method(PackedStringArray, fill, sarray("value"), varray()); bind_method(PackedStringArray, resize, sarray("new_size"), varray()); bind_method(PackedStringArray, has, sarray("value"), varray()); bind_method(PackedStringArray, reverse, sarray(), varray()); @@ -1821,6 +1828,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedVector2Array, append_array, sarray("array"), varray()); bind_method(PackedVector2Array, remove, sarray("index"), varray()); bind_method(PackedVector2Array, insert, sarray("at_index", "value"), varray()); + bind_method(PackedVector2Array, fill, sarray("value"), varray()); bind_method(PackedVector2Array, resize, sarray("new_size"), varray()); bind_method(PackedVector2Array, has, sarray("value"), varray()); bind_method(PackedVector2Array, reverse, sarray(), varray()); @@ -1839,6 +1847,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedVector3Array, append_array, sarray("array"), varray()); bind_method(PackedVector3Array, remove, sarray("index"), varray()); bind_method(PackedVector3Array, insert, sarray("at_index", "value"), varray()); + bind_method(PackedVector3Array, fill, sarray("value"), varray()); bind_method(PackedVector3Array, resize, sarray("new_size"), varray()); bind_method(PackedVector3Array, has, sarray("value"), varray()); bind_method(PackedVector3Array, reverse, sarray(), varray()); @@ -1857,6 +1866,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedColorArray, append_array, sarray("array"), varray()); bind_method(PackedColorArray, remove, sarray("index"), varray()); bind_method(PackedColorArray, insert, sarray("at_index", "value"), varray()); + bind_method(PackedColorArray, fill, sarray("value"), varray()); bind_method(PackedColorArray, resize, sarray("new_size"), varray()); bind_method(PackedColorArray, has, sarray("value"), varray()); bind_method(PackedColorArray, reverse, sarray(), varray()); |