File Coverage

t/MyTest_xsgen.cc
Criterion Covered Total %
statement 39 47 82.9
branch 15 46 32.6
condition n/a
subroutine n/a
pod n/a
total 54 93 58.0


line stmt bran cond sub pod time code
1             /*
2             * This file was generated automatically by ExtUtils::ParseXS version 3.34 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
11             #include
12              
13             using namespace xs;
14             using namespace panda;
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 ExtUtils::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             #line 161 "t/MyTest_xsgen.cc"
161              
162              
163 6           XS_EUPXS(XS_MyTest_default_trace_depth) { xs::throw_guard(cv, [=]()
164             {
165 3           dVAR; dXSARGS;
166 3 50         if (items != 0)
167 0           croak_xs_usage(cv, "");
168             {
169             size_t RETVAL;
170 3 50         dXSTARG;
    0          
171             #line 11 "t/MyTest.xs"
172             RETVAL = Backtrace().get_backtrace_info()->frames.size();
173             #line 174 "t/MyTest_xsgen.cc"
174 3 50         XSprePUSH; PUSHu((UV)RETVAL);
    50          
175             }
176 3           XSRETURN(1);
177 3 50         }); }
178              
179              
180              
181 2           XS_EUPXS(XS_MyTest_call) { xs::throw_guard(cv, [=]()
182             {
183 1           dVAR; dXSARGS;
184 1 50         if (items != 1)
185 0           croak_xs_usage(cv, "cb");
186             PERL_UNUSED_VAR(ax); /* -Wall */
187 1           SP -= items;
188             {
189 2 50         Sub cb = ST(0);
190 1 50         if (!cb && SvOK(ST(0))) throw "arg is not a 'Sub' reference"
    0          
    0          
    0          
    50          
191 0           ;
192             #line 15 "t/MyTest.xs"
193             cb();
194             #line 195 "t/MyTest_xsgen.cc"
195 0           PUTBACK;
196 0           return;
197             }
198 1 0         }); }
199              
200              
201              
202 2           XS_EUPXS(XS_MyTest_throw_logic_error) { xs::throw_guard(cv, [=]()
203             {
204 1           dVAR; dXSARGS;
205 1 50         if (items != 0)
206 0           croak_xs_usage(cv, "");
207             PERL_UNUSED_VAR(ax); /* -Wall */
208 1           SP -= items;
209             {
210             #line 19 "t/MyTest.xs"
211             throw std::logic_error("my-logic-error");
212             #line 213 "t/MyTest_xsgen.cc"
213             PUTBACK;
214             return;
215             }
216 1 0         }); }
217              
218              
219              
220 4           XS_EUPXS(XS_MyTest_throw_backtrace) { xs::throw_guard(cv, [=]()
221             {
222 2           dVAR; dXSARGS;
223 2 50         if (items != 0)
224 0           croak_xs_usage(cv, "");
225             PERL_UNUSED_VAR(ax); /* -Wall */
226 2           SP -= items;
227             {
228             #line 23 "t/MyTest.xs"
229             throw panda::exception("my-error");
230             #line 231 "t/MyTest_xsgen.cc"
231             PUTBACK;
232             return;
233             }
234 2 0         }); }
235              
236              
237              
238 2           XS_EUPXS(XS_MyTest_throw_with_newline) { xs::throw_guard(cv, [=]()
239             {
240 1           dVAR; dXSARGS;
241 1 50         if (items != 0)
242 0           croak_xs_usage(cv, "");
243             PERL_UNUSED_VAR(ax); /* -Wall */
244 1           SP -= items;
245             {
246             #line 27 "t/MyTest.xs"
247             throw std::logic_error("my-error\n");
248             #line 249 "t/MyTest_xsgen.cc"
249             PUTBACK;
250             return;
251             }
252 1 0         }); }
253              
254             #ifdef __cplusplus
255             extern "C"
256             #endif
257              
258 10           XS_EXTERNAL(boot_MyTest) { xs::throw_guard(cv, [=]() mutable
259             {
260             #if PERL_VERSION_LE(5, 21, 5)
261             dVAR; dXSARGS;
262             #else
263 5 50         dVAR; dXSBOOTARGSXSAPIVERCHK;
    50          
264             #endif
265             #if (PERL_REVISION == 5 && PERL_VERSION < 9)
266             char* file = __FILE__;
267             #else
268 5           const char* file = __FILE__;
269             #endif
270              
271             PERL_UNUSED_VAR(file);
272              
273             PERL_UNUSED_VAR(cv); /* -W */
274             PERL_UNUSED_VAR(items); /* -W */
275             #if PERL_VERSION_LE(5, 21, 5)
276             XS_VERSION_BOOTCHECK;
277             # ifdef XS_APIVERSION_BOOTCHECK
278             XS_APIVERSION_BOOTCHECK;
279             # endif
280             #endif
281              
282 5           newXS_deffile("MyTest::default_trace_depth", XS_MyTest_default_trace_depth);
283 5           newXS_deffile("MyTest::call", XS_MyTest_call);
284 5           newXS_deffile("MyTest::throw_logic_error", XS_MyTest_throw_logic_error);
285 5           newXS_deffile("MyTest::throw_backtrace", XS_MyTest_throw_backtrace);
286 5           newXS_deffile("MyTest::throw_with_newline", XS_MyTest_throw_with_newline);
287             #if PERL_VERSION_LE(5, 21, 5)
288             # if PERL_VERSION_GE(5, 9, 0)
289             if (PL_unitcheckav)
290             call_list(PL_scopestack_ix, PL_unitcheckav);
291             # endif
292             XSRETURN_YES;
293             #else
294 5           Perl_xs_boot_epilog(aTHX_ ax);
295             #endif
296 5 50         }); }
297