pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:2087:
INIT { THIS->int_buffer = 0; THIS->buffer_bits = 0; } /*! @decl string(8bit) random_string(int(0..)) *! *! Prototype for the randomness generating function. *!
-
*! Override this symbol to implement a
useable
class.
+
*! Override this symbol to implement a
usable
class.
*/ PIKEFUN string(8bit) random_string(int(0..)) prototype; {} static void fill_int_buffer() { push_int(8); apply_current(f_RandomInterface_random_string_fun_num, 1); if( TYPEOF(Pike_sp[-1]) != T_STRING ||
pike.git/src/builtin.cmod:2170:
if (THIS->buffer_bits < 64) fill_int_buffer(); value = THIS->int_buffer; THIS->buffer_bits = 0; RETURN (FLOAT_TYPE)ldexp((double)f * value, -64); } /*! @decl mixed random(array|multiset x) *! Returns a random element from @[x].
+
*!
+
*! @throws
+
*! Throws an exception if the array or multiset is empty.
*/ PIKEFUN mixed random(array a) rawtype tFunc(tArr(tSetvar(0,tMix)),tVar(0)); { if(!a->size) SIMPLE_ARG_TYPE_ERROR("random", 1, "array with elements in it"); push_svalue(a->item + (read_int(a->size))); }
pike.git/src/builtin.cmod:2191:
rawtype tFunc(tSet(tSetvar(1,tMix)),tVar(1)); { if(multiset_is_empty (m)) SIMPLE_ARG_TYPE_ERROR("random", 1, "multiset with elements in it"); push_multiset_index (m, multiset_get_nth (m, read_int(multiset_sizeof (m)))); sub_msnode_ref (m); } /*! @decl array random(mapping m) *! Returns a random index-value pair from the mapping.
+
*!
+
*! @array
+
*! @elem mixed 0
+
*! The index of the mapping entry.
+
*! @elem mixed 1
+
*! The value f the mapping entry.
+
*! @endarray
+
*!
+
*! @throws
+
*! Throws an exception if the mapping is empty.
*/ PIKEFUN array random(mapping m) { struct keypair *k; int e, count; if(!m_sizeof(m)) SIMPLE_ARG_TYPE_ERROR("random", 1, "mapping with elements in it"); count = read_int( m_sizeof(m) );
pike.git/src/builtin.cmod:2220:
} } UNREACHABLE(); } /*! @decl mixed random(object o) *! If random is called with an object, @[lfun::_random] will be *! called in the object. *!
+
*! @throws
+
*! Throws an exception if the object doesn't have a _radnom method.
+
*!
*! @seealso *! @[lfun::_random()] */ PIKEFUN mixed random(object o) { int f = low_find_lfun(o->prog, LFUN__RANDOM); if (f < 0) Pike_error("Calling undefined lfun::%s.\n", lfun_names[LFUN__RANDOM]); struct object *co = Pike_fp->current_object; ref_push_function(co, f_RandomInterface_random_string_fun_num);