--- rxvt-unicode/src/iom_perl.h 2006/12/14 15:19:31 1.1 +++ rxvt-unicode/src/iom_perl.h 2007/12/04 16:23:59 1.6 @@ -1,3 +1,11 @@ +typedef int IOM_CHAINED; + +static SV * +iom_new_ref (HV *hv, const char *klass) +{ + return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); +} + ///////////////////////////////////////////////////////////////////////////// #define SvWATCHER(sv) (perl_watcher *)SvPTR (sv, IOM_CLASS "::watcher") @@ -50,75 +58,70 @@ LEAVE; if (SvTRUE (ERRSV)) - rxvt_warn ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV)); + IOM_WARN ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV)); } -#define newSVtimer(timer) new_ref ((timer)->self, IOM_CLASS "::timer") +#define newSVtimer(timer) iom_new_ref ((timer)->self, IOM_CLASS "::timer") #define SvTIMER(sv) (timer *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::timer") -struct timer : perl_watcher, time_watcher +struct timer : perl_watcher, ev::timer { - tstamp interval; - timer () - : time_watcher (this, &timer::execute) { + set (this); } - void execute (time_watcher &w) + void execute (ev::timer &w, int revents) { - if (interval) - start (at + interval); - invoke (IOM_CLASS "::timer", newSVtimer (this)); } }; -#define newSViow(iow) new_ref ((iow)->self, IOM_CLASS "::iow") +#define newSViow(iow) iom_new_ref ((iow)->self, IOM_CLASS "::iow") #define SvIOW(sv) (iow *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iow") -struct iow : perl_watcher, io_watcher +struct iow : perl_watcher, ev::io { iow () - : io_watcher (this, &iow::execute) { + set (this); } - void execute (io_watcher &w, short revents) + void execute (ev::io &w, int revents) { invoke (IOM_CLASS "::iow", newSViow (this), revents); } }; -#define newSViw(iw) new_ref ((iw)->self, IOM_CLASS "::iw") +#define newSViw(iw) iom_new_ref ((iw)->self, IOM_CLASS "::iw") #define SvIW(sv) (iw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iw") -struct iw : perl_watcher, idle_watcher +struct iw : perl_watcher, ev::idle { iw () - : idle_watcher (this, &iw::execute) { + set (this); } - void execute (idle_watcher &w) + void execute (ev::idle &w, int revents) { invoke (IOM_CLASS "::iw", newSViw (this)); } }; -#define newSVpw(pw) new_ref ((pw)->self, IOM_CLASS "::pw") +#define newSVpw(pw) iom_new_ref ((pw)->self, IOM_CLASS "::pw") #define SvPW(sv) (pw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::pw") -struct pw : perl_watcher, child_watcher +struct pw : perl_watcher, ev::child { pw () - : child_watcher (this, &pw::execute) { + set (this); } - void execute (child_watcher &w, int status) + void execute (ev::child &w, int revents) { - invoke (IOM_CLASS "::pw", newSVpw (this), status); + invoke (IOM_CLASS "::pw", newSVpw (this), w.rstatus); } };