ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/iom_perl.h
(Generate patch)

Comparing rxvt-unicode/src/iom_perl.h (file contents):
Revision 1.1 by root, Thu Dec 14 15:19:31 2006 UTC vs.
Revision 1.5 by root, Sun Nov 11 04:08:00 2007 UTC

1typedef int IOM_CHAINED;
2
3static SV *
4iom_new_ref (HV *hv, const char *klass)
5{
6 return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1));
7}
8
1///////////////////////////////////////////////////////////////////////////// 9/////////////////////////////////////////////////////////////////////////////
2 10
3#define SvWATCHER(sv) (perl_watcher *)SvPTR (sv, IOM_CLASS "::watcher") 11#define SvWATCHER(sv) (perl_watcher *)SvPTR (sv, IOM_CLASS "::watcher")
4 12
5struct perl_watcher 13struct perl_watcher
48 PUTBACK; 56 PUTBACK;
49 FREETMPS; 57 FREETMPS;
50 LEAVE; 58 LEAVE;
51 59
52 if (SvTRUE (ERRSV)) 60 if (SvTRUE (ERRSV))
53 rxvt_warn ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV)); 61 IOM_WARN ("%s callback evaluation error: %s", type, SvPV_nolen (ERRSV));
54} 62}
55 63
56#define newSVtimer(timer) new_ref ((timer)->self, IOM_CLASS "::timer") 64#define newSVtimer(timer) iom_new_ref ((timer)->self, IOM_CLASS "::timer")
57#define SvTIMER(sv) (timer *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::timer") 65#define SvTIMER(sv) (timer *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::timer")
58 66
59struct timer : perl_watcher, time_watcher 67struct timer : perl_watcher, ev::timer
60{ 68{
61 tstamp interval;
62
63 timer () 69 timer ()
64 : time_watcher (this, &timer::execute) 70 : ev::timer (this, &timer::execute)
65 { 71 {
66 } 72 }
67 73
68 void execute (time_watcher &w) 74 void execute (ev::timer &w, int revents)
69 { 75 {
70 if (interval)
71 start (at + interval);
72
73 invoke (IOM_CLASS "::timer", newSVtimer (this)); 76 invoke (IOM_CLASS "::timer", newSVtimer (this));
74 } 77 }
75}; 78};
76 79
77#define newSViow(iow) new_ref ((iow)->self, IOM_CLASS "::iow") 80#define newSViow(iow) iom_new_ref ((iow)->self, IOM_CLASS "::iow")
78#define SvIOW(sv) (iow *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iow") 81#define SvIOW(sv) (iow *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iow")
79 82
80struct iow : perl_watcher, io_watcher 83struct iow : perl_watcher, ev::io
81{ 84{
82 iow () 85 iow ()
83 : io_watcher (this, &iow::execute) 86 : ev::io (this, &iow::execute)
84 { 87 {
85 } 88 }
86 89
87 void execute (io_watcher &w, short revents) 90 void execute (ev::io &w, int revents)
88 { 91 {
89 invoke (IOM_CLASS "::iow", newSViow (this), revents); 92 invoke (IOM_CLASS "::iow", newSViow (this), revents);
90 } 93 }
91}; 94};
92 95
93#define newSViw(iw) new_ref ((iw)->self, IOM_CLASS "::iw") 96#define newSViw(iw) iom_new_ref ((iw)->self, IOM_CLASS "::iw")
94#define SvIW(sv) (iw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iw") 97#define SvIW(sv) (iw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iw")
95 98
96struct iw : perl_watcher, idle_watcher 99struct iw : perl_watcher, ev::idle
97{ 100{
98 iw () 101 iw ()
99 : idle_watcher (this, &iw::execute) 102 : ev::idle (this, &iw::execute)
100 { 103 {
101 } 104 }
102 105
103 void execute (idle_watcher &w) 106 void execute (ev::idle &w, int revents)
104 { 107 {
105 invoke (IOM_CLASS "::iw", newSViw (this)); 108 invoke (IOM_CLASS "::iw", newSViw (this));
106 } 109 }
107}; 110};
108 111
109#define newSVpw(pw) new_ref ((pw)->self, IOM_CLASS "::pw") 112#define newSVpw(pw) iom_new_ref ((pw)->self, IOM_CLASS "::pw")
110#define SvPW(sv) (pw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::pw") 113#define SvPW(sv) (pw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::pw")
111 114
112struct pw : perl_watcher, child_watcher 115struct pw : perl_watcher, ev::child
113{ 116{
114 pw () 117 pw ()
115 : child_watcher (this, &pw::execute) 118 : ev::child (this, &pw::execute)
116 { 119 {
117 } 120 }
118 121
119 void execute (child_watcher &w, int status) 122 void execute (ev::child &w, int revents)
120 { 123 {
121 invoke (IOM_CLASS "::pw", newSVpw (this), status); 124 invoke (IOM_CLASS "::pw", newSVpw (this), w.rstatus);
122 } 125 }
123}; 126};
124 127

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines