MRO_Compat.c

filter: Statementstmt 0.0% 0 / 4 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 4 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« example/inc/Module/Install/Base.pm ↑ Summary blib/lib/XS/MRO/Compat.pm »
1 /*
2 * This file was generated automatically by ExtUtils::ParseXS version 3.63 from the
3 * contents of MRO_Compat.xs. Do not edit this file, edit MRO_Compat.xs instead.
4 *
5 * ANY CHANGES MADE HERE WILL BE LOST!
6 *
7 */
8  
9 #line 1 "MRO_Compat.xs"
10 #define PERL_NO_GET_CONTEXT
11 #include <EXTERN.h>
12 #include <perl.h>
13 #include <XSUB.h>
14  
15 #include "ppport.h"
16  
17 #include "mro_compat.h"
18  
19 #if MRO_COMPAT
20  
21 #define ISA_CACHE "::XS::MRO::Compat::"
22  
23 /* call &mro::get_linear_isa */
24 AV*
25 mro_compat_mro_get_linear_isa(pTHX_ HV* const stash){
26 dVAR;
27 GV* cachegv;
28 AV* isa; /* linearized ISA cache */
29 SV* gen; /* package generation */
30  
31 assert(stash != NULL);
32 assert(SvTYPE(stash) == SVt_PVHV);
33  
34 cachegv = *(GV**)hv_fetchs(stash, ISA_CACHE, TRUE);
35 if(!isGV(cachegv))
36 gv_init(cachegv, stash, ISA_CACHE, sizeof(ISA_CACHE)-1, GV_ADD);
37  
38 isa = GvAVn(cachegv);
39 gen = GvSVn(cachegv);
40  
41 if(SvIOK(gen) && SvIVX(gen) == (IV)mro_get_pkg_gen(stash)){
42 return isa; /* returns the cache if available */
43 }
44  
45 SvREADONLY_off(isa); /* unlock */
46 av_clear(isa);
47  
48  
49 {
50 SV* avref;
51 dSP;
52  
53 ENTER;
54 SAVETMPS;
55  
56 PUSHMARK(SP);
57 mXPUSHp(HvNAME_get(stash), HvNAMELEN_get(stash));
58 PUTBACK;
59  
60 call_pv("mro::get_linear_isa", G_SCALAR);
61  
62 SPAGAIN;
63 avref = POPs;
64 PUTBACK;
65  
66 if(SvROK(avref) && SvTYPE(SvRV(avref)) == SVt_PVAV){
67 AV* const av = (AV*)SvRV(avref);
68 SV** svp = AvARRAY(av);
69 SV** const end = svp + AvFILLp(av) + 1;
70  
71 while(svp != end){
72 HV* const st = gv_stashsv(*svp, FALSE);
73 if(st)
74 av_push(isa, newSVpv(HvNAME_get(st), 0));
75  
76 svp++;
77 }
78 }
79 else{
80 Perl_croak(aTHX_ "panic: mro::get_linear_isa() didn't return an ARRAY reference");
81 }
82  
83 FREETMPS;
84 LEAVE;
85 }
86  
87 SvREADONLY_on(isa); /* lock */
88  
89 sv_setuv(gen, (UV)mro_get_pkg_gen(stash));
90 return isa;
91 }
92  
93 /* call &mro::method_changed_in */
94 void
95 mro_compat_mro_method_changed_in(pTHX_ HV* const stash){
96 dVAR;
97 dSP;
98  
99 assert(stash != NULL);
100 assert(SvTYPE(stash) == SVt_PVHV);
101  
102 ENTER;
103 SAVETMPS;
104  
105 PUSHMARK(SP);
106 mXPUSHp(HvNAME_get(stash), HvNAMELEN_get(stash));
107 PUTBACK;
108  
109 call_pv("mro::method_changed_in", G_VOID | G_DISCARD);
110  
111 FREETMPS;
112 LEAVE;
113 }
114  
115 #endif /* !MRO_COMPAT */
116  
117 #line 118 "MRO_Compat.c"
118 #ifndef PERL_UNUSED_VAR
119 # define PERL_UNUSED_VAR(var) if (0) var = var
120 #endif
121  
122 #ifndef dVAR
123 # define dVAR dNOOP
124 #endif
125  
126  
127 /* This stuff is not part of the API! You have been warned. */
128 #ifndef PERL_VERSION_DECIMAL
129 # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
130 #endif
131 #ifndef PERL_DECIMAL_VERSION
132 # define PERL_DECIMAL_VERSION \
133 PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
134 #endif
135 #ifndef PERL_VERSION_GE
136 # define PERL_VERSION_GE(r,v,s) \
137 (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
138 #endif
139 #ifndef PERL_VERSION_LE
140 # define PERL_VERSION_LE(r,v,s) \
141 (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
142 #endif
143  
144 /* XS_INTERNAL is the explicit static-linkage variant of the default
145 * XS macro.
146 *
147 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
148 * "static", ie. it exports XSUB symbols. You probably don't want that
149 * for anything but the BOOT XSUB.
150 *
151 * See XSUB.h in core!
152 */
153  
154  
155 /* TODO: This might be compatible further back than 5.10.0. */
156 #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
157 # undef XS_EXTERNAL
158 # undef XS_INTERNAL
159 # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
160 # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
161 # define XS_INTERNAL(name) static XSPROTO(name)
162 # endif
163 # if defined(__SYMBIAN32__)
164 # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
165 # define XS_INTERNAL(name) EXPORT_C static XSPROTO(name)
166 # endif
167 # ifndef XS_EXTERNAL
168 # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
169 # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
170 # define XS_INTERNAL(name) static void name(pTHX_ CV* cv __attribute__unused__)
171 # else
172 # ifdef __cplusplus
173 # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
174 # define XS_INTERNAL(name) static XSPROTO(name)
175 # else
176 # define XS_EXTERNAL(name) XSPROTO(name)
177 # define XS_INTERNAL(name) static XSPROTO(name)
178 # endif
179 # endif
180 # endif
181 #endif
182  
183 /* perl >= 5.10.0 && perl <= 5.15.1 */
184  
185  
186 /* The XS_EXTERNAL macro is used for functions that must not be static
187 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
188 * macro defined, the best we can do is assume XS is the same.
189 * Dito for XS_INTERNAL.
190 */
191 #ifndef XS_EXTERNAL
192 # define XS_EXTERNAL(name) XS(name)
193 #endif
194 #ifndef XS_INTERNAL
195 # define XS_INTERNAL(name) XS(name)
196 #endif
197  
198 /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
199 * internal macro that we're free to redefine for varying linkage due
200 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
201 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
202 */
203  
204 #undef XS_EUPXS
205 #if defined(PERL_EUPXS_ALWAYS_EXPORT)
206 # define XS_EUPXS(name) XS_EXTERNAL(name)
207 #else
208 /* default to internal */
209 # define XS_EUPXS(name) XS_INTERNAL(name)
210 #endif
211  
212 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
213 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
214  
215 /* prototype to pass -Wmissing-prototypes */
216 static void
217 S_croak_xs_usage(const CV *const cv, const char *const params);
218  
219 static void
220 S_croak_xs_usage(const CV *const cv, const char *const params)
221 {
222 const GV *const gv = CvGV(cv);
223  
224 PERL_ARGS_ASSERT_CROAK_XS_USAGE;
225  
226 if (gv) {
227 const char *const gvname = GvNAME(gv);
228 const HV *const stash = GvSTASH(gv);
229 const char *const hvname = stash ? HvNAME(stash) : NULL;
230  
231 if (hvname)
232 Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
233 else
234 Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
235 } else {
236 /* Pants. I don't think that it should be possible to get here. */
237 Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
238 }
239 }
240 #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
241  
242 #define croak_xs_usage S_croak_xs_usage
243  
244 #endif
245  
246 /* NOTE: the prototype of newXSproto() is different in versions of perls,
247 * so we define a portable version of newXSproto()
248 */
249 #ifdef newXS_flags
250 #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
251 #else
252 #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
253 #endif /* !defined(newXS_flags) */
254  
255 #if PERL_VERSION_LE(5, 21, 5)
256 # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
257 #else
258 # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
259 #endif
260  
261 /* simple backcompat versions of the TARGx() macros with no optimisation */
262 #ifndef TARGi
263 # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
264 # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
265 # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
266 #endif
267  
268 #line 269 "MRO_Compat.c"
269 #ifdef __cplusplus
270 extern "C" {
271 #endif
272 XS_EXTERNAL(boot_XS__MRO__Compat); /* prototype to pass -Wmissing-prototypes */
273 0 XS_EXTERNAL(boot_XS__MRO__Compat)
274 {
275 #if PERL_VERSION_LE(5, 21, 5)
276 dVAR; dXSARGS;
277 #else
278 0 dVAR; dXSBOOTARGSXSAPIVERCHK;
279 #endif
280  
281 PERL_UNUSED_VAR(cv); /* -W */
282 PERL_UNUSED_VAR(items); /* -W */
283 #if PERL_VERSION_LE(5, 21, 5)
284 XS_VERSION_BOOTCHECK;
285 # ifdef XS_APIVERSION_BOOTCHECK
286 XS_APIVERSION_BOOTCHECK;
287 # endif
288 #endif
289  
290 #if PERL_VERSION_LE(5, 21, 5)
291 # if PERL_VERSION_GE(5, 9, 0)
292 if (PL_unitcheckav)
293 call_list(PL_scopestack_ix, PL_unitcheckav);
294 # endif
295 XSRETURN_YES;
296 #else
297 0 Perl_xs_boot_epilog(aTHX_ ax);
298 #endif
299 0 }
300  
301 #ifdef __cplusplus
302 }
303 #endif
« example/inc/Module/Install/Base.pm ↑ Summary blib/lib/XS/MRO/Compat.pm »