1 | typedef int IOM_CHAINED; |
1 | typedef int IOM_CHAINED; |
|
|
2 | |
|
|
3 | static SV * |
|
|
4 | iom_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 | |
61 | struct timer : perl_watcher, time_watcher |
67 | struct timer : perl_watcher, time_watcher |
62 | { |
68 | { |
63 | tstamp interval; |
69 | tstamp interval; |
… | |
… | |
74 | |
80 | |
75 | invoke (IOM_CLASS "::timer", newSVtimer (this)); |
81 | invoke (IOM_CLASS "::timer", newSVtimer (this)); |
76 | } |
82 | } |
77 | }; |
83 | }; |
78 | |
84 | |
79 | #define newSViow(iow) new_ref ((iow)->self, IOM_CLASS "::iow") |
85 | #define newSViow(iow) iom_new_ref ((iow)->self, IOM_CLASS "::iow") |
80 | #define SvIOW(sv) (iow *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iow") |
86 | #define SvIOW(sv) (iow *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iow") |
81 | |
87 | |
82 | struct iow : perl_watcher, io_watcher |
88 | struct iow : perl_watcher, io_watcher |
83 | { |
89 | { |
84 | iow () |
90 | iow () |
… | |
… | |
90 | { |
96 | { |
91 | invoke (IOM_CLASS "::iow", newSViow (this), revents); |
97 | invoke (IOM_CLASS "::iow", newSViow (this), revents); |
92 | } |
98 | } |
93 | }; |
99 | }; |
94 | |
100 | |
95 | #define newSViw(iw) new_ref ((iw)->self, IOM_CLASS "::iw") |
101 | #define newSViw(iw) iom_new_ref ((iw)->self, IOM_CLASS "::iw") |
96 | #define SvIW(sv) (iw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iw") |
102 | #define SvIW(sv) (iw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::iw") |
97 | |
103 | |
98 | struct iw : perl_watcher, idle_watcher |
104 | struct iw : perl_watcher, idle_watcher |
99 | { |
105 | { |
100 | iw () |
106 | iw () |
… | |
… | |
106 | { |
112 | { |
107 | invoke (IOM_CLASS "::iw", newSViw (this)); |
113 | invoke (IOM_CLASS "::iw", newSViw (this)); |
108 | } |
114 | } |
109 | }; |
115 | }; |
110 | |
116 | |
111 | #define newSVpw(pw) new_ref ((pw)->self, IOM_CLASS "::pw") |
117 | #define newSVpw(pw) iom_new_ref ((pw)->self, IOM_CLASS "::pw") |
112 | #define SvPW(sv) (pw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::pw") |
118 | #define SvPW(sv) (pw *)(perl_watcher *)SvPTR ((sv), IOM_CLASS "::pw") |
113 | |
119 | |
114 | struct pw : perl_watcher, child_watcher |
120 | struct pw : perl_watcher, child_watcher |
115 | { |
121 | { |
116 | pw () |
122 | pw () |