t/MyTest_xsgen.cc

filter: Statementstmt 26.8% 22 / 82 Branchbran 9.6% 5 / 52 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 20.1% 27 / 134 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« src/xs/Glob.h ↑ Summary src/xs/Scalar.h »
1 /*
2 * This file was generated automatically by XS::Install::FrozenShit::ParseXS version 3.57 from the
3 * contents of MyTest.xs. Do not edit this file, edit MyTest.xs instead.
4 *
5 * ANY CHANGES MADE HERE WILL BE LOST!
6 *
7 */
8  
9 #line 1 "t/MyTest.xs"
10 #include <xs.h>
11 #include <panda/exception.h>
12  
13 using namespace xs;
14 using panda::string;
15  
16 #line 17 "t/MyTest_xsgen.cc"
17 #ifndef PERL_UNUSED_VAR
18 # define PERL_UNUSED_VAR(var) if (0) var = var
19 #endif
20  
21 #ifndef dVAR
22 # define dVAR dNOOP
23 #endif
24  
25  
26 /* This stuff is not part of the API! You have been warned. */
27 #ifndef PERL_VERSION_DECIMAL
28 # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
29 #endif
30 #ifndef PERL_DECIMAL_VERSION
31 # define PERL_DECIMAL_VERSION \
32 PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
33 #endif
34 #ifndef PERL_VERSION_GE
35 # define PERL_VERSION_GE(r,v,s) \
36 (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
37 #endif
38 #ifndef PERL_VERSION_LE
39 # define PERL_VERSION_LE(r,v,s) \
40 (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
41 #endif
42  
43 /* XS_INTERNAL is the explicit static-linkage variant of the default
44 * XS macro.
45 *
46 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
47 * "STATIC", ie. it exports XSUB symbols. You probably don't want that
48 * for anything but the BOOT XSUB.
49 *
50 * See XSUB.h in core!
51 */
52  
53  
54 /* TODO: This might be compatible further back than 5.10.0. */
55 #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
56 # undef XS_EXTERNAL
57 # undef XS_INTERNAL
58 # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
59 # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
60 # define XS_INTERNAL(name) STATIC XSPROTO(name)
61 # endif
62 # if defined(__SYMBIAN32__)
63 # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
64 # define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
65 # endif
66 # ifndef XS_EXTERNAL
67 # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
68 # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
69 # define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
70 # else
71 # ifdef __cplusplus
72 # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
73 # define XS_INTERNAL(name) static XSPROTO(name)
74 # else
75 # define XS_EXTERNAL(name) XSPROTO(name)
76 # define XS_INTERNAL(name) STATIC XSPROTO(name)
77 # endif
78 # endif
79 # endif
80 #endif
81  
82 /* perl >= 5.10.0 && perl <= 5.15.1 */
83  
84  
85 /* The XS_EXTERNAL macro is used for functions that must not be static
86 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
87 * macro defined, the best we can do is assume XS is the same.
88 * Dito for XS_INTERNAL.
89 */
90 #ifndef XS_EXTERNAL
91 # define XS_EXTERNAL(name) XS(name)
92 #endif
93 #ifndef XS_INTERNAL
94 # define XS_INTERNAL(name) XS(name)
95 #endif
96  
97 /* Now, finally, after all this mess, we want an XS::Install::FrozenShit::ParseXS
98 * internal macro that we're free to redefine for varying linkage due
99 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
100 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
101 */
102  
103 #undef XS_EUPXS
104 #if defined(PERL_EUPXS_ALWAYS_EXPORT)
105 # define XS_EUPXS(name) XS_EXTERNAL(name)
106 #else
107 /* default to internal */
108 # define XS_EUPXS(name) XS_INTERNAL(name)
109 #endif
110  
111 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
112 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
113  
114 /* prototype to pass -Wmissing-prototypes */
115 STATIC void
116 S_croak_xs_usage(const CV *const cv, const char *const params);
117  
118 STATIC void
119 S_croak_xs_usage(const CV *const cv, const char *const params)
120 {
121 const GV *const gv = CvGV(cv);
122  
123 PERL_ARGS_ASSERT_CROAK_XS_USAGE;
124  
125 if (gv) {
126 const char *const gvname = GvNAME(gv);
127 const HV *const stash = GvSTASH(gv);
128 const char *const hvname = stash ? HvNAME(stash) : NULL;
129  
130 if (hvname)
131 Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
132 else
133 Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
134 } else {
135 /* Pants. I don't think that it should be possible to get here. */
136 Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
137 }
138 }
139 #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
140  
141 #define croak_xs_usage S_croak_xs_usage
142  
143 #endif
144  
145 /* NOTE: the prototype of newXSproto() is different in versions of perls,
146 * so we define a portable version of newXSproto()
147 */
148 #ifdef newXS_flags
149 #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
150 #else
151 #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
152 #endif /* !defined(newXS_flags) */
153  
154 #if PERL_VERSION_LE(5, 21, 5)
155 # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
156 #else
157 # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
158 #endif
159  
160 /* simple backcompat versions of the TARGx() macros with no optimisation */
161 #ifndef TARGi
162 # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
163 # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
164 # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
165 #endif
166  
167 #line 168 "t/MyTest_xsgen.cc"
168  
169  
170 0 ▶XS_EUPXS(XS_MyTest_bench_sv_payload_get) { xs::throw_guard(cv, [=]()
Branch: 1 branch
BranchTrueFalseTotal
XS_EUPXS(XS_MyTest_bench_sv_payload_get) { xs::throw_guard(cv, [=]() 0 0 0
171 {
172 0 dVAR; dXSARGS;
173 0 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 0 0
174 0 croak_xs_usage(cv, "count");
175 {
176 uint64_t RETVAL;
177 0 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 0 0 0
178 0 int count = (int)SvIV(ST(0))
179 ;
180 #line 16 "t/MyTest.xs"
181 RETVAL = 0;
182 struct Epta {};
183 for (int i = 0; i < count; ++i) {
184 RETVAL += (uint64_t)typemap::object::TypemapMarker<Epta>::get();
185 }
186 #line 187 "t/MyTest_xsgen.cc"
187 0 ▶ TARGu((UV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGu((UV)RETVAL, 1); 0 0 0
188 0 ST(0) = TARG;
189 }
190 0 XSRETURN(1);
191 0 }); }
192  
193  
194  
195 0 ▶XS_EUPXS(XS_MyTest_throw_exception) { xs::throw_guard(cv, [=]()
Branch: 1 branch
BranchTrueFalseTotal
XS_EUPXS(XS_MyTest_throw_exception) { xs::throw_guard(cv, [=]() 0 0 0
196 {
197 0 dVAR; dXSARGS;
198 0 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 0 0
199 0 croak_xs_usage(cv, "sv");
200 PERL_UNUSED_VAR(ax); /* -Wall */
201 0 SP -= items;
202 {
203 0 Sv sv = ST(0)
204 ;
205 #line 24 "t/MyTest.xs"
206 throw sv;
207 #line 208 "t/MyTest_xsgen.cc"
208 PUTBACK;
209 return;
210 }
211 0 }); }
212  
213  
214  
215 0 ▶XS_EUPXS(XS_MyTest_throw_logic_error) { xs::throw_guard(cv, [=]()
Branch: 1 branch
BranchTrueFalseTotal
XS_EUPXS(XS_MyTest_throw_logic_error) { xs::throw_guard(cv, [=]() 0 0 0
216 {
217 0 dVAR; dXSARGS;
218 0 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 0 0
219 0 croak_xs_usage(cv, "");
220 PERL_UNUSED_VAR(ax); /* -Wall */
221 0 SP -= items;
222 {
223 #line 28 "t/MyTest.xs"
224 throw std::logic_error("my-logic-error");
225 #line 226 "t/MyTest_xsgen.cc"
226 PUTBACK;
227 return;
228 }
229 0 }); }
230  
231  
232  
233 0 ▶XS_EUPXS(XS_MyTest_throw_backtrace) { xs::throw_guard(cv, [=]()
Branch: 1 branch
BranchTrueFalseTotal
XS_EUPXS(XS_MyTest_throw_backtrace) { xs::throw_guard(cv, [=]() 0 0 0
234 {
235 0 dVAR; dXSARGS;
236 0 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 0 0
237 0 croak_xs_usage(cv, "");
238 PERL_UNUSED_VAR(ax); /* -Wall */
239 0 SP -= items;
240 {
241 #line 32 "t/MyTest.xs"
242 throw panda::exception("my-error");
243 #line 244 "t/MyTest_xsgen.cc"
244 PUTBACK;
245 return;
246 }
247 0 }); }
248  
249  
250  
251 0 ▶XS_EUPXS(XS_MyTest_test_leaks1) { xs::throw_guard(cv, [=]()
Branch: 1 branch
BranchTrueFalseTotal
XS_EUPXS(XS_MyTest_test_leaks1) { xs::throw_guard(cv, [=]() 0 0 0
252 {
253 0 dVAR; dXSARGS;
254 0 ▶ if (items != 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 3) 0 0 0
255 0 croak_xs_usage(cv, "cls, meth, cnt");
256 {
257 uint64_t RETVAL;
258 0 ▶ dXSTARG;
Branch: 2 branches
BranchTrueFalseTotal
dXSTARG; 0 0 0
dXSTARG; 0 0 0
259 0 string cls;
260 0 string meth;
261 0 ▶ int cnt = (int)SvIV(ST(2))
Branch: 1 branch
BranchTrueFalseTotal
int cnt = (int)SvIV(ST(2)) 0 0 0
262 ;
263  
264 { STRLEN __cls_len;
265 0 const char* __cls_buf = SvPV(ST(0), __cls_len);
266 0 ▶ cls.assign(__cls_buf, __cls_len); }
Branch: 1 branch
BranchTrueFalseTotal
cls.assign(__cls_buf, __cls_len); } 0 0 0
267 ;
268  
269 { STRLEN __meth_len;
270 0 const char* __meth_buf = SvPV(ST(1), __meth_len);
271 0 ▶ meth.assign(__meth_buf, __meth_len); }
Branch: 1 branch
BranchTrueFalseTotal
meth.assign(__meth_buf, __meth_len); } 0 0 0
272 ;
273 #line 36 "t/MyTest.xs"
274 RETVAL = 0;
275 for (int i = 0; i < cnt; ++i) {
276 Stash stash(cls);
277 auto ref = stash.call(meth);
278 RETVAL += (uint64_t)ref.get();
279 }
280 #line 281 "t/MyTest_xsgen.cc"
281 0 ▶ TARGu((UV)RETVAL, 1);
Branch: 2 branches
BranchTrueFalseTotal
TARGu((UV)RETVAL, 1); 0 0 0
TARGu((UV)RETVAL, 1); 0 0 0
282 0 ST(0) = TARG;
283 0 }
284 0 XSRETURN(1);
285 0 }); }
286  
287  
288  
289 2 ▶XS_EUPXS(XS_MyTest_call_me) { xs::throw_guard(cv, [=]()
Branch: 1 branch
BranchTrueFalseTotal
XS_EUPXS(XS_MyTest_call_me) { xs::throw_guard(cv, [=]() 0 0 0
290 {
291 1 dVAR; dXSARGS;
292 1 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 1 1
293 0 croak_xs_usage(cv, "s");
294 PERL_UNUSED_VAR(ax); /* -Wall */
295 1 SP -= items;
296 {
297 1 ▶ Sub s = ST(0);
Branch: 1 branch
BranchTrueFalseTotal
Sub s = ST(0); 1 0 1
298 1 ▶ if (!s && SvOK(ST(0))) throw "arg is not a 'Sub' reference"
Branch: 3 branches
BranchTrueFalseTotal
if (!s && SvOK(ST(0))) throw "arg is not a 'Sub' reference" 0 1 1
if (!s && SvOK(ST(0))) throw "arg is not a 'Sub' reference" 0 0 0
if (!s && SvOK(ST(0))) throw "arg is not a 'Sub' reference" 0 1 1
299 ;
300 #line 45 "t/MyTest.xs"
301 s();
302 #line 303 "t/MyTest_xsgen.cc"
303 0 PUTBACK;
304 0 return;
305 1 }
306 0 }); }
307  
308 #ifdef __cplusplus
309 extern "C" {
310 #endif
311  
312 70 ▶XS_EXTERNAL(boot_MyTest) { xs::throw_guard(cv, [=]() mutable
Branch: 1 branch
BranchTrueFalseTotal
XS_EXTERNAL(boot_MyTest) { xs::throw_guard(cv, [=]() mutable 35 0 35
313 {
314 #if PERL_VERSION_LE(5, 21, 5)
315 dVAR; dXSARGS;
316 #else
317 35 dVAR; dXSBOOTARGSXSAPIVERCHK;
318 #endif
319 #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
320 char* file = __FILE__;
321 #else
322 35 const char* file = __FILE__;
323 #endif
324  
325 PERL_UNUSED_VAR(file);
326  
327 PERL_UNUSED_VAR(cv); /* -W */
328 PERL_UNUSED_VAR(items); /* -W */
329 #if PERL_VERSION_LE(5, 21, 5)
330 XS_VERSION_BOOTCHECK;
331 # ifdef XS_APIVERSION_BOOTCHECK
332 XS_APIVERSION_BOOTCHECK;
333 # endif
334 #endif
335  
336 35 newXS_deffile("MyTest::bench_sv_payload_get", XS_MyTest_bench_sv_payload_get);
337 35 newXS_deffile("MyTest::throw_exception", XS_MyTest_throw_exception);
338 35 newXS_deffile("MyTest::throw_logic_error", XS_MyTest_throw_logic_error);
339 35 newXS_deffile("MyTest::throw_backtrace", XS_MyTest_throw_backtrace);
340 35 newXS_deffile("MyTest::test_leaks1", XS_MyTest_test_leaks1);
341 35 newXS_deffile("MyTest::call_me", XS_MyTest_call_me);
342  
343 /* Initialisation Section */
344  
345 #line 10 "t/MyTest.xs"
346 {
347 XS_BOOT(MyTest__Cookbook);
348 XS_BOOT(MyTest__Typemap);
349 }
350  
351 #line 352 "t/MyTest_xsgen.cc"
352  
353 /* End of Initialisation Section */
354  
355 #if PERL_VERSION_LE(5, 21, 5)
356 # if PERL_VERSION_GE(5, 9, 0)
357 if (PL_unitcheckav)
358 call_list(PL_scopestack_ix, PL_unitcheckav);
359 # endif
360 XSRETURN_YES;
361 #else
362 35 Perl_xs_boot_epilog(aTHX_ ax);
363 #endif
364 35 }); }
365  
366 #ifdef __cplusplus
367 }
368 #endif
« src/xs/Glob.h ↑ Summary src/xs/Scalar.h »