pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:2948:    int ret;       if (!args || TYPEOF(Pike_sp[-1]) != PIKE_T_TYPE)    SIMPLE_ARG_TYPE_ERROR("deprecated_typep", 1, "type");       ret = deprecated_typep(Pike_sp[-1].u.type);    pop_n_elems(args);    push_int(ret);   }    + /*! @decl type typeof_identifier(program p, string identifier) +  *! +  *! Allows access to the static type of an identifier ("member") in a +  *! program. +  *! +  *! @returns +  *! The static type of @expr{p->identifier@}, or @expr{UNDEFINED@} +  *! if it can not be determined, be it because @expr{identifier@} does not +  *! exist in @expr{p@} or for other reasons. +  */ + PMOD_EXPORT void f_typeof_identifier(INT32 args) + { +  struct program *prog; +  struct pike_string *identifier; +  int identifier_int; +  +  get_all_args("typeof_identifier", args, "%p%t", &prog, &identifier); +  +  identifier_int = find_shared_string_identifier(identifier, prog); +  +  if (identifier_int != -1) +  { +  struct pike_type *ret; +  +  copy_pike_type(ret, ID_FROM_INT(prog, identifier_int)->type); +  pop_n_elems(args); +  push_type_value(ret); +  } +  else +  { +  pop_n_elems(args); +  push_undefined(); +  } + } +    /*! @decl string(0..255) __parse_pike_type(string(0..255) t)    */   static void f_parse_pike_type( INT32 args )   {    struct pike_type *t;       if( !args || TYPEOF(Pike_sp[-1]) != T_STRING ||    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) );
pike.git/src/builtin_functions.c:10292:    ADD_EFUN("validate_utf8", f_validate_utf8,    tFunc(tStr8 tOr(tInt,tVoid),tInt01), OPT_TRY_OPTIMIZE);          ADD_EFUN("__parse_pike_type", f_parse_pike_type,    tFunc(tStr8,tStr8),OPT_TRY_OPTIMIZE);       ADD_EFUN("deprecated_typep", f_deprecated_typep,    tFunc(tType(tMix),tInt), OPT_TRY_OPTIMIZE);    +  ADD_EFUN("typeof_identifier", f_typeof_identifier, +  tFunc(tPrg(tObj) tStr, tType(tMix)), OPT_TRY_OPTIMIZE); +     ADD_EFUN("__soft_cast", f___soft_cast,    tFunc(tSetvar(0, tType(tMix)) tSetvar(1, tType(tMix)),    tAnd(tVar(0), tVar(1))),    OPT_TRY_OPTIMIZE);       ADD_EFUN("__low_check_call", f___low_check_call,    tFunc(tType(tCallable) tType(tMix) tOr(tInt,tVoid) tOr(tMix,tVoid),    tType(tCallable)),    OPT_TRY_OPTIMIZE);