pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:4388:    if (new_type) {    free_type(n->type);    n->type = new_type;    }    return NULL;   }      /*! @decl string reverse(string s, int|void start, int|void end)    *! @decl array reverse(array a, int|void start, int|void end)    *! @decl int reverse(int i, int|void start, int|void end) +  *! @decl mixed reverse(object o, mixed... options)    *!    *! Reverses a string, array or int.    *!    *! @param s    *! String to reverse.    *! @param a    *! Array to reverse.    *! @param i    *! Integer to reverse. -  +  *! @param o +  *! Object to reverse.    *! @param start    *! Optional start index of the range to reverse.    *! Default: @expr{0@} (zero).    *! @param end    *! Optional end index of the range to reverse.    *! Default for strings: @expr{sizeof(s)-1@}.    *! Default for arrays: @expr{sizeof(a)-1@}.    *! Default for integers: @expr{Pike.get_runtime_info()->int_size - 1@}. -  +  *! @param options +  *! Optional arguments that are to be passed to @[lfun::_reverse()].    *!    *! This function reverses a string, char by char, an array, value    *! by value or an int, bit by bit and returns the result. It's not -  *! destructive on the input value. +  *! destructive on the input value. For objects it simply calls +  *! @[lfun::_reverse()] in the object, and returns the result.    *!    *! Reversing strings can be particularly useful for parsing difficult    *! syntaxes which require scanning backwards.    *!    *! @seealso    *! @[sscanf()]    */   PMOD_EXPORT void f_reverse(INT32 args)   {    struct svalue *sv;
pike.git/src/builtin_functions.c:4543:       case T_ARRAY:    {    struct array *a = sv->u.array;    a = reverse_array(a, start, (end < 0)?a->size:end);    pop_n_elems(args);    push_array(a);    break;    }    +  case T_OBJECT: +  { +  apply_lfun(sv->u.object, LFUN__REVERSE, args - 1); +  stack_swap(); +  pop_stack(); +  break; +  } +     default:    SIMPLE_ARG_TYPE_ERROR("reverse", 1, "string|int|array");    }   }      /* Magic, magic and more magic */   /* Returns the index in v for the string that is the longest prefix of    * str (if any).    *    * v is the sorted (according to generic_quick_binary_strcmp()) vector
pike.git/src/builtin_functions.c:10169:       ADD_EFUN2("replace", f_replace,    tOr5(tFunc(tStr tStr tStr,tStr),    tFunc(tStr tArr(tStr) tOr(tArr(tStr), tStr), tStr),    tFunc(tStr tMap(tStr,tStr),tStr),    tFunc(tSetvar(0,tArray) tMix tMix,tVar(0)),    tFunc(tSetvar(1,tMapping) tMix tMix,tVar(1))),    OPT_TRY_OPTIMIZE, optimize_replace, 0);       ADD_EFUN("reverse",f_reverse, -  tOr3(tFunc(tInt tOr(tVoid, tInt) tOr(tVoid, tInt), tInt), +  tOr4(tFunc(tInt tOr(tVoid, tInt) tOr(tVoid, tInt), tInt),    tFunc(tStr tOr(tVoid, tInt) tOr(tVoid, tInt), tStr),    tFunc(tSetvar(0, tArray) tOr(tVoid, tInt) tOr(tVoid, tInt), -  tVar(0))),0); +  tVar(0)), +  tFuncV(tObj, tOr(tMix, tVoid), tMix)),0);       /* function(mixed,array:array) */    ADD_EFUN("rows",f_rows,    tOr6(tFunc(tMap(tSetvar(0,tMix),tSetvar(1,tMix)) tArr(tVar(0)),    tArr(tVar(1))),    tFunc(tSet(tSetvar(0,tMix)) tArr(tVar(0)), tArr(tInt01)),    tFunc(tString tArr(tInt), tArr(tInt)),    tFunc(tArr(tSetvar(0,tMix)) tArr(tInt), tArr(tVar(1))),    tFunc(tArray tArr(tNot(tInt)), tArray),    tFunc(tOr4(tObj,tFunction,tPrg(tObj),tInt) tArray, tArray)), 0);