hax/perl-additions.c.inc

filter: Statementstmt 14.2% 11 / 77 Branchbran 9.3% 6 / 64 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 12.0% 17 / 141 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/XS/Parse/Keyword/FromPerl.pm ↑ Summary hax/newSVop.c.inc »
1 /* vi: set ft=c : */
2  
3 #if HAVE_PERL_VERSION(5, 22, 0)
4 # define PadnameIsNULL(pn) (!(pn))
5 #else
6 # define PadnameIsNULL(pn) (!(pn) || (pn) == &PL_sv_undef)
7 #endif
8  
9 #ifndef hv_deletes
10 # define hv_deletes(hv, skey, flags) hv_delete((hv), ("" skey ""), (sizeof(skey) - 1), flags)
11 #endif
12  
13 #ifndef gv_fetchmeth_pvs
14 # define gv_fetchmeth_pvs(stash, name, level, flags) gv_fetchmeth_pvn((stash), ("" name ""), (sizeof(name) - 1), level, flags)
15 #endif
16  
17 #if HAVE_PERL_VERSION(5, 22, 0)
18 # define PadnameOUTER_off(pn) (PadnameFLAGS(pn) &= ~PADNAMEt_OUTER)
19 #else
20 /* PadnameOUTER is really the SvFAKE flag */
21 # define PadnameOUTER_off(pn) SvFAKE_off(pn)
22 #endif
23  
24 #define save_strndup(s, l) S_save_strndup(aTHX_ s, l)
25 0 static char *S_save_strndup(pTHX_ char *s, STRLEN l)
26 {
27 /* savepvn doesn't put anything on the save stack, despite its name */
28 0 char *ret = savepvn(s, l);
29 0 SAVEFREEPV(ret);
30 0 return ret;
31 }
32  
33 #define dKWARG(count) \
34 U32 kwargi = count; \
35 U32 kwarg; \
36 SV *kwval; \
37 /* TODO: complain about odd number of args */
38  
39 #define KWARG_NEXT(args) \
40 S_kwarg_next(aTHX_ args, &kwargi, items, ax, &kwarg, &kwval)
41 74 static bool S_kwarg_next(pTHX_ const char *args[], U32 *kwargi, U32 argc, U32 ax, U32 *kwarg, SV **kwval)
42 {
43 74 ▶ if(*kwargi >= argc)
Branch: 1 branch
BranchTrueFalseTotal
if(*kwargi >= argc) 19 55 74
44 19 return FALSE;
45  
46 55 SV *argname = ST(*kwargi); (*kwargi)++;
47 55 ▶ if(!SvOK(argname))
Branch: 1 branch
BranchTrueFalseTotal
if(!SvOK(argname)) 0 55 55
48 0 croak("Expected string for next argument name, got undef");
49  
50 55 *kwarg = 0;
51 213 ▶ while(args[*kwarg]) {
Branch: 1 branch
BranchTrueFalseTotal
while(args[*kwarg]) { 213 0 213
52 426 ▶ if(strEQ(SvPV_nolen(argname), args[*kwarg])) {
Branch: 1 branch
BranchTrueFalseTotal
if(strEQ(SvPV_nolen(argname), args[*kwarg])) { 55 158 213
53 55 *kwval = ST(*kwargi); (*kwargi)++;
54 55 return TRUE;
55 }
56 158 (*kwarg)++;
57 }
58  
59 0 croak("Unrecognised argument name '%" SVf "'", SVfARG(argname));
60 }
61  
62 #define import_pragma(pragma, arg) S_import_pragma(aTHX_ pragma, arg)
63 0 static void S_import_pragma(pTHX_ const char *pragma, const char *arg)
64 {
65 0 dSP;
66 0 bool unimport = FALSE;
67  
68 0 ▶ if(pragma[0] == '-') {
Branch: 1 branch
BranchTrueFalseTotal
if(pragma[0] == '-') { 0 0 0
69 0 unimport = TRUE;
70 0 pragma++;
71 }
72  
73 0 SAVETMPS;
74  
75 0 ▶ EXTEND(SP, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 2); 0 0 0
76 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
77 0 mPUSHp(pragma, strlen(pragma));
78 0 ▶ if(arg)
Branch: 1 branch
BranchTrueFalseTotal
if(arg) 0 0 0
79 0 mPUSHp(arg, strlen(arg));
80 0 PUTBACK;
81  
82 0 ▶ call_method(unimport ? "unimport" : "import", G_VOID);
Branch: 1 branch
BranchTrueFalseTotal
call_method(unimport ? "unimport" : "import", G_VOID); 0 0 0
83  
84 0 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 0 0 0
85 0 }
86  
87 #define ensure_module_version(module, version) S_ensure_module_version(aTHX_ module, version)
88 0 static void S_ensure_module_version(pTHX_ SV *module, SV *version)
89 {
90 0 dSP;
91  
92 0 ENTER;
93  
94 0 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 0 0
95 0 PUSHs(module);
96 0 PUSHs(version);
97 0 PUTBACK;
98  
99 0 call_method("VERSION", G_VOID);
100  
101 0 LEAVE;
102 0 }
103  
104 #if HAVE_PERL_VERSION(5, 16, 0)
105 /* TODO: perl 5.14 lacks HvNAMEUTF8, gv_fetchmeth_pvn() */
106 # define fetch_superclass_method_pv(stash, pv, len, level) S_fetch_superclass_method_pv(aTHX_ stash, pv, len, level)
107 0 static CV *S_fetch_superclass_method_pv(pTHX_ HV *stash, const char *pv, STRLEN len, U32 level)
108 {
109 # if HAVE_PERL_VERSION(5, 18, 0)
110 0 GV *gv = gv_fetchmeth_pvn(stash, pv, len, level, GV_SUPER);
111 # else
112 SV *superclassname = newSVpvf("%*s::SUPER", HvNAMELEN_get(stash), HvNAME_get(stash));
113 if(HvNAMEUTF8(stash))
114 SvUTF8_on(superclassname);
115 SAVEFREESV(superclassname);
116  
117 HV *superstash = gv_stashsv(superclassname, GV_ADD);
118 GV *gv = gv_fetchmeth_pvn(superstash, pv, len, level, 0);
119 # endif
120  
121 0 ▶ if(!gv)
Branch: 1 branch
BranchTrueFalseTotal
if(!gv) 0 0 0
122 0 return NULL;
123 0 return GvCV(gv);
124 }
125 #endif /* HAVE_PERL_VERSION(5, 16, 0) */
126  
127 #define get_class_isa(stash) S_get_class_isa(aTHX_ stash)
128 0 static AV *S_get_class_isa(pTHX_ HV *stash)
129 {
130 0 GV **gvp = (GV **)hv_fetchs(stash, "ISA", 0);
131 0 ▶ if(!gvp || !GvAV(*gvp))
Branch: 2 branches
BranchTrueFalseTotal
if(!gvp || !GvAV(*gvp)) 0 0 0
if(!gvp || !GvAV(*gvp)) 0 0 0
132 0 ▶ croak("Expected %s to have a @ISA list", HvNAME(stash));
Branch: 6 branches
BranchTrueFalseTotal
croak("Expected %s to have a @ISA list", HvNAME(stash)); 0 0 0
croak("Expected %s to have a @ISA list", HvNAME(stash)); 0 0 0
croak("Expected %s to have a @ISA list", HvNAME(stash)); 0 0 0
croak("Expected %s to have a @ISA list", HvNAME(stash)); 0 0 0
croak("Expected %s to have a @ISA list", HvNAME(stash)); 0 0 0
croak("Expected %s to have a @ISA list", HvNAME(stash)); 0 0 0
133  
134 0 return GvAV(*gvp);
135 }
136  
137 #define find_cop_for_lvintro(padix, o, copp) S_find_cop_for_lvintro(aTHX_ padix, o, copp)
138 0 static COP *S_find_cop_for_lvintro(pTHX_ PADOFFSET padix, OP *o, COP **copp)
139 {
140 0 ▶ for( ; o; o = OpSIBLING(o)) {
Branch: 2 branches
BranchTrueFalseTotal
for( ; o; o = OpSIBLING(o)) { 0 0 0
for( ; o; o = OpSIBLING(o)) { 0 0 0
141 0 ▶ if(OP_CLASS(o) == OA_COP) {
Branch: 2 branches
BranchTrueFalseTotal
if(OP_CLASS(o) == OA_COP) { 0 0 0
if(OP_CLASS(o) == OA_COP) { 0 0 0
142 0 *copp = (COP *)o;
143 }
144 0 ▶ else if(o->op_type == OP_PADSV && o->op_targ == padix && o->op_private & OPpLVAL_INTRO) {
Branch: 3 branches
BranchTrueFalseTotal
else if(o->op_type == OP_PADSV && o->op_targ == padix && o->op_private & OPpLVAL_INTRO) { 0 0 0
else if(o->op_type == OP_PADSV && o->op_targ == padix && o->op_private & OPpLVAL_INTRO) { 0 0 0
else if(o->op_type == OP_PADSV && o->op_targ == padix && o->op_private & OPpLVAL_INTRO) { 0 0 0
145 0 return *copp;
146 }
147 0 ▶ else if(o->op_flags & OPf_KIDS) {
Branch: 1 branch
BranchTrueFalseTotal
else if(o->op_flags & OPf_KIDS) { 0 0 0
148 0 COP *ret = find_cop_for_lvintro(padix, cUNOPx(o)->op_first, copp);
149 0 ▶ if(ret)
Branch: 1 branch
BranchTrueFalseTotal
if(ret) 0 0 0
150 0 return ret;
151 }
152 }
153  
154 0 return NULL;
155 }
156  
157 #define lex_consume_unichar(c) MY_lex_consume_unichar(aTHX_ c)
158 0 static bool MY_lex_consume_unichar(pTHX_ U32 c)
159 {
160 0 ▶ if(lex_peek_unichar(0) != c)
Branch: 1 branch
BranchTrueFalseTotal
if(lex_peek_unichar(0) != c) 0 0 0
161 0 return FALSE;
162  
163 0 lex_read_unichar(0);
164 0 return TRUE;
165 }
166  
167 #define av_push_from_av_inc(dst, src) S_av_push_from_av(aTHX_ dst, src, TRUE)
168 #define av_push_from_av_noinc(dst, src) S_av_push_from_av(aTHX_ dst, src, FALSE)
169 0 static void S_av_push_from_av(pTHX_ AV *dst, AV *src, bool refcnt_inc)
170 {
171 0 SSize_t count = av_count(src);
172 SSize_t i;
173  
174 0 av_extend(dst, av_count(dst) + count - 1);
175  
176 0 SV **vals = AvARRAY(src);
177  
178 0 ▶ for(i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for(i = 0; i < count; i++) { 0 0 0
179 0 SV *sv = vals[i];
180 0 ▶ av_push(dst, refcnt_inc ? SvREFCNT_inc(sv) : sv);
Branch: 1 branch
BranchTrueFalseTotal
av_push(dst, refcnt_inc ? SvREFCNT_inc(sv) : sv); 0 0 0
181 }
182 0 }
« blib/lib/XS/Parse/Keyword/FromPerl.pm ↑ Summary hax/newSVop.c.inc »