Loop.c

filter: Statementstmt 72.7% 302 / 415 Branchbran 44.8% 69 / 154 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 65.2% 371 / 569 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/dbil_native.h ↑ Summary xs/loop.xs »
1 /*
2 * This file was generated automatically by ExtUtils::ParseXS version 3.63 from the
3 * contents of Loop.xs. Do not edit this file, edit Loop.xs instead.
4 *
5 * ANY CHANGES MADE HERE WILL BE LOST!
6 *
7 */
8  
9 #line 1 "Loop.xs"
10 /*
11 * Loop.xs - root XS file.
12 *
13 * Thin wrapper (the Chandra pattern): pull in the C implementation headers,
14 * then splice the per-component XS fragments via INCLUDE: so xsubpp compiles
15 * them all into one Loop.c / Loop.o - no EUMM subdir-object trouble.
16 *
17 * include/ - the C core (future, DBI executor, object dispatch)
18 * xs/ - the XS fragments, one per package
19 */
20  
21 #define PERL_NO_GET_CONTEXT
22 #include "EXTERN.h"
23 #include "perl.h"
24 #include "XSUB.h"
25  
26 #include "dbil_compat.h" /* perl-version shims: must come first */
27  
28 #include "dbil_future.h" /* DBIx::Loop::Future (C) */
29 #include "dbil_run.h" /* run one DBI statement from C */
30 #include "dbil_vt.h" /* pure-C loop seam (adapter vtable) */
31 #include "dbil_pool.h" /* Backend B: forked worker pool */
32 #include "dbil_txn.h" /* transactions pinned to a pool slot */
33 #include "dbil_native.h" /* Backend A: native fd async (Pg) */
34 #include "dbil_hm.h" /* Hyperman adapter over its C ABI */
35 #include "dbil_obs.h" /* statement observers (v2); fired by dbil_loop */
36 #include "dbil_obs_perl.h" /* ... and the Perl door onto that registry */
37 #include "dbil_loop.h" /* driver-name, capability, dispatch */
38 #include "dbil_abi.h" /* the public C ABI (installed header) */
39 #include "dbil_abi_impl.h" /* ... and the provider side of it */
40  
41 #line 42 "Loop.c"
42 #ifndef PERL_UNUSED_VAR
43 # define PERL_UNUSED_VAR(var) if (0) var = var
44 #endif
45  
46 #ifndef dVAR
47 # define dVAR dNOOP
48 #endif
49  
50  
51 /* This stuff is not part of the API! You have been warned. */
52 #ifndef PERL_VERSION_DECIMAL
53 # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
54 #endif
55 #ifndef PERL_DECIMAL_VERSION
56 # define PERL_DECIMAL_VERSION \
57 PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
58 #endif
59 #ifndef PERL_VERSION_GE
60 # define PERL_VERSION_GE(r,v,s) \
61 (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
62 #endif
63 #ifndef PERL_VERSION_LE
64 # define PERL_VERSION_LE(r,v,s) \
65 (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
66 #endif
67  
68 /* XS_INTERNAL is the explicit static-linkage variant of the default
69 * XS macro.
70 *
71 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
72 * "static", ie. it exports XSUB symbols. You probably don't want that
73 * for anything but the BOOT XSUB.
74 *
75 * See XSUB.h in core!
76 */
77  
78  
79 /* TODO: This might be compatible further back than 5.10.0. */
80 #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
81 # undef XS_EXTERNAL
82 # undef XS_INTERNAL
83 # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
84 # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
85 # define XS_INTERNAL(name) static XSPROTO(name)
86 # endif
87 # if defined(__SYMBIAN32__)
88 # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
89 # define XS_INTERNAL(name) EXPORT_C static XSPROTO(name)
90 # endif
91 # ifndef XS_EXTERNAL
92 # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
93 # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
94 # define XS_INTERNAL(name) static void name(pTHX_ CV* cv __attribute__unused__)
95 # else
96 # ifdef __cplusplus
97 # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
98 # define XS_INTERNAL(name) static XSPROTO(name)
99 # else
100 # define XS_EXTERNAL(name) XSPROTO(name)
101 # define XS_INTERNAL(name) static XSPROTO(name)
102 # endif
103 # endif
104 # endif
105 #endif
106  
107 /* perl >= 5.10.0 && perl <= 5.15.1 */
108  
109  
110 /* The XS_EXTERNAL macro is used for functions that must not be static
111 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
112 * macro defined, the best we can do is assume XS is the same.
113 * Dito for XS_INTERNAL.
114 */
115 #ifndef XS_EXTERNAL
116 # define XS_EXTERNAL(name) XS(name)
117 #endif
118 #ifndef XS_INTERNAL
119 # define XS_INTERNAL(name) XS(name)
120 #endif
121  
122 /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
123 * internal macro that we're free to redefine for varying linkage due
124 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
125 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
126 */
127  
128 #undef XS_EUPXS
129 #if defined(PERL_EUPXS_ALWAYS_EXPORT)
130 # define XS_EUPXS(name) XS_EXTERNAL(name)
131 #else
132 /* default to internal */
133 # define XS_EUPXS(name) XS_INTERNAL(name)
134 #endif
135  
136 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
137 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
138  
139 /* prototype to pass -Wmissing-prototypes */
140 static void
141 S_croak_xs_usage(const CV *const cv, const char *const params);
142  
143 static void
144 S_croak_xs_usage(const CV *const cv, const char *const params)
145 {
146 const GV *const gv = CvGV(cv);
147  
148 PERL_ARGS_ASSERT_CROAK_XS_USAGE;
149  
150 if (gv) {
151 const char *const gvname = GvNAME(gv);
152 const HV *const stash = GvSTASH(gv);
153 const char *const hvname = stash ? HvNAME(stash) : NULL;
154  
155 if (hvname)
156 Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
157 else
158 Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
159 } else {
160 /* Pants. I don't think that it should be possible to get here. */
161 Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
162 }
163 }
164 #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
165  
166 #define croak_xs_usage S_croak_xs_usage
167  
168 #endif
169  
170 /* NOTE: the prototype of newXSproto() is different in versions of perls,
171 * so we define a portable version of newXSproto()
172 */
173 #ifdef newXS_flags
174 #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
175 #else
176 #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
177 #endif /* !defined(newXS_flags) */
178  
179 #if PERL_VERSION_LE(5, 21, 5)
180 # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
181 #else
182 # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
183 #endif
184  
185 /* simple backcompat versions of the TARGx() macros with no optimisation */
186 #ifndef TARGi
187 # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
188 # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
189 # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
190 #endif
191  
192 #line 193 "Loop.c"
193  
194 /* INCLUDE: Including 'xs/loop.xs' from 'Loop.xs' */
195  
196  
197 XS_EUPXS(XS_DBIx__Loop__capability); /* prototype to pass -Wmissing-prototypes */
198 5 XS_EUPXS(XS_DBIx__Loop__capability)
199 {
200 5 dVAR; dXSARGS;
201 5 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 5 5
202 0 croak_xs_usage(cv, "driver_name");
203 {
204 5 ▶ SV * driver_name = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * driver_name = ST(0) 5 0 5
205 ;
206 SV * RETVAL;
207 #line 10 "./xs/loop.xs"
208 RETVAL = newSVpv(dbil_capability(aTHX_ SvOK(driver_name) ? driver_name : NULL), 0);
209 #line 210 "Loop.c"
210 5 RETVAL = sv_2mortal(RETVAL);
211 5 ST(0) = RETVAL;
212 }
213 5 XSRETURN(1);
214 }
215  
216  
217 XS_EUPXS(XS_DBIx__Loop_new); /* prototype to pass -Wmissing-prototypes */
218 21 XS_EUPXS(XS_DBIx__Loop_new)
219 {
220 21 dVAR; dXSARGS;
221 21 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 21 21
222 0 croak_xs_usage(cv, "class, ...");
223 {
224 21 ▶ SV * class = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * class = ST(0) 0 21 21
225 ;
226 SV * RETVAL;
227 #line 19 "./xs/loop.xs"
228 {
229 SV *dbh = NULL, *loop = NULL;
230 SV *dsn = NULL, *user = NULL, *pass = NULL, *attr = NULL;
231 int nworkers = 4;
232 int max_queue = 0;
233 int i;
234 const char *cls = (SvROK(class) && SvOBJECT(SvRV(class)))
235 ? HvNAME(SvSTASH(SvRV(class))) : SvPV_nolen(class);
236 for (i = 1; i + 1 < items; i += 2) {
237 STRLEN kl; const char *k = SvPV_const(ST(i), kl);
238 if (kl == 3 && memEQ(k, "dbh", 3)) dbh = ST(i + 1);
239 else if (kl == 4 && memEQ(k, "loop", 4)) loop = ST(i + 1);
240 else if (kl == 3 && memEQ(k, "dsn", 3)) dsn = ST(i + 1);
241 else if (kl == 4 && memEQ(k, "user", 4)) user = ST(i + 1);
242 else if (kl == 4 && memEQ(k, "pass", 4)) pass = ST(i + 1);
243 else if (kl == 4 && memEQ(k, "attr", 4)) attr = ST(i + 1);
244 else if (kl == 7 && memEQ(k, "workers", 7))
245 nworkers = SvIV(ST(i + 1)) > 0 ? (int)SvIV(ST(i + 1)) : 1;
246 else if (kl == 9 && memEQ(k, "max_queue", 9))
247 max_queue = SvIV(ST(i + 1)) > 0 ? (int)SvIV(ST(i + 1)) : 0;
248 /* other options (backend, ...) reserved for later phases */
249 }
250 RETVAL = dbil_new(aTHX_ cls, dbh, loop, dsn, user, pass, attr,
251 nworkers, max_queue);
252 }
253 #line 254 "Loop.c"
254 20 RETVAL = sv_2mortal(RETVAL);
255 20 ST(0) = RETVAL;
256 }
257 20 XSRETURN(1);
258 }
259  
260  
261 XS_EUPXS(XS_DBIx__Loop_query); /* prototype to pass -Wmissing-prototypes */
262 97 XS_EUPXS(XS_DBIx__Loop_query)
263 {
264 97 dVAR; dXSARGS;
265 97 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 0 97 97
266 0 croak_xs_usage(cv, "self, sql, ...");
267 {
268 97 SV * self = ST(0)
269 ;
270 97 SV * sql = ST(1)
271 ;
272 SV * RETVAL;
273 #line 53 "./xs/loop.xs"
274 {
275 AV *bind = (AV *)sv_2mortal((SV *)newAV());
276 int i;
277 for (i = 2; i < items; i++) av_push(bind, newSVsv(ST(i)));
278 RETVAL = dbil_exec(aTHX_ self, 1, sql, bind);
279 }
280 #line 281 "Loop.c"
281 97 RETVAL = sv_2mortal(RETVAL);
282 97 ST(0) = RETVAL;
283 }
284 97 XSRETURN(1);
285 }
286  
287  
288 XS_EUPXS(XS_DBIx__Loop_do); /* prototype to pass -Wmissing-prototypes */
289 574 XS_EUPXS(XS_DBIx__Loop_do)
290 {
291 574 dVAR; dXSARGS;
292 574 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 0 574 574
293 0 croak_xs_usage(cv, "self, sql, ...");
294 {
295 574 SV * self = ST(0)
296 ;
297 574 SV * sql = ST(1)
298 ;
299 SV * RETVAL;
300 #line 68 "./xs/loop.xs"
301 {
302 AV *bind = (AV *)sv_2mortal((SV *)newAV());
303 int i;
304 for (i = 2; i < items; i++) av_push(bind, newSVsv(ST(i)));
305 RETVAL = dbil_exec(aTHX_ self, 0, sql, bind);
306 }
307 #line 308 "Loop.c"
308 574 RETVAL = sv_2mortal(RETVAL);
309 574 ST(0) = RETVAL;
310 }
311 574 XSRETURN(1);
312 }
313  
314  
315 XS_EUPXS(XS_DBIx__Loop_selectall_arrayref); /* prototype to pass -Wmissing-prototypes */
316 24 XS_EUPXS(XS_DBIx__Loop_selectall_arrayref)
317 {
318 24 dVAR; dXSARGS;
319 24 dXSI32;
320 24 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 0 24 24
321 0 croak_xs_usage(cv, "self, sql, ...");
322 {
323 24 SV * self = ST(0)
324 ;
325 24 SV * sql = ST(1)
326 ;
327 SV * RETVAL;
328 #line 94 "./xs/loop.xs"
329 {
330 AV *bind = (AV *)sv_2mortal((SV *)newAV());
331 SV *key = NULL;
332 SV *qf, *next;
333 int i = 2;
334 if (ix == DBIL_T_ALL_HASHREF) {
335 if (items < 3)
336 croak("DBIx::Loop->selectall_hashref: a key field is required");
337 key = ST(2);
338 i = 3;
339 }
340 for (; i < items; i++) av_push(bind, newSVsv(ST(i)));
341 qf = sv_2mortal(dbil_exec(aTHX_ self, 1, sql, bind));
342 next = dbil_future_new(aTHX_ "DBIx::Loop::Future");
343 dbil_then_attach4(aTHX_ qf, next, sv_2mortal(newSViv((IV)ix)),
344 NULL, key);
345 RETVAL = next;
346 }
347 #line 348 "Loop.c"
348 23 RETVAL = sv_2mortal(RETVAL);
349 23 ST(0) = RETVAL;
350 }
351 23 XSRETURN(1);
352 }
353  
354  
355 XS_EUPXS(XS_DBIx__Loop_capability); /* prototype to pass -Wmissing-prototypes */
356 5 XS_EUPXS(XS_DBIx__Loop_capability)
357 {
358 5 dVAR; dXSARGS;
359 5 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 5 5
360 0 croak_xs_usage(cv, "self");
361 {
362 5 SV * self = ST(0)
363 ;
364 SV * RETVAL;
365 #line 119 "./xs/loop.xs"
366 {
367 SV *v = dbil_field(aTHX_ self, "capability", 10);
368 RETVAL = v ? newSVsv(v) : &PL_sv_undef;
369 }
370 #line 371 "Loop.c"
371 5 RETVAL = sv_2mortal(RETVAL);
372 5 ST(0) = RETVAL;
373 }
374 5 XSRETURN(1);
375 }
376  
377  
378 XS_EUPXS(XS_DBIx__Loop_loop); /* prototype to pass -Wmissing-prototypes */
379 3 XS_EUPXS(XS_DBIx__Loop_loop)
380 {
381 3 dVAR; dXSARGS;
382 3 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 3 3
383 0 croak_xs_usage(cv, "self");
384 {
385 3 SV * self = ST(0)
386 ;
387 SV * RETVAL;
388 #line 130 "./xs/loop.xs"
389 {
390 SV *v = dbil_field(aTHX_ self, "loop", 4);
391 RETVAL = v ? newSVsv(v) : &PL_sv_undef;
392 }
393 #line 394 "Loop.c"
394 3 RETVAL = sv_2mortal(RETVAL);
395 3 ST(0) = RETVAL;
396 }
397 3 XSRETURN(1);
398 }
399  
400  
401 XS_EUPXS(XS_DBIx__Loop_dbh); /* prototype to pass -Wmissing-prototypes */
402 0 XS_EUPXS(XS_DBIx__Loop_dbh)
403 {
404 0 dVAR; dXSARGS;
405 0 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 0 0
406 0 croak_xs_usage(cv, "self");
407 {
408 0 SV * self = ST(0)
409 ;
410 SV * RETVAL;
411 #line 141 "./xs/loop.xs"
412 {
413 SV *v = dbil_field(aTHX_ self, "dbh", 3);
414 RETVAL = v ? newSVsv(v) : &PL_sv_undef;
415 }
416 #line 417 "Loop.c"
417 0 RETVAL = sv_2mortal(RETVAL);
418 0 ST(0) = RETVAL;
419 }
420 0 XSRETURN(1);
421 }
422  
423  
424 XS_EUPXS(XS_DBIx__Loop_disconnect); /* prototype to pass -Wmissing-prototypes */
425 12 XS_EUPXS(XS_DBIx__Loop_disconnect)
426 {
427 12 dVAR; dXSARGS;
428 12 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 12 12
429 0 croak_xs_usage(cv, "self");
430 {
431 12 ▶ SV * self = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * self = ST(0) 12 0 12
432 ;
433 #line 152 "./xs/loop.xs"
434 {
435 HV *h = (SvROK(self) && SvTYPE(SvRV(self)) == SVt_PVHV)
436 ? (HV *)SvRV(self) : NULL;
437 SV *dbh = dbil_field(aTHX_ self, "dbh", 3);
438 /* tear the pool down deterministically here (reap workers, drop fds)
439 * rather than at global destruction */
440 if (h) {
441 SV **pp = hv_fetchs(h, "_pool", 0);
442 SV **np = hv_fetchs(h, "_native", 0);
443 if (pp && *pp && SvIOK(*pp)) {
444 dbil_pool_free(aTHX_ INT2PTR(dbil_pool *, SvIV(*pp)));
445 (void)hv_delete(h, "_pool", 5, G_DISCARD);
446 }
447 if (np && *np && SvIOK(*np)) {
448 dbil_native_free(aTHX_ INT2PTR(dbil_native *, SvIV(*np)));
449 (void)hv_delete(h, "_native", 7, G_DISCARD);
450 }
451 }
452 if (dbh && SvROK(dbh)) {
453 dSP;
454 ENTER; SAVETMPS; PUSHMARK(SP);
455 EXTEND(SP, 1); PUSHs(dbh); PUTBACK;
456 call_method("disconnect", G_VOID | G_DISCARD | G_EVAL);
457 SPAGAIN; PUTBACK; FREETMPS; LEAVE;
458 }
459 }
460 #line 461 "Loop.c"
461 }
462 12 XSRETURN_EMPTY;
463 }
464  
465  
466 XS_EUPXS(XS_DBIx__Loop_txn); /* prototype to pass -Wmissing-prototypes */
467 14 XS_EUPXS(XS_DBIx__Loop_txn)
468 {
469 14 dVAR; dXSARGS;
470 14 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 14 14
471 0 croak_xs_usage(cv, "self, block");
472 {
473 14 SV * self = ST(0)
474 ;
475 14 SV * block = ST(1)
476 ;
477 SV * RETVAL;
478 #line 189 "./xs/loop.xs"
479 {
480 SV *cap = dbil_field(aTHX_ self, "capability", 10);
481 SV *cargs = dbil_field(aTHX_ self, "connect_args", 12);
482 if (!SvROK(block) || SvTYPE(SvRV(block)) != SVt_PVCV)
483 croak("DBIx::Loop->txn: need a coderef");
484 if (!(cap && SvPOK(cap) && strEQ(SvPVX(cap), "pool")
485 && cargs && SvROK(cargs)))
486 croak("DBIx::Loop->txn: transactions need the pool backend "
487 "(connect() with a dsn); native-backend transactions arrive "
488 "with the native connection pool");
489 RETVAL = dbil_txn_start(aTHX_ self, block,
490 dbil_pool_of(aTHX_ self, cargs));
491 }
492 #line 493 "Loop.c"
493 14 RETVAL = sv_2mortal(RETVAL);
494 14 ST(0) = RETVAL;
495 }
496 14 XSRETURN(1);
497 }
498  
499  
500 XS_EUPXS(XS_DBIx__Loop__worker_pids); /* prototype to pass -Wmissing-prototypes */
501 16 XS_EUPXS(XS_DBIx__Loop__worker_pids)
502 {
503 16 dVAR; dXSARGS;
504 16 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 16 16
505 0 croak_xs_usage(cv, "self");
506 PERL_UNUSED_VAR(ax); /* -Wall */
507 16 SP -= items;
508 {
509 16 ▶ SV * self = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * self = ST(0) 16 0 16
510 ;
511 #line 210 "./xs/loop.xs"
512 {
513 if (SvROK(self) && SvTYPE(SvRV(self)) == SVt_PVHV) {
514 SV **pp = hv_fetchs((HV *)SvRV(self), "_pool", 0);
515 if (pp && *pp && SvIOK(*pp)) {
516 dbil_pool *p = INT2PTR(dbil_pool *, SvIV(*pp));
517 int i;
518 EXTEND(SP, p->nw);
519 for (i = 0; i < p->nw; i++)
520 mPUSHi((IV)p->w[i].pid);
521 }
522 }
523 }
524 #line 525 "Loop.c"
525 16 PUTBACK;
526 16 return;
527 }
528 }
529  
530  
531 XS_EUPXS(XS_DBIx__Loop_DESTROY); /* prototype to pass -Wmissing-prototypes */
532 21 XS_EUPXS(XS_DBIx__Loop_DESTROY)
533 {
534 21 dVAR; dXSARGS;
535 21 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 21 21
536 0 croak_xs_usage(cv, "self");
537 {
538 21 ▶ SV * self = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * self = ST(0) 21 0 21
539 ;
540 #line 227 "./xs/loop.xs"
541 {
542 if (SvROK(self) && SvTYPE(SvRV(self)) == SVt_PVHV) {
543 SV **pp = hv_fetchs((HV *)SvRV(self), "_pool", 0);
544 SV **np = hv_fetchs((HV *)SvRV(self), "_native", 0);
545 if (pp && *pp && SvIOK(*pp))
546 dbil_pool_free(aTHX_ INT2PTR(dbil_pool *, SvIV(*pp)));
547 if (np && *np && SvIOK(*np))
548 dbil_native_free(aTHX_ INT2PTR(dbil_native *, SvIV(*np)));
549 }
550 }
551 #line 552 "Loop.c"
552 }
553 21 XSRETURN_EMPTY;
554 }
555  
556  
557 /* INCLUDE: Returning to 'Loop.xs' from 'xs/loop.xs' */
558  
559  
560 /* INCLUDE: Including 'xs/future.xs' from 'Loop.xs' */
561  
562  
563 XS_EUPXS(XS_DBIx__Loop__Future_new); /* prototype to pass -Wmissing-prototypes */
564 16 XS_EUPXS(XS_DBIx__Loop__Future_new)
565 {
566 16 dVAR; dXSARGS;
567 16 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 16 16
568 0 croak_xs_usage(cv, "class");
569 {
570 16 ▶ SV * class = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * class = ST(0) 0 16 16
571 ;
572 SV * RETVAL;
573 #line 9 "./xs/future.xs"
574 RETVAL = dbil_future_new(aTHX_
575 SvROK(class) ? sv_reftype(SvRV(class), 1) : SvPV_nolen(class));
576 #line 577 "Loop.c"
577 16 RETVAL = sv_2mortal(RETVAL);
578 16 ST(0) = RETVAL;
579 }
580 16 XSRETURN(1);
581 }
582  
583  
584 XS_EUPXS(XS_DBIx__Loop__Future_done); /* prototype to pass -Wmissing-prototypes */
585 12 XS_EUPXS(XS_DBIx__Loop__Future_done)
586 {
587 12 dVAR; dXSARGS;
588 12 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 12 12
589 0 croak_xs_usage(cv, "self, ...");
590 {
591 12 SV * self = ST(0)
592 ;
593 SV * RETVAL;
594 #line 18 "./xs/future.xs"
595 {
596 dbil_future *f = dbil_future_of(aTHX_ self);
597 AV *res = newAV();
598 int i;
599 if (f->state)
600 croak("DBIx::Loop::Future: already settled");
601 for (i = 1; i < items; i++) av_push(res, newSVsv(ST(i)));
602 f->result = newRV_noinc((SV *)res);
603 f->state = 1;
604 dbil_future_fire(aTHX_ self, f);
605 RETVAL = SvREFCNT_inc(self);
606 }
607 #line 608 "Loop.c"
608 11 RETVAL = sv_2mortal(RETVAL);
609 11 ST(0) = RETVAL;
610 }
611 11 XSRETURN(1);
612 }
613  
614  
615 XS_EUPXS(XS_DBIx__Loop__Future_fail); /* prototype to pass -Wmissing-prototypes */
616 4 XS_EUPXS(XS_DBIx__Loop__Future_fail)
617 {
618 4 dVAR; dXSARGS;
619 4 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 4 4
620 0 croak_xs_usage(cv, "self, error");
621 {
622 4 SV * self = ST(0)
623 ;
624 4 SV * error = ST(1)
625 ;
626 SV * RETVAL;
627 #line 38 "./xs/future.xs"
628 {
629 dbil_future *f = dbil_future_of(aTHX_ self);
630 if (f->state)
631 croak("DBIx::Loop::Future: already settled");
632 f->error = newSVsv(error);
633 f->state = 2;
634 dbil_future_fire(aTHX_ self, f);
635 RETVAL = SvREFCNT_inc(self);
636 }
637 #line 638 "Loop.c"
638 4 RETVAL = sv_2mortal(RETVAL);
639 4 ST(0) = RETVAL;
640 }
641 4 XSRETURN(1);
642 }
643  
644  
645 XS_EUPXS(XS_DBIx__Loop__Future_on_ready); /* prototype to pass -Wmissing-prototypes */
646 8 XS_EUPXS(XS_DBIx__Loop__Future_on_ready)
647 {
648 8 dVAR; dXSARGS;
649 8 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 8 8
650 0 croak_xs_usage(cv, "self, cb");
651 {
652 8 SV * self = ST(0)
653 ;
654 8 SV * cb = ST(1)
655 ;
656 SV * RETVAL;
657 #line 55 "./xs/future.xs"
658 {
659 dbil_future *f = dbil_future_of(aTHX_ self);
660 if (!SvROK(cb) || SvTYPE(SvRV(cb)) != SVt_PVCV)
661 croak("DBIx::Loop::Future->on_ready: need a coderef");
662 if (f->state) {
663 dSP;
664 ENTER; SAVETMPS; PUSHMARK(SP);
665 EXTEND(SP, 1); PUSHs(self); PUTBACK;
666 call_sv(cb, G_DISCARD | G_EVAL);
667 if (SvTRUE(ERRSV))
668 warn("DBIx::Loop::Future: on_ready callback died: %s",
669 SvPV_nolen(ERRSV));
670 FREETMPS; LEAVE;
671 } else {
672 av_push(f->cbs, newSVsv(cb));
673 }
674 RETVAL = SvREFCNT_inc(self);
675 }
676 #line 677 "Loop.c"
677 8 RETVAL = sv_2mortal(RETVAL);
678 8 ST(0) = RETVAL;
679 }
680 8 XSRETURN(1);
681 }
682  
683  
684 XS_EUPXS(XS_DBIx__Loop__Future_then); /* prototype to pass -Wmissing-prototypes */
685 2015 XS_EUPXS(XS_DBIx__Loop__Future_then)
686 {
687 2015 dVAR; dXSARGS;
688 2015 dXSI32;
689 2015 ▶ if (items < 1 || items > 3)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 1 || items > 3) 2015 0 2015
if (items < 1 || items > 3) 0 2015 2015
690 0 croak_xs_usage(cv, "self, on_done = &PL_sv_undef, on_fail = &PL_sv_undef");
691 {
692 2015 SV * self = ST(0)
693 ;
694 SV * on_done;
695 SV * on_fail;
696 SV * RETVAL;
697  
698 2015 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 0 2015 2015
699 0 on_done = &PL_sv_undef;
700 else {
701 2015 on_done = ST(1)
702 ;
703 }
704  
705 2015 ▶ if (items < 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 3) 2015 0 2015
706 2015 on_fail = &PL_sv_undef;
707 else {
708 0 on_fail = ST(2)
709 ;
710 }
711 #line 90 "./xs/future.xs"
712 {
713 SV *next;
714 /* else($cb): the one argument is the failure handler */
715 if (ix == 1) { on_fail = on_done; on_done = &PL_sv_undef; }
716 (void)dbil_future_of(aTHX_ self); /* croak early if not one */
717 next = dbil_future_new(aTHX_ "DBIx::Loop::Future");
718 dbil_then_attach(aTHX_ self, next, on_done, on_fail);
719 RETVAL = next;
720 }
721 #line 722 "Loop.c"
722 2015 RETVAL = sv_2mortal(RETVAL);
723 2015 ST(0) = RETVAL;
724 }
725 2015 XSRETURN(1);
726 }
727  
728  
729 XS_EUPXS(XS_DBIx__Loop__Future_is_ready); /* prototype to pass -Wmissing-prototypes */
730 1445 XS_EUPXS(XS_DBIx__Loop__Future_is_ready)
731 {
732 1445 dVAR; dXSARGS;
733 1445 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 1445 1445
734 0 croak_xs_usage(cv, "self");
735 {
736 1445 SV * self = ST(0)
737 ;
738 int RETVAL;
739 1445 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1445 0 1445
740 #line 106 "./xs/future.xs"
741 RETVAL = dbil_future_of(aTHX_ self)->state != 0;
742 #line 743 "Loop.c"
743 1445 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 1420 25 1445
744 1445 ST(0) = TARG;
745 }
746 1445 XSRETURN(1);
747 }
748  
749  
750 XS_EUPXS(XS_DBIx__Loop__Future_is_done); /* prototype to pass -Wmissing-prototypes */
751 60 XS_EUPXS(XS_DBIx__Loop__Future_is_done)
752 {
753 60 dVAR; dXSARGS;
754 60 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 60 60
755 0 croak_xs_usage(cv, "self");
756 {
757 60 SV * self = ST(0)
758 ;
759 int RETVAL;
760 60 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 60 0 60
761 #line 114 "./xs/future.xs"
762 RETVAL = dbil_future_of(aTHX_ self)->state == 1;
763 #line 764 "Loop.c"
764 60 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 31 29 60
765 60 ST(0) = TARG;
766 }
767 60 XSRETURN(1);
768 }
769  
770  
771 XS_EUPXS(XS_DBIx__Loop__Future_is_failed); /* prototype to pass -Wmissing-prototypes */
772 525 XS_EUPXS(XS_DBIx__Loop__Future_is_failed)
773 {
774 525 dVAR; dXSARGS;
775 525 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 525 525
776 0 croak_xs_usage(cv, "self");
777 {
778 525 SV * self = ST(0)
779 ;
780 int RETVAL;
781 525 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 525 0 525
782 #line 122 "./xs/future.xs"
783 RETVAL = dbil_future_of(aTHX_ self)->state == 2;
784 #line 785 "Loop.c"
785 525 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 501 24 525
786 525 ST(0) = TARG;
787 }
788 525 XSRETURN(1);
789 }
790  
791  
792 XS_EUPXS(XS_DBIx__Loop__Future_failure); /* prototype to pass -Wmissing-prototypes */
793 19 XS_EUPXS(XS_DBIx__Loop__Future_failure)
794 {
795 19 dVAR; dXSARGS;
796 19 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 19 19
797 0 croak_xs_usage(cv, "self");
798 {
799 19 SV * self = ST(0)
800 ;
801 SV * RETVAL;
802 #line 130 "./xs/future.xs"
803 {
804 dbil_future *f = dbil_future_of(aTHX_ self);
805 RETVAL = (f->state == 2 && f->error) ? newSVsv(f->error) : newSV(0);
806 }
807 #line 808 "Loop.c"
808 19 RETVAL = sv_2mortal(RETVAL);
809 19 ST(0) = RETVAL;
810 }
811 19 XSRETURN(1);
812 }
813  
814  
815 XS_EUPXS(XS_DBIx__Loop__Future_get); /* prototype to pass -Wmissing-prototypes */
816 167 XS_EUPXS(XS_DBIx__Loop__Future_get)
817 {
818 167 dVAR; dXSARGS;
819 167 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 167 167
820 0 croak_xs_usage(cv, "self");
821 PERL_UNUSED_VAR(ax); /* -Wall */
822 167 SP -= items;
823 {
824 167 SV * self = ST(0)
825 ;
826 #line 141 "./xs/future.xs"
827 {
828 dbil_future *f = dbil_future_of(aTHX_ self);
829 if (f->state == 0)
830 croak("DBIx::Loop::Future->get: future is not ready "
831 "(await it on your event loop first)");
832 if (f->state == 2)
833 croak_sv(f->error ? f->error : sv_2mortal(newSVpvs("failed")));
834 {
835 AV *res = (AV *)SvRV(f->result);
836 SSize_t i, n = av_len(res) + 1;
837 EXTEND(SP, n);
838 for (i = 0; i < n; i++) {
839 SV **e = av_fetch(res, i, 0);
840 PUSHs(e && *e ? sv_2mortal(newSVsv(*e)) : &PL_sv_undef);
841 }
842 }
843 }
844 #line 845 "Loop.c"
845 163 PUTBACK;
846 163 return;
847 }
848 }
849  
850  
851 /* INCLUDE: Returning to 'Loop.xs' from 'xs/future.xs' */
852  
853  
854 /* INCLUDE: Including 'xs/txn.xs' from 'Loop.xs' */
855  
856  
857 XS_EUPXS(XS_DBIx__Loop__Txn_query); /* prototype to pass -Wmissing-prototypes */
858 3 XS_EUPXS(XS_DBIx__Loop__Txn_query)
859 {
860 3 dVAR; dXSARGS;
861 3 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 0 3 3
862 0 croak_xs_usage(cv, "self, sql, ...");
863 {
864 3 SV * self = ST(0)
865 ;
866 3 SV * sql = ST(1)
867 ;
868 SV * RETVAL;
869 #line 11 "./xs/txn.xs"
870 {
871 AV *bind = (AV *)sv_2mortal((SV *)newAV());
872 int i;
873 for (i = 2; i < items; i++) av_push(bind, newSVsv(ST(i)));
874 RETVAL = dbil_txn_stmt(aTHX_ self, 1, sql, bind);
875 }
876 #line 877 "Loop.c"
877 3 RETVAL = sv_2mortal(RETVAL);
878 3 ST(0) = RETVAL;
879 }
880 3 XSRETURN(1);
881 }
882  
883  
884 XS_EUPXS(XS_DBIx__Loop__Txn_do); /* prototype to pass -Wmissing-prototypes */
885 16 XS_EUPXS(XS_DBIx__Loop__Txn_do)
886 {
887 16 dVAR; dXSARGS;
888 16 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 0 16 16
889 0 croak_xs_usage(cv, "self, sql, ...");
890 {
891 16 SV * self = ST(0)
892 ;
893 16 SV * sql = ST(1)
894 ;
895 SV * RETVAL;
896 #line 26 "./xs/txn.xs"
897 {
898 AV *bind = (AV *)sv_2mortal((SV *)newAV());
899 int i;
900 for (i = 2; i < items; i++) av_push(bind, newSVsv(ST(i)));
901 RETVAL = dbil_txn_stmt(aTHX_ self, 0, sql, bind);
902 }
903 #line 904 "Loop.c"
904 16 RETVAL = sv_2mortal(RETVAL);
905 16 ST(0) = RETVAL;
906 }
907 16 XSRETURN(1);
908 }
909  
910  
911 XS_EUPXS(XS_DBIx__Loop__Txn_is_active); /* prototype to pass -Wmissing-prototypes */
912 1 XS_EUPXS(XS_DBIx__Loop__Txn_is_active)
913 {
914 1 dVAR; dXSARGS;
915 1 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 1 1
916 0 croak_xs_usage(cv, "self");
917 {
918 1 SV * self = ST(0)
919 ;
920 int RETVAL;
921 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
922 #line 39 "./xs/txn.xs"
923 RETVAL = dbil_tx_iv(aTHX_ self, "active") == 1;
924 #line 925 "Loop.c"
925 1 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 1 1
926 1 ST(0) = TARG;
927 }
928 1 XSRETURN(1);
929 }
930  
931  
932 /* INCLUDE: Returning to 'Loop.xs' from 'xs/txn.xs' */
933  
934  
935 /* INCLUDE: Including 'xs/loop_hyperman.xs' from 'Loop.xs' */
936  
937  
938 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_new); /* prototype to pass -Wmissing-prototypes */
939 0 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_new)
940 {
941 0 dVAR; dXSARGS;
942 0 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 0 0
943 0 croak_xs_usage(cv, "class, ...");
944 {
945 0 SV * class = ST(0)
946 ;
947 SV * RETVAL;
948 #line 12 "./xs/loop_hyperman.xs"
949 {
950 const hm_abi *A = dbil_hm(aTHX);
951 SV *loop_sv = NULL;
952 void *loop;
953 dbil_hm_ctx *c;
954 HV *self;
955 int i;
956 const char *cls = (SvROK(class) && SvOBJECT(SvRV(class)))
957 ? HvNAME(SvSTASH(SvRV(class))) : SvPV_nolen(class);
958 if (!A)
959 croak("DBIx::Loop::Loop::Hyperman: no Hyperman C ABI version %d - "
960 "either Hyperman is not loaded (use Hyperman first) or it "
961 "predates the ABI (needs Hyperman 0.10 or newer)",
962 HM_ABI_VERSION);
963 for (i = 1; i + 1 < items; i += 2) {
964 STRLEN kl; const char *k = SvPV_const(ST(i), kl);
965 if (kl == 4 && memEQ(k, "loop", 4) && SvOK(ST(i + 1)))
966 loop_sv = ST(i + 1);
967 }
968 if (loop_sv) {
969 loop = A->loop_of_sv(aTHX_ loop_sv); /* croaks if not one */
970 loop_sv = newSVsv(loop_sv);
971 } else if ((loop = A->cur_loop(aTHX))) {
972 loop_sv = A->sv_of_loop(aTHX_ loop); /* +1, we own it */
973 } else {
974 /* no loop given, none running: make one (IO::Async parity) */
975 dSP; int n;
976 ENTER; SAVETMPS; PUSHMARK(SP);
977 EXTEND(SP, 1); mPUSHp("Hyperman::Loop", 14); PUTBACK;
978 n = call_method("new", G_SCALAR);
979 SPAGAIN;
980 if (n > 0) { SV *s = POPs; loop_sv = newSVsv(s); }
981 PUTBACK; FREETMPS; LEAVE;
982 if (!loop_sv)
983 croak("DBIx::Loop::Loop::Hyperman: Hyperman::Loop->new "
984 "returned nothing");
985 loop = A->loop_of_sv(aTHX_ loop_sv);
986 }
987 c = dbil_hm_ctx_new(A, loop);
988 self = newHV();
989 (void)hv_stores(self, "loop", loop_sv);
990 (void)hv_stores(self, "_ctx", newSViv(PTR2IV(c)));
991 (void)hv_stores(self, "_vt", newSViv(PTR2IV(&c->vt)));
992 RETVAL = sv_bless(newRV_noinc((SV *)self), gv_stashpv(cls, GV_ADD));
993 }
994 #line 995 "Loop.c"
995 0 RETVAL = sv_2mortal(RETVAL);
996 0 ST(0) = RETVAL;
997 }
998 0 XSRETURN(1);
999 }
1000  
1001  
1002 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_loop); /* prototype to pass -Wmissing-prototypes */
1003 0 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_loop)
1004 {
1005 0 dVAR; dXSARGS;
1006 0 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 0 0
1007 0 croak_xs_usage(cv, "self");
1008 {
1009 0 SV * self = ST(0)
1010 ;
1011 SV * RETVAL;
1012 #line 65 "./xs/loop_hyperman.xs"
1013 {
1014 SV **e;
1015 (void)dbil_hm_ctx_of(aTHX_ self); /* validates */
1016 e = hv_fetchs((HV *)SvRV(self), "loop", 0);
1017 RETVAL = (e && *e) ? newSVsv(*e) : &PL_sv_undef;
1018 }
1019 #line 1020 "Loop.c"
1020 0 RETVAL = sv_2mortal(RETVAL);
1021 0 ST(0) = RETVAL;
1022 }
1023 0 XSRETURN(1);
1024 }
1025  
1026  
1027 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_add_reader); /* prototype to pass -Wmissing-prototypes */
1028 0 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_add_reader)
1029 {
1030 0 dVAR; dXSARGS;
1031 0 dXSI32;
1032 0 ▶ if (items != 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 3) 0 0 0
1033 0 croak_xs_usage(cv, "self, fd, cb");
1034 {
1035 0 SV * self = ST(0)
1036 ;
1037 0 int fd = (int)SvIV(ST(1))
1038 ;
1039 0 ▶ SV * cb = ST(2)
Branch: 1 branch
BranchTrueFalseTotal
SV * cb = ST(2) 0 0 0
1040 ;
1041 #line 82 "./xs/loop_hyperman.xs"
1042 dbil_hm_add_io(aTHX_ self, fd, ix ? HM_ABI_WRITE : HM_ABI_READ, cb);
1043 #line 1044 "Loop.c"
1044 }
1045 0 XSRETURN_EMPTY;
1046 }
1047  
1048  
1049 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_remove); /* prototype to pass -Wmissing-prototypes */
1050 0 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_remove)
1051 {
1052 0 dVAR; dXSARGS;
1053 0 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 0 0
1054 0 croak_xs_usage(cv, "self, fd");
1055 {
1056 0 SV * self = ST(0)
1057 ;
1058 0 int fd = (int)SvIV(ST(1))
1059 ;
1060 #line 89 "./xs/loop_hyperman.xs"
1061 dbil_hm_remove(aTHX_ self, fd);
1062 #line 1063 "Loop.c"
1063 }
1064 0 XSRETURN_EMPTY;
1065 }
1066  
1067  
1068 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_timer); /* prototype to pass -Wmissing-prototypes */
1069 0 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_timer)
1070 {
1071 0 dVAR; dXSARGS;
1072 0 ▶ if (items != 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 3) 0 0 0
1073 0 croak_xs_usage(cv, "self, secs, cb");
1074 {
1075 0 SV * self = ST(0)
1076 ;
1077 0 double secs = (double)SvNV(ST(1))
1078 ;
1079 0 SV * cb = ST(2)
1080 ;
1081 SV * RETVAL;
1082 #line 99 "./xs/loop_hyperman.xs"
1083 {
1084 dbil_hm_ctx *c = dbil_hm_ctx_of(aTHX_ self);
1085 dbil_hm_tmr *tm;
1086 Newxz(tm, 1, dbil_hm_tmr);
1087 tm->cb = newSVsv(cb);
1088 tm->t = c->A->timer(aTHX_ c->loop, secs, dbil_hm_timer_tramp, tm);
1089 RETVAL = newSViv(PTR2IV(tm));
1090 }
1091 #line 1092 "Loop.c"
1092 0 RETVAL = sv_2mortal(RETVAL);
1093 0 ST(0) = RETVAL;
1094 }
1095 0 XSRETURN(1);
1096 }
1097  
1098  
1099 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_cancel_timer); /* prototype to pass -Wmissing-prototypes */
1100 0 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_cancel_timer)
1101 {
1102 0 dVAR; dXSARGS;
1103 0 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 0 0
1104 0 croak_xs_usage(cv, "self, handle");
1105 {
1106 0 SV * self = ST(0)
1107 ;
1108 0 SV * handle = ST(1)
1109 ;
1110 #line 115 "./xs/loop_hyperman.xs"
1111 {
1112 dbil_hm_ctx *c = dbil_hm_ctx_of(aTHX_ self);
1113 dbil_hm_tmr *tm;
1114 if (!SvIOK(handle))
1115 croak("cancel_timer: not a timer handle");
1116 tm = INT2PTR(dbil_hm_tmr *, SvIV(handle));
1117 c->A->timer_cancel(aTHX_ c->loop, tm->t);
1118 SvREFCNT_dec(tm->cb);
1119 Safefree(tm);
1120 }
1121 #line 1122 "Loop.c"
1122 }
1123 0 XSRETURN_EMPTY;
1124 }
1125  
1126  
1127 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_new_future); /* prototype to pass -Wmissing-prototypes */
1128 0 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_new_future)
1129 {
1130 0 dVAR; dXSARGS;
1131 0 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 0 0
1132 0 croak_xs_usage(cv, "self");
1133 {
1134 0 SV * self = ST(0)
1135 ;
1136 SV * RETVAL;
1137 #line 131 "./xs/loop_hyperman.xs"
1138 RETVAL = dbil_hm_ctx_of(aTHX_ self)->A->future_new(aTHX);
1139 #line 1140 "Loop.c"
1140 0 RETVAL = sv_2mortal(RETVAL);
1141 0 ST(0) = RETVAL;
1142 }
1143 0 XSRETURN(1);
1144 }
1145  
1146  
1147 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_await); /* prototype to pass -Wmissing-prototypes */
1148 0 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_await)
1149 {
1150 0 dVAR; dXSARGS;
1151 0 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 0 0
1152 0 croak_xs_usage(cv, "self, future");
1153 {
1154 0 SV * self = ST(0)
1155 ;
1156 0 SV * future = ST(1)
1157 ;
1158 SV * RETVAL;
1159 #line 142 "./xs/loop_hyperman.xs"
1160 dbil_hm_await(aTHX_ dbil_hm_ctx_of(aTHX_ self), future);
1161 RETVAL = newSVsv(future);
1162 #line 1163 "Loop.c"
1163 0 RETVAL = sv_2mortal(RETVAL);
1164 0 ST(0) = RETVAL;
1165 }
1166 0 XSRETURN(1);
1167 }
1168  
1169  
1170 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_DESTROY); /* prototype to pass -Wmissing-prototypes */
1171 0 XS_EUPXS(XS_DBIx__Loop__Loop__Hyperman_DESTROY)
1172 {
1173 0 dVAR; dXSARGS;
1174 0 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 0 0
1175 0 croak_xs_usage(cv, "self");
1176 {
1177 0 ▶ SV * self = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * self = ST(0) 0 0 0
1178 ;
1179 #line 151 "./xs/loop_hyperman.xs"
1180 {
1181 HV *h;
1182 SV **e;
1183 if (!(SvROK(self) && SvTYPE(SvRV(self)) == SVt_PVHV)) XSRETURN_EMPTY;
1184 h = (HV *)SvRV(self);
1185 e = hv_fetchs(h, "_ctx", 0);
1186 if (e && *e && SvIOK(*e)) {
1187 dbil_hm_ctx *c = INT2PTR(dbil_hm_ctx *, SvIV(*e));
1188 /* drop any still-registered Perl-seam watchers so the loop never
1189 * fires into freed callbacks; skip during global destruction */
1190 if (!PL_dirty) {
1191 int m;
1192 for (m = 0; m < 2; m++) {
1193 HV *cbs = dbil_hm_cbh(aTHX_ self,
1194 m ? HM_ABI_WRITE : HM_ABI_READ, 0);
1195 if (cbs) {
1196 HE *he;
1197 hv_iterinit(cbs);
1198 while ((he = hv_iternext(cbs))) {
1199 I32 kl;
1200 const char *k = hv_iterkey(he, &kl);
1201 c->A->io_unwatch(aTHX_ c->loop, atoi(k),
1202 m ? HM_ABI_WRITE : HM_ABI_READ);
1203 }
1204 }
1205 }
1206 }
1207 Safefree(c);
1208 (void)hv_delete(h, "_ctx", 4, G_DISCARD);
1209 (void)hv_delete(h, "_vt", 3, G_DISCARD);
1210 }
1211 }
1212 #line 1213 "Loop.c"
1213 }
1214 0 XSRETURN_EMPTY;
1215 }
1216  
1217  
1218 /* INCLUDE: Returning to 'Loop.xs' from 'xs/loop_hyperman.xs' */
1219  
1220  
1221 /* INCLUDE: Including 'xs/abi.xs' from 'Loop.xs' */
1222  
1223  
1224 XS_EUPXS(XS_DBIx__Loop__abi_ptr); /* prototype to pass -Wmissing-prototypes */
1225 2 XS_EUPXS(XS_DBIx__Loop__abi_ptr)
1226 {
1227 2 dVAR; dXSARGS;
1228 2 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 2 2
1229 0 croak_xs_usage(cv, "");
1230 {
1231 IV RETVAL;
1232 2 ▶ dXSTARG;
Branch: 2 branches
BranchTrueFalseTotal
dXSTARG; 2 0 2
dXSTARG; 0 2 2
1233 #line 11 "./xs/abi.xs"
1234 RETVAL = PTR2IV(&dbil_abi_table);
1235 #line 1236 "Loop.c"
1236 2 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 2 2
1237 2 ST(0) = TARG;
1238 }
1239 2 XSRETURN(1);
1240 }
1241  
1242  
1243 XS_EUPXS(XS_DBIx__Loop__abi_selftest); /* prototype to pass -Wmissing-prototypes */
1244 1 XS_EUPXS(XS_DBIx__Loop__abi_selftest)
1245 {
1246 1 dVAR; dXSARGS;
1247 1 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 1 1
1248 0 croak_xs_usage(cv, "");
1249 {
1250 IV RETVAL;
1251 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
1252 #line 22 "./xs/abi.xs"
1253 RETVAL = dbil_abi_selftest(aTHX);
1254 #line 1255 "Loop.c"
1255 1 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 1 1
1256 1 ST(0) = TARG;
1257 }
1258 1 XSRETURN(1);
1259 }
1260  
1261  
1262 XS_EUPXS(XS_DBIx__Loop__abi_version); /* prototype to pass -Wmissing-prototypes */
1263 4 XS_EUPXS(XS_DBIx__Loop__abi_version)
1264 {
1265 4 dVAR; dXSARGS;
1266 4 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 4 4
1267 0 croak_xs_usage(cv, "");
1268 {
1269 IV RETVAL;
1270 4 ▶ dXSTARG;
Branch: 2 branches
BranchTrueFalseTotal
dXSTARG; 4 0 4
dXSTARG; 0 4 4
1271 #line 31 "./xs/abi.xs"
1272 RETVAL = dbil_abi_table.abi_version;
1273 #line 1274 "Loop.c"
1274 4 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 4 4
1275 4 ST(0) = TARG;
1276 }
1277 4 XSRETURN(1);
1278 }
1279  
1280  
1281 XS_EUPXS(XS_DBIx__Loop_on_exec); /* prototype to pass -Wmissing-prototypes */
1282 4 XS_EUPXS(XS_DBIx__Loop_on_exec)
1283 {
1284 4 dVAR; dXSARGS;
1285 4 ▶ if (items < 2 || items > 3)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 2 || items > 3) 4 0 4
if (items < 2 || items > 3) 0 4 4
1286 0 croak_xs_usage(cv, "class, start, done = &PL_sv_undef");
1287 {
1288 4 SV * class = ST(0)
1289 ;
1290 4 SV * start = ST(1)
1291 ;
1292 SV * done;
1293 IV RETVAL;
1294 4 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 4 0 4
1295  
1296 4 ▶ if (items < 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 3) 2 2 4
1297 2 done = &PL_sv_undef;
1298 else {
1299 2 done = ST(2)
1300 ;
1301 }
1302 #line 46 "./xs/abi.xs"
1303 PERL_UNUSED_VAR(class);
1304 RETVAL = dbil_obs_add_perl(aTHX_ start, done);
1305 #line 1306 "Loop.c"
1306 2 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 2 2
1307 2 ST(0) = TARG;
1308 }
1309 2 XSRETURN(1);
1310 }
1311  
1312  
1313 XS_EUPXS(XS_DBIx__Loop__abi_observer_install); /* prototype to pass -Wmissing-prototypes */
1314 1 XS_EUPXS(XS_DBIx__Loop__abi_observer_install)
1315 {
1316 1 dVAR; dXSARGS;
1317 1 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 1 1
1318 0 croak_xs_usage(cv, "");
1319 {
1320 IV RETVAL;
1321 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
1322 #line 56 "./xs/abi.xs"
1323 RETVAL = dbil_obs_selftest_install(aTHX);
1324 #line 1325 "Loop.c"
1325 1 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 1 1
1326 1 ST(0) = TARG;
1327 }
1328 1 XSRETURN(1);
1329 }
1330  
1331  
1332 XS_EUPXS(XS_DBIx__Loop__abi_observer_state); /* prototype to pass -Wmissing-prototypes */
1333 10 XS_EUPXS(XS_DBIx__Loop__abi_observer_state)
1334 {
1335 10 dVAR; dXSARGS;
1336 10 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 10 10
1337 0 croak_xs_usage(cv, "");
1338 PERL_UNUSED_VAR(ax); /* -Wall */
1339 10 ▶ SP -= items;
Branch: 1 branch
BranchTrueFalseTotal
SP -= items; 0 10 10
1340 {
1341 #line 64 "./xs/abi.xs"
1342 EXTEND(SP, 7);
1343 mPUSHi(DBIL_OBS_ST_STARTS);
1344 mPUSHi(DBIL_OBS_ST_DONES);
1345 mPUSHi(DBIL_OBS_ST_OK);
1346 mPUSHi(DBIL_OBS_ST_ERR);
1347 mPUSHi(DBIL_OBS_ST_BIND);
1348 mPUSHi(DBIL_OBS_ST_QUERY);
1349 mPUSHp(DBIL_OBS_ST_SQL, strlen(DBIL_OBS_ST_SQL));
1350 #line 1351 "Loop.c"
1351 10 PUTBACK;
1352 10 return;
1353 }
1354 }
1355  
1356  
1357 XS_EUPXS(XS_DBIx__Loop__abi_dbtest); /* prototype to pass -Wmissing-prototypes */
1358 1 XS_EUPXS(XS_DBIx__Loop__abi_dbtest)
1359 {
1360 1 dVAR; dXSARGS;
1361 1 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 1 1
1362 0 croak_xs_usage(cv, "adapter, dsn");
1363 {
1364 1 SV * adapter = ST(0)
1365 ;
1366 1 SV * dsn = ST(1)
1367 ;
1368 IV RETVAL;
1369 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
1370 #line 81 "./xs/abi.xs"
1371 RETVAL = dbil_abi_dbtest(aTHX_ adapter, dsn);
1372 #line 1373 "Loop.c"
1373 1 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 1 1
1374 1 ST(0) = TARG;
1375 }
1376 1 XSRETURN(1);
1377 }
1378  
1379  
1380 /* INCLUDE: Returning to 'Loop.xs' from 'xs/abi.xs' */
1381  
1382 #ifdef __cplusplus
1383 extern "C" {
1384 #endif
1385 XS_EXTERNAL(boot_DBIx__Loop); /* prototype to pass -Wmissing-prototypes */
1386 20 XS_EXTERNAL(boot_DBIx__Loop)
1387 {
1388 #if PERL_VERSION_LE(5, 21, 5)
1389 dVAR; dXSARGS;
1390 #else
1391 20 dVAR; dXSBOOTARGSXSAPIVERCHK;
1392 #endif
1393 #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
1394 char* file = __FILE__;
1395 #else
1396 20 const char* file = __FILE__;
1397 #endif
1398  
1399 PERL_UNUSED_VAR(file);
1400  
1401 PERL_UNUSED_VAR(cv); /* -W */
1402 PERL_UNUSED_VAR(items); /* -W */
1403 #if PERL_VERSION_LE(5, 21, 5)
1404 XS_VERSION_BOOTCHECK;
1405 # ifdef XS_APIVERSION_BOOTCHECK
1406 XS_APIVERSION_BOOTCHECK;
1407 # endif
1408 #endif
1409  
1410 {
1411 CV * cv;
1412  
1413 20 newXS_deffile("DBIx::Loop::_capability", XS_DBIx__Loop__capability);
1414 20 newXS_deffile("DBIx::Loop::new", XS_DBIx__Loop_new);
1415 20 newXS_deffile("DBIx::Loop::query", XS_DBIx__Loop_query);
1416 20 newXS_deffile("DBIx::Loop::do", XS_DBIx__Loop_do);
1417 20 cv = newXS_deffile("DBIx::Loop::selectall_arrayref", XS_DBIx__Loop_selectall_arrayref);
1418 20 XSANY.any_i32 = 1;
1419 20 cv = newXS_deffile("DBIx::Loop::selectall_hashref", XS_DBIx__Loop_selectall_arrayref);
1420 20 XSANY.any_i32 = 6;
1421 20 cv = newXS_deffile("DBIx::Loop::selectall_rowhash", XS_DBIx__Loop_selectall_arrayref);
1422 20 XSANY.any_i32 = 7;
1423 20 cv = newXS_deffile("DBIx::Loop::selectcol_arrayref", XS_DBIx__Loop_selectall_arrayref);
1424 20 XSANY.any_i32 = 5;
1425 20 cv = newXS_deffile("DBIx::Loop::selectrow_array", XS_DBIx__Loop_selectall_arrayref);
1426 20 XSANY.any_i32 = 3;
1427 20 cv = newXS_deffile("DBIx::Loop::selectrow_arrayref", XS_DBIx__Loop_selectall_arrayref);
1428 20 XSANY.any_i32 = 2;
1429 20 cv = newXS_deffile("DBIx::Loop::selectrow_hashref", XS_DBIx__Loop_selectall_arrayref);
1430 20 XSANY.any_i32 = 4;
1431 20 newXS_deffile("DBIx::Loop::capability", XS_DBIx__Loop_capability);
1432 20 newXS_deffile("DBIx::Loop::loop", XS_DBIx__Loop_loop);
1433 20 newXS_deffile("DBIx::Loop::dbh", XS_DBIx__Loop_dbh);
1434 20 newXS_deffile("DBIx::Loop::disconnect", XS_DBIx__Loop_disconnect);
1435 20 newXS_deffile("DBIx::Loop::txn", XS_DBIx__Loop_txn);
1436 20 newXS_deffile("DBIx::Loop::_worker_pids", XS_DBIx__Loop__worker_pids);
1437 20 newXS_deffile("DBIx::Loop::DESTROY", XS_DBIx__Loop_DESTROY);
1438 20 newXS_deffile("DBIx::Loop::Future::new", XS_DBIx__Loop__Future_new);
1439 20 newXS_deffile("DBIx::Loop::Future::done", XS_DBIx__Loop__Future_done);
1440 20 newXS_deffile("DBIx::Loop::Future::fail", XS_DBIx__Loop__Future_fail);
1441 20 newXS_deffile("DBIx::Loop::Future::on_ready", XS_DBIx__Loop__Future_on_ready);
1442 20 cv = newXS_deffile("DBIx::Loop::Future::else", XS_DBIx__Loop__Future_then);
1443 20 XSANY.any_i32 = 1;
1444 20 cv = newXS_deffile("DBIx::Loop::Future::then", XS_DBIx__Loop__Future_then);
1445 20 XSANY.any_i32 = 0;
1446 20 newXS_deffile("DBIx::Loop::Future::is_ready", XS_DBIx__Loop__Future_is_ready);
1447 20 newXS_deffile("DBIx::Loop::Future::is_done", XS_DBIx__Loop__Future_is_done);
1448 20 newXS_deffile("DBIx::Loop::Future::is_failed", XS_DBIx__Loop__Future_is_failed);
1449 20 newXS_deffile("DBIx::Loop::Future::failure", XS_DBIx__Loop__Future_failure);
1450 20 newXS_deffile("DBIx::Loop::Future::get", XS_DBIx__Loop__Future_get);
1451 20 newXS_deffile("DBIx::Loop::Txn::query", XS_DBIx__Loop__Txn_query);
1452 20 newXS_deffile("DBIx::Loop::Txn::do", XS_DBIx__Loop__Txn_do);
1453 20 newXS_deffile("DBIx::Loop::Txn::is_active", XS_DBIx__Loop__Txn_is_active);
1454 20 newXS_deffile("DBIx::Loop::Loop::Hyperman::new", XS_DBIx__Loop__Loop__Hyperman_new);
1455 20 newXS_deffile("DBIx::Loop::Loop::Hyperman::loop", XS_DBIx__Loop__Loop__Hyperman_loop);
1456 20 cv = newXS_deffile("DBIx::Loop::Loop::Hyperman::add_reader", XS_DBIx__Loop__Loop__Hyperman_add_reader);
1457 20 XSANY.any_i32 = 0;
1458 20 cv = newXS_deffile("DBIx::Loop::Loop::Hyperman::add_writer", XS_DBIx__Loop__Loop__Hyperman_add_reader);
1459 20 XSANY.any_i32 = 1;
1460 20 newXS_deffile("DBIx::Loop::Loop::Hyperman::remove", XS_DBIx__Loop__Loop__Hyperman_remove);
1461 20 newXS_deffile("DBIx::Loop::Loop::Hyperman::timer", XS_DBIx__Loop__Loop__Hyperman_timer);
1462 20 newXS_deffile("DBIx::Loop::Loop::Hyperman::cancel_timer", XS_DBIx__Loop__Loop__Hyperman_cancel_timer);
1463 20 newXS_deffile("DBIx::Loop::Loop::Hyperman::new_future", XS_DBIx__Loop__Loop__Hyperman_new_future);
1464 20 newXS_deffile("DBIx::Loop::Loop::Hyperman::await", XS_DBIx__Loop__Loop__Hyperman_await);
1465 20 newXS_deffile("DBIx::Loop::Loop::Hyperman::DESTROY", XS_DBIx__Loop__Loop__Hyperman_DESTROY);
1466 20 newXS_deffile("DBIx::Loop::_abi_ptr", XS_DBIx__Loop__abi_ptr);
1467 20 newXS_deffile("DBIx::Loop::_abi_selftest", XS_DBIx__Loop__abi_selftest);
1468 20 newXS_deffile("DBIx::Loop::_abi_version", XS_DBIx__Loop__abi_version);
1469 20 newXS_deffile("DBIx::Loop::on_exec", XS_DBIx__Loop_on_exec);
1470 20 newXS_deffile("DBIx::Loop::_abi_observer_install", XS_DBIx__Loop__abi_observer_install);
1471 20 newXS_deffile("DBIx::Loop::_abi_observer_state", XS_DBIx__Loop__abi_observer_state);
1472 20 newXS_deffile("DBIx::Loop::_abi_dbtest", XS_DBIx__Loop__abi_dbtest);
1473 }
1474 #if PERL_VERSION_LE(5, 21, 5)
1475 # if PERL_VERSION_GE(5, 9, 0)
1476 if (PL_unitcheckav)
1477 call_list(PL_scopestack_ix, PL_unitcheckav);
1478 # endif
1479 XSRETURN_YES;
1480 #else
1481 20 Perl_xs_boot_epilog(aTHX_ ax);
1482 #endif
1483 20 }
1484  
1485 #ifdef __cplusplus
1486 }
1487 #endif
« include/dbil_native.h ↑ Summary xs/loop.xs »