--- rxvt-unicode/src/rxvtperl.xs 2006/12/10 15:14:05 1.108 +++ rxvt-unicode/src/rxvtperl.xs 2006/12/14 15:19:31 1.109 @@ -119,130 +119,6 @@ ///////////////////////////////////////////////////////////////////////////// -#define SvWATCHER(sv) (perl_watcher *)SvPTR (sv, "urxvt::watcher") - -struct perl_watcher -{ - SV *cbsv; - HV *self; - - perl_watcher () - : cbsv (0) - { - } - - ~perl_watcher () - { - SvREFCNT_dec (cbsv); - } - - void cb (SV *cb) - { - SvREFCNT_dec (cbsv); - cbsv = newSVsv (cb); - } - - void invoke (const char *type, SV *self, int arg = -1); -}; - -void -perl_watcher::invoke (const char *type, SV *self, int arg) -{ - dSP; - - ENTER; - SAVETMPS; - - PUSHMARK (SP); - - XPUSHs (sv_2mortal (self)); - - if (arg >= 0) - XPUSHs (sv_2mortal (newSViv (arg))); - - PUTBACK; - call_sv (cbsv, G_VOID | G_EVAL | G_DISCARD); - SPAGAIN; - - PUTBACK; - FREETMPS; - LEAVE; - - if (SvTRUE (ERRSV)) - rxvt_warn ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV)); -} - -#define newSVtimer(timer) new_ref ((timer)->self, "urxvt::timer") -#define SvTIMER(sv) (timer *)(perl_watcher *)SvPTR ((sv), "urxvt::timer") - -struct timer : perl_watcher, time_watcher -{ - tstamp interval; - - timer () - : time_watcher (this, &timer::execute) - { - } - - void execute (time_watcher &w) - { - if (interval) - start (at + interval); - - invoke ("urxvt::timer", newSVtimer (this)); - } -}; - -#define newSViow(iow) new_ref ((iow)->self, "urxvt::iow") -#define SvIOW(sv) (iow *)(perl_watcher *)SvPTR ((sv), "urxvt::iow") - -struct iow : perl_watcher, io_watcher -{ - iow () - : io_watcher (this, &iow::execute) - { - } - - void execute (io_watcher &w, short revents) - { - invoke ("urxvt::iow", newSViow (this), revents); - } -}; - -#define newSViw(iw) new_ref ((iw)->self, "urxvt::iw") -#define SvIW(sv) (iw *)(perl_watcher *)SvPTR ((sv), "urxvt::iw") - -struct iw : perl_watcher, idle_watcher -{ - iw () - : idle_watcher (this, &iw::execute) - { - } - - void execute (idle_watcher &w) - { - invoke ("urxvt::iw", newSViw (this)); - } -}; - -#define newSVpw(pw) new_ref ((pw)->self, "urxvt::pw") -#define SvPW(sv) (pw *)(perl_watcher *)SvPTR ((sv), "urxvt::pw") - -struct pw : perl_watcher, child_watcher -{ - pw () - : child_watcher (this, &pw::execute) - { - } - - void execute (child_watcher &w, int status) - { - invoke ("urxvt::pw", newSVpw (this), status); - } -}; - -///////////////////////////////////////////////////////////////////////////// - #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") class overlay { @@ -427,6 +303,10 @@ THIS->want_refresh = 1; } +///////////////////////////////////////////////////////////////////////////// + +#define IOM_CLASS "urxvt" +#include ///////////////////////////////////////////////////////////////////////////// @@ -1948,188 +1828,5 @@ void overlay::DESTROY () -############################################################################# -# urxvt::watcher -############################################################################# - -MODULE = urxvt PACKAGE = urxvt::watcher - -CHAINED -perl_watcher::cb (SV *cb) - CODE: - THIS->cb (cb); - OUTPUT: - RETVAL - -############################################################################# -# urxvt::timer -############################################################################# - -MODULE = urxvt PACKAGE = urxvt::timer - -SV * -timer::new () - CODE: - timer *w = new timer; - w->start (NOW); - RETVAL = newSVptr ((void *)(perl_watcher *)w, "urxvt::timer"); - w->self = (HV *)SvRV (RETVAL); - OUTPUT: - RETVAL - -NV -timer::at () - CODE: - RETVAL = THIS->at; - OUTPUT: - RETVAL - -CHAINED -timer::interval (NV interval) - CODE: - THIS->interval = interval; - OUTPUT: - RETVAL - -CHAINED -timer::set (NV tstamp) - CODE: - THIS->set (tstamp); - OUTPUT: - RETVAL - -CHAINED -timer::start (NV tstamp = THIS->at) - CODE: - THIS->start (tstamp); - OUTPUT: - RETVAL - -CHAINED -timer::after (NV delay) - CODE: - THIS->start (NOW + delay); - OUTPUT: - RETVAL - -CHAINED -timer::stop () - CODE: - THIS->stop (); - OUTPUT: - RETVAL - -void -timer::DESTROY () - -############################################################################# -# urxvt::iow -############################################################################# - -MODULE = urxvt PACKAGE = urxvt::iow - -SV * -iow::new () - CODE: - iow *w = new iow; - RETVAL = newSVptr ((void *)(perl_watcher *)w, "urxvt::iow"); - w->self = (HV *)SvRV (RETVAL); - OUTPUT: - RETVAL - -CHAINED -iow::fd (int fd) - CODE: - THIS->fd = fd; - OUTPUT: - RETVAL - -CHAINED -iow::events (short events) - CODE: - THIS->events = events; - OUTPUT: - RETVAL - -CHAINED -iow::start () - CODE: - THIS->start (); - OUTPUT: - RETVAL - -CHAINED -iow::stop () - CODE: - THIS->stop (); - OUTPUT: - RETVAL - -void -iow::DESTROY () - -############################################################################# -# urxvt::iw -############################################################################# - -MODULE = urxvt PACKAGE = urxvt::iw - -SV * -iw::new () - CODE: - iw *w = new iw; - RETVAL = newSVptr ((void *)(perl_watcher *)w, "urxvt::iw"); - w->self = (HV *)SvRV (RETVAL); - OUTPUT: - RETVAL - -CHAINED -iw::start () - CODE: - THIS->start (); - OUTPUT: - RETVAL - -CHAINED -iw::stop () - CODE: - THIS->stop (); - OUTPUT: - RETVAL - -void -iw::DESTROY () - -############################################################################# -# urxvt::pw -############################################################################# - -MODULE = urxvt PACKAGE = urxvt::pw - -SV * -pw::new () - CODE: - pw *w = new pw; - RETVAL = newSVptr ((void *)(perl_watcher *)w, "urxvt::pw"); - w->self = (HV *)SvRV (RETVAL); - OUTPUT: - RETVAL - -CHAINED -pw::start (int pid) - CODE: - THIS->start (pid); - OUTPUT: - RETVAL - -CHAINED -pw::stop () - CODE: - THIS->stop (); - OUTPUT: - RETVAL - -void -pw::DESTROY () - +INCLUDE: $PERL