xs-src/MouseTypeConstraints.xs

filter: Statementstmt 92.8% 325 / 350 Branchbran 70.7% 232 / 328 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 82.1% 557 / 678 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« lib/Mouse.xs ↑ Summary xs-src/MouseAccessor.xs »
1 /*
2 * TypeConstraint stuff
3 * - Mouse::Util::TypeConstraints (including OptimizedConstraints)
4 * - Mouse::Meta::TypeConstraint
5 */
6  
7 #include "mouse.h"
8 #include "xs_version.h"
9  
10 #define MY_CXT_KEY "Mouse::Util::TypeConstraints::_guts" XS_VERSION
11 typedef struct sui_cxt{
12 GV* universal_isa;
13 GV* universal_can;
14 AV* tc_extra_args;
15 } my_cxt_t;
16 START_MY_CXT
17  
18 typedef int (*check_fptr_t)(pTHX_ SV* const data, SV* const sv);
19  
20 static
21 XSPROTO(XS_Mouse_constraint_check);
22  
23 static MGVTBL mouse_util_type_constraints_vtbl; /* not used, only for identity */
24  
25 /*
26 NOTE: mouse_tc_check() handles GETMAGIC
27 */
28 int
29 3399 mouse_tc_check(pTHX_ SV* const tc_code, SV* const sv) {
30 3399 CV* const cv = (CV*)SvRV(tc_code);
31 assert(SvTYPE(cv) == SVt_PVCV);
32  
33 3399 ▶ if(CvXSUB(cv) == XS_Mouse_constraint_check){ /* built-in type constraints */
Branch: 1 branch
BranchTrueFalseTotal
if(CvXSUB(cv) == XS_Mouse_constraint_check){ /* built-in type constraints */ 3049 350 3399
34 3049 MAGIC* const mg = MOUSE_get_magic(aTHX_ cv, &mouse_util_type_constraints_vtbl);
35 #ifndef MULTIPLICITY
36 assert(CvXSUBANY(cv).any_ptr != NULL);
37 #endif
38 assert(mg->mg_ptr != NULL);
39  
40 3049 ▶ SvGETMAGIC(sv);
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(sv); 18 3031 3049
SvGETMAGIC(sv); 0 18 18
41 /* call the check function directly, skipping call_sv() */
42 3049 return CALL_FPTR((check_fptr_t)mg->mg_ptr)(aTHX_ mg->mg_obj, sv);
43 }
44 else { /* custom */
45 int ok;
46 350 dSP;
47 dMY_CXT;
48  
49 350 ENTER;
50 350 SAVETMPS;
51  
52 350 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 350 350
53 350 ▶ XPUSHs(sv);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv); 0 350 350
54 350 ▶ if( MY_CXT.tc_extra_args ) {
Branch: 1 branch
BranchTrueFalseTotal
if( MY_CXT.tc_extra_args ) { 2 348 350
55 2 AV* const av = MY_CXT.tc_extra_args;
56 2 I32 const len = AvFILLp(av) + 1;
57 int i;
58 5 ▶ for(i = 0; i < len; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < len; i++) { 3 2 5
59 3 ▶ XPUSHs( AvARRAY(av)[i] );
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs( AvARRAY(av)[i] ); 0 3 3
60 }
61 }
62 350 PUTBACK;
63  
64 350 call_sv(tc_code, G_SCALAR);
65  
66 350 SPAGAIN;
67 350 ok = sv_true(POPs);
68 350 PUTBACK;
69  
70 350 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 350 0 350
71 350 LEAVE;
72  
73 350 return ok;
74 }
75 }
76  
77 /*
78 The following type check functions return an integer, not a bool, to keep
79 the code simple,
80 so if you assign these return value to a bool variable, you must use
81 "expr ? TRUE : FALSE".
82 */
83  
84 int
85 147 mouse_tc_Any(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv PERL_UNUSED_DECL) {
86 assert(sv);
87 147 return TRUE;
88 }
89  
90 int
91 89 mouse_tc_Bool(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
92 assert(sv);
93  
94 89 ▶ if(sv_true(sv)){
Branch: 1 branch
BranchTrueFalseTotal
if(sv_true(sv)){ 69 20 89
95 69 ▶ if(SvPOKp(sv)){ /* "1" */
Branch: 1 branch
BranchTrueFalseTotal
if(SvPOKp(sv)){ /* "1" */ 17 52 69
96 17 ▶ return SvCUR(sv) == 1 && SvPVX(sv)[0] == '1';
Branch: 2 branches
BranchTrueFalseTotal
return SvCUR(sv) == 1 && SvPVX(sv)[0] == '1'; 6 11 17
return SvCUR(sv) == 1 && SvPVX(sv)[0] == '1'; 2 4 6
97 }
98 52 ▶ else if(SvIOKp(sv)){
Branch: 1 branch
BranchTrueFalseTotal
else if(SvIOKp(sv)){ 16 36 52
99 16 return SvIVX(sv) == 1;
100 }
101 36 ▶ else if(SvNOKp(sv)){
Branch: 1 branch
BranchTrueFalseTotal
else if(SvNOKp(sv)){ 2 34 36
102 2 return SvNVX(sv) == 1.0;
103 }
104 else{
105 STRLEN len;
106 34 char * ptr = SvPV(sv, len);
107 34 ▶ if(len == 1 && ptr[0] == '1'){
Branch: 2 branches
BranchTrueFalseTotal
if(len == 1 && ptr[0] == '1'){ 1 33 34
if(len == 1 && ptr[0] == '1'){ 1 0 1
108 1 return TRUE;
109 } else {
110 33 return FALSE;
111 }
112 }
113 }
114 else{
115 /* any false value is a boolean */
116 20 return TRUE;
117 }
118 }
119  
120 int
121 94 mouse_tc_Undef(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
122 assert(sv);
123 94 return !SvOK(sv);
124 }
125  
126 int
127 75 mouse_tc_Defined(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
128 assert(sv);
129 75 return SvOK(sv);
130 }
131  
132 int
133 104 mouse_tc_Value(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
134 assert(sv);
135 104 ▶ return SvOK(sv) && !SvROK(sv);
Branch: 2 branches
BranchTrueFalseTotal
return SvOK(sv) && !SvROK(sv); 99 5 104
return SvOK(sv) && !SvROK(sv); 62 37 99
136 }
137  
138 int
139 101 mouse_tc_Num(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
140 assert(sv);
141 101 return LooksLikeNumber(sv);
142 }
143  
144 static int
145 18 S_nv_is_integer(pTHX_ NV const nv) {
146 18 ▶ if(nv == (NV)(IV)nv){
Branch: 1 branch
BranchTrueFalseTotal
if(nv == (NV)(IV)nv){ 0 18 18
147 0 return TRUE;
148 }
149 else {
150 const char* p;
151 #if defined(USE_QUADMATH)
152 char buf[128]; /* Must fit __float128 */
153 // my_snprintf cannot handle ".*Q" modifier correctly, so hard-code NV_DIG as the field-width
154 PERL_UNUSED_RESULT(my_snprintf(buf, sizeof(buf), "%.33Qg", nv));
155 #else
156 char buf[64]; /* Must fit sprintf/Gconvert of longest NV */
157 18 PERL_UNUSED_RESULT(Gconvert(nv, NV_DIG, 0, buf));
158 #endif
159 18 p = &buf[0];
160  
161 /* -?[0-9]+ */
162 18 ▶ if(*p == '-') p++;
Branch: 1 branch
BranchTrueFalseTotal
if(*p == '-') p++; 3 15 18
163  
164 106 ▶ while(*p){
Branch: 1 branch
BranchTrueFalseTotal
while(*p){ 106 0 106
165 106 ▶ if(!isDIGIT(*p)){
Branch: 1 branch
BranchTrueFalseTotal
if(!isDIGIT(*p)){ 18 88 106
166 18 return FALSE;
167 }
168 88 p++;
169 }
170 0 return TRUE;
171 }
172 }
173  
174 int
175 405 mouse_tc_Int(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
176 assert(sv);
177 405 ▶ if(SvPOKp(sv)){
Branch: 1 branch
BranchTrueFalseTotal
if(SvPOKp(sv)){ 69 336 405
178 69 int const num_type = grok_number(SvPVX(sv), SvCUR(sv), NULL);
179 69 ▶ return num_type && !(num_type & IS_NUMBER_NOT_INT);
Branch: 2 branches
BranchTrueFalseTotal
return num_type && !(num_type & IS_NUMBER_NOT_INT); 8 61 69
return num_type && !(num_type & IS_NUMBER_NOT_INT); 6 2 8
180 }
181 336 ▶ else if(SvIOKp(sv)){
Branch: 1 branch
BranchTrueFalseTotal
else if(SvIOKp(sv)){ 273 63 336
182 273 return TRUE;
183 }
184 63 ▶ else if(SvNOKp(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
else if(SvNOKp(sv)) { 18 45 63
185 18 return S_nv_is_integer(aTHX_ SvNVX(sv));
186 }
187 45 return FALSE;
188 }
189  
190 int
191 385 mouse_tc_Str(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
192 assert(sv);
193 385 ▶ return SvOK(sv) && !SvROK(sv) && !isGV(sv);
Branch: 3 branches
BranchTrueFalseTotal
return SvOK(sv) && !SvROK(sv) && !isGV(sv); 373 12 385
return SvOK(sv) && !SvROK(sv) && !isGV(sv); 326 47 373
return SvOK(sv) && !SvROK(sv) && !isGV(sv); 325 1 326
194 }
195  
196 int
197 93 mouse_tc_ClassName(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv){
198 assert(sv);
199 93 return is_class_loaded(sv);
200 }
201  
202 int
203 19 mouse_tc_RoleName(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
204 assert(sv);
205 19 ▶ if(is_class_loaded(sv)){
Branch: 1 branch
BranchTrueFalseTotal
if(is_class_loaded(sv)){ 4 15 19
206 int ok;
207  
208 4 ENTER;
209 4 SAVETMPS;
210  
211 4 ok = is_an_instance_of("Mouse::Meta::Role", get_metaclass(sv));
212  
213 4 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 4 4
214 4 LEAVE;
215  
216 4 return ok;
217 }
218 15 return FALSE;
219 }
220  
221 int
222 75 mouse_tc_Ref(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
223 assert(sv);
224 75 return SvROK(sv);
225 }
226  
227 int
228 69 mouse_tc_ScalarRef(pTHX_ SV* const data PERL_UNUSED_DECL, SV* sv) {
229 assert(sv);
230 69 ▶ if(SvROK(sv)){
Branch: 1 branch
BranchTrueFalseTotal
if(SvROK(sv)){ 35 34 69
231 35 sv = SvRV(sv);
232 35 ▶ return !SvOBJECT(sv) && (SvTYPE(sv) <= SVt_PVLV && !isGV(sv));
Branch: 3 branches
BranchTrueFalseTotal
return !SvOBJECT(sv) && (SvTYPE(sv) <= SVt_PVLV && !isGV(sv)); 27 8 35
return !SvOBJECT(sv) && (SvTYPE(sv) <= SVt_PVLV && !isGV(sv)); 14 13 27
return !SvOBJECT(sv) && (SvTYPE(sv) <= SVt_PVLV && !isGV(sv)); 8 6 14
233 }
234 34 return FALSE;
235 }
236  
237 int
238 241 mouse_tc_ArrayRef(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
239 assert(sv);
240 241 ▶ return IsArrayRef(sv);
Branch: 3 branches
BranchTrueFalseTotal
return IsArrayRef(sv); 194 47 241
return IsArrayRef(sv); 186 8 194
return IsArrayRef(sv); 147 39 186
241 }
242  
243 int
244 197 mouse_tc_HashRef(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
245 assert(sv);
246 197 ▶ return IsHashRef(sv);
Branch: 3 branches
BranchTrueFalseTotal
return IsHashRef(sv); 147 50 197
return IsHashRef(sv); 137 10 147
return IsHashRef(sv); 108 29 137
247 }
248  
249 int
250 273 mouse_tc_CodeRef(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
251 assert(sv);
252 273 ▶ return IsCodeRef(sv);
Branch: 3 branches
BranchTrueFalseTotal
return IsCodeRef(sv); 236 37 273
return IsCodeRef(sv); 228 8 236
return IsCodeRef(sv); 203 25 228
253 }
254  
255 int
256 66 mouse_tc_RegexpRef(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
257 assert(sv);
258 66 return SvRXOK(sv);
259 }
260  
261 int
262 67 mouse_tc_GlobRef(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
263 assert(sv);
264 67 ▶ return SvROK(sv) && !SvOBJECT(SvRV(sv)) && isGV(SvRV(sv));
Branch: 3 branches
BranchTrueFalseTotal
return SvROK(sv) && !SvOBJECT(SvRV(sv)) && isGV(SvRV(sv)); 33 34 67
return SvROK(sv) && !SvOBJECT(SvRV(sv)) && isGV(SvRV(sv)); 24 9 33
return SvROK(sv) && !SvOBJECT(SvRV(sv)) && isGV(SvRV(sv)); 6 18 24
265 }
266  
267 int
268 67 mouse_tc_FileHandle(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
269 GV* gv;
270 assert(sv);
271  
272 /* see pp_fileno() in pp_sys.c and Scalar::Util::openhandle() */
273  
274 67 ▶ gv = (GV*)(SvROK(sv) ? SvRV(sv) : sv);
Branch: 1 branch
BranchTrueFalseTotal
gv = (GV*)(SvROK(sv) ? SvRV(sv) : sv); 33 34 67
275 67 ▶ if(isGV(gv) || SvTYPE(gv) == SVt_PVIO){
Branch: 2 branches
BranchTrueFalseTotal
if(isGV(gv) || SvTYPE(gv) == SVt_PVIO){ 58 9 67
if(isGV(gv) || SvTYPE(gv) == SVt_PVIO){ 0 58 58
276 9 ▶ IO* const io = isGV(gv) ? GvIO(gv) : (IO*)gv;
Branch: 5 branches
BranchTrueFalseTotal
IO* const io = isGV(gv) ? GvIO(gv) : (IO*)gv; 9 0 9
IO* const io = isGV(gv) ? GvIO(gv) : (IO*)gv; 9 0 9
IO* const io = isGV(gv) ? GvIO(gv) : (IO*)gv; 0 9 9
IO* const io = isGV(gv) ? GvIO(gv) : (IO*)gv; 0 0 0
IO* const io = isGV(gv) ? GvIO(gv) : (IO*)gv; 9 0 9
277  
278 9 ▶ if(io && ( IoIFP(io) || SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar) )){
Branch: 4 branches
BranchTrueFalseTotal
if(io && ( IoIFP(io) || SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar) )){ 3 6 9
if(io && ( IoIFP(io) || SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar) )){ 0 3 3
if(io && ( IoIFP(io) || SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar) )){ 0 0 0
if(io && ( IoIFP(io) || SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar) )){ 0 0 0
279 3 return TRUE;
280 }
281 }
282  
283 64 return is_an_instance_of("IO::Handle", sv);
284 }
285  
286 int
287 101 mouse_tc_Object(pTHX_ SV* const data PERL_UNUSED_DECL, SV* const sv) {
288 assert(sv);
289 101 ▶ return SvROK(sv) && SvOBJECT(SvRV(sv)) && !SvRXOK(sv);
Branch: 3 branches
BranchTrueFalseTotal
return SvROK(sv) && SvOBJECT(SvRV(sv)) && !SvRXOK(sv); 64 37 101
return SvROK(sv) && SvOBJECT(SvRV(sv)) && !SvRXOK(sv); 29 35 64
return SvROK(sv) && SvOBJECT(SvRV(sv)) && !SvRXOK(sv); 26 3 29
290 }
291  
292 /* Parameterized type constraints */
293  
294 static int
295 59 mouse_parameterized_ArrayRef(pTHX_ SV* const param, SV* const sv) {
296 59 ▶ if(IsArrayRef(sv)){
Branch: 3 branches
BranchTrueFalseTotal
if(IsArrayRef(sv)){ 59 0 59
if(IsArrayRef(sv)){ 59 0 59
if(IsArrayRef(sv)){ 59 0 59
297 59 AV* const av = (AV*)SvRV(sv);
298 59 I32 const len = av_len(av) + 1;
299 I32 i;
300 163 ▶ for(i = 0; i < len; i++){
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < len; i++){ 124 39 163
301 124 SV* const value = *av_fetch(av, i, TRUE);
302 124 ▶ if(!mouse_tc_check(aTHX_ param, value)){
Branch: 1 branch
BranchTrueFalseTotal
if(!mouse_tc_check(aTHX_ param, value)){ 20 104 124
303 20 return FALSE;
304 }
305 }
306 39 return TRUE;
307 }
308 0 return FALSE;
309 }
310  
311 static int
312 63 mouse_parameterized_HashRef(pTHX_ SV* const param, SV* const sv) {
313 63 ▶ if(IsHashRef(sv)){
Branch: 3 branches
BranchTrueFalseTotal
if(IsHashRef(sv)){ 63 0 63
if(IsHashRef(sv)){ 63 0 63
if(IsHashRef(sv)){ 63 0 63
314 63 HV* const hv = (HV*)SvRV(sv);
315 HE* he;
316  
317 63 hv_iterinit(hv);
318 153 ▶ while((he = hv_iternext(hv))){
Branch: 1 branch
BranchTrueFalseTotal
while((he = hv_iternext(hv))){ 110 43 153
319 110 SV* const value = hv_iterval(hv, he);
320 110 ▶ if(!mouse_tc_check(aTHX_ param, value)){
Branch: 1 branch
BranchTrueFalseTotal
if(!mouse_tc_check(aTHX_ param, value)){ 20 90 110
321 20 hv_iterinit(hv); /* reset */
322 20 return FALSE;
323 }
324 }
325 43 return TRUE;
326 }
327 0 return FALSE;
328 }
329  
330 static int
331 54 mouse_parameterized_Maybe(pTHX_ SV* const param, SV* const sv) {
332 54 ▶ if(SvOK(sv)){
Branch: 1 branch
BranchTrueFalseTotal
if(SvOK(sv)){ 39 15 54
333 39 return mouse_tc_check(aTHX_ param, sv);
334 }
335 15 return TRUE;
336 }
337  
338 static int
339 73 mouse_types_union_check(pTHX_ AV* const types, SV* const sv) {
340 73 I32 const len = AvFILLp(types) + 1;
341 I32 i;
342  
343 164 ▶ for(i = 0; i < len; i++){
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < len; i++){ 139 25 164
344 139 ▶ if(mouse_tc_check(aTHX_ AvARRAY(types)[i], sv)){
Branch: 1 branch
BranchTrueFalseTotal
if(mouse_tc_check(aTHX_ AvARRAY(types)[i], sv)){ 48 91 139
345 48 return TRUE;
346 }
347 }
348  
349 25 return FALSE;
350 }
351  
352 static int
353 507 mouse_types_check(pTHX_ AV* const types, SV* const sv) {
354 507 I32 const len = AvFILLp(types) + 1;
355 I32 i;
356  
357 507 ENTER;
358 507 SAVE_DEFSV;
359 507 DEFSV_set(sv);
360  
361 1095 ▶ for(i = 0; i < len; i++){
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < len; i++){ 789 306 1095
362 789 ▶ if(!mouse_tc_check(aTHX_ AvARRAY(types)[i], sv)){
Branch: 1 branch
BranchTrueFalseTotal
if(!mouse_tc_check(aTHX_ AvARRAY(types)[i], sv)){ 201 588 789
363 201 LEAVE;
364 201 return FALSE;
365 }
366 }
367  
368 306 LEAVE;
369  
370 306 return TRUE;
371 }
372  
373 /*
374 * This class_type generator is taken from Scalar::Util::Instance
375 */
376  
377  
378 #define MG_klass_stash(mg) ((HV*)(mg)->mg_obj)
379 #define MG_klass_pv(mg) ((mg)->mg_ptr)
380 #define MG_klass_len(mg) ((mg)->mg_len)
381  
382 static const char*
383 585 mouse_canonicalize_package_name(const char* name){
384  
385 /* "::Foo" -> "Foo" */
386 585 ▶ if(name[0] == ':' && name[1] == ':'){
Branch: 2 branches
BranchTrueFalseTotal
if(name[0] == ':' && name[1] == ':'){ 0 585 585
if(name[0] == ':' && name[1] == ':'){ 0 0 0
387 0 name += 2;
388 }
389  
390 /* "main::main::main::Foo" -> "Foo" */
391 585 ▶ while(strnEQ(name, "main::", sizeof("main::")-1)){
Branch: 1 branch
BranchTrueFalseTotal
while(strnEQ(name, "main::", sizeof("main::")-1)){ 0 585 585
392 0 name += sizeof("main::")-1;
393 }
394  
395 585 return name;
396 }
397  
398 static int
399 9 mouse_lookup_isa(pTHX_ HV* const instance_stash, const char* const klass_pv){
400 9 AV* const linearized_isa = mro_get_linear_isa(instance_stash);
401 9 SV** svp = AvARRAY(linearized_isa);
402 9 SV** const end = svp + AvFILLp(linearized_isa) + 1;
403  
404 20 ▶ while(svp != end){
Branch: 1 branch
BranchTrueFalseTotal
while(svp != end){ 12 8 20
405 assert(SvPVX(*svp));
406 12 ▶ if(strEQ(klass_pv, mouse_canonicalize_package_name(SvPVX(*svp)))){
Branch: 1 branch
BranchTrueFalseTotal
if(strEQ(klass_pv, mouse_canonicalize_package_name(SvPVX(*svp)))){ 1 11 12
407 1 return TRUE;
408 }
409 11 svp++;
410 }
411 8 return FALSE;
412 }
413  
414 #define find_method_pvn(a, b, c) mouse_stash_find_method(aTHX_ a, b, c)
415 #define find_method_pvs(a, b) mouse_stash_find_method(aTHX_ a, STR_WITH_LEN(b))
416  
417 STATIC_INLINE GV*
418 2361 mouse_stash_find_method(pTHX_ HV* const stash, const char* const name, I32 const namelen){
419 2361 GV** const gvp = (GV**)hv_fetch(stash, name, namelen, FALSE);
420 2361 ▶ if(gvp && isGV(*gvp) && GvCV(*gvp)){ /* shortcut */
Branch: 3 branches
BranchTrueFalseTotal
if(gvp && isGV(*gvp) && GvCV(*gvp)){ /* shortcut */ 1918 443 2361
if(gvp && isGV(*gvp) && GvCV(*gvp)){ /* shortcut */ 1918 0 1918
if(gvp && isGV(*gvp) && GvCV(*gvp)){ /* shortcut */ 1626 292 1918
421 1626 return *gvp;
422 }
423  
424 735 return gv_fetchmeth(stash, name, namelen, 0);
425 }
426  
427 int
428 358 mouse_is_an_instance_of(pTHX_ HV* const stash, SV* const instance){
429 assert(stash);
430 assert(SvTYPE(stash) == SVt_PVHV);
431  
432 358 ▶ if(IsObject(instance)){
Branch: 2 branches
BranchTrueFalseTotal
if(IsObject(instance)){ 235 123 358
if(IsObject(instance)){ 188 47 235
433 dMY_CXT;
434 188 HV* const instance_stash = SvSTASH(SvRV(instance));
435 188 GV* const myisa = find_method_pvs(instance_stash, "isa");
436  
437 /* the instance has no own isa method */
438 188 ▶ if(myisa == NULL || GvCV(myisa) == GvCV(MY_CXT.universal_isa)){
Branch: 2 branches
BranchTrueFalseTotal
if(myisa == NULL || GvCV(myisa) == GvCV(MY_CXT.universal_isa)){ 188 0 188
if(myisa == NULL || GvCV(myisa) == GvCV(MY_CXT.universal_isa)){ 188 0 188
439 return stash == instance_stash
440 188 ▶ || mouse_lookup_isa(aTHX_ instance_stash, HvNAME_get(stash));
Branch: 8 branches
BranchTrueFalseTotal
|| mouse_lookup_isa(aTHX_ instance_stash, HvNAME_get(stash)); 9 179 188
|| mouse_lookup_isa(aTHX_ instance_stash, HvNAME_get(stash)); 9 0 9
|| mouse_lookup_isa(aTHX_ instance_stash, HvNAME_get(stash)); 9 0 9
|| mouse_lookup_isa(aTHX_ instance_stash, HvNAME_get(stash)); 0 9 9
|| mouse_lookup_isa(aTHX_ instance_stash, HvNAME_get(stash)); 0 0 0
|| mouse_lookup_isa(aTHX_ instance_stash, HvNAME_get(stash)); 9 0 9
|| mouse_lookup_isa(aTHX_ instance_stash, HvNAME_get(stash)); 0 9 9
|| mouse_lookup_isa(aTHX_ instance_stash, HvNAME_get(stash)); 1 8 9
441 }
442 /* the instance has its own isa method */
443 else {
444 SV* package;
445 int ok;
446  
447 0 ENTER;
448 0 SAVETMPS;
449  
450 0 ▶ package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U);
Branch: 12 branches
BranchTrueFalseTotal
package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); 0 0 0
package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); 0 0 0
package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); 0 0 0
package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); 0 0 0
package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); 0 0 0
package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); 0 0 0
package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); 0 0 0
package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); 0 0 0
package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); 0 0 0
package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); 0 0 0
package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); 0 0 0
package = newSVpvn_share(HvNAME_get(stash), HvNAMELEN_get(stash), 0U); 0 0 0
451 0 ok = sv_true(mcall1s(instance, "isa", sv_2mortal(package)));
452  
453 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
454 0 LEAVE;
455  
456 0 return ok;
457 }
458 }
459 170 return FALSE;
460 }
461  
462 static int
463 2 mouse_is_an_instance_of_universal(pTHX_ SV* const data, SV* const sv){
464 PERL_UNUSED_ARG(data);
465 2 ▶ return SvROK(sv) && SvOBJECT(SvRV(sv));
Branch: 2 branches
BranchTrueFalseTotal
return SvROK(sv) && SvOBJECT(SvRV(sv)); 1 1 2
return SvROK(sv) && SvOBJECT(SvRV(sv)); 1 0 1
466 }
467  
468 static int
469 3370 mouse_can_methods(pTHX_ AV* const methods, SV* const instance){
470 3370 ▶ if(IsObject(instance)){
Branch: 2 branches
BranchTrueFalseTotal
if(IsObject(instance)){ 1088 2282 3370
if(IsObject(instance)){ 1087 1 1088
471 dMY_CXT;
472 1087 HV* const mystash = SvSTASH(SvRV(instance));
473 1087 GV* const mycan = find_method_pvs(mystash, "can");
474 1087 ▶ bool const use_builtin = (mycan == NULL || GvCV(mycan) == GvCV(MY_CXT.universal_can)) ? TRUE : FALSE;
Branch: 2 branches
BranchTrueFalseTotal
bool const use_builtin = (mycan == NULL || GvCV(mycan) == GvCV(MY_CXT.universal_can)) ? TRUE : FALSE; 1087 0 1087
bool const use_builtin = (mycan == NULL || GvCV(mycan) == GvCV(MY_CXT.universal_can)) ? TRUE : FALSE; 1084 3 1087
475 1087 I32 const len = AvFILLp(methods) + 1;
476 I32 i;
477 1734 ▶ for(i = 0; i < len; i++){
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < len; i++){ 1089 645 1734
478 1089 ▶ SV* const name = MOUSE_av_at(methods, i);
Branch: 1 branch
BranchTrueFalseTotal
SV* const name = MOUSE_av_at(methods, i); 1089 0 1089
479  
480 1089 ▶ if(use_builtin){
Branch: 1 branch
BranchTrueFalseTotal
if(use_builtin){ 1086 3 1089
481 1086 ▶ if(!find_method_pvn(mystash, SvPVX(name), SvCUR(name))){
Branch: 1 branch
BranchTrueFalseTotal
if(!find_method_pvn(mystash, SvPVX(name), SvCUR(name))){ 440 646 1086
482 440 return FALSE;
483 }
484 }
485 else{
486 bool ok;
487  
488 3 ENTER;
489 3 SAVETMPS;
490  
491 3 ok = sv_true(mcall1s(instance, "can", sv_mortalcopy(name)));
492  
493 3 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 3 0 3
494 3 LEAVE;
495  
496 3 ▶ if(!ok){
Branch: 1 branch
BranchTrueFalseTotal
if(!ok){ 2 1 3
497 2 return FALSE;
498 }
499 }
500 }
501 645 return TRUE;
502 }
503 2283 return FALSE;
504 }
505  
506 static CV*
507 7083 mouse_tc_generate(pTHX_ const char* const name, check_fptr_t const fptr, SV* const param) {
508 CV* xsub;
509 MAGIC* mg;
510  
511 7083 xsub = newXS((const char*)name, XS_Mouse_constraint_check, __FILE__);
512 7083 mg = sv_magicext(
513 (SV*)xsub,
514 param, /* mg_obj: refcnt will be increased */
515 PERL_MAGIC_ext,
516 &mouse_util_type_constraints_vtbl,
517 (char*)fptr, /* mg_ptr */
518 0 /* mg_len: 0 for static data */
519 );
520 #ifndef MULTIPLICITY
521 7083 CvXSUBANY(xsub).any_ptr = (void*)mg;
522 #endif
523  
524 7083 ▶ if(!name){
Branch: 1 branch
BranchTrueFalseTotal
if(!name){ 791 6292 7083
525 791 sv_2mortal((SV*)xsub);
526 }
527  
528 7083 return xsub;
529 }
530  
531 CV*
532 573 mouse_generate_isa_predicate_for(pTHX_ SV* const klass, const char* const predicate_name){
533 STRLEN klass_len;
534 573 const char* klass_pv = SvPV_const(klass, klass_len);
535 SV* param;
536 check_fptr_t fptr;
537  
538 573 klass_pv = mouse_canonicalize_package_name(klass_pv);
539  
540 573 ▶ if(strNE(klass_pv, "UNIVERSAL")){
Branch: 1 branch
BranchTrueFalseTotal
if(strNE(klass_pv, "UNIVERSAL")){ 572 1 573
541 572 param = (SV*)gv_stashpvn(klass_pv, klass_len, GV_ADD);
542 572 fptr = (check_fptr_t)mouse_is_an_instance_of;
543  
544 }
545 else{
546 1 param = NULL;
547 1 fptr = (check_fptr_t)mouse_is_an_instance_of_universal;
548 }
549  
550 573 return mouse_tc_generate(aTHX_ predicate_name, fptr, param);
551 }
552  
553 CV*
554 864 mouse_generate_can_predicate_for(pTHX_ SV* const methods, const char* const predicate_name){
555 AV* av;
556 864 AV* const param = newAV_mortal();
557 I32 len;
558 I32 i;
559  
560 864 must_ref(methods, "an ARRAY ref for method names", SVt_PVAV);
561 864 av = (AV*)SvRV(methods);
562  
563 864 len = av_len(av) + 1;
564 1729 ▶ for(i = 0; i < len; i++){
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < len; i++){ 865 864 1729
565 865 SV* const name = *av_fetch(av, i, TRUE);
566 STRLEN pvlen;
567 865 const char* const pv = SvPV_const(name, pvlen);
568  
569 865 av_push(param, newSVpvn_share(pv, pvlen, 0U));
570 }
571  
572 864 return mouse_tc_generate(aTHX_ predicate_name, (check_fptr_t)mouse_can_methods, (SV*)param);
573 }
574  
575 static
576 3834 XSPROTO(XS_Mouse_constraint_check) {
577 dVAR;
578 3834 dXSARGS;
579 3834 MAGIC* const mg = MOUSE_get_magic(aTHX_ cv, &mouse_util_type_constraints_vtbl);
580 SV* sv;
581  
582 3834 ▶ if(items < 1){
Branch: 1 branch
BranchTrueFalseTotal
if(items < 1){ 0 3834 3834
583 0 croak("Too few arguments for type constraint check functions");
584 }
585  
586 3834 sv = ST(0);
587 3834 ▶ SvGETMAGIC(sv);
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(sv); 1 3833 3834
SvGETMAGIC(sv); 0 1 1
588 3834 ▶ ST(0) = boolSV( CALL_FPTR((check_fptr_t)mg->mg_ptr)(aTHX_ mg->mg_obj, sv) );
Branch: 1 branch
BranchTrueFalseTotal
ST(0) = boolSV( CALL_FPTR((check_fptr_t)mg->mg_ptr)(aTHX_ mg->mg_obj, sv) ); 867 2967 3834
589 3834 XSRETURN(1);
590 }
591  
592 static
593 0 XSPROTO(XS_Mouse_TypeConstraint_fallback) {
594 0 dXSARGS;
595 PERL_UNUSED_VAR(cv);
596 PERL_UNUSED_VAR(items);
597 0 XSRETURN_EMPTY;
598 }
599  
600 static void
601 286 setup_my_cxt(pTHX_ pMY_CXT){
602 286 MY_CXT.universal_isa = gv_fetchpvs("UNIVERSAL::isa", GV_ADD, SVt_PVCV);
603 286 SvREFCNT_inc_simple_void_NN(MY_CXT.universal_isa);
604  
605 286 MY_CXT.universal_can = gv_fetchpvs("UNIVERSAL::can", GV_ADD, SVt_PVCV);
606 286 SvREFCNT_inc_simple_void_NN(MY_CXT.universal_can);
607  
608 286 MY_CXT.tc_extra_args = NULL;
609 286 }
610  
611 #define DEFINE_TC(name) mouse_tc_generate(aTHX_ "Mouse::Util::TypeConstraints::" STRINGIFY(name), CAT2(mouse_tc_, name), NULL)
612  
613 #define MTC_CLASS "Mouse::Meta::TypeConstraint"
614  
615 MODULE = Mouse::Util::TypeConstraints PACKAGE = Mouse::Util::TypeConstraints
616  
617 PROTOTYPES: DISABLE
618 VERSIONCHECK: DISABLE
619  
620 BOOT:
621 {
622 MY_CXT_INIT;
623 286 setup_my_cxt(aTHX_ aMY_CXT);
624  
625 /* setup built-in type constraints */
626 286 DEFINE_TC(Any);
627 286 DEFINE_TC(Undef);
628 286 DEFINE_TC(Defined);
629 286 DEFINE_TC(Bool);
630 286 DEFINE_TC(Value);
631 286 DEFINE_TC(Ref);
632 286 DEFINE_TC(Str);
633 286 DEFINE_TC(Num);
634 286 DEFINE_TC(Int);
635 286 DEFINE_TC(ScalarRef);
636 286 DEFINE_TC(ArrayRef);
637 286 DEFINE_TC(HashRef);
638 286 DEFINE_TC(CodeRef);
639 286 DEFINE_TC(GlobRef);
640 286 DEFINE_TC(FileHandle);
641 286 DEFINE_TC(RegexpRef);
642 286 DEFINE_TC(Object);
643 286 DEFINE_TC(ClassName);
644 286 DEFINE_TC(RoleName);
645 }
646  
647 #ifdef USE_ITHREADS
648  
649 void
650 CLONE(...)
651 CODE:
652 {
653 MY_CXT_CLONE;
654 setup_my_cxt(aTHX_ aMY_CXT);
655 PERL_UNUSED_VAR(items);
656 }
657  
658 #endif /* !USE_ITHREADS */
659  
660 #define MOUSE_TC_MAYBE 0
661 #define MOUSE_TC_ARRAY_REF 1
662 #define MOUSE_TC_HASH_REF 2
663  
664 CV*
665 _parameterize_ArrayRef_for(SV* param)
666 ALIAS:
667 _parameterize_ArrayRef_for = MOUSE_TC_ARRAY_REF
668 _parameterize_HashRef_for = MOUSE_TC_HASH_REF
669 _parameterize_Maybe_for = MOUSE_TC_MAYBE
670 CODE:
671 {
672 check_fptr_t fptr;
673 51 SV* const tc_code = mcall0s(param, "_compiled_type_constraint");
674 51 ▶ if(!IsCodeRef(tc_code)){
Branch: 3 branches
BranchTrueFalseTotal
if(!IsCodeRef(tc_code)){ 51 0 51
if(!IsCodeRef(tc_code)){ 51 0 51
if(!IsCodeRef(tc_code)){ 0 51 51
675 0 croak("_compiled_type_constraint didn't return a CODE reference");
676 }
677  
678 51 switch(ix){
679 20 case MOUSE_TC_ARRAY_REF:
680 20 fptr = mouse_parameterized_ArrayRef;
681 20 break;
682 16 case MOUSE_TC_HASH_REF:
683 16 fptr = mouse_parameterized_HashRef;
684 16 break;
685 15 default: /* Maybe type */
686 15 fptr = mouse_parameterized_Maybe;
687 }
688 51 RETVAL = mouse_tc_generate(aTHX_ NULL, fptr, tc_code);
689 }
690 OUTPUT:
691 RETVAL
692  
693 MODULE = Mouse::Util::TypeConstraints PACKAGE = Mouse::Meta::TypeConstraint
694  
695 BOOT:
696 286 INSTALL_SIMPLE_READER(TypeConstraint, name);
697 286 INSTALL_SIMPLE_READER(TypeConstraint, parent);
698 286 INSTALL_SIMPLE_READER(TypeConstraint, message);
699  
700 286 INSTALL_SIMPLE_READER(TypeConstraint, type_parameter);
701  
702 286 INSTALL_SIMPLE_READER_WITH_KEY(TypeConstraint, _compiled_type_constraint, compiled_type_constraint);
703  
704 286 INSTALL_SIMPLE_PREDICATE_WITH_KEY(TypeConstraint, has_coercion, _compiled_type_coercion);
705 286 INSTALL_SIMPLE_PREDICATE_WITH_KEY(TypeConstraint, __is_parameterized, type_parameter); /* Mouse specific */
706  
707 /* overload stuff */
708 286 PL_amagic_generation++;
709 286 (void)newXS( MTC_CLASS "::()",
710 XS_Mouse_TypeConstraint_fallback, file);
711  
712 /* fallback => 1 */
713 286 sv_setsv(
714 get_sv( MTC_CLASS "::()", GV_ADD ),
715 &PL_sv_yes
716 );
717  
718 /* '""' => '_as_string' */
719 {
720 286 SV* const code_ref = sv_2mortal(newRV_inc(
721 (SV*)get_cv( MTC_CLASS "::_as_string", GV_ADD )));
722 286 sv_setsv_mg(
723 (SV*)gv_fetchpvs( MTC_CLASS "::(\"\"", GV_ADDMULTI, SVt_PVCV ),
724 code_ref );
725 }
726  
727 /* '0+' => '_identity' */
728 {
729 286 SV* const code_ref = sv_2mortal(newRV_inc(
730 (SV*)get_cv( MTC_CLASS "::_identity", GV_ADD )));
731 286 sv_setsv_mg(
732 (SV*)gv_fetchpvs( MTC_CLASS "::(0+", GV_ADDMULTI, SVt_PVCV ),
733 code_ref );
734 }
735  
736 /* '|' => '_unite' */
737 {
738 286 SV* const code_ref = sv_2mortal(newRV_inc(
739 (SV*)get_cv( MTC_CLASS "::_unite", GV_ADD )));
740 286 sv_setsv_mg(
741 (SV*)gv_fetchpvs( MTC_CLASS "::(|", GV_ADDMULTI, SVt_PVCV ),
742 code_ref );
743 }
744  
745 UV
746 _identity(SV* self, ...)
747 CODE:
748 {
749 134 ▶ if(!SvROK(self)) {
Branch: 1 branch
BranchTrueFalseTotal
if(!SvROK(self)) { 0 134 134
750 0 croak("Invalid object instance: '%"SVf"'", self);
751 }
752 134 ▶ RETVAL = PTR2UV(SvRV(self));
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = PTR2UV(SvRV(self)); 0 134 134
753 }
754 OUTPUT:
755 RETVAL
756  
757 void
758 compile_type_constraint(SV* self)
759 CODE:
760 {
761 1002 AV* const checks = newAV_mortal();
762 SV* check; /* check function */
763 SV* parent;
764 SV* types_ref;
765  
766 1951 ▶ for(parent = get_slots(self, "parent"); parent; parent = get_slots(parent, "parent")){
Branch: 1 branch
BranchTrueFalseTotal
for(parent = get_slots(self, "parent"); parent; parent = get_slots(parent, "parent")){ 1035 916 1951
767 1035 check = get_slots(parent, "hand_optimized_type_constraint");
768 1035 ▶ if(check && SvOK(check)){
Branch: 2 branches
BranchTrueFalseTotal
if(check && SvOK(check)){ 86 949 1035
if(check && SvOK(check)){ 86 0 86
769 86 ▶ if(!IsCodeRef(check)){
Branch: 3 branches
BranchTrueFalseTotal
if(!IsCodeRef(check)){ 86 0 86
if(!IsCodeRef(check)){ 86 0 86
if(!IsCodeRef(check)){ 0 86 86
770 0 croak("Not a CODE reference");
771 }
772 86 av_unshift(checks, 1);
773 86 av_store(checks, 0, newSVsv(check));
774 86 break; /* a hand optimized constraint must include all the parent */
775 }
776  
777 949 check = get_slots(parent, "constraint");
778 949 ▶ if(check && SvOK(check)){
Branch: 2 branches
BranchTrueFalseTotal
if(check && SvOK(check)){ 35 914 949
if(check && SvOK(check)){ 35 0 35
779 35 ▶ if(!mouse_tc_CodeRef(aTHX_ NULL, check)){
Branch: 1 branch
BranchTrueFalseTotal
if(!mouse_tc_CodeRef(aTHX_ NULL, check)){ 0 35 35
780 0 croak("Not a CODE reference");
781 }
782 35 av_unshift(checks, 1);
783 35 av_store(checks, 0, newSVsv(check));
784 }
785 }
786  
787 1002 check = get_slots(self, "constraint");
788 1002 ▶ if(check && SvOK(check)){
Branch: 2 branches
BranchTrueFalseTotal
if(check && SvOK(check)){ 118 884 1002
if(check && SvOK(check)){ 118 0 118
789 118 ▶ if(!mouse_tc_CodeRef(aTHX_ NULL, check)){
Branch: 1 branch
BranchTrueFalseTotal
if(!mouse_tc_CodeRef(aTHX_ NULL, check)){ 0 118 118
790 0 croak("Not a CODE reference");
791 }
792 118 av_push(checks, newSVsv(check));
793 }
794  
795 1002 types_ref = get_slots(self, "type_constraints");
796 1002 ▶ if(types_ref && SvOK(types_ref)){ /* union type */
Branch: 2 branches
BranchTrueFalseTotal
if(types_ref && SvOK(types_ref)){ /* union type */ 20 982 1002
if(types_ref && SvOK(types_ref)){ /* union type */ 20 0 20
797 AV* types;
798 AV* union_checks;
799 CV* union_check;
800 I32 len;
801 I32 i;
802  
803 20 ▶ if(!IsArrayRef(types_ref)){
Branch: 3 branches
BranchTrueFalseTotal
if(!IsArrayRef(types_ref)){ 20 0 20
if(!IsArrayRef(types_ref)){ 20 0 20
if(!IsArrayRef(types_ref)){ 0 20 20
804 0 croak("Not an ARRAY reference");
805 }
806 20 types = (AV*)SvRV(types_ref);
807 20 len = av_len(types) + 1;
808  
809 20 union_checks = newAV_mortal();
810  
811 64 ▶ for(i = 0; i < len; i++){
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < len; i++){ 44 20 64
812 44 SV* const tc = *av_fetch(types, i, TRUE);
813 44 SV* const c = get_slots(tc, "compiled_type_constraint");
814 44 ▶ if(!(c && mouse_tc_CodeRef(aTHX_ NULL, c))){
Branch: 2 branches
BranchTrueFalseTotal
if(!(c && mouse_tc_CodeRef(aTHX_ NULL, c))){ 44 0 44
if(!(c && mouse_tc_CodeRef(aTHX_ NULL, c))){ 0 44 44
815 0 mouse_throw_error(self, c, "'%"SVf"' has no compiled type constraint", self);
816 }
817 44 av_push(union_checks, newSVsv(c));
818 }
819  
820 20 union_check = mouse_tc_generate(aTHX_ NULL, (check_fptr_t)mouse_types_union_check, (SV*)union_checks);
821 20 av_push(checks, newRV_inc((SV*)union_check));
822 }
823  
824 1002 ▶ if(AvFILLp(checks) < 0){
Branch: 1 branch
BranchTrueFalseTotal
if(AvFILLp(checks) < 0){ 861 141 1002
825 861 check = newRV_inc((SV*)get_cv("Mouse::Util::TypeConstraints::Any", TRUE));
826 }
827 else{
828 141 check = newRV_inc((SV*)mouse_tc_generate(aTHX_ NULL, (check_fptr_t)mouse_types_check, (SV*)checks));
829 }
830 1002 (void)set_slots(self, "compiled_type_constraint", check);
831 }
832  
833 bool
834 check(SV* self, SV* sv, ...)
835 CODE:
836 {
837 289 SV* const check = get_slots(self, "compiled_type_constraint");
838 289 ▶ if(!(check && IsCodeRef(check))){
Branch: 4 branches
BranchTrueFalseTotal
if(!(check && IsCodeRef(check))){ 289 0 289
if(!(check && IsCodeRef(check))){ 289 0 289
if(!(check && IsCodeRef(check))){ 289 0 289
if(!(check && IsCodeRef(check))){ 0 289 289
839 0 mouse_throw_error(self, check,
840 "'%"SVf"' has no compiled type constraint", self);
841 }
842 289 ▶ if( items > 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if( items > 2 ) { 2 287 289
843 int i;
844 AV* av;
845 dMY_CXT;
846 2 SAVESPTR(MY_CXT.tc_extra_args);
847 2 av = MY_CXT.tc_extra_args = newAV_mortal();
848 2 av_extend(av, items - 3);
849 5 ▶ for(i = 2; i < items; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 2; i < items; i++) { 3 2 5
850 3 av_push(av, SvREFCNT_inc_NN( ST(i) ) );
851 }
852 }
853 289 ▶ RETVAL = mouse_tc_check(aTHX_ check, sv) ? TRUE : FALSE;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = mouse_tc_check(aTHX_ check, sv) ? TRUE : FALSE; 80 209 289
854 }
855 OUTPUT:
856 RETVAL
857  
« lib/Mouse.xs ↑ Summary xs-src/MouseAccessor.xs »