pike.git/
src/
builtin.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2003-04-10
2003-04-10 17:08:16 by Martin Nilsson <mani@lysator.liu.se>
18c2251b81345eebb047177191c5542b065f90b7 (
82
lines) (+
74
/-
8
)
[
Show
|
Annotate
]
Branch:
7.9
Added more documentation about random. Added some autodoc prototypes.
Rev: src/builtin.cmod:1.132
2:
|| This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
-
|| $Id: builtin.cmod,v 1.
131
2003/04/
07
17:
28
:
54
nilsson Exp $
+
|| $Id: builtin.cmod,v 1.
132
2003/04/
10
17:
08
:
16
nilsson Exp $
*/ #include "global.h"
828:
#endif }
+
/*! @decl program __empty_program(int|void line, string|void file)
+
*/
PIKEFUN program __empty_program(int|void line, string|void file) efun; optflags OPT_EXTERNAL_DEPEND;
1019:
}
+
/*! @decl mixed random(object o)
+
*! If random is called with an object, @[lfun::random] will be
+
*! called in the object.
+
*! @seealso
+
*! @[lfun::_random]
+
*/
-
/*! @decl
int
random(
int max
)
-
*!
-
*!
This
function
returns
a
random
number
in
the
range
0
-
@[max]-1.
-
*!
+
/*! @decl
mixed
lfun::_
random()
+
*!
Called by @[random]. Typical uses is when the object implements
+
*!
a
ADT,
then
a
call to this lfun should return a
random
member
of
+
*!
the
ADT or
range
implied
by
the ADT
.
*! @seealso
-
*! @[random
_seed
()]
+
*! @[
predef::
random()]
*/
-
+
PIKEFUN mixed random(object o) efun; optflags OPT_TRY_OPTIMIZE|OPT_EXTERNAL_DEPEND;
1038:
pop_stack(); }
+
/*! @decl int random(int max)
+
*! @decl float random(float max)
+
*!
+
*! This function returns a random number in the range 0 - @[max]-1.
+
*!
+
*! @seealso
+
*! @[random_seed()]
+
*/
+
PIKEFUN int random(int i) { if(i <= 0) RETURN 0;
1053:
}
+
/*! @decl mixed random(array|multiset xa)
+
*! Returns a random element from @[x].
+
*/
+
PIKEFUN mixed random(array a) { if(!a->size)
1085:
pop_stack(); }
+
/*! @decl array random(mapping m)
+
*! Returns a random index-value pair from the mapping.
+
*/
+
PIKEFUN array random(mapping m) { struct mapping_data *md=m->data;
1174:
THIS->fun.u.integer = 0; }
+
/*! @decl int(0..1) _is_type(string t)
+
*! This object claims to be an array for backward compatibility.
+
*/
PIKEFUN int(0..1) _is_type(string t) { INT_TYPE res = (t == findstring("array"));
1205:
} }
+
/*! @decl string _sprintf(int c, mapping|void opts)
+
*/
PIKEFUN string _sprintf(int c, mapping|void opts) { pop_n_elems(args);
1255:
f_add(5); }
-
PIKEFUN int _sizeof()
+
/*! @decl int(3..) _sizeof()
+
*/
+
PIKEFUN int
(3..)
_sizeof()
{ if (THIS->args) { push_int(THIS->args->size + 3);
1264:
} }
+
/*! @decl mixed `[](int index, int|void end_or_none)
+
*! The BacktraceFrame object can be indexed as an array.
+
*/
PIKEFUN mixed `[](int index, int|void end_or_none) { INT_TYPE end = index;
1342:
} }
+
/*! @decl mixed `[]=(int index, mixed value)
+
*/
PIKEFUN mixed `[]=(int index, mixed value) { INT32 numargs = 0;
1607:
} }
+
/*! @decl string _sprintf( int flag, mapping flags )
+
*! It is possible to @[sprintf] a String.Buffer object
+
*! as @tt{%s@} just as if it was a string.
+
*/
PIKEFUN string _sprintf( int flag, mapping flags ) { switch( flag )
1651:
Pike_sp[-1].subtype = 1; }
+
/*! @decl mixed cast( string type )
+
*! It is possible to cast a String.Buffer object to
+
*! a @expr{string@} and an @expr{int@}.
+
*/
PIKEFUN mixed cast( string type ) { struct pike_string *string_t;
1682:
Pike_error("Cannot cast to %s\n", type->str ); }
+
/*! @decl String.Buffer `+( string what )
+
*/
PIKEFUN object `+( string what ) { struct Buffer_struct *str = THIS, *str2;
1694:
RETURN res; }
+
/*! @decl String.Buffer `+=( string what )
+
*/
PIKEFUN object `+=( string what ) { f_Buffer_add( 1 );
1841:
return DO_NOT_WARN((int)my_quick_strcmp(a->ind, b->ind)); }
+
/*! @decl void create(array(string)|void from, array(string)|void to)
+
*/
PIKEFUN void create(array(string)|void from_, array(string)|void to_) { int i;
1974:
return match; }
+
/*! @decl string `()(string str)
+
*/
PIKEFUN string `()(string str) { struct string_builder ret;
2033:
RETURN finish_string_builder(&ret); }
+
/*! @decl array(string) _encode()
+
*/
PIKEFUN array(string) _encode() { size_t i;
2047:
f_aggregate(2); }
+
/*! @decl void _decode(array(array(string)) encoded)
+
*/
PIKEFUN void _decode(array(array(string)) encoded) { INT32 i;
2122:
} }
+
/*! @decl void create(string|void del, string|void to)
+
*/
PIKEFUN void create(string|void del_, string|void to_) { struct pike_string *del;
2151:
/*** replace function ***/ typedef char *(* replace_searchfunc)(void *,void *,size_t);
+
+
/*! @decl string `()(string str)
+
*/
PIKEFUN string `()(string str) { int shift;
2237:
RETURN end_shared_string(ret); }
+
/*! @decl array(string) _encode()
+
*/
PIKEFUN array(string) _encode() { if (THIS->del) {
2248:
} }
+
/*! @decl void _decode(array(string)|int(0..0) encoded)
+
*/
PIKEFUN void _decode(array(string)|int(0..0) encoded_) { INT32 i = 0;