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.3 by root, Thu Dec 14 17:40:03 2006 UTC vs.
Revision 1.5 by root, Sun Nov 11 04:08:00 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines