summaryrefslogtreecommitdiffstats
path: root/src/iom_perl.xs
blob: be7a10f6b7227845788be4483688c30f48e0041a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#############################################################################
# IOM_CLASS constants
#############################################################################

BOOT:
{
  {
    HV *stash     = gv_stashpv ("IOM_CLASS", 1);
    SV *baseclass = newSVpv ("IOM_CLASS::watcher", 0);

    static const struct {
      const char *name;
      IV iv;
    } *civ, iom_const_iv[] = {
#   define iom_const_iv(name) { # name, (IV)name }
      iom_const_iv (EV_NONE),
      iom_const_iv (EV_READ),
      iom_const_iv (EV_WRITE),
#   undef iom_const
    };

    for (civ = iom_const_iv + sizeof (iom_const_iv) / sizeof (iom_const_iv [0]); civ > iom_const_iv; civ--)
      newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));

    /* slightly dirty to put the same scalar into all those arrays, but */
    /* we do not expect users to modify them anyways */
    av_push (get_av ("IOM_CLASS" "::timer::ISA", 1), SvREFCNT_inc (baseclass));
    av_push (get_av ("IOM_CLASS"   "::iow::ISA", 1), SvREFCNT_inc (baseclass));
    av_push (get_av ("IOM_CLASS"    "::pw::ISA", 1), SvREFCNT_inc (baseclass));
    av_push (get_av ("IOM_CLASS"    "::iw::ISA", 1), SvREFCNT_inc (baseclass));

    SvREFCNT_dec (baseclass);
  }
}

#############################################################################
# IOM_CLASS::watcher
#############################################################################

MODULE = IOM_MODULE             PACKAGE = IOM_CLASS::watcher

IOM_CHAINED
perl_watcher::cb (SV *cb)
	CODE:
        THIS->cb (cb);
        OUTPUT:
        RETVAL

#############################################################################
# IOM_CLASS::timer
#############################################################################

MODULE = IOM_MODULE             PACKAGE = IOM_CLASS::timer

SV *
timer::new ()
	CODE:
        timer *w =  new timer;
        w->start (0);
        RETVAL = newSVptr ((void *)(perl_watcher *)w, "IOM_CLASS::timer");
        w->self = (HV *)SvRV (RETVAL);
        OUTPUT:
        RETVAL

# deprecated
NV
timer::at ()
	CODE:
        RETVAL = THIS->remaining () + ev_now ();
        OUTPUT:
        RETVAL

IOM_CHAINED
timer::interval (NV repeat)
	CODE:
        THIS->repeat = repeat;
        OUTPUT:
        RETVAL

IOM_CHAINED
timer::set (NV tstamp, NV repeat = THIS->repeat)
	CODE:
        THIS->set (tstamp, repeat);
        OUTPUT:
        RETVAL

IOM_CHAINED
timer::start (NV tstamp = ev::now (), NV repeat = THIS->repeat)
	CODE:
        THIS->start (tstamp - ev::now (), repeat);
        OUTPUT:
        RETVAL

IOM_CHAINED
timer::after (NV delay, NV repeat = THIS->repeat)
	CODE:
        THIS->start (delay, repeat);
        OUTPUT:
        RETVAL

IOM_CHAINED
timer::stop ()
	CODE:
        THIS->stop ();
        OUTPUT:
        RETVAL

void
timer::DESTROY ()

#############################################################################
# IOM_CLASS::iow
#############################################################################

MODULE = IOM_MODULE             PACKAGE = IOM_CLASS::iow

SV *
iow::new ()
	CODE:
        iow *w =  new iow;
        RETVAL = newSVptr ((void *)(perl_watcher *)w, "IOM_CLASS::iow");
        w->self = (HV *)SvRV (RETVAL);
        OUTPUT:
        RETVAL

IOM_CHAINED
iow::fd (int fd)
	CODE:
        THIS->fd = fd;
        OUTPUT:
        RETVAL

IOM_CHAINED
iow::events (short events)
	CODE:
        THIS->events = events;
        OUTPUT:
        RETVAL

IOM_CHAINED
iow::start ()
	CODE:
        THIS->start ();
        OUTPUT:
        RETVAL

IOM_CHAINED
iow::stop ()
	CODE:
        THIS->stop ();
        OUTPUT:
        RETVAL

void
iow::DESTROY ()

#############################################################################
# IOM_CLASS::iw
#############################################################################

MODULE = IOM_MODULE             PACKAGE = IOM_CLASS::iw

SV *
iw::new ()
	CODE:
        iw *w =  new iw;
        RETVAL = newSVptr ((void *)(perl_watcher *)w, "IOM_CLASS::iw");
        w->self = (HV *)SvRV (RETVAL);
        OUTPUT:
        RETVAL

IOM_CHAINED
iw::start ()
	CODE:
        THIS->start ();
        OUTPUT:
        RETVAL

IOM_CHAINED
iw::stop ()
	CODE:
        THIS->stop ();
        OUTPUT:
        RETVAL

void
iw::DESTROY ()

#############################################################################
# IOM_CLASS::pw
#############################################################################

MODULE = IOM_MODULE             PACKAGE = IOM_CLASS::pw

SV *
pw::new ()
	CODE:
        pw *w =  new pw;
        RETVAL = newSVptr ((void *)(perl_watcher *)w, "IOM_CLASS::pw");
        w->self = (HV *)SvRV (RETVAL);
        OUTPUT:
        RETVAL

IOM_CHAINED
pw::start (int pid)
	CODE:
        THIS->start (pid);
        OUTPUT:
        RETVAL

IOM_CHAINED
pw::stop ()
	CODE:
        THIS->stop ();
        OUTPUT:
        RETVAL

int
pw::rpid ()
	CODE:
        RETVAL = THIS->rpid;
        OUTPUT:
        RETVAL

int
pw::rstatus ()
	CODE:
        RETVAL = THIS->rstatus;
        OUTPUT:
        RETVAL

void
pw::DESTROY ()