--- cvsroot/EV/EV.xs 2007/10/31 11:52:11 1.17 +++ cvsroot/EV/EV.xs 2007/10/31 14:44:35 1.21 @@ -2,15 +2,12 @@ #include "perl.h" #include "XSUB.h" -#include -#include +/*#include */ #define TIMEOUT_NONE HUGE_VAL +#define HAVE_EPOLL 0 -#define EV_COMMON \ - SV *self; /* contains this struct */ \ - SV *cb_sv, *fh; - +#define EV_PROTOTYPES 1 #include "EV/EVAPI.h" #include "libev/ev.c" @@ -44,21 +41,6 @@ return -1; } -static void -api_once (int fd, short events, double timeout, void (*cb)(int, short, void *), void *arg) -{ -#if 0 - if (timeout >= 0.) - { - struct timeval tv; - tv_set (&tv, timeout); - event_once (fd, events, cb, arg, &tv); - } - else - event_once (fd, events, cb, arg, 0); -#endif -} - ///////////////////////////////////////////////////////////////////////////// // Event @@ -213,11 +195,16 @@ } #endif +#define CHECK_REPEAT(repeat) if (repeat < 0.) \ + croak (# repeat " value must be >= 0"); + ///////////////////////////////////////////////////////////////////////////// // XS interface functions MODULE = EV PACKAGE = EV PREFIX = ev_ +PROTOTYPES: ENABLE + BOOT: { int i; @@ -228,6 +215,7 @@ IV iv; } *civ, const_iv[] = { # define const_iv(pfx, name) { # name, (IV) pfx ## name }, + const_iv (EV_, UNDEF) const_iv (EV_, NONE) const_iv (EV_, TIMEOUT) const_iv (EV_, READ) @@ -235,6 +223,7 @@ const_iv (EV_, SIGNAL) const_iv (EV_, IDLE) const_iv (EV_, CHECK) + const_iv (EV_, ERROR) const_iv (EV, LOOP_ONESHOT) const_iv (EV, LOOP_NONBLOCK) @@ -263,7 +252,6 @@ /* the poor man's shared library emulator */ evapi.ver = EV_API_VERSION; evapi.rev = EV_API_REVISION; - evapi.once = api_once; evapi.sv_fileno = sv_fileno; evapi.sv_signum = sv_signum; evapi.now = &ev_now; @@ -271,6 +259,7 @@ evapi.loop_done = &ev_loop_done; evapi.time = ev_time; evapi.loop = ev_loop; + evapi.once = ev_once; evapi.io_start = evio_start; evapi.io_stop = evio_stop; evapi.timer_start = evtimer_start; @@ -326,6 +315,8 @@ struct ev_timer *timer (NV after, NV repeat, SV *cb) ALIAS: timer_ns = 1 + INIT: + CHECK_REPEAT (repeat); CODE: RETVAL = e_new (sizeof (struct ev_timer), cb); evtimer_set (RETVAL, after, repeat); @@ -336,6 +327,8 @@ struct ev_periodic *periodic (NV at, NV interval, SV *cb) ALIAS: periodic_ns = 1 + INIT: + CHECK_REPEAT (interval); CODE: RETVAL = e_new (sizeof (struct ev_periodic), cb); evperiodic_set (RETVAL, at, interval); @@ -468,12 +461,18 @@ MODULE = EV PACKAGE = EV::Timer PREFIX = evtimer_ void evtimer_start (struct ev_timer *w) + INIT: + CHECK_REPEAT (w->repeat); void evtimer_stop (struct ev_timer *w) void evtimer_again (struct ev_timer *w) + INIT: + CHECK_REPEAT (w->repeat); void set (struct ev_timer *w, NV after, NV repeat = 0.) + INIT: + CHECK_REPEAT (repeat); CODE: { int active = w->active; @@ -485,10 +484,14 @@ MODULE = EV PACKAGE = EV::Periodic PREFIX = evperiodic_ void evperiodic_start (struct ev_periodic *w) + INIT: + CHECK_REPEAT (w->interval); void evperiodic_stop (struct ev_periodic *w) void set (struct ev_periodic *w, NV at, NV interval = 0.) + INIT: + CHECK_REPEAT (interval); CODE: { int active = w->active;