XS_xsgen.cc

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