Branch: Tag:

2018-05-29

2018-05-29 13:15:54 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Runtime: Added macro SAFE_MAYBE_APPLY_MASTER().

This macro behaves like SAFE_APPLY_MASTER(), but does not complain
if the function is missing (and instead returns UNDEFINED).

599:    safe_apply_low2(master_ob, id_, _args_, _fun_); \   }while(0)    + #define SAFE_MAYBE_APPLY_MASTER(FUN,ARGS) \ + do{ \ +  const char* _fun_ = (FUN); \ +  int _args_ = (ARGS); \ +  static int id_, master_cnt=0; \ +  struct object *master_ob=master(); \ +  if(master_cnt != master_ob->prog->id) \ +  { \ +  id_=find_identifier(_fun_,master_ob->prog); \ +  master_cnt = master_ob->prog->id; \ +  } \ +  if (id_ >= 0) { \ +  safe_apply_low2(master_ob, id_, _args_, _fun_); \ +  } else { \ +  pop_n_elems(_args_); \ +  push_undefined(); \ +  } \ + }while(0) +    #define SAFE_APPLY_HANDLER(FUN, HANDLER, COMPAT, ARGS) do { \    static int h_fun_=-1, h_id_=0; \    static int c_fun_=-1, c_fun_id_=0; \