diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2016-06-23 07:21:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-23 07:21:10 +0200 |
commit | 20112a338d94364b6a296ce9ca3753699e76c98b (patch) | |
tree | 001357096756e2166f8724ef3617ca2ec3171891 | |
parent | daa41802109d690962129cd7a4264ad1f9a23068 (diff) | |
parent | 3284e7b9d40b37de76cbf487a31ea4ac3675fd0c (diff) |
Merge pull request #5338 from J08nY/array-bindings
*Array bindings
-rw-r--r-- | core/variant_call.cpp | 49 | ||||
-rw-r--r-- | doc/base/classes.xml | 223 |
2 files changed, 265 insertions, 7 deletions
diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 84015d2b04..34e5164b24 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -511,6 +511,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(ByteArray,get); VCALL_LOCALMEM1(ByteArray,push_back); VCALL_LOCALMEM1(ByteArray,resize); + VCALL_LOCALMEM2R(ByteArray,insert); + VCALL_LOCALMEM1(ByteArray,remove); VCALL_LOCALMEM1(ByteArray,append); VCALL_LOCALMEM1(ByteArray,append_array); @@ -519,6 +521,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(IntArray,get); VCALL_LOCALMEM1(IntArray,push_back); VCALL_LOCALMEM1(IntArray,resize); + VCALL_LOCALMEM2R(IntArray,insert); + VCALL_LOCALMEM1(IntArray,remove); VCALL_LOCALMEM1(IntArray,append); VCALL_LOCALMEM1(IntArray,append_array); @@ -527,6 +531,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(RealArray,get); VCALL_LOCALMEM1(RealArray,push_back); VCALL_LOCALMEM1(RealArray,resize); + VCALL_LOCALMEM2R(RealArray,insert); + VCALL_LOCALMEM1(RealArray,remove); VCALL_LOCALMEM1(RealArray,append); VCALL_LOCALMEM1(RealArray,append_array); @@ -535,6 +541,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(StringArray,get); VCALL_LOCALMEM1(StringArray,push_back); VCALL_LOCALMEM1(StringArray,resize); + VCALL_LOCALMEM2R(StringArray,insert); + VCALL_LOCALMEM1(StringArray,remove); VCALL_LOCALMEM1(StringArray,append); VCALL_LOCALMEM1(StringArray,append_array); @@ -543,6 +551,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(Vector2Array,get); VCALL_LOCALMEM1(Vector2Array,push_back); VCALL_LOCALMEM1(Vector2Array,resize); + VCALL_LOCALMEM2R(Vector2Array,insert); + VCALL_LOCALMEM1(Vector2Array,remove); VCALL_LOCALMEM1(Vector2Array,append); VCALL_LOCALMEM1(Vector2Array,append_array); @@ -551,6 +561,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(Vector3Array,get); VCALL_LOCALMEM1(Vector3Array,push_back); VCALL_LOCALMEM1(Vector3Array,resize); + VCALL_LOCALMEM2R(Vector3Array,insert); + VCALL_LOCALMEM1(Vector3Array,remove); VCALL_LOCALMEM1(Vector3Array,append); VCALL_LOCALMEM1(Vector3Array,append_array); @@ -559,6 +571,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(ColorArray,get); VCALL_LOCALMEM1(ColorArray,push_back); VCALL_LOCALMEM1(ColorArray,resize); + VCALL_LOCALMEM2R(ColorArray,insert); + VCALL_LOCALMEM1(ColorArray,remove); VCALL_LOCALMEM1(ColorArray,append); VCALL_LOCALMEM1(ColorArray,append_array); @@ -1484,8 +1498,11 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(RAW_ARRAY,INT,ByteArray,size,varray()); ADDFUNC2(RAW_ARRAY,NIL,ByteArray,set,INT,"idx",INT,"byte",varray()); - //ADDFUNC1(RAW_ARRAY,INT,ByteArray,get,INT,"idx",varray()); ADDFUNC1(RAW_ARRAY,NIL,ByteArray,push_back,INT,"byte",varray()); + ADDFUNC1(RAW_ARRAY,NIL,ByteArray,append,INT,"byte",varray()); + ADDFUNC1(RAW_ARRAY,NIL,ByteArray,append_array,RAW_ARRAY,"array",varray()); + ADDFUNC1(RAW_ARRAY,NIL,ByteArray,remove,INT,"idx",varray()); + ADDFUNC2(RAW_ARRAY,INT,ByteArray,insert,INT,"idx",INT,"byte",varray()); ADDFUNC1(RAW_ARRAY,NIL,ByteArray,resize,INT,"idx",varray()); ADDFUNC0(RAW_ARRAY,STRING,ByteArray,get_string_from_ascii,varray()); @@ -1494,38 +1511,56 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(INT_ARRAY,INT,IntArray,size,varray()); ADDFUNC2(INT_ARRAY,NIL,IntArray,set,INT,"idx",INT,"integer",varray()); - //ADDFUNC1(INT_ARRAY,INT,IntArray,get,INT,"idx",varray()); ADDFUNC1(INT_ARRAY,NIL,IntArray,push_back,INT,"integer",varray()); + ADDFUNC1(INT_ARRAY,NIL,IntArray,append,INT,"integer",varray()); + ADDFUNC1(INT_ARRAY,NIL,IntArray,append_array,INT_ARRAY,"array",varray()); + ADDFUNC1(INT_ARRAY,NIL,IntArray,remove,INT,"idx",varray()); + ADDFUNC2(INT_ARRAY,INT,IntArray,insert,INT,"idx",INT,"integer",varray()); ADDFUNC1(INT_ARRAY,NIL,IntArray,resize,INT,"idx",varray()); ADDFUNC0(REAL_ARRAY,INT,RealArray,size,varray()); ADDFUNC2(REAL_ARRAY,NIL,RealArray,set,INT,"idx",REAL,"value",varray()); - //ADDFUNC1(REAL_ARRAY,REAL,RealArray,get,INT,"idx",varray()); ADDFUNC1(REAL_ARRAY,NIL,RealArray,push_back,REAL,"value",varray()); + ADDFUNC1(REAL_ARRAY,NIL,RealArray,append,REAL,"value",varray()); + ADDFUNC1(REAL_ARRAY,NIL,RealArray,append_array,REAL_ARRAY,"array",varray()); + ADDFUNC1(REAL_ARRAY,NIL,RealArray,remove,INT,"idx",varray()); + ADDFUNC2(REAL_ARRAY,INT,RealArray,insert,INT,"idx",REAL,"value",varray()); ADDFUNC1(REAL_ARRAY,NIL,RealArray,resize,INT,"idx",varray()); ADDFUNC0(STRING_ARRAY,INT,StringArray,size,varray()); ADDFUNC2(STRING_ARRAY,NIL,StringArray,set,INT,"idx",STRING,"string",varray()); - //ADDFUNC1(STRING_ARRAY,STRING,StringArray,get,INT,"idx",varray()); ADDFUNC1(STRING_ARRAY,NIL,StringArray,push_back,STRING,"string",varray()); + ADDFUNC1(STRING_ARRAY,NIL,StringArray,append,STRING,"string",varray()); + ADDFUNC1(STRING_ARRAY,NIL,StringArray,append_array,STRING_ARRAY,"array",varray()); + ADDFUNC1(STRING_ARRAY,NIL,StringArray,remove,INT,"idx",varray()); + ADDFUNC2(STRING_ARRAY,INT,StringArray,insert,INT,"idx",STRING,"string",varray()); ADDFUNC1(STRING_ARRAY,NIL,StringArray,resize,INT,"idx",varray()); ADDFUNC0(VECTOR2_ARRAY,INT,Vector2Array,size,varray()); ADDFUNC2(VECTOR2_ARRAY,NIL,Vector2Array,set,INT,"idx",VECTOR2,"vector2",varray()); - //ADDFUNC1(VECTOR2_ARRAY,VECTOR2,Vector2Array,get,INT,"idx",varray()); ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,push_back,VECTOR2,"vector2",varray()); + ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,append,VECTOR2,"vector2",varray()); + ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,append_array,VECTOR2_ARRAY,"array",varray()); + ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,remove,INT,"idx",varray()); + ADDFUNC2(VECTOR2_ARRAY,INT,Vector2Array,insert,INT,"idx",VECTOR2,"vector2",varray()); ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,resize,INT,"idx",varray()); ADDFUNC0(VECTOR3_ARRAY,INT,Vector3Array,size,varray()); ADDFUNC2(VECTOR3_ARRAY,NIL,Vector3Array,set,INT,"idx",VECTOR3,"vector3",varray()); - //ADDFUNC1(VECTOR3_ARRAY,VECTOR3,Vector3Array,get,INT,"idx",varray()); ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,push_back,VECTOR3,"vector3",varray()); + ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,append,VECTOR3,"vector3",varray()); + ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,append_array,VECTOR3_ARRAY,"array",varray()); + ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,remove,INT,"idx",varray()); + ADDFUNC2(VECTOR3_ARRAY,INT,Vector3Array,insert,INT,"idx",VECTOR3,"vector3",varray()); ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,resize,INT,"idx",varray()); ADDFUNC0(COLOR_ARRAY,INT,ColorArray,size,varray()); ADDFUNC2(COLOR_ARRAY,NIL,ColorArray,set,INT,"idx",COLOR,"color",varray()); - //ADDFUNC1(COLOR_ARRAY,COLOR,ColorArray,get,INT,"idx",varray()); ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,push_back,COLOR,"color",varray()); + ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,append,COLOR,"color",varray()); + ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,append_array,COLOR_ARRAY,"array",varray()); + ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,remove,INT,"idx",varray()); + ADDFUNC2(COLOR_ARRAY,INT,ColorArray,insert,INT,"idx",COLOR,"color",varray()); ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,resize,INT,"idx",varray()); //pointerbased diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 067d73034b..808bf20c25 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -8497,6 +8497,31 @@ Create from a generic array. </description> </method> + <method name="append"> + <argument index="0" name="color" type="Color"> + </argument> + <description> + Append an element at the end of the array (alias of [method push_back]). + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="ColorArray"> + </argument> + <description> + Append an [ColorArray] at the end of this array. + </description> + </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="color" type="Color"> + </argument> + <description> + Insert a new element at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="color" type="Color"> </argument> @@ -8504,6 +8529,13 @@ Append a value to the array. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> @@ -17113,6 +17145,31 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Create from a generic array. </description> </method> + <method name="append"> + <argument index="0" name="integer" type="int"> + </argument> + <description> + Append an element at the end of the array (alias of [method push_back]). + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="IntArray"> + </argument> + <description> + Append an [IntArray] at the end of this array. + </description> + </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="integer" type="int"> + </argument> + <description> + Insert a new int at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="integer" type="int"> </argument> @@ -17120,6 +17177,13 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Append a value to the array. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> @@ -30127,6 +30191,19 @@ A similar effect may be achieved moving this node's descendants. Create from a generic array. </description> </method> + <method name="append"> + <argument index="0" name="byte" type="int"> + </argument> + <description> + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="RawArray"> + </argument> + <description> + Append an [RawArray] at the end of this array. + </description> + </method> <method name="get_string_from_ascii"> <return type="String"> </return> @@ -30141,6 +30218,17 @@ A similar effect may be achieved moving this node's descendants. Returns a copy of the array's contents formatted as String, assuming the array is formatted as UTF-8. Slower than get_string_from_ascii(), but works for UTF-8. Usually you should prefer this function over get_string_from_ascii() to support international input. </description> </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="byte" type="int"> + </argument> + <description> + Insert a new element at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="byte" type="int"> </argument> @@ -30148,6 +30236,13 @@ A similar effect may be achieved moving this node's descendants. Append an element at the end of the array. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> @@ -30487,6 +30582,31 @@ A similar effect may be achieved moving this node's descendants. Create from a generic array. </description> </method> + <method name="append"> + <argument index="0" name="value" type="float"> + </argument> + <description> + Append an element at the end of the array (alias of [method push_back]). + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="RealArray"> + </argument> + <description> + Append an [RealArray] at the end of this array. + </description> + </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="value" type="float"> + </argument> + <description> + Insert a new element at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="value" type="float"> </argument> @@ -30494,6 +30614,13 @@ A similar effect may be achieved moving this node's descendants. Append an element at the end of the array. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> @@ -37898,6 +38025,31 @@ A similar effect may be achieved moving this node's descendants. Create from a generic array. </description> </method> + <method name="append"> + <argument index="0" name="string" type="String"> + </argument> + <description> + Append an element at the end of the array (alias of [method push_back]). + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="StringArray"> + </argument> + <description> + Append an [StringArray] at the end of this array. + </description> + </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="string" type="String"> + </argument> + <description> + Insert a new element at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="string" type="String"> </argument> @@ -37905,6 +38057,13 @@ A similar effect may be achieved moving this node's descendants. Append a string element at end of the array. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> @@ -42793,6 +42952,31 @@ A similar effect may be achieved moving this node's descendants. Construct a new [Vector2Array]. Optionally, you can pass in an Array that will be converted. </description> </method> + <method name="append"> + <argument index="0" name="vector2" type="Vector2"> + </argument> + <description> + Append an element at the end of the array (alias of [method push_back]). + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="Vector2Array"> + </argument> + <description> + Append an [Vector2Array] at the end of this array. + </description> + </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="vector2" type="Vector2"> + </argument> + <description> + Insert a new element at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="vector2" type="Vector2"> </argument> @@ -42800,6 +42984,13 @@ A similar effect may be achieved moving this node's descendants. Insert a [Vector2] at the end. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> @@ -43052,6 +43243,31 @@ A similar effect may be achieved moving this node's descendants. Construct a new Vector3Array. Optionally, you can pass in an Array that will be converted. </description> </method> + <method name="append"> + <argument index="0" name="vector3" type="Vector3"> + </argument> + <description> + Append an element at the end of the array (alias of [method push_back]). + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="Vector3Array"> + </argument> + <description> + Append an [Vector3Array] at the end of this array. + </description> + </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="vector3" type="Vector3"> + </argument> + <description> + Insert a new element at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="vector3" type="Vector3"> </argument> @@ -43059,6 +43275,13 @@ A similar effect may be achieved moving this node's descendants. Insert a Vector3 at the end. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> |