From a6ec3af349914ea54725e87a699fa5b6f942dd80 Mon Sep 17 00:00:00 2001 From: George Marques Date: Sat, 25 Jun 2016 14:16:28 -0300 Subject: [PATCH 1/2] Expose *Array.invert() to script Properly solve #4601. --- core/variant_call.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/variant_call.cpp b/core/variant_call.cpp index c0f8930eedf..7b9dea4eab9 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -516,6 +516,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1(ByteArray,remove); VCALL_LOCALMEM1(ByteArray,append); VCALL_LOCALMEM1(ByteArray,append_array); + VCALL_LOCALMEM0(ByteArray,invert); VCALL_LOCALMEM0R(IntArray,size); VCALL_LOCALMEM2(IntArray,set); @@ -526,6 +527,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1(IntArray,remove); VCALL_LOCALMEM1(IntArray,append); VCALL_LOCALMEM1(IntArray,append_array); + VCALL_LOCALMEM0(IntArray,invert); VCALL_LOCALMEM0R(RealArray,size); VCALL_LOCALMEM2(RealArray,set); @@ -536,6 +538,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1(RealArray,remove); VCALL_LOCALMEM1(RealArray,append); VCALL_LOCALMEM1(RealArray,append_array); + VCALL_LOCALMEM0(RealArray,invert); VCALL_LOCALMEM0R(StringArray,size); VCALL_LOCALMEM2(StringArray,set); @@ -546,6 +549,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1(StringArray,remove); VCALL_LOCALMEM1(StringArray,append); VCALL_LOCALMEM1(StringArray,append_array); + VCALL_LOCALMEM0(StringArray,invert); VCALL_LOCALMEM0R(Vector2Array,size); VCALL_LOCALMEM2(Vector2Array,set); @@ -556,6 +560,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1(Vector2Array,remove); VCALL_LOCALMEM1(Vector2Array,append); VCALL_LOCALMEM1(Vector2Array,append_array); + VCALL_LOCALMEM0(Vector2Array,invert); VCALL_LOCALMEM0R(Vector3Array,size); VCALL_LOCALMEM2(Vector3Array,set); @@ -566,6 +571,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1(Vector3Array,remove); VCALL_LOCALMEM1(Vector3Array,append); VCALL_LOCALMEM1(Vector3Array,append_array); + VCALL_LOCALMEM0(Vector3Array,invert); VCALL_LOCALMEM0R(ColorArray,size); VCALL_LOCALMEM2(ColorArray,set); @@ -576,6 +582,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1(ColorArray,remove); VCALL_LOCALMEM1(ColorArray,append); VCALL_LOCALMEM1(ColorArray,append_array); + VCALL_LOCALMEM0(ColorArray,invert); #define VCALL_PTR0(m_type,m_method)\ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast(p_self._data._ptr)->m_method(); } @@ -1506,6 +1513,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl 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,NIL,ByteArray,invert,varray()); ADDFUNC0(RAW_ARRAY,STRING,ByteArray,get_string_from_ascii,varray()); ADDFUNC0(RAW_ARRAY,STRING,ByteArray,get_string_from_utf8,varray()); @@ -1519,6 +1527,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl 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(INT_ARRAY,NIL,IntArray,invert,varray()); ADDFUNC0(REAL_ARRAY,INT,RealArray,size,varray()); ADDFUNC2(REAL_ARRAY,NIL,RealArray,set,INT,"idx",REAL,"value",varray()); @@ -1528,6 +1537,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl 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(REAL_ARRAY,NIL,RealArray,invert,varray()); ADDFUNC0(STRING_ARRAY,INT,StringArray,size,varray()); ADDFUNC2(STRING_ARRAY,NIL,StringArray,set,INT,"idx",STRING,"string",varray()); @@ -1537,6 +1547,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl 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(STRING_ARRAY,NIL,StringArray,invert,varray()); ADDFUNC0(VECTOR2_ARRAY,INT,Vector2Array,size,varray()); ADDFUNC2(VECTOR2_ARRAY,NIL,Vector2Array,set,INT,"idx",VECTOR2,"vector2",varray()); @@ -1546,6 +1557,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl 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(VECTOR2_ARRAY,NIL,Vector2Array,invert,varray()); ADDFUNC0(VECTOR3_ARRAY,INT,Vector3Array,size,varray()); ADDFUNC2(VECTOR3_ARRAY,NIL,Vector3Array,set,INT,"idx",VECTOR3,"vector3",varray()); @@ -1555,6 +1567,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl 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(VECTOR3_ARRAY,NIL,Vector3Array,invert,varray()); ADDFUNC0(COLOR_ARRAY,INT,ColorArray,size,varray()); ADDFUNC2(COLOR_ARRAY,NIL,ColorArray,set,INT,"idx",COLOR,"color",varray()); @@ -1564,6 +1577,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl 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()); + ADDFUNC0(COLOR_ARRAY,NIL,ColorArray,invert,varray()); //pointerbased From 441640506f5aaba3467e5bad706f101b7752d119 Mon Sep 17 00:00:00 2001 From: George Marques Date: Sat, 25 Jun 2016 14:47:32 -0300 Subject: [PATCH 2/2] Add *Array.invert() documentation --- doc/base/classes.xml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 09554e6a987..805f64ad8aa 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -8544,6 +8544,11 @@ 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()). + + + Reverse the order of the elements in the array (so first element will now be the last). + + @@ -17192,6 +17197,11 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) 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()). + + + Reverse the order of the elements in the array (so first element will now be the last). + + @@ -30279,6 +30289,11 @@ A similar effect may be achieved moving this node's descendants. 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()). + + + Reverse the order of the elements in the array (so first element will now be the last). + + @@ -30657,6 +30672,11 @@ A similar effect may be achieved moving this node's descendants. 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()). + + + Reverse the order of the elements in the array (so first element will now be the last). + + @@ -38120,6 +38140,11 @@ A similar effect may be achieved moving this node's descendants. 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()). + + + Reverse the order of the elements in the array (so first element will now be the last). + + @@ -43043,6 +43068,11 @@ A similar effect may be achieved moving this node's descendants. 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()). + + + Reverse the order of the elements in the array (so first element will now be the last). + + @@ -43334,6 +43364,11 @@ A similar effect may be achieved moving this node's descendants. 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()). + + + Reverse the order of the elements in the array (so first element will now be the last). + +