Branch: Tag:

2001-12-19

2001-12-19 23:48:42 by Martin Stjernholm <mast@lysator.liu.se>

Added low_unsafe_apply_handler.

Rev: src/interpret.c:1.255
Rev: src/interpret.h:1.106

5:   \*/   /**/   #include "global.h" - RCSID("$Id: interpret.c,v 1.254 2001/12/16 02:49:39 mast Exp $"); + RCSID("$Id: interpret.c,v 1.255 2001/12/19 23:48:41 mast Exp $");   #include "interpret.h"   #include "object.h"   #include "program.h"
1577:    safe_apply_low2(o, find_identifier(fun, o->prog), args, 1);   }    + /* Returns nonzero if the function was called in some handler. */ + PMOD_EXPORT int low_unsafe_apply_handler(const char *fun, +  struct object *handler, +  struct object *compat, +  INT32 args) + { +  int i; + #if 0 +  fprintf(stderr, "low_unsafe_apply_handler(\"%s\", 0x%08p, 0x%08p, %d)\n", +  fun, handler, compat, args); + #endif /* 0 */ +  if (handler && handler->prog && +  (i = find_identifier(fun, handler->prog)) != -1) { +  apply_low(handler, i, args); +  } else if (compat && compat->prog && +  (i = find_identifier(fun, compat->prog)) != -1) { +  apply_low(compat, i, args); +  } else { +  struct object *master_obj = master(); +  if ((i = find_identifier(fun, master_obj->prog)) != -1) +  apply_low(master_obj, i, args); +  else { +  pop_n_elems(args); +  push_undefined(); +  return 0; +  } +  } +  return 1; + } +    PMOD_EXPORT void low_safe_apply_handler(const char *fun,    struct object *handler,    struct object *compat,
1626:    else {    Pike_sp += args;    -  if (handler && handler->prog && -  (i = find_identifier(fun, handler->prog)) != -1) { -  apply_low(handler, i, args); -  } else if (compat && compat->prog && -  (i = find_identifier(fun, compat->prog)) != -1) { -  apply_low(compat, i, args); -  } else { -  struct object *master_obj = master(); -  if ((i = find_identifier(fun, master_obj->prog)) != -1) -  apply_low(master_obj, i, args); -  else { -  pop_n_elems(args); -  push_undefined(); -  goto dont_check_ret_type; -  } -  } -  -  if (rettypes && +  if (low_unsafe_apply_handler (fun, handler, compat, args) && +  rettypes &&    !(((1 << Pike_sp[-1].type) & rettypes) ||    ((rettypes & BIT_ZERO) &&    Pike_sp[-1].type == T_INT &&
1658:    Pike_error("Invalid return value from %s\n", fun);    }    -  dont_check_ret_type: +     ret = 1;    }