pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:222:    /*! @decl int unix_time()    *! Return the unix time corresponding to this time_t. If no time    *! can be parsed from the structure -1 is returned.    */    PIKEFUN int unix_time()    {    FIX_THIS();    RETURN THIS->unix_time;    }    -  /*! @decl string asctime() +  /*! @decl string|zero asctime()    *! Return a string representing the time. Mostly useful for debug    *! purposes, the exact format is very locale (see    *! @[Gettext.setlocale]) and OS dependent.    */ -  PIKEFUN string asctime() +  PIKEFUN string|zero asctime()    {    FIX_THIS();    {   #define STRFTIME_MAXSIZE 26    char s[STRFTIME_MAXSIZE];    if( !strftime(s, STRFTIME_MAXSIZE, "%c\n", &THIS->t) )    push_undefined();    else    push_text(s);    }
pike.git/src/builtin.cmod:299:    }    if( to == literal_string_string )    {    f_TM_asctime(0);    return;    }    pop_stack();    push_undefined();    }    -  /*! @decl string zone +  /*! @decl string|zero zone    *!    *! The timezone of this structure    */ -  PIKEFUN string `zone() { +  PIKEFUN string|zero `zone() {    FIX_THIS();    if( GET_ZONE(THIS) )    push_text( GET_ZONE(THIS) );    else    push_undefined();    }       /*! @decl int gmtoff    *! The offset from GMT for the time in this tm-struct    */
pike.git/src/builtin.cmod:1578:    *!    *! Returns a string with filename and linenumber describing where    *! the program @[p] was defined.    *!    *! The returned string is of the format @expr{"filename:linenumber"@}.    *!    *! If it cannot be determined where the program was defined, @expr{0@}    *! (zero) will be returned.    */   PMOD_EXPORT - PIKEFUN string program_defined(program p) + PIKEFUN string|zero program_defined(program p)    errname defined;    optflags OPT_TRY_OPTIMIZE;   {    INT_TYPE line;    struct pike_string *tmp = low_get_program_line(p, &line);       pop_n_elems(args);       if (tmp) {    push_string(tmp);
pike.git/src/builtin.cmod:1999:    i = FIND_LFUN(p, LFUN__SPRINTF);    if (i >= 0) {    struct reference *ref = PTR_FROM_INT(p, i);    struct identifier *id = ID_FROM_PTR(p, ref);    id_flags = ref->id_flags;    fun_type = id->type;    } else {    type_stack_mark();    push_int_type(MIN_INT32, MAX_INT32);    push_unlimited_array_type(T_STRING); +  push_type(PIKE_T_ZERO); +  push_type(T_OR);    push_type(T_VOID);    push_type(T_MANY);    push_int_type(MIN_INT32, MAX_INT32);    push_unlimited_array_type(T_STRING);    push_int_type(MIN_INT32, MAX_INT32);    push_type(T_MAPPING);    push_type(T_VOID);    push_type(T_OR);    push_type(T_FUNCTION);    push_int_type(MIN_INT32, MAX_INT32);
pike.git/src/builtin.cmod:2059:       mapping_insert(proxy_lookup, Pike_sp-2, Pike_sp-1);       pop_stack();    }       pop_stack();       return p;   } - PIKEFUN program ProxyFactory(program p) + PIKEFUN program|zero ProxyFactory(program p)    optflags OPT_TRY_OPTIMIZE; -  rawtype tFunc(tSetvar(0, tPrg(tObj)), tVar(0)); +  rawtype tFunc(tSetvar(0, tPrg(tObj)), tOr(tVar(0), tZero));   {    struct program *res = proxy_factory(p, NULL, 0);       if (res) {    push_program(res);    } else {    push_undefined();    }   }   
pike.git/src/builtin.cmod:2404:    *!    *! Return the name of the function or program @[f].    *!    *! If @[f] is a global function defined in the runtime @expr{0@}    *! (zero) will be returned.    *!    *! @seealso    *! @[function_object()]    */   PMOD_EXPORT - PIKEFUN string function_name(program|function func) + PIKEFUN string|zero function_name(program|function func)    efun;    optflags OPT_TRY_OPTIMIZE;   {    int f = -1;    struct program *p = NULL;       switch(TYPEOF(*func))    {    default:    SIMPLE_ARG_TYPE_ERROR("function_name", 1, "function|program");
pike.git/src/builtin.cmod:2497:    *! (zero) will be returned.    *!    *! Zero will also be returned if @[f] is a constant in the    *! parent class. In that case @[function_program()] can be    *! used to get the parent program.    *!    *! @seealso    *! @[function_name()], @[function_program()]    */   PMOD_EXPORT - PIKEFUN object function_object(function|program func) + PIKEFUN object|zero function_object(function|program func)    efun;    optflags OPT_TRY_OPTIMIZE; -  type function(function:object); +  type function(function:object|zero);   {    switch(TYPEOF(*func))    {    case PIKE_T_PROGRAM:    break;       case PIKE_T_FUNCTION:    if(SUBTYPEOF(*func) == FUNCTION_BUILTIN) break;    if(func->u.object->prog == pike_trampoline_program)    {
pike.git/src/builtin.cmod:2540:    *!    *! Return the program the function @[f] is in.    *!    *! If @[f] is a global function defined in the runtime @expr{0@}    *! (zero) will be returned.    *!    *! @seealso    *! @[function_name()], @[function_object()]    */   PMOD_EXPORT - PIKEFUN program function_program(program|function func) + PIKEFUN program|zero function_program(program|function func)    efun;    optflags OPT_TRY_OPTIMIZE;   {    switch(TYPEOF(*func))    {    case PIKE_T_PROGRAM:    {    struct program *p;    if(!(p=func->u.program->parent)) break;    add_ref(p);
pike.git/src/builtin.cmod:2900:    * variable names, values are the "name=value" strings.    *    * This is not needed when using {,un}setenv(), since they maintain    * their own corresponding table. */   static struct mapping *env_allocs = NULL;   #endif      /* Works exactly like the getenv efun defined in the master, but only    * accesses the real environment. Everyone should use the caching    * version in the master instead. */ - PIKEFUN string|mapping _getenv (void|string var) -  rawtype tOr(tFunc(tStr, tString), tFunc(tVoid, tMap (tStr, tStr))); + PIKEFUN string|mapping|zero _getenv (void|string var) +  rawtype tOr(tFunc(tStr, tOr(tString, tZero)), +  tFunc(tNone, tMap (tStr, tStr)));   {    /* FIXME: Perhaps add the amigaos4 stuff from pike_push_env here too. */       if (var) {    if (var->size_shift)    SIMPLE_ARG_TYPE_ERROR ("getenv", 1, "void|string(0..255)");       if (string_has_null (var)) {    /* Won't find a variable name like this. */    pop_stack();
pike.git/src/builtin.cmod:3395:    }    }       PIKEFUN void fill_in_file_and_line()    flags ID_PROTECTED;    {    if (THIS->lineno) return;    fill_in_file_and_line(THIS, NULL);    }    -  PIKEFUN string `filename() +  PIKEFUN string|zero `filename()    {    apply_current(f_backtrace_frame_fill_in_file_and_line_fun_num, 0);    pop_stack();    if (THIS->filename) {    ref_push_string(THIS->filename);    return;    }    push_undefined();    }       PIKEFUN int `line()    {    apply_current(f_backtrace_frame_fill_in_file_and_line_fun_num, 0);    pop_stack();    push_int(THIS->lineno);    }       /*! @decl string _sprintf(int c, mapping|void opts)    */ -  PIKEFUN string _sprintf(int c, mapping|void opts) +  PIKEFUN string|zero _sprintf(int c, mapping|void opts)    flags ID_PROTECTED;    {    pop_n_elems(args);       if (c != 'O') {    push_undefined ();    return;    }       push_static_text("backtrace_frame(");
pike.git/src/builtin.cmod:3758:    }       /*! @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)    {    RETURN (t == literal_array_string);    }    -  PIKEFUN array `args() +  PIKEFUN array|zero `args()    {    struct pike_frame *fp = THIS->fp;    struct array *res;       if (!fp) {    push_undefined();    return;    }       push_array(res = allocate_array_no_init(fp->num_args, 0));
pike.git/src/builtin.cmod:3806:    * respectively.    */    struct object *o = clone_fake_object(s->u.object);    free_object(s->u.object);    SET_SVAL(*s, T_OBJECT, 0, object, o);    }    }    }    }    -  PIKEFUN string `filename() +  PIKEFUN string|zero `filename()    {    apply_current(f_LiveBacktraceFrame_fill_in_file_and_line_fun_num, 0);    pop_stack();    if (THIS->filename) {    ref_push_string(THIS->filename);    return;    }    push_undefined();    }   
pike.git/src/builtin.cmod:3972:       PIKEFUN mixed set_local(int(0..) l, mixed val)    {    struct pike_frame *fp = THIS->fp;    if (!fp || (l >= fp->num_locals)) {    Pike_error("No such local: #%d\n", l);    }    assign_svalue(fp->locals + l, val);    }    -  PIKEFUN string get_local_name(int(0..) l) +  PIKEFUN string|zero get_local_name(int(0..) l)    {    struct pike_frame *fp = THIS->fp;    if (!fp || (l >= fp->num_locals)) {    Pike_error("No such local: #%d\n", l);    }    apply_current(f_LiveBacktraceFrame_fill_in_file_and_line_fun_num, 0);    pop_stack();    if ((l < THIS->locals.num_local) && fp->current_object &&    fp->current_object->prog) {    int strno = THIS->locals.names[l];    if (strno < THIS->fp->current_object->prog->num_strings) {    ref_push_string(THIS->fp->current_object->prog->strings[strno]);    return;    }    }    push_undefined();    }    -  PIKEFUN type get_local_type(int(0..) l) +  PIKEFUN type|zero get_local_type(int(0..) l)    {    struct pike_frame *fp = THIS->fp;    if (!fp || (l >= fp->num_locals)) {    Pike_error("No such local: #%d\n", l);    }    apply_current(f_LiveBacktraceFrame_fill_in_file_and_line_fun_num, 0);    pop_stack();    if ((l < THIS->locals.num_local) && fp->current_object &&    fp->current_object->prog) {    int constno = THIS->locals.types[l];
pike.git/src/builtin.cmod:4444:    if (!THIS->ctx.v) {    /* The result is already on the stack in the correct place... */    return;    }       RETURN execute_replace_many(&THIS->ctx, str);    }       /*! @decl array(array(string)) _encode()    */ -  PIKEFUN array(array(string)) _encode() +  PIKEFUN array(array(string))|zero _encode()    {    if (THIS->from) {    ref_push_array(THIS->from);    } else {    push_undefined();    }    if (THIS->to) {    ref_push_array(THIS->to);    } else {    push_undefined();
pike.git/src/builtin.cmod:4640:    INC_PCHARP(r,(tmp-s)>>str->size_shift);    pike_string_cpy(r,to);    INC_PCHARP(r,to->len);    s=tmp+(del->len << str->size_shift);    }    generic_memcpy(r,MKPCHARP(s,str->size_shift),(end-s)>>str->size_shift);    }    RETURN end_shared_string(ret);    }    -  /*! @decl array(string) _encode() +  /*! @decl array(string)|zero _encode()    */ -  PIKEFUN array(string) _encode() +  PIKEFUN array(string)|zero _encode()    {    if (THIS->del) {    ref_push_string(THIS->del);    ref_push_string(THIS->to);    f_aggregate(2);    } else {    push_int(0);    }    }   
pike.git/src/builtin.cmod:5126:    *! 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;    pop_n_elems(2);    }    -  PIKEFUN string _sprintf(int mode, mapping flags) +  PIKEFUN string|zero _sprintf(int mode, mapping flags)    {    pop_n_elems(args);    if (mode != 'O') {    push_undefined ();    return;    }    push_static_text("%O%*'[*]'n");    if(THIS->arg)    ref_push_array(THIS->arg);    else
pike.git/src/builtin.cmod:5332:      PMOD_EXPORT struct object *get_setter(struct object *o, int f)   {    struct object *res = clone_object(Setter_program, 0);    struct Setter_struct *setter = OBJ2_SETTER(res);    add_ref(setter->o = o);    setter->f = f;    return res;   }    - /*! @decl function(mixed_void) _get_setter(object o, string varname) + /*! @decl function(mixed_void)|zero _get_setter(object o, string varname)    *!    *! Get a setter for the variable named @[varname] in object @[o].    *!    *! @returns    *! Returns a @[Setter()->`()()] for the variable if it exists,    *! and @expr{UNDEFINED@} otherwise.    *!    *! @seealso    *! @[object_variablep()]    */ - PIKEFUN function(mixed:void) _get_setter(object o, string s) + PIKEFUN function(mixed:void)|zero _get_setter(object o, string s)   {    struct program *p;    struct inherit *inh;    int f;    if (!(p = o->prog)) {    Pike_error("Indexing a destructed object.\n");    }    inh = p->inherits + SUBTYPEOF(Pike_sp[-args]);    p = inh->prog;    f = find_shared_string_identifier(s, p);
pike.git/src/builtin.cmod:5399:       /*! @decl constant is_sql_null = 1    *!    *! SQL Null marker.    *!    *! @deprecated is_val_null    */    add_integer_constant("is_sql_null", 1, 0);    }    -  PIKEFUN int `!() +  PIKEFUN int(0..1) `!()    flags ID_PROTECTED;    {    RETURN 1;    }    -  PIKEFUN string _sprintf(int fmt, mixed ... extras) +  PIKEFUN string|zero _sprintf(int fmt, mixed ... extras)    flags ID_PROTECTED;    {    pop_n_elems(args);    if (fmt == 'O') {    push_static_text("Val.null");    } else {    push_undefined();    }    }   
pike.git/src/builtin.cmod:6317:    if (THIS->num_elems) {    struct pike_list_node *node = THIS->head;    int i;    for (i = 0; i < THIS->num_elems; i++) {    assign_svalue_no_free(ITEM(a) + i, &node->val);    node = node->next;    }    }    }    -  /*! @decl array cast(string type) +  /*! @decl array|zero cast(string type)    *!    *! Cast the lists. @expr{array@} is the only    *! supported type.    */ -  PIKEFUN array cast(string type) +  PIKEFUN array|zero cast(string type)    flags ID_PROTECTED;    {    pop_stack(); /* type as at least one more reference. */    if (type == literal_array_string)    apply_current(f_List_cq__values_fun_num, 0);    else    push_undefined();    }      
pike.git/src/builtin.cmod:7197:    PIKEFUN mixed cast(string to)    flags ID_PROTECTED;    {    if( to == MK_STRING("array") ) {    apply_current(f_Stack_cq__values_fun_num, 0);    } else {    push_undefined();    }    }    -  PIKEFUN string _sprintf(int t) +  PIKEFUN string|zero _sprintf(int t)    flags ID_PROTECTED;    {    if (t != '0') {    push_undefined();    }       push_constant_text("%O%O");    ref_push_program(Pike_fp->current_program);    apply_current(f_Stack_cq__values_fun_num, 0);    f_sprintf(3);
pike.git/src/builtin.cmod:7369:    PIKEFUN int(0..1) `!()    {    if (!THIS->trampoline.frame || !THIS->trampoline.frame->current_object ||    !THIS->trampoline.frame->current_object->prog) {    push_int(1);    } else {    push_int(0);    }    }    -  PIKEFUN string _sprintf(int c, mapping|void opts) +  PIKEFUN string|zero _sprintf(int c, mapping|void opts)    {    struct byte_buffer buf = BUFFER_INIT();       if (!args || TYPEOF(Pike_sp[-args]) != T_INT ||    Pike_sp[-args].u.integer != 'O' ||    !THIS->trampoline.frame || !THIS->trampoline.frame->current_object) {    pop_n_elems (args);    push_int (0);    return;    }