1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

Merge pull request #92737 from AThousandShips/packed_erase

[Core] Expose `Packed*Array::erase`
This commit is contained in:
Thaddeus Crews
2025-03-10 10:01:06 -05:00
11 changed files with 85 additions and 0 deletions

View File

@@ -2451,6 +2451,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedByteArray, find, sarray("value", "from"), varray(0)); bind_method(PackedByteArray, find, sarray("value", "from"), varray(0));
bind_method(PackedByteArray, rfind, sarray("value", "from"), varray(-1)); bind_method(PackedByteArray, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedByteArray, count, sarray("value"), varray()); 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_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()); bind_function(PackedByteArray, get_string_from_utf8, _VariantCall::func_PackedByteArray_get_string_from_utf8, sarray(), varray());
@@ -2517,6 +2518,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedInt32Array, find, sarray("value", "from"), varray(0)); bind_method(PackedInt32Array, find, sarray("value", "from"), varray(0));
bind_method(PackedInt32Array, rfind, sarray("value", "from"), varray(-1)); bind_method(PackedInt32Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedInt32Array, count, sarray("value"), varray()); bind_method(PackedInt32Array, count, sarray("value"), varray());
bind_method(PackedInt32Array, erase, sarray("value"), varray());
/* Int64 Array */ /* Int64 Array */
@@ -2540,6 +2542,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedInt64Array, find, sarray("value", "from"), varray(0)); bind_method(PackedInt64Array, find, sarray("value", "from"), varray(0));
bind_method(PackedInt64Array, rfind, sarray("value", "from"), varray(-1)); bind_method(PackedInt64Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedInt64Array, count, sarray("value"), varray()); bind_method(PackedInt64Array, count, sarray("value"), varray());
bind_method(PackedInt64Array, erase, sarray("value"), varray());
/* Float32 Array */ /* Float32 Array */
@@ -2563,6 +2566,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedFloat32Array, find, sarray("value", "from"), varray(0)); bind_method(PackedFloat32Array, find, sarray("value", "from"), varray(0));
bind_method(PackedFloat32Array, rfind, sarray("value", "from"), varray(-1)); bind_method(PackedFloat32Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedFloat32Array, count, sarray("value"), varray()); bind_method(PackedFloat32Array, count, sarray("value"), varray());
bind_method(PackedFloat32Array, erase, sarray("value"), varray());
/* Float64 Array */ /* Float64 Array */
@@ -2586,6 +2590,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedFloat64Array, find, sarray("value", "from"), varray(0)); bind_method(PackedFloat64Array, find, sarray("value", "from"), varray(0));
bind_method(PackedFloat64Array, rfind, sarray("value", "from"), varray(-1)); bind_method(PackedFloat64Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedFloat64Array, count, sarray("value"), varray()); bind_method(PackedFloat64Array, count, sarray("value"), varray());
bind_method(PackedFloat64Array, erase, sarray("value"), varray());
/* String Array */ /* 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, find, sarray("value", "from"), varray(0));
bind_method(PackedStringArray, rfind, sarray("value", "from"), varray(-1)); bind_method(PackedStringArray, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedStringArray, count, sarray("value"), varray()); bind_method(PackedStringArray, count, sarray("value"), varray());
bind_method(PackedStringArray, erase, sarray("value"), varray());
/* Vector2 Array */ /* Vector2 Array */
@@ -2632,6 +2638,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedVector2Array, find, sarray("value", "from"), varray(0)); bind_method(PackedVector2Array, find, sarray("value", "from"), varray(0));
bind_method(PackedVector2Array, rfind, sarray("value", "from"), varray(-1)); bind_method(PackedVector2Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedVector2Array, count, sarray("value"), varray()); bind_method(PackedVector2Array, count, sarray("value"), varray());
bind_method(PackedVector2Array, erase, sarray("value"), varray());
/* Vector3 Array */ /* Vector3 Array */
@@ -2655,6 +2662,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedVector3Array, find, sarray("value", "from"), varray(0)); bind_method(PackedVector3Array, find, sarray("value", "from"), varray(0));
bind_method(PackedVector3Array, rfind, sarray("value", "from"), varray(-1)); bind_method(PackedVector3Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedVector3Array, count, sarray("value"), varray()); bind_method(PackedVector3Array, count, sarray("value"), varray());
bind_method(PackedVector3Array, erase, sarray("value"), varray());
/* Color Array */ /* Color Array */
@@ -2678,6 +2686,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedColorArray, find, sarray("value", "from"), varray(0)); bind_method(PackedColorArray, find, sarray("value", "from"), varray(0));
bind_method(PackedColorArray, rfind, sarray("value", "from"), varray(-1)); bind_method(PackedColorArray, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedColorArray, count, sarray("value"), varray()); bind_method(PackedColorArray, count, sarray("value"), varray());
bind_method(PackedColorArray, erase, sarray("value"), varray());
/* Vector4 Array */ /* Vector4 Array */
@@ -2701,6 +2710,7 @@ static void _register_variant_builtin_methods_array() {
bind_method(PackedVector4Array, find, sarray("value", "from"), varray(0)); bind_method(PackedVector4Array, find, sarray("value", "from"), varray(0));
bind_method(PackedVector4Array, rfind, sarray("value", "from"), varray(-1)); bind_method(PackedVector4Array, rfind, sarray("value", "from"), varray(-1));
bind_method(PackedVector4Array, count, sarray("value"), varray()); bind_method(PackedVector4Array, count, sarray("value"), varray());
bind_method(PackedVector4Array, erase, sarray("value"), varray());
} }
static void _register_variant_builtin_constants() { static void _register_variant_builtin_constants() {

View File

@@ -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. 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.
</description> </description>
</method> </method>
<method name="erase">
<return type="bool" />
<param index="0" name="value" type="int" />
<description>
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.
</description>
</method>
<method name="fill"> <method name="fill">
<return type="void" /> <return type="void" />
<param index="0" name="value" type="int" /> <param index="0" name="value" type="int" />

View File

@@ -79,6 +79,13 @@
Creates a copy of the array, and returns it. Creates a copy of the array, and returns it.
</description> </description>
</method> </method>
<method name="erase">
<return type="bool" />
<param index="0" name="value" type="Color" />
<description>
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.
</description>
</method>
<method name="fill"> <method name="fill">
<return type="void" /> <return type="void" />
<param index="0" name="value" type="Color" /> <param index="0" name="value" type="Color" />

View File

@@ -77,6 +77,14 @@
Creates a copy of the array, and returns it. Creates a copy of the array, and returns it.
</description> </description>
</method> </method>
<method name="erase">
<return type="bool" />
<param index="0" name="value" type="float" />
<description>
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.
</description>
</method>
<method name="fill"> <method name="fill">
<return type="void" /> <return type="void" />
<param index="0" name="value" type="float" /> <param index="0" name="value" type="float" />

View File

@@ -78,6 +78,14 @@
Creates a copy of the array, and returns it. Creates a copy of the array, and returns it.
</description> </description>
</method> </method>
<method name="erase">
<return type="bool" />
<param index="0" name="value" type="float" />
<description>
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.
</description>
</method>
<method name="fill"> <method name="fill">
<return type="void" /> <return type="void" />
<param index="0" name="value" type="float" /> <param index="0" name="value" type="float" />

View File

@@ -75,6 +75,13 @@
Creates a copy of the array, and returns it. Creates a copy of the array, and returns it.
</description> </description>
</method> </method>
<method name="erase">
<return type="bool" />
<param index="0" name="value" type="int" />
<description>
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.
</description>
</method>
<method name="fill"> <method name="fill">
<return type="void" /> <return type="void" />
<param index="0" name="value" type="int" /> <param index="0" name="value" type="int" />

View File

@@ -76,6 +76,13 @@
Creates a copy of the array, and returns it. Creates a copy of the array, and returns it.
</description> </description>
</method> </method>
<method name="erase">
<return type="bool" />
<param index="0" name="value" type="int" />
<description>
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.
</description>
</method>
<method name="fill"> <method name="fill">
<return type="void" /> <return type="void" />
<param index="0" name="value" type="int" /> <param index="0" name="value" type="int" />

View File

@@ -82,6 +82,13 @@
Creates a copy of the array, and returns it. Creates a copy of the array, and returns it.
</description> </description>
</method> </method>
<method name="erase">
<return type="bool" />
<param index="0" name="value" type="String" />
<description>
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.
</description>
</method>
<method name="fill"> <method name="fill">
<return type="void" /> <return type="void" />
<param index="0" name="value" type="String" /> <param index="0" name="value" type="String" />

View File

@@ -82,6 +82,14 @@
Creates a copy of the array, and returns it. Creates a copy of the array, and returns it.
</description> </description>
</method> </method>
<method name="erase">
<return type="bool" />
<param index="0" name="value" type="Vector2" />
<description>
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.
</description>
</method>
<method name="fill"> <method name="fill">
<return type="void" /> <return type="void" />
<param index="0" name="value" type="Vector2" /> <param index="0" name="value" type="Vector2" />

View File

@@ -81,6 +81,14 @@
Creates a copy of the array, and returns it. Creates a copy of the array, and returns it.
</description> </description>
</method> </method>
<method name="erase">
<return type="bool" />
<param index="0" name="value" type="Vector3" />
<description>
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.
</description>
</method>
<method name="fill"> <method name="fill">
<return type="void" /> <return type="void" />
<param index="0" name="value" type="Vector3" /> <param index="0" name="value" type="Vector3" />

View File

@@ -81,6 +81,14 @@
Creates a copy of the array, and returns it. Creates a copy of the array, and returns it.
</description> </description>
</method> </method>
<method name="erase">
<return type="bool" />
<param index="0" name="value" type="Vector4" />
<description>
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.
</description>
</method>
<method name="fill"> <method name="fill">
<return type="void" /> <return type="void" />
<param index="0" name="value" type="Vector4" /> <param index="0" name="value" type="Vector4" />