pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:1:   /*   || 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_functions.c,v 1.628 2007/03/26 11:13:11 grubba Exp $ + || $Id: builtin_functions.c,v 1.629 2007/03/28 15:29:47 grubba Exp $   */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"
pike.git/src/builtin_functions.c:2216:    Pike_sp[-1].u.string->size_shift )    Pike_error( "__parse_pike_type requires a 8bit string as its first argument\n" );    t = parse_type( (char *)STR0(Pike_sp[-1].u.string) );    pop_stack();       push_string(type_to_string(t));    free_type(t);   }      /*! @decl type __check_call(type arg_type, type fun_type) +  *! @decl type __check_call(type arg_type, type fun_type, int flags)    *!    *! Check whether a function of type @[fun_type] may be called    *! with a first argument of type @[arg_type].    *! -  +  *! @param flags +  *! The following flags are currently defined: +  *! @int +  *! @value 1 +  *! Strict types. Fail if not all possible values in @[arg_type] +  *! are valid as the first argument to @[fun_type]. +  *! @value 2 +  *! Last argument. @[arg_type] is the last argument to @[fun_type]. +  *! @value 3 +  *! Both strict types and last argument as above. +  *! @endint +  *!    *! @returns    *! Returns a continuation type on success.    *!    *! Returns @tt{0@} (zero) on failure.    */   static void f___check_call(INT32 args)   {    struct pike_type *res; -  if (args != 2) Pike_error("Bad number of arguments to __check_call().\n"); -  if (Pike_sp[-2].type != PIKE_T_TYPE) { +  INT32 flags = 0; +  if (args < 2) Pike_error("Bad number of arguments to __check_call().\n"); +  if (Pike_sp[-args].type != PIKE_T_TYPE) {    Pike_error("Bad argument 1 to __check_call() expected type.\n");    } -  if (Pike_sp[-1].type != PIKE_T_TYPE) { -  Pike_error("Bad argument 1 to __check_call() expected type.\n"); +  if (Pike_sp[1-args].type != PIKE_T_TYPE) { +  Pike_error("Bad argument 2 to __check_call() expected type.\n");    } -  if (!(res = low_new_check_call(Pike_sp[-2].u.type, -  Pike_sp[-1].u.type, 0))) { +  if (args > 2) { +  if (Pike_sp[2-args].type != PIKE_T_INT) { +  Pike_error("Bad argument 3 to __check_call() expected int.\n"); +  } +  flags = Pike_sp[2-args].u.integer; +  } +  if (!(res = low_new_check_call(Pike_sp[-args].u.type, +  Pike_sp[1-args].u.type, flags))) {    pop_n_elems(args);    push_undefined();    } else {    pop_n_elems(args);    push_type_value(res);    }   }      /*! @decl type __get_return_type(type fun_type)    *!
pike.git/src/builtin_functions.c:9077:      /* function(string(8),int|void:string) */    ADD_EFUN("utf8_to_string", f_utf8_to_string,    tFunc(tStr8 tOr(tInt,tVoid),tStr), OPT_TRY_OPTIMIZE);          ADD_EFUN("__parse_pike_type", f_parse_pike_type,    tFunc(tStr8,tStr8),OPT_TRY_OPTIMIZE);       ADD_EFUN("__check_call", f___check_call, -  tFunc(tType(tMix) tType(tCallable), tType(tCallable)), +  tFunc(tType(tMix) tType(tCallable) tOr(tInt,tVoid), +  tType(tCallable)),    OPT_TRY_OPTIMIZE);       /* FIXME: Could have a stricter type. */    ADD_EFUN("__get_return_type", f___get_return_type,    tFunc(tType(tCallable), tType(tMix)),    OPT_TRY_OPTIMIZE);       /* FIXME: Could have a stricter type. */    ADD_EFUN("__get_first_arg_type", f___get_first_arg_type,    tFunc(tType(tCallable), tType(tMix)),