diff options
author | bjj <bjj> | 2001-03-12 05:10:54 +0000 |
---|---|---|
committer | bjj <bjj> | 2001-03-12 05:10:54 +0000 |
commit | ae1c936c4a610af266c79c61d7eba01edd2ffe15 (patch) | |
tree | 1e6075b1a8790269aa756a611e85a35b439b9193 | |
parent | 5036fa0534956f008c2aa41884d1db10a10359b9 (diff) | |
download | moo-ae1c936c4a610af266c79c61d7eba01edd2ffe15.tar.gz moo-ae1c936c4a610af266c79c61d7eba01edd2ffe15.tar.xz moo-ae1c936c4a610af266c79c61d7eba01edd2ffe15.zip |
Split out call_verb and call_verb2. The latter must only be called with
strings that are already MOO strings (str_ref-able).
-rw-r--r-- | execute.c | 32 | ||||
-rw-r--r-- | execute.h | 8 | ||||
-rw-r--r-- | functions.c | 6 |
3 files changed, 40 insertions, 6 deletions
@@ -535,12 +535,31 @@ free_activation(activation a, char data_too) /** Set up another activation for calling a verb does not change the vm in case of any error **/ +enum error call_verb2(Objid this, const char *vname, Var args, int do_pass); + +/* + * Historical interface for things which want to call with vname not + * already in a moo-str. + */ enum error -call_verb(Objid this, const char *vname, Var args, int do_pass) +call_verb(Objid this, const char *vname_in, Var args, int do_pass) +{ + const char *vname = str_dup(vname_in); + enum error result; + + result = call_verb2(this, vname, args, do_pass); + /* call_verb2 got any refs it wanted */ + free_str(vname); + return result; +} + +enum error +call_verb2(Objid this, const char *vname, Var args, int do_pass) { /* if call succeeds, args will be consumed. If call fails, args will NOT be consumed -- it must therefore be freed by caller */ /* vname will never be consumed */ + /* vname *must* already be a MOO-string (as in str_ref-able) */ /* will only return E_MAXREC, E_INVIND, E_VERBNF, or E_NONE */ /* returns an error if there is one, and does not change the vm in that @@ -570,7 +589,6 @@ call_verb(Objid this, const char *vname, Var args, int do_pass) return E_MAXREC; program = db_verb_program(h); - vname = str_dup(vname); /* ensure that vname is heap-allocated */ RUN_ACTIV.prog = program_ref(program); RUN_ACTIV.this = this; RUN_ACTIV.progr = db_verb_owner(h); @@ -612,7 +630,7 @@ call_verb(Objid this, const char *vname, Var args, int do_pass) #undef ENV_COPY v.type = TYPE_STR; - v.v.str = vname; + v.v.str = str_ref(vname); set_rt_env_var(env, SLOT_VERB, v); /* no var_dup */ set_rt_env_var(env, SLOT_ARGS, args); /* no var_dup */ @@ -1538,7 +1556,7 @@ do { \ err = E_INVIND; else { STORE_STATE_VARIABLES(); - err = call_verb(obj.v.obj, verb.v.str, args, 0); + err = call_verb2(obj.v.obj, verb.v.str, args, 0); /* if there is no error, RUN_ACTIV is now the CALLEE's. args will be consumed in the new rt_env */ /* if there is an error, then RUN_ACTIV is unchanged, and @@ -2522,7 +2540,7 @@ bf_ticks_left(Var arglist, Byte next, void *vdata, Objid progr) static package bf_pass(Var arglist, Byte next, void *vdata, Objid progr) { - enum error e = call_verb(RUN_ACTIV.this, RUN_ACTIV.verb, arglist, 1); + enum error e = call_verb2(RUN_ACTIV.this, RUN_ACTIV.verb, arglist, 1); if (e == E_NONE) return tail_call_pack(); @@ -2860,6 +2878,10 @@ char rcsid_execute[] = "$Id$"; /* * $Log$ + * Revision 1.12 2001/03/12 05:10:54 bjj + * Split out call_verb and call_verb2. The latter must only be called with + * strings that are already MOO strings (str_ref-able). + * * Revision 1.11 2001/03/12 03:25:16 bjj * Added new package type BI_KILL which kills the task calling the builtin. * Removed the static int task_killed in execute.c which wa tested on every @@ -81,6 +81,10 @@ typedef enum { or E_NONE. the vm will only be changed if E_NONE is returned */ extern enum error call_verb(Objid obj, const char *vname, Var args, int do_pass); +/* if your vname is already a moo str (via str_dup) then you can + use this interface instead */ +extern enum error call_verb2(Objid obj, const char *vname, Var args, + int do_pass); extern int setup_activ_for_eval(Program * prog); @@ -131,6 +135,10 @@ extern int read_activ(activation * a, int which_vector); /* * $Log$ + * Revision 1.5 2001/03/12 05:10:54 bjj + * Split out call_verb and call_verb2. The latter must only be called with + * strings that are already MOO strings (str_ref-able). + * * Revision 1.4 1998/12/14 13:17:51 nop * Merge UNSAFE_OPTS (ref fixups); fix Log tag placement to fit CVS whims * diff --git a/functions.c b/functions.c index 4098b1f..3184482 100644 --- a/functions.c +++ b/functions.c @@ -202,7 +202,7 @@ call_bi_func(unsigned n, Var arglist, Byte func_pc, /* if (caller() != SYSTEM_OBJECT && server_flag_option(f->protect_str)) { */ if (caller() != SYSTEM_OBJECT && f->protected) { /* Try calling #0:bf_FUNCNAME(@ARGS) instead */ - enum error e = call_verb(SYSTEM_OBJECT, f->verb_str, arglist, 0); + enum error e = call_verb2(SYSTEM_OBJECT, f->verb_str, arglist, 0); if (e == E_NONE) return tail_call_pack(); @@ -468,6 +468,10 @@ char rcsid_functions[] = "$Id$"; /* * $Log$ + * Revision 1.7 2001/03/12 05:10:54 bjj + * Split out call_verb and call_verb2. The latter must only be called with + * strings that are already MOO strings (str_ref-able). + * * Revision 1.6 2001/03/12 03:25:16 bjj * Added new package type BI_KILL which kills the task calling the builtin. * Removed the static int task_killed in execute.c which wa tested on every |