From e385b6cc8f5958fdf6b80d0123968ca3802ffed9 Mon Sep 17 00:00:00 2001
From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Date: Mon, 3 Jun 2024 21:19:52 +0200
Subject: [PATCH] [Core] Expose `Packed*Array::erase`
---
core/variant/variant_call.cpp | 10 ++++++++++
doc/classes/PackedByteArray.xml | 7 +++++++
doc/classes/PackedColorArray.xml | 7 +++++++
doc/classes/PackedFloat32Array.xml | 8 ++++++++
doc/classes/PackedFloat64Array.xml | 8 ++++++++
doc/classes/PackedInt32Array.xml | 7 +++++++
doc/classes/PackedInt64Array.xml | 7 +++++++
doc/classes/PackedStringArray.xml | 7 +++++++
doc/classes/PackedVector2Array.xml | 8 ++++++++
doc/classes/PackedVector3Array.xml | 8 ++++++++
doc/classes/PackedVector4Array.xml | 8 ++++++++
11 files changed, 85 insertions(+)
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index 042384939545..8e94013b6dd4 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -2446,6 +2446,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedByteArray, find, sarray("value", "from"), varray(0));
bind_method(PackedByteArray, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedByteArray, count, sarray("value"), varray());
+ bind_method(PackedByteArray, erase, sarray("value"), varray());
bind_function(PackedByteArray, get_string_from_ascii, _VariantCall::func_PackedByteArray_get_string_from_ascii, sarray(), varray());
bind_function(PackedByteArray, get_string_from_utf8, _VariantCall::func_PackedByteArray_get_string_from_utf8, sarray(), varray());
@@ -2513,6 +2514,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedInt32Array, find, sarray("value", "from"), varray(0));
bind_method(PackedInt32Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedInt32Array, count, sarray("value"), varray());
+ bind_method(PackedInt32Array, erase, sarray("value"), varray());
/* Int64 Array */
@@ -2537,6 +2539,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedInt64Array, find, sarray("value", "from"), varray(0));
bind_method(PackedInt64Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedInt64Array, count, sarray("value"), varray());
+ bind_method(PackedInt64Array, erase, sarray("value"), varray());
/* Float32 Array */
@@ -2561,6 +2564,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedFloat32Array, find, sarray("value", "from"), varray(0));
bind_method(PackedFloat32Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedFloat32Array, count, sarray("value"), varray());
+ bind_method(PackedFloat32Array, erase, sarray("value"), varray());
/* Float64 Array */
@@ -2585,6 +2589,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedFloat64Array, find, sarray("value", "from"), varray(0));
bind_method(PackedFloat64Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedFloat64Array, count, sarray("value"), varray());
+ bind_method(PackedFloat64Array, erase, sarray("value"), varray());
/* String Array */
@@ -2609,6 +2614,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedStringArray, find, sarray("value", "from"), varray(0));
bind_method(PackedStringArray, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedStringArray, count, sarray("value"), varray());
+ bind_method(PackedStringArray, erase, sarray("value"), varray());
/* Vector2 Array */
@@ -2633,6 +2639,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedVector2Array, find, sarray("value", "from"), varray(0));
bind_method(PackedVector2Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedVector2Array, count, sarray("value"), varray());
+ bind_method(PackedVector2Array, erase, sarray("value"), varray());
/* Vector3 Array */
@@ -2657,6 +2664,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedVector3Array, find, sarray("value", "from"), varray(0));
bind_method(PackedVector3Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedVector3Array, count, sarray("value"), varray());
+ bind_method(PackedVector3Array, erase, sarray("value"), varray());
/* Color Array */
@@ -2681,6 +2689,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedColorArray, find, sarray("value", "from"), varray(0));
bind_method(PackedColorArray, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedColorArray, count, sarray("value"), varray());
+ bind_method(PackedColorArray, erase, sarray("value"), varray());
/* Vector4 Array */
@@ -2705,6 +2714,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedVector4Array, find, sarray("value", "from"), varray(0));
bind_method(PackedVector4Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedVector4Array, count, sarray("value"), varray());
+ bind_method(PackedVector4Array, erase, sarray("value"), varray());
}
static void _register_variant_builtin_constants() {
diff --git a/doc/classes/PackedByteArray.xml b/doc/classes/PackedByteArray.xml
index 2f8e4889a7eb..82f1f22d6f63 100644
--- a/doc/classes/PackedByteArray.xml
+++ b/doc/classes/PackedByteArray.xml
@@ -292,6 +292,13 @@
Encodes a [Variant] at the index of [param byte_offset] bytes. A sufficient space must be allocated, depending on the encoded variant's size. If [param allow_objects] is [code]false[/code], [Object]-derived values are not permitted and will instead be serialized as ID-only.
+
+
+
+
+ Removes the first occurrence of a value from the array and returns [code]true[/code]. If the value does not exist in the array, nothing happens and [code]false[/code] is returned. To remove an element by index, use [method remove_at] instead.
+
+
diff --git a/doc/classes/PackedColorArray.xml b/doc/classes/PackedColorArray.xml
index b9cef0ead697..1a882a03380b 100644
--- a/doc/classes/PackedColorArray.xml
+++ b/doc/classes/PackedColorArray.xml
@@ -79,6 +79,13 @@
Creates a copy of the array, and returns it.
+
+
+
+
+ Removes the first occurrence of a value from the array and returns [code]true[/code]. If the value does not exist in the array, nothing happens and [code]false[/code] is returned. To remove an element by index, use [method remove_at] instead.
+
+
diff --git a/doc/classes/PackedFloat32Array.xml b/doc/classes/PackedFloat32Array.xml
index 237b659a5225..bde684607bcc 100644
--- a/doc/classes/PackedFloat32Array.xml
+++ b/doc/classes/PackedFloat32Array.xml
@@ -77,6 +77,14 @@
Creates a copy of the array, and returns it.
+
+
+
+
+ Removes the first occurrence of a value from the array and returns [code]true[/code]. If the value does not exist in the array, nothing happens and [code]false[/code] is returned. To remove an element by index, use [method remove_at] instead.
+ [b]Note:[/b] [constant @GDScript.NAN] doesn't behave the same as other numbers. Therefore, the results from this method may not be accurate if NaNs are included.
+
+
diff --git a/doc/classes/PackedFloat64Array.xml b/doc/classes/PackedFloat64Array.xml
index 56cc08d8c409..474523cdc477 100644
--- a/doc/classes/PackedFloat64Array.xml
+++ b/doc/classes/PackedFloat64Array.xml
@@ -78,6 +78,14 @@
Creates a copy of the array, and returns it.
+
+
+
+
+ Removes the first occurrence of a value from the array and returns [code]true[/code]. If the value does not exist in the array, nothing happens and [code]false[/code] is returned. To remove an element by index, use [method remove_at] instead.
+ [b]Note:[/b] [constant @GDScript.NAN] doesn't behave the same as other numbers. Therefore, the results from this method may not be accurate if NaNs are included.
+
+
diff --git a/doc/classes/PackedInt32Array.xml b/doc/classes/PackedInt32Array.xml
index 5bb2ea97ef95..272978f561ef 100644
--- a/doc/classes/PackedInt32Array.xml
+++ b/doc/classes/PackedInt32Array.xml
@@ -75,6 +75,13 @@
Creates a copy of the array, and returns it.
+
+
+
+
+ Removes the first occurrence of a value from the array and returns [code]true[/code]. If the value does not exist in the array, nothing happens and [code]false[/code] is returned. To remove an element by index, use [method remove_at] instead.
+
+
diff --git a/doc/classes/PackedInt64Array.xml b/doc/classes/PackedInt64Array.xml
index 2ed854895881..ec7a1099580a 100644
--- a/doc/classes/PackedInt64Array.xml
+++ b/doc/classes/PackedInt64Array.xml
@@ -76,6 +76,13 @@
Creates a copy of the array, and returns it.
+
+
+
+
+ Removes the first occurrence of a value from the array and returns [code]true[/code]. If the value does not exist in the array, nothing happens and [code]false[/code] is returned. To remove an element by index, use [method remove_at] instead.
+
+
diff --git a/doc/classes/PackedStringArray.xml b/doc/classes/PackedStringArray.xml
index 511850d6450b..edc6b5be1e1e 100644
--- a/doc/classes/PackedStringArray.xml
+++ b/doc/classes/PackedStringArray.xml
@@ -82,6 +82,13 @@
Creates a copy of the array, and returns it.
+
+
+
+
+ Removes the first occurrence of a value from the array and returns [code]true[/code]. If the value does not exist in the array, nothing happens and [code]false[/code] is returned. To remove an element by index, use [method remove_at] instead.
+
+
diff --git a/doc/classes/PackedVector2Array.xml b/doc/classes/PackedVector2Array.xml
index 4d487b6dc29b..022cec8c9821 100644
--- a/doc/classes/PackedVector2Array.xml
+++ b/doc/classes/PackedVector2Array.xml
@@ -82,6 +82,14 @@
Creates a copy of the array, and returns it.
+
+
+
+
+ Removes the first occurrence of a value from the array and returns [code]true[/code]. If the value does not exist in the array, nothing happens and [code]false[/code] is returned. To remove an element by index, use [method remove_at] instead.
+ [b]Note:[/b] Vectors with [constant @GDScript.NAN] elements don't behave the same as other vectors. Therefore, the results from this method may not be accurate if NaNs are included.
+
+
diff --git a/doc/classes/PackedVector3Array.xml b/doc/classes/PackedVector3Array.xml
index d47f2f3cd1f7..3963595de254 100644
--- a/doc/classes/PackedVector3Array.xml
+++ b/doc/classes/PackedVector3Array.xml
@@ -81,6 +81,14 @@
Creates a copy of the array, and returns it.
+
+
+
+
+ Removes the first occurrence of a value from the array and returns [code]true[/code]. If the value does not exist in the array, nothing happens and [code]false[/code] is returned. To remove an element by index, use [method remove_at] instead.
+ [b]Note:[/b] Vectors with [constant @GDScript.NAN] elements don't behave the same as other vectors. Therefore, the results from this method may not be accurate if NaNs are included.
+
+
diff --git a/doc/classes/PackedVector4Array.xml b/doc/classes/PackedVector4Array.xml
index 7bebee79c71d..94cffa5fa25d 100644
--- a/doc/classes/PackedVector4Array.xml
+++ b/doc/classes/PackedVector4Array.xml
@@ -81,6 +81,14 @@
Creates a copy of the array, and returns it.
+
+
+
+
+ Removes the first occurrence of a value from the array and returns [code]true[/code]. If the value does not exist in the array, nothing happens and [code]false[/code] is returned. To remove an element by index, use [method remove_at] instead.
+ [b]Note:[/b] Vectors with [constant @GDScript.NAN] elements don't behave the same as other vectors. Therefore, the results from this method may not be accurate if NaNs are included.
+
+