From 797168e62dfb43762dbf91a47ec6484502904723 Mon Sep 17 00:00:00 2001 From: J08nY Date: Tue, 21 Jun 2016 16:35:39 +0200 Subject: [PATCH 1/2] *Array: added bindings for other DVector methods - affects {RAW,INT,REAL,STRING,VECTOR2,VECTOR3,COLOR}_ARRAY - adds bindings for append(),append_array(),remove(),insert() - broadens #4245 --- core/variant_call.cpp | 49 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 84015d2b04d..34e5164b242 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 From 3284e7b9d40b37de76cbf487a31ea4ac3675fd0c Mon Sep 17 00:00:00 2001 From: J08nY Date: Tue, 21 Jun 2016 16:41:24 +0200 Subject: [PATCH 2/2] Classref: added for new *Array bindings - append(),append_array(),insert(),remove() --- doc/base/classes.xml | 223 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 223 insertions(+) diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 067d73034bd..808bf20c25a 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -8497,6 +8497,31 @@ Create from a generic array. + + + + + Append an element at the end of the array (alias of [method push_back]). + + + + + + + Append an [ColorArray] at the end of this array. + + + + + + + + + + + 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()). + + @@ -8504,6 +8529,13 @@ Append a value to the array. + + + + + Remove an element from the array by index. + + @@ -17113,6 +17145,31 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Create from a generic array. + + + + + Append an element at the end of the array (alias of [method push_back]). + + + + + + + Append an [IntArray] at the end of this array. + + + + + + + + + + + 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()). + + @@ -17120,6 +17177,13 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Append a value to the array. + + + + + Remove an element from the array by index. + + @@ -30127,6 +30191,19 @@ A similar effect may be achieved moving this node's descendants. Create from a generic array. + + + + + + + + + + + Append an [RawArray] at the end of this array. + + @@ -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. + + + + + + + + + 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()). + + @@ -30148,6 +30236,13 @@ A similar effect may be achieved moving this node's descendants. Append an element at the end of the array. + + + + + Remove an element from the array by index. + + @@ -30487,6 +30582,31 @@ A similar effect may be achieved moving this node's descendants. Create from a generic array. + + + + + Append an element at the end of the array (alias of [method push_back]). + + + + + + + Append an [RealArray] at the end of this array. + + + + + + + + + + + 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()). + + @@ -30494,6 +30614,13 @@ A similar effect may be achieved moving this node's descendants. Append an element at the end of the array. + + + + + Remove an element from the array by index. + + @@ -37898,6 +38025,31 @@ A similar effect may be achieved moving this node's descendants. Create from a generic array. + + + + + Append an element at the end of the array (alias of [method push_back]). + + + + + + + Append an [StringArray] at the end of this array. + + + + + + + + + + + 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()). + + @@ -37905,6 +38057,13 @@ A similar effect may be achieved moving this node's descendants. Append a string element at end of the array. + + + + + Remove an element from the array by index. + + @@ -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. + + + + + Append an element at the end of the array (alias of [method push_back]). + + + + + + + Append an [Vector2Array] at the end of this array. + + + + + + + + + + + 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()). + + @@ -42800,6 +42984,13 @@ A similar effect may be achieved moving this node's descendants. Insert a [Vector2] at the end. + + + + + Remove an element from the array by index. + + @@ -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. + + + + + Append an element at the end of the array (alias of [method push_back]). + + + + + + + Append an [Vector3Array] at the end of this array. + + + + + + + + + + + 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()). + + @@ -43059,6 +43275,13 @@ A similar effect may be achieved moving this node's descendants. Insert a Vector3 at the end. + + + + + Remove an element from the array by index. + +