pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:3793:    if ((ref->id_flags & ID_HIDDEN) ||    ((ref->id_flags & (ID_PRIVATE|ID_INHERITED)) ==    (ID_PRIVATE|ID_INHERITED))) {    continue;    }    id = ID_FROM_PTR(p, ref);    if (!IDENTIFIER_IS_VARIABLE(id->identifier_flags)) {    continue;    }    push_svalue(fun); -  ref_push_string(id->name); -  ref_push_type_value(id->type); +     if (use_setter) {    push_function(get_setter(Pike_fp->current_object,    i + inh->identifier_level),    f_Setter_cq__backtick_28_29_fun_num);    } else {    low_object_index_no_free(Pike_sp, Pike_fp->current_object,    i + inh->identifier_level);    Pike_sp++;    } -  +  ref_push_string(id->name); +  ref_push_type_value(id->type);    apply_current(fun_num, 4);    pop_stack();    }    if (Pike_sp != save_sp) {    /* Not likely, but... */    pop_n_elems(Pike_sp - save_sp);    }    }       /*! @decl protected void _serialize_variable( @ -  *! function(string, type, mixed:void) serializer, @ +  *! function(mixed, string, type:void) serializer, @ +  *! mixed value, @    *! string symbol, @ -  *! type symbol_type, @ -  *! mixed value) +  *! type symbol_type)    *!    *! Default serialization function for variables.    *!    *! @param serializer    *! Function to be called in turn.    *! -  +  *! @param value +  *! Value of the variable. +  *!    *! @param symbol    *! Variable name.    *!    *! @param symbol_type    *! Type of the variable.    *! -  *! @param value -  *! Value of the variable. -  *! +     *! This function is typically called from @[_serialize()], and just does    *! @code -  *! serializer(symbol, symbol_type, value); +  *! serializer(value, symbol, symbol_type);    *! @endcode    *!    *! It is provided for overloading for eg filtering or validation purposes.    *!    *! @seealso    *! @[_serialize()], @[_deserialize_variable()]    */ -  PIKEFUN void _serialize_variable(function(string, type, mixed:void) -  serializer, string symbol, -  type symbol_type, mixed value) +  PIKEFUN void _serialize_variable(function(mixed, string, type:void) +  serializer, mixed value, +  string symbol, type symbol_type)    flags ID_PROTECTED; -  rawtype tFunc(tFunc(tStr tType(tMix) tMix, tVoid) -  tStr tType(tMix) tMix, tVoid); +  rawtype tFunc(tFunc(tMix tStr tType(tMix), tVoid) +  tMix tStr tType(tMix), tVoid);    {    f_call_function(args);    pop_stack();    push_int(0);    }       /*! @decl protected void _serialize(object o, @ -  *! function(string, type, mixed:void) serializer) +  *! function(mixed, string, type:void) serializer)    *!    *! Dispatch function for serialization.    *!    *! @param o    *! Object to serialize. Always a context of the current object.    *!    *! @param serializer    *! Function to typically be called once for every variable    *! in the inheriting class.    *!
pike.git/src/builtin.cmod:3878:    *! for every variable in the inheriting class.    *!    *! @note    *! The symbols will be listed in the order they were defined    *! in the class.    *!    *! @note    *! This function is typically called via @[Serializer.serialize()].    */    PIKEFUN void _serialize(object o, -  function(string, type, mixed:void) serializer) +  function(mixed, string, type:void) serializer)    flags ID_PROTECTED; -  rawtype tFunc(tObj tFunc(tStr tType(tMix) tMix, tVoid), tVoid); +  rawtype tFunc(tObj tFunc(tMix tStr tType(tMix), tVoid), tVoid);    {    if (o != Pike_fp->current_object) {    SIMPLE_BAD_ARG_ERROR("_serialize", 1, "this");    }    low_serialize(Pike_sp[-args].subtype, serializer, 0,    f_Serializable_cq__serialize_variable_fun_num);    pop_n_elems(args);    push_int(0);    }   
pike.git/src/builtin.cmod:3904:    if ((t->type != PIKE_T_OBJECT) || !t->cdr) return NULL;    p = id_to_program(CDR_TO_INT(t));    if (!p || (p->flags & PROGRAM_NEEDS_PARENT) ||    (low_find_lfun(p, LFUN__DESERIALIZE) == -1)) return NULL;    return p;    }       DEFAULT_CMOD_STORAGE void f_deserialize(INT32 args);       /*! @decl protected void _deserialize_variable( @ -  *! function(string, type, @ -  *! function(mixed:void): void) deserializer, @ +  *! function(function(mixed:void), @ +  *! string, type: void) deserializer, @ +  *! function(mixed:void) setter, @    *! string symbol, @ -  *! type symbol_type, @ -  *! function(mixed:void) setter) +  *! type symbol_type)    *!    *! Default deserialization function for variables.    *!    *! @param deserializer    *! Function to be called in turn.    *! -  +  *! @param setter +  *! Function that sets the value of the variable. +  *!    *! @param symbol    *! Variable name.    *!    *! @param symbol_type    *! Type of the variable.    *! -  *! @param setter -  *! Function that sets the value of the variable. -  *! +     *! This function is typically called from @[_deserialize()], and does    *! something like:    *! @code    *! if (object_typep(symbol_type)) {    *! program p = program_from_type(symbol_type);    *! if (p && !needs_parent(p) && is_deserializable(p)) {    *! object value = p();    *! setter(value);    *! Serializer.deserialize(value, deserializer);    *! return;    *! }    *! } -  *! deserializer(symbol, symbol_type, setter); +  *! deserializer(setter, symbol, symbol_type);    *! @endcode    *!    *! @note    *! The above takes care of the most common cases, but    *! @ul    *! @item    *! Does not support anonymous object types.    *! @item    *! Does not support objects needing a parent.    *! @item
pike.git/src/builtin.cmod:3961:    *! in case there are multiple choices that satisfy the above.    *! @item    *! Is likely to throw errors if @tt{p()@} requires arguments.    *! @endul    *!    *! These issues can all be solved by overloading this function.    *!    *! @seealso    *! @[_deserialize()], @[_serialize_variable()]    */ -  PIKEFUN void _deserialize_variable(function(string, type, -  function(mixed:void): void) -  deserializer, string symbol, -  type symbol_type, -  function(mixed:void) setter) +  PIKEFUN void _deserialize_variable(function(function(mixed:void), +  string, type: void) +  deserializer, function(mixed:void) setter, +  string symbol, +  type symbol_type)    flags ID_PROTECTED; -  rawtype tFunc(tFunc(tStr tType(tMix) tFunc(tMix, tVoid), tVoid) -  tStr tType(tMix) tFunc(tMix, tVoid), tVoid); +  rawtype tFunc(tFunc(tFunc(tMix, tVoid) tStr tType(tMix), tVoid) +  tFunc(tMix, tVoid) tStr tType(tMix), tVoid);    {    struct program *p = find_type(symbol_type,    find_program_from_object_type_cb);    if (p) {    struct object *o = clone_object(p, 0);    push_object(o); /* Protection against errors and arg to deserialize. */    ref_push_object(o);    apply_svalue(setter, 1);    pop_stack();    push_svalue(deserializer);    f_deserialize(2);    return;    }    f_call_function(args);    pop_stack();    push_int(0);    }       /*! @decl protected void _deserialize(object o, @ -  *! function(string, type, @ -  *! function(mixed:void): void) deserializer) +  *! function(function(mixed:void), @ +  *! string, type: void) deserializer)    *!    *! Dispatch function for deserialization.    *!    *! @param o    *! Object to serialize. Always a context of the current object.    *!    *! @param deserializer    *! Function to typically be called once for every variable    *! in the inheriting class.    *!
pike.git/src/builtin.cmod:4011:    *! for every variable in the inheriting class.    *!    *! @note    *! The symbols will be listed in the order they were defined    *! in the class.    *!    *! @note    *! This function is typically called via @[Serializer.deserialize()].    */    PIKEFUN void _deserialize(object o, -  function(string, type, -  function(mixed:void): void) deserializer) +  function(function(mixed:void), +  string, type: void) deserializer)    flags ID_PROTECTED; -  rawtype tFunc(tObj tFunc(tStr tType(tMix) tFunc(tMix, tVoid), tVoid), tVoid); +  rawtype tFunc(tObj tFunc(tFunc(tMix, tVoid) tStr tType(tMix), tVoid), tVoid);    {    if (o != Pike_fp->current_object) {    SIMPLE_BAD_ARG_ERROR("_serialize", 1, "this");    }    low_serialize(Pike_sp[-args].subtype, deserializer, 1,    f_Serializable_cq__deserialize_variable_fun_num);    pop_n_elems(args);    push_int(0);    }   }   /*! @endclass    */      /*! @decl void serialize(object o, @ -  *! function(string, type, mixed:void) serializer) +  *! function(mixed, string, type:void) serializer)    *!    *! Call @[lfun::_serialize()] in @[o].    *!    *! @seealso    *! @[deserialize()], @[lfun::_serialize()],    *! @[Serializable()->_serialize()]    */   PIKEFUN void serialize(object o, -  function(string, type, mixed:void) serializer) -  rawtype tFunc(tObj tFunc(tStr tType(tMix) tMix, tVoid), tVoid); +  function(mixed, string, type:void) serializer) +  rawtype tFunc(tObj tFunc(tMix tStr tType(tMix), tVoid), tVoid);   {    struct inherit *inh;    struct program *p;    ptrdiff_t fun;    if (!(p = o->prog)) {    Pike_error("Indexing a destructed object.\n");    }    inh = p->inherits + Pike_sp[-args].subtype;    p = inh->prog;    if ((fun = low_find_lfun(p, LFUN__SERIALIZE)) == -1) {    Pike_error("Serialization not supported by object.\n");    }    apply_low(o, fun + inh->identifier_level, args);   }      /*! @decl void deserialize(object o, @ -  *! function(string, type, @ -  *! function(mixed:void):void) deserializer) +  *! function(function(mixed:void), @ +  *! string, type: void) deserializer)    *!    *! Call @[lfun::_deserialize()] in @[o].    *!    *! @seealso    *! @[serialize()], @[lfun::_deserialize()],    *! @[Serializable()->_deserialize()]    */   PIKEFUN void deserialize(object o, -  function(string, type, -  function(mixed:void):void) deserializer) -  rawtype tFunc(tObj tFunc(tStr tType(tMix) tFunc(tMix, tVoid), tVoid), tVoid); +  function(function(mixed:void), +  string, type:void) deserializer) +  rawtype tFunc(tObj tFunc(tFunc(tMix, tVoid) tStr tType(tMix), tVoid), tVoid);   {    struct inherit *inh;    struct program *p;    ptrdiff_t fun;    if (!(p = o->prog)) {    Pike_error("Indexing a destructed object.\n");    }    inh = p->inherits + Pike_sp[-args].subtype;    p = inh->prog;    if ((fun = low_find_lfun(p, LFUN__DESERIALIZE)) == -1) {