File Coverage

Recursive_xsgen.cc
Criterion Covered Total %
statement 80 112 71.4
branch 55 150 36.6
condition n/a
subroutine n/a
pod n/a
total 135 262 51.5


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 Recursive.xs. Do not edit this file, edit Recursive.xs instead.
4             *
5             * ANY CHANGES MADE HERE WILL BE LOST!
6             *
7             */
8              
9             #line 1 "Recursive.xs"
10             #include
11             #include
12             #include
13             #include
14             #include
15              
16             using namespace xs;
17              
18             #line 19 "Recursive_xsgen.cc"
19             #ifndef PERL_UNUSED_VAR
20             # define PERL_UNUSED_VAR(var) if (0) var = var
21             #endif
22              
23             #ifndef dVAR
24             # define dVAR dNOOP
25             #endif
26              
27              
28             /* This stuff is not part of the API! You have been warned. */
29             #ifndef PERL_VERSION_DECIMAL
30             # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
31             #endif
32             #ifndef PERL_DECIMAL_VERSION
33             # define PERL_DECIMAL_VERSION \
34             PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
35             #endif
36             #ifndef PERL_VERSION_GE
37             # define PERL_VERSION_GE(r,v,s) \
38             (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
39             #endif
40             #ifndef PERL_VERSION_LE
41             # define PERL_VERSION_LE(r,v,s) \
42             (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
43             #endif
44              
45             /* XS_INTERNAL is the explicit static-linkage variant of the default
46             * XS macro.
47             *
48             * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
49             * "STATIC", ie. it exports XSUB symbols. You probably don't want that
50             * for anything but the BOOT XSUB.
51             *
52             * See XSUB.h in core!
53             */
54              
55              
56             /* TODO: This might be compatible further back than 5.10.0. */
57             #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
58             # undef XS_EXTERNAL
59             # undef XS_INTERNAL
60             # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
61             # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
62             # define XS_INTERNAL(name) STATIC XSPROTO(name)
63             # endif
64             # if defined(__SYMBIAN32__)
65             # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
66             # define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
67             # endif
68             # ifndef XS_EXTERNAL
69             # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
70             # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
71             # define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
72             # else
73             # ifdef __cplusplus
74             # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
75             # define XS_INTERNAL(name) static XSPROTO(name)
76             # else
77             # define XS_EXTERNAL(name) XSPROTO(name)
78             # define XS_INTERNAL(name) STATIC XSPROTO(name)
79             # endif
80             # endif
81             # endif
82             #endif
83              
84             /* perl >= 5.10.0 && perl <= 5.15.1 */
85              
86              
87             /* The XS_EXTERNAL macro is used for functions that must not be static
88             * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
89             * macro defined, the best we can do is assume XS is the same.
90             * Dito for XS_INTERNAL.
91             */
92             #ifndef XS_EXTERNAL
93             # define XS_EXTERNAL(name) XS(name)
94             #endif
95             #ifndef XS_INTERNAL
96             # define XS_INTERNAL(name) XS(name)
97             #endif
98              
99             /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
100             * internal macro that we're free to redefine for varying linkage due
101             * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
102             * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
103             */
104              
105             #undef XS_EUPXS
106             #if defined(PERL_EUPXS_ALWAYS_EXPORT)
107             # define XS_EUPXS(name) XS_EXTERNAL(name)
108             #else
109             /* default to internal */
110             # define XS_EUPXS(name) XS_INTERNAL(name)
111             #endif
112              
113             #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
114             #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
115              
116             /* prototype to pass -Wmissing-prototypes */
117             STATIC void
118             S_croak_xs_usage(const CV *const cv, const char *const params);
119              
120             STATIC void
121             S_croak_xs_usage(const CV *const cv, const char *const params)
122             {
123             const GV *const gv = CvGV(cv);
124              
125             PERL_ARGS_ASSERT_CROAK_XS_USAGE;
126              
127             if (gv) {
128             const char *const gvname = GvNAME(gv);
129             const HV *const stash = GvSTASH(gv);
130             const char *const hvname = stash ? HvNAME(stash) : NULL;
131              
132             if (hvname)
133             Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
134             else
135             Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
136             } else {
137             /* Pants. I don't think that it should be possible to get here. */
138             Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
139             }
140             }
141             #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
142              
143             #define croak_xs_usage S_croak_xs_usage
144              
145             #endif
146              
147             /* NOTE: the prototype of newXSproto() is different in versions of perls,
148             * so we define a portable version of newXSproto()
149             */
150             #ifdef newXS_flags
151             #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
152             #else
153             #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
154             #endif /* !defined(newXS_flags) */
155              
156             #if PERL_VERSION_LE(5, 21, 5)
157             # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
158             #else
159             # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
160             #endif
161              
162             #line 163 "Recursive_xsgen.cc"
163              
164              
165 40           XS_EUPXS(XS_Data__Recursive_lclone) { xs::throw_guard(cv, [=]()
166             {
167 20           dVAR; dXSARGS;
168 20 50         if (items != 1)
169 0           croak_xs_usage(cv, "source");
170             {
171 40           Scalar RETVAL;
172 20           SV* source = ST(0)
173             ;
174             #line 28 "Recursive.xs"
175             RETVAL = clone(source, 0);
176             #line 177 "Recursive_xsgen.cc"
177             {
178             SV * RETVALSV;
179 19           RETVALSV = NULL;
180 19 50         if (!RETVAL) XSRETURN_UNDEF;
181 19           RETVALSV = RETVAL.detach();
182 19 50         RETVALSV = sv_2mortal(RETVALSV);
183 19 50         ST(0) = RETVALSV;
184             }
185             }
186 19           XSRETURN(1);
187 20 50         }); }
188              
189              
190              
191 22           XS_EUPXS(XS_Data__Recursive_clone) { xs::throw_guard(cv, [=]()
192             {
193 11           dVAR; dXSARGS;
194 11 50         if (items < 1 || items > 2)
    50          
195 0           croak_xs_usage(cv, "source, flags= CloneFlags::TRACK_REFS");
196             {
197 22           Scalar RETVAL;
198 11           SV* source = ST(0)
199             ;
200             int flags;
201              
202 11 100         if (items < 2)
203 9           flags = CloneFlags::TRACK_REFS;
204             else {
205 0 0         flags = (int)SvIV(ST(1))
206 2 50         ;
207             }
208             #line 32 "Recursive.xs"
209             RETVAL = clone(source, flags);
210             #line 211 "Recursive_xsgen.cc"
211             {
212             SV * RETVALSV;
213 10           RETVALSV = NULL;
214 10 50         if (!RETVAL) XSRETURN_UNDEF;
215 10           RETVALSV = RETVAL.detach();
216 10 50         RETVALSV = sv_2mortal(RETVALSV);
217 10 50         ST(0) = RETVALSV;
218             }
219             }
220 10           XSRETURN(1);
221 11 50         }); }
222              
223              
224              
225 16           XS_EUPXS(XS_Data__Recursive_merge) { xs::throw_guard(cv, [=]()
226             {
227 8           dVAR; dXSARGS;
228 8 50         if (items < 2 || items > 3)
    50          
229 0           croak_xs_usage(cv, "dest, source, flags= 0");
230             {
231 16           Scalar RETVAL;
232 8           SV* dest = ST(0)
233             ;
234 8           SV* source = ST(1)
235             ;
236             int flags;
237              
238 8 100         if (items < 3)
239 4           flags = 0;
240             else {
241 0 0         flags = (int)SvIV(ST(2))
242 4 50         ;
243             }
244             #line 36 "Recursive.xs"
245             RETVAL = merge(Sv(dest), Sv(source), flags);
246             #line 247 "Recursive_xsgen.cc"
247             {
248             SV * RETVALSV;
249 8           RETVALSV = NULL;
250 8 50         if (!RETVAL) XSRETURN_UNDEF;
251 8           RETVALSV = RETVAL.detach();
252 8 50         RETVALSV = sv_2mortal(RETVALSV);
253 8 50         ST(0) = RETVALSV;
254             }
255             }
256 8           XSRETURN(1);
257 8 50         }); }
258              
259              
260              
261 40           XS_EUPXS(XS_Data__Recursive_hash_merge) { xs::throw_guard(cv, [=]()
262             {
263 20           dVAR; dXSARGS;
264 20 50         if (items < 2 || items > 3)
    50          
265 0           croak_xs_usage(cv, "dest, source, flags= 0");
266             {
267 40           Scalar RETVAL;
268 40 50         Hash dest = ST(0);
    50          
269 20 100         if (!dest && SvOK(ST(0))) throw "arg is not a 'Hash' reference"
    50          
    50          
    50          
    50          
270 0           ;
271 40 50         Hash source = ST(1);
    50          
272 20 100         if (!source && SvOK(ST(1))) throw "arg is not a 'Hash' reference"
    50          
    50          
    50          
    50          
273 0           ;
274             int flags;
275              
276 20 100         if (items < 3)
277 10           flags = 0;
278             else {
279 0 0         flags = (int)SvIV(ST(2))
280 10 50         ;
281             }
282             #line 40 "Recursive.xs"
283             auto result = merge(dest, source, flags);
284             if (result == dest) RETVAL = ST(0); // hash not changed - return the same Ref for speed
285             else RETVAL = Ref::create(result);
286             #line 287 "Recursive_xsgen.cc"
287             {
288             SV * RETVALSV;
289 19           RETVALSV = NULL;
290 19 50         if (!RETVAL) XSRETURN_UNDEF;
291 19           RETVALSV = RETVAL.detach();
292 19 50         RETVALSV = sv_2mortal(RETVALSV);
293 19 50         ST(0) = RETVALSV;
294             }
295             }
296 20           XSRETURN(1);
297 20 50         }); }
298              
299              
300              
301 0           XS_EUPXS(XS_Data__Recursive_array_merge) { xs::throw_guard(cv, [=]()
302             {
303 0           dVAR; dXSARGS;
304 0 0         if (items < 2 || items > 3)
    0          
305 0           croak_xs_usage(cv, "dest, source, flags= 0");
306             {
307 0           Scalar RETVAL;
308 0 0         Array dest = ST(0);
    0          
309 0 0         if (!dest && SvOK(ST(0))) throw "arg is not a 'Array' reference"
    0          
    0          
    0          
    0          
310 0           ;
311 0 0         Array source = ST(1);
    0          
312 0 0         if (!source && SvOK(ST(1))) throw "arg is not a 'Array' reference"
    0          
    0          
    0          
    0          
313 0           ;
314             int flags;
315              
316 0 0         if (items < 3)
317 0           flags = 0;
318             else {
319 0 0         flags = (int)SvIV(ST(2))
320 0 0         ;
321             }
322             #line 46 "Recursive.xs"
323             auto result = merge(dest, source, flags);
324             if (result == dest) RETVAL = ST(0); // array not changed - return the same Ref for speed
325             else RETVAL = Ref::create(result);
326             #line 327 "Recursive_xsgen.cc"
327             {
328             SV * RETVALSV;
329 0           RETVALSV = NULL;
330 0 0         if (!RETVAL) XSRETURN_UNDEF;
331 0           RETVALSV = RETVAL.detach();
332 0 0         RETVALSV = sv_2mortal(RETVALSV);
333 0 0         ST(0) = RETVALSV;
334             }
335             }
336 0           XSRETURN(1);
337 0 0         }); }
338              
339              
340              
341 114           XS_EUPXS(XS_Data__Recursive_compare) { xs::throw_guard(cv, [=]()
342             {
343 57           dVAR; dXSARGS;
344 57 50         if (items != 2)
345 0           croak_xs_usage(cv, "first, second");
346             {
347             bool RETVAL;
348 114           Sv first = ST(0)
349             ;
350 114           Sv second = ST(1)
351             ;
352             #line 51 "Recursive.xs"
353             RETVAL = compare(first, second);
354             #line 355 "Recursive_xsgen.cc"
355 57 100         ST(0) = boolSV(RETVAL);
356             }
357 57           XSRETURN(1);
358 57 50         }); }
359              
360             #ifdef __cplusplus
361             extern "C"
362             #endif
363              
364 14           XS_EXTERNAL(boot_Data__Recursive) { xs::throw_guard(cv, [=]() mutable
365             {
366             #if PERL_VERSION_LE(5, 21, 5)
367             dVAR; dXSARGS;
368             #else
369 7 50         dVAR; dXSBOOTARGSXSAPIVERCHK;
    50          
370             #endif
371             #if (PERL_REVISION == 5 && PERL_VERSION < 9)
372             char* file = __FILE__;
373             #else
374 7           const char* file = __FILE__;
375             #endif
376              
377             PERL_UNUSED_VAR(file);
378              
379             PERL_UNUSED_VAR(cv); /* -W */
380             PERL_UNUSED_VAR(items); /* -W */
381             #if PERL_VERSION_LE(5, 21, 5)
382             XS_VERSION_BOOTCHECK;
383             # ifdef XS_APIVERSION_BOOTCHECK
384             XS_APIVERSION_BOOTCHECK;
385             # endif
386             #endif
387              
388 7           newXS_deffile("Data::Recursive::lclone", XS_Data__Recursive_lclone);
389 7           newXS_deffile("Data::Recursive::clone", XS_Data__Recursive_clone);
390 7           newXS_deffile("Data::Recursive::merge", XS_Data__Recursive_merge);
391 7           newXS_deffile("Data::Recursive::hash_merge", XS_Data__Recursive_hash_merge);
392 7           newXS_deffile("Data::Recursive::array_merge", XS_Data__Recursive_array_merge);
393 7           newXS_deffile("Data::Recursive::compare", XS_Data__Recursive_compare);
394              
395             /* Initialisation Section */
396              
397             #line 12 "Recursive.xs"
398             {
399             Stash s("Data::Recursive");
400             xs::exp::create_constants(s, {
401             {"TRACK_REFS", CloneFlags::TRACK_REFS},
402             {"ARRAY_CONCAT", MergeFlags::ARRAY_CONCAT},
403             {"ARRAY_MERGE", MergeFlags::ARRAY_MERGE},
404             {"COPY_DEST", MergeFlags::COPY_DEST},
405             {"LAZY", MergeFlags::LAZY},
406             {"SKIP_UNDEF", MergeFlags::SKIP_UNDEF},
407             {"DELETE_UNDEF", MergeFlags::DELETE_UNDEF},
408             {"COPY_SOURCE", MergeFlags::COPY_SOURCE},
409             {"COPY_ALL", MergeFlags::COPY_ALL}
410             });
411             }
412              
413             #line 414 "Recursive_xsgen.cc"
414              
415             /* End of Initialisation Section */
416              
417             #if PERL_VERSION_LE(5, 21, 5)
418             # if PERL_VERSION_GE(5, 9, 0)
419             if (PL_unitcheckav)
420             call_list(PL_scopestack_ix, PL_unitcheckav);
421             # endif
422             XSRETURN_YES;
423             #else
424 7           Perl_xs_boot_epilog(aTHX_ ax);
425             #endif
426 14 50         }); }
427