pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:4234:
} } /*! @endclass */ /*! @endmodule */
+
/*! @module Builtin
+
*/
+
+
/*! @class automap_marker
+
*!
+
*! This is an internal class used by @[__automap__()].
+
*!
+
*! It may show up during module dumping or in backtraces
+
*! and the like.
+
*!
+
*! It should in normal circumstances never be used directly.
+
*!
+
*! @seealso
+
*! @[__automap__()], @[map()]
+
*/
PIKECLASS automap_marker { PIKEVAR array arg; PIKEVAR int depth;
-
+
/*! @decl void create(array arr, int depth)
+
*!
+
*! @param arr
+
*! Array that @[__automap__()] is to loop over.
+
*!
+
*! @param depth
+
*! Recursion depth of @[arr] where the loop will be.
+
*/
PIKEFUN void create(array a, int d) { if(THIS->arg) free_array(THIS->arg); add_ref(THIS->arg=a); THIS->depth=d; } PIKEFUN string _sprintf(int mode, mapping flags) { pop_n_elems(args);
pike.git/src/builtin.cmod:4263:
push_text("%O%*'[*]'n"); if(THIS->arg) ref_push_array(THIS->arg); else push_int(0); push_int(THIS->depth*3); f_sprintf(3); } }
+
/*! @endclass
+
*/
-
+
/*! @endmodule
+
*/
+
static void low_automap(int d, int depth, struct svalue *fun, struct svalue *real_args, INT32 args) { INT32 x,e,tmp,size=0x7fffffff; struct svalue *tmpargs=Pike_sp - args; struct array *ret; TYPE_FIELD types;
pike.git/src/builtin.cmod:4294:
args, tmpargs, NULL, "Automap on non-array.\n"); tmp=tmpargs[e].u.array->size; if(tmp < size) size=tmp; } }
-
#ifdef PIKE_DEBUG
+
if(size == 0x7fffffff)
-
Pike_
fatal
("No automap markers found in
low
_
automap\n
");
-
#endif
+
Pike_
error
("No automap markers found in _
_automap__\n
");
push_array(ret=allocate_array(size)); types = 0; for(x=0;x<size;x++) { for(e=0;e<args;e++) { if(TYPEOF(real_args[e]) == T_OBJECT && real_args[e].u.object->prog == automap_marker_program &&
pike.git/src/builtin.cmod:4331:
apply_svalue(fun,args); else low_automap(d+1,depth,fun,real_args,args); stack_pop_to_no_free (ITEM(ret) + x); types |= 1 << TYPEOF(ITEM(ret)[x]); } ret->type_field = types; stack_unlink(args); }
-
+
/*! @decl array __automap__(function fun, mixed ... args)
+
*!
+
*! Automap execution function.
+
*!
+
*! @param fun
+
*! Function to call for each of the mapped arguments.
+
*!
+
*! @param args
+
*! Arguments for @[fun]. Either
+
*! @mixed
+
*! @type Builtin.automap_marker
+
*! Wrapper for an array to loop over. All of the
+
*! arrays will be looped over in parallel.
+
*! @type mixed
+
*! All other arguments will be held constant during
+
*! the automap, and sent as is to @[fun].
+
*! @endmixed
+
*!
+
*! @note
+
*! This function is used by the compiler to implement the
+
*! automap syntax, and should in normal circumstances never
+
*! be used directly.
+
*!
+
*! It may however show up during module dumping and in
+
*! backtraces.
+
*!
+
*! @note
+
*! It is an error not to have any @[Builtin.automap_marker]s
+
*! in @[args].
+
*!
+
*! @seealso
+
*! @[Builtin.automap_marker], @[map()]
+
*/
PIKEFUN array __automap__(mixed fun, mixed ... tmpargs) efun; { int e,depth=-1; check_stack(args); for(e=0;e<args-1;e++) { if(TYPEOF(tmpargs[e]) == T_OBJECT && tmpargs[e].u.object->prog == automap_marker_program)