Add clear method to pool arrays

This commit is contained in:
Haoyu Qiu 2022-08-10 17:31:29 +08:00
parent 450c178570
commit 2d93718cd2
9 changed files with 50 additions and 0 deletions

View File

@ -499,6 +499,7 @@ public:
inline T operator[](int p_index) const;
Error resize(int p_size);
Error clear() { return resize(0); }
void invert();
void sort();

View File

@ -696,6 +696,7 @@ struct _VariantCall {
VCALL_LOCALMEM1(PoolByteArray, push_back);
VCALL_LOCALMEM1(PoolByteArray, fill);
VCALL_LOCALMEM1(PoolByteArray, resize);
VCALL_LOCALMEM0(PoolByteArray, clear);
VCALL_LOCALMEM2R(PoolByteArray, insert);
VCALL_LOCALMEM1(PoolByteArray, remove);
VCALL_LOCALMEM1(PoolByteArray, append);
@ -715,6 +716,7 @@ struct _VariantCall {
VCALL_LOCALMEM1(PoolIntArray, push_back);
VCALL_LOCALMEM1(PoolIntArray, fill);
VCALL_LOCALMEM1(PoolIntArray, resize);
VCALL_LOCALMEM0(PoolIntArray, clear);
VCALL_LOCALMEM2R(PoolIntArray, insert);
VCALL_LOCALMEM1(PoolIntArray, remove);
VCALL_LOCALMEM1(PoolIntArray, append);
@ -733,6 +735,7 @@ struct _VariantCall {
VCALL_LOCALMEM1(PoolRealArray, push_back);
VCALL_LOCALMEM1(PoolRealArray, fill);
VCALL_LOCALMEM1(PoolRealArray, resize);
VCALL_LOCALMEM0(PoolRealArray, clear);
VCALL_LOCALMEM2R(PoolRealArray, insert);
VCALL_LOCALMEM1(PoolRealArray, remove);
VCALL_LOCALMEM1(PoolRealArray, append);
@ -751,6 +754,7 @@ struct _VariantCall {
VCALL_LOCALMEM1(PoolStringArray, push_back);
VCALL_LOCALMEM1(PoolStringArray, fill);
VCALL_LOCALMEM1(PoolStringArray, resize);
VCALL_LOCALMEM0(PoolStringArray, clear);
VCALL_LOCALMEM2R(PoolStringArray, insert);
VCALL_LOCALMEM1(PoolStringArray, remove);
VCALL_LOCALMEM1(PoolStringArray, append);
@ -770,6 +774,7 @@ struct _VariantCall {
VCALL_LOCALMEM1(PoolVector2Array, push_back);
VCALL_LOCALMEM1(PoolVector2Array, fill);
VCALL_LOCALMEM1(PoolVector2Array, resize);
VCALL_LOCALMEM0(PoolVector2Array, clear);
VCALL_LOCALMEM2R(PoolVector2Array, insert);
VCALL_LOCALMEM1(PoolVector2Array, remove);
VCALL_LOCALMEM1(PoolVector2Array, append);
@ -788,6 +793,7 @@ struct _VariantCall {
VCALL_LOCALMEM1(PoolVector3Array, push_back);
VCALL_LOCALMEM1(PoolVector3Array, fill);
VCALL_LOCALMEM1(PoolVector3Array, resize);
VCALL_LOCALMEM0(PoolVector3Array, clear);
VCALL_LOCALMEM2R(PoolVector3Array, insert);
VCALL_LOCALMEM1(PoolVector3Array, remove);
VCALL_LOCALMEM1(PoolVector3Array, append);
@ -806,6 +812,7 @@ struct _VariantCall {
VCALL_LOCALMEM1(PoolColorArray, push_back);
VCALL_LOCALMEM1(PoolColorArray, fill);
VCALL_LOCALMEM1(PoolColorArray, resize);
VCALL_LOCALMEM0(PoolColorArray, clear);
VCALL_LOCALMEM2R(PoolColorArray, insert);
VCALL_LOCALMEM1(PoolColorArray, remove);
VCALL_LOCALMEM1(PoolColorArray, append);
@ -1981,6 +1988,7 @@ void register_variant_methods() {
ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, remove, INT, "idx", varray());
ADDFUNC2R(POOL_BYTE_ARRAY, INT, PoolByteArray, insert, INT, "idx", INT, "byte", varray());
ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_BYTE_ARRAY, NIL, PoolByteArray, clear, varray());
ADDFUNC0(POOL_BYTE_ARRAY, NIL, PoolByteArray, invert, varray());
ADDFUNC2R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, subarray, INT, "from", INT, "to", varray());
ADDFUNC2R(POOL_BYTE_ARRAY, INT, PoolByteArray, find, INT, "value", INT, "from", varray(0));
@ -2006,6 +2014,7 @@ void register_variant_methods() {
ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, remove, INT, "idx", varray());
ADDFUNC2R(POOL_INT_ARRAY, INT, PoolIntArray, insert, INT, "idx", INT, "integer", varray());
ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_INT_ARRAY, NIL, PoolIntArray, clear, varray());
ADDFUNC0(POOL_INT_ARRAY, NIL, PoolIntArray, invert, varray());
ADDFUNC2R(POOL_INT_ARRAY, INT, PoolIntArray, find, INT, "value", INT, "from", varray(0));
ADDFUNC2R(POOL_INT_ARRAY, INT, PoolIntArray, rfind, INT, "value", INT, "from", varray(-1));
@ -2023,6 +2032,7 @@ void register_variant_methods() {
ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, remove, INT, "idx", varray());
ADDFUNC2R(POOL_REAL_ARRAY, INT, PoolRealArray, insert, INT, "idx", REAL, "value", varray());
ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_REAL_ARRAY, NIL, PoolRealArray, clear, varray());
ADDFUNC0(POOL_REAL_ARRAY, NIL, PoolRealArray, invert, varray());
ADDFUNC2R(POOL_REAL_ARRAY, INT, PoolRealArray, find, REAL, "value", INT, "from", varray(0));
ADDFUNC2R(POOL_REAL_ARRAY, INT, PoolRealArray, rfind, REAL, "value", INT, "from", varray(-1));
@ -2040,6 +2050,7 @@ void register_variant_methods() {
ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, remove, INT, "idx", varray());
ADDFUNC2R(POOL_STRING_ARRAY, INT, PoolStringArray, insert, INT, "idx", STRING, "string", varray());
ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_STRING_ARRAY, NIL, PoolStringArray, clear, varray());
ADDFUNC0(POOL_STRING_ARRAY, NIL, PoolStringArray, invert, varray());
ADDFUNC1(POOL_STRING_ARRAY, STRING, PoolStringArray, join, STRING, "delimiter", varray());
ADDFUNC2R(POOL_STRING_ARRAY, INT, PoolStringArray, find, STRING, "value", INT, "from", varray(0));
@ -2058,6 +2069,7 @@ void register_variant_methods() {
ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, remove, INT, "idx", varray());
ADDFUNC2R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, insert, INT, "idx", VECTOR2, "vector2", varray());
ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, resize, INT, "idx", varray());
ADDFUNC0(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, clear, varray());
ADDFUNC0(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, invert, varray());
ADDFUNC2R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, find, VECTOR2, "value", INT, "from", varray(0));
ADDFUNC2R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, rfind, VECTOR2, "value", INT, "from", varray(-1));
@ -2075,6 +2087,7 @@ void register_variant_methods() {
ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, remove, INT, "idx", varray());
ADDFUNC2R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, insert, INT, "idx", VECTOR3, "vector3", varray());
ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, resize, INT, "idx", varray());
ADDFUNC0(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, clear, varray());
ADDFUNC0(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, invert, varray());
ADDFUNC2R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, find, VECTOR3, "value", INT, "from", varray(0));
ADDFUNC2R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, rfind, VECTOR3, "value", INT, "from", varray(-1));
@ -2092,6 +2105,7 @@ void register_variant_methods() {
ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, remove, INT, "idx", varray());
ADDFUNC2R(POOL_COLOR_ARRAY, INT, PoolColorArray, insert, INT, "idx", COLOR, "color", varray());
ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_COLOR_ARRAY, NIL, PoolColorArray, clear, varray());
ADDFUNC0(POOL_COLOR_ARRAY, NIL, PoolColorArray, invert, varray());
ADDFUNC2R(POOL_COLOR_ARRAY, INT, PoolColorArray, find, COLOR, "value", INT, "from", varray(0));
ADDFUNC2R(POOL_COLOR_ARRAY, INT, PoolColorArray, rfind, COLOR, "value", INT, "from", varray(-1));

View File

@ -42,6 +42,11 @@
Appends a [PoolByteArray] at the end of this array.
</description>
</method>
<method name="clear">
<description>
Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code].
</description>
</method>
<method name="compress">
<return type="PoolByteArray" />
<argument index="0" name="compression_mode" type="int" default="0" />

View File

@ -42,6 +42,11 @@
Appends a [PoolColorArray] at the end of this array.
</description>
</method>
<method name="clear">
<description>
Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code].
</description>
</method>
<method name="count">
<return type="int" />
<argument index="0" name="value" type="Color" />

View File

@ -43,6 +43,11 @@
Appends a [PoolIntArray] at the end of this array.
</description>
</method>
<method name="clear">
<description>
Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code].
</description>
</method>
<method name="count">
<return type="int" />
<argument index="0" name="value" type="int" />

View File

@ -43,6 +43,11 @@
Appends a [PoolRealArray] at the end of this array.
</description>
</method>
<method name="clear">
<description>
Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code].
</description>
</method>
<method name="count">
<return type="int" />
<argument index="0" name="value" type="float" />

View File

@ -43,6 +43,11 @@
Appends a [PoolStringArray] at the end of this array.
</description>
</method>
<method name="clear">
<description>
Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code].
</description>
</method>
<method name="count">
<return type="int" />
<argument index="0" name="value" type="String" />

View File

@ -43,6 +43,11 @@
Appends a [PoolVector2Array] at the end of this array.
</description>
</method>
<method name="clear">
<description>
Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code].
</description>
</method>
<method name="count">
<return type="int" />
<argument index="0" name="value" type="Vector2" />

View File

@ -42,6 +42,11 @@
Appends a [PoolVector3Array] at the end of this array.
</description>
</method>
<method name="clear">
<description>
Clears the array. This is equivalent to using [method resize] with a size of [code]0[/code].
</description>
</method>
<method name="count">
<return type="int" />
<argument index="0" name="value" type="Vector3" />