|
|
| version 1.24, 2024/10/26 00:21:02 | version 1.26, 2024/10/26 18:53:36 |
|---|---|
| Line 38 const char* const PARAM_INDEX = "index m | Line 38 const char* const PARAM_INDEX = "index m |
| // methods | // methods |
| static void _create_or_add(Request& r, MethodParams& params) { | static void _copy_or_add(Request& r, MethodParams& params) { |
| if(params.count()) { | if(params.count()) { |
| Value& vsrc=params.as_no_junction(0, PARAM_ARRAY_OR_HASH); | Value& vsrc=params.as_no_junction(0, PARAM_ARRAY_OR_HASH); |
| VArray& self=GET_SELF(r, VArray); | VArray& self=GET_SELF(r, VArray); |
| Line 608 static void _count(Request& r, MethodPar | Line 608 static void _count(Request& r, MethodPar |
| r.write(*new VInt(array.used())); | r.write(*new VInt(array.used())); |
| } | } |
| static void _append(Request& r, MethodParams& params) { | static void _create_or_append(Request& r, MethodParams& params) { |
| ArrayValue& array=GET_SELF(r, VArray).array(); | ArrayValue& array=GET_SELF(r, VArray).array(); |
| int count=params.count(); | int count=params.count(); |
| for(int i=0; i<count; i++){ | if(array.count()){ |
| array+=&r.process(params[i]); | for(int i=0; i<count; i++) |
| array+=&r.process(params[i]); | |
| array.invalidate(); | |
| } else { | |
| for(int i=0; i<count; i++) | |
| array+=&r.process(params[i]); | |
| array.confirm_all_used(); | |
| } | } |
| array.invalidate(); | |
| } | } |
| static void _insert(Request& r, MethodParams& params) { | static void _insert(Request& r, MethodParams& params) { |
| Line 856 static void _sort(Request& r, MethodPara | Line 861 static void _sort(Request& r, MethodPara |
| for(pos=0; pos<count; pos++) | for(pos=0; pos<count; pos++) |
| array+=seq[pos].array_data; | array+=seq[pos].array_data; |
| array.invalidate(); | array.confirm_all_used(); |
| delete[] seq; | delete[] seq; |
| } | } |
| Line 873 static Value& SingleElementHash(String:: | Line 878 static Value& SingleElementHash(String:: |
| } | } |
| static void _at(Request& r, MethodParams& params) { | static void _at(Request& r, MethodParams& params) { |
| VArray& self=GET_SELF(r, VArray); | ArrayValue& array=GET_SELF(r, VArray).array(); |
| ArrayValue& array=self.array(); | |
| size_t count=array.used(); // not array.count() | size_t count=array.used(); // not array.count() |
| int pos=0; | int pos=0; |
| Line 910 static void _at(Request& r, MethodParams | Line 914 static void _at(Request& r, MethodParams |
| r.write(*new VString(*new String(pa_uitoa(pos), String::L_TAINTED))); | r.write(*new VString(*new String(pa_uitoa(pos), String::L_TAINTED))); |
| break; | break; |
| case AtResultTypeValue: | case AtResultTypeValue: |
| r.write(*array[pos]); | r.write(*array.get(pos)); |
| break; | break; |
| case AtResultTypeHash: | case AtResultTypeHash: |
| r.write(SingleElementHash(pa_uitoa(pos), array[pos])); | r.write(SingleElementHash(pa_uitoa(pos), array.get(pos))); |
| break; | break; |
| } | } |
| } else { | } else { |
| Line 1044 static void _compact(Request& r, MethodP | Line 1048 static void _compact(Request& r, MethodP |
| compact_undef=true; | compact_undef=true; |
| } | } |
| } | } |
| GET_SELF(r, VArray).array().compact(compact_undef); | ArrayValue& array=GET_SELF(r, VArray).array(); |
| array.compact(compact_undef); | |
| array.confirm_all_used(); | |
| } | } |
| Line 1053 static void _compact(Request& r, MethodP | Line 1059 static void _compact(Request& r, MethodP |
| MArray::MArray(): Methoded(VARRAY_TYPE) { | MArray::MArray(): Methoded(VARRAY_TYPE) { |
| // ^array::copy[[copy_from]] | // ^array::copy[[copy_from]] |
| add_native_method("copy", Method::CT_DYNAMIC, _create_or_add, 0, 1); | add_native_method("copy", Method::CT_DYNAMIC, _copy_or_add, 0, 1); |
| // ^array.add[add_from] | // ^array.add[add_from] |
| add_native_method("add", Method::CT_DYNAMIC, _create_or_add, 1, 1); | add_native_method("add", Method::CT_DYNAMIC, _copy_or_add, 1, 1); |
| // ^array.join[join_from[;options]] | // ^array.join[join_from[;options]] |
| add_native_method("join", Method::CT_DYNAMIC, _join, 1, 2); | add_native_method("join", Method::CT_DYNAMIC, _join, 1, 2); |
| // ^array::create[value;value] | // ^array::create[value;value] |
| add_native_method("create", Method::CT_DYNAMIC, _append, 0, 10000); | add_native_method("create", Method::CT_DYNAMIC, _create_or_append, 0, 10000); |
| // ^array.append[value;value] | // ^array.append[value;value] |
| add_native_method("append", Method::CT_DYNAMIC, _append, 1, 10000); | add_native_method("append", Method::CT_DYNAMIC, _create_or_append, 1, 10000); |
| // ^array.insert[index;value...] | // ^array.insert[index;value...] |
| add_native_method("insert", Method::CT_DYNAMIC, _insert, 2, 10000); | add_native_method("insert", Method::CT_DYNAMIC, _insert, 2, 10000); |