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.2 by root, Thu Dec 14 17:33:53 2006 UTC vs.
Revision 1.7 by root, Fri Jan 7 21:17:07 2011 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines