hax/perl-additions.c.inc

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