--- deliantra/server/plugins/cfperl/cfperl.xs 2006/03/31 20:21:53 1.44 +++ deliantra/server/plugins/cfperl/cfperl.xs 2006/03/31 20:59:17 1.45 @@ -296,49 +296,6 @@ ///////////////////////////////////////////////////////////////////////////// -void -inject_event (const char *func, CFPContext *context) -{ - dSP; - - ENTER; - SAVETMPS; - - PUSHMARK (SP); - - EXTEND (SP, 10); - - HV *hv = newHV (); -#define hv_context(type,addr,expr) hv_store (hv, #expr, sizeof (#expr) - 1, newSVcfapi (type, addr context->expr), 0) - hv_context (CFAPI_POBJECT, ,who); - hv_context (CFAPI_POBJECT, ,activator); - hv_context (CFAPI_POBJECT, ,third); - hv_context (CFAPI_POBJECT, ,event); - hv_context (CFAPI_PMAP, ,map); - hv_context (CFAPI_STRING , ,message); - hv_context (CFAPI_INT ,&,fix); - hv_context (CFAPI_INT ,&,event_code); - hv_context (CFAPI_STRING , ,options); - hv_context (CFAPI_STRING , ,extension); - - PUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); - - PUTBACK; - int count = call_pv (func, G_SCALAR | G_EVAL); - SPAGAIN; - - if (SvTRUE (ERRSV)) - LOG (llevError, "event '%d' callback evaluation error: %s", context->event_code, SvPV_nolen (ERRSV)); - - context->returnvalue = count > 0 ? POPi : 0; - - PUTBACK; - FREETMPS; - LEAVE; -} - -///////////////////////////////////////////////////////////////////////////// - int initPlugin (const char *iversion, f_plug_api gethooksptr) { @@ -644,9 +601,44 @@ context.event = va_arg (args, object *); va_end (args); - context.returnvalue = 0; + { + dSP; + + ENTER; + SAVETMPS; + + PUSHMARK (SP); - inject_event ("cf::inject_event", &context); + EXTEND (SP, 10); + + HV *hv = newHV (); +#define hv_context(type,addr,expr) hv_store (hv, #expr, sizeof (#expr) - 1, newSVcfapi (type, addr context.expr), 0) + hv_context (CFAPI_POBJECT, ,who); + hv_context (CFAPI_POBJECT, ,activator); + hv_context (CFAPI_POBJECT, ,third); + hv_context (CFAPI_POBJECT, ,event); + hv_context (CFAPI_PMAP, ,map); + hv_context (CFAPI_STRING , ,message); + hv_context (CFAPI_INT ,&,fix); + hv_context (CFAPI_INT ,&,event_code); + hv_context (CFAPI_STRING , ,options); + hv_context (CFAPI_STRING , ,extension); + + PUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); + + PUTBACK; + int count = call_pv ("cf::inject_event", G_SCALAR | G_EVAL); + SPAGAIN; + + if (SvTRUE (ERRSV)) + LOG (llevError, "event '%d' callback evaluation error: %s", context.event_code, SvPV_nolen (ERRSV)); + + context.returnvalue = count > 0 ? POPi : 0; + + PUTBACK; + FREETMPS; + LEAVE; + } rv = context.returnvalue; return &rv;