easyxs/easyxs_perlcall.h

filter: Statementstmt 97.6% 42 / 43 Branchbran 61.7% 21 / 34 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 81.8% 63 / 77 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« easyxs/easyxs_numeric.h ↑ Summary QuickJS.xs »
1 #ifndef EASYXS_PERLCALL_H
2 #define EASYXS_PERLCALL_H 1
3  
4 #include "init.h"
5  
6 3 static inline void _EASYXS_SET_ARGS (pTHX_ SV* object, SV** args) {
7 3 dSP;
8  
9 3 unsigned argscount = 0;
10  
11 3 ▶ if (args) {
Branch: 1 branch
BranchTrueFalseTotal
if (args) { 3 0 3
12 5 ▶ while (args[argscount] != NULL) argscount++;
Branch: 1 branch
BranchTrueFalseTotal
while (args[argscount] != NULL) argscount++; 2 3 5
13 }
14  
15 3 ENTER;
16 3 SAVETMPS;
17  
18 3 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 3 3
19  
20 3 ▶ if (object || argscount) {
Branch: 2 branches
BranchTrueFalseTotal
if (object || argscount) { 3 0 3
if (object || argscount) { 2 1 3
21 2 ▶ EXTEND(SP, (object ? 1 : 0) + argscount);
Branch: 3 branches
BranchTrueFalseTotal
EXTEND(SP, (object ? 1 : 0) + argscount); 0 2 2
EXTEND(SP, (object ? 1 : 0) + argscount); 0 2 2
EXTEND(SP, (object ? 1 : 0) + argscount); 0 0 0
22  
23 2 ▶ if (object) PUSHs( sv_mortalcopy(object) );
Branch: 1 branch
BranchTrueFalseTotal
if (object) PUSHs( sv_mortalcopy(object) ); 0 2 2
24  
25 2 unsigned a=0;
26 4 ▶ while (a < argscount) mPUSHs( args[a++] );
Branch: 1 branch
BranchTrueFalseTotal
while (a < argscount) mPUSHs( args[a++] ); 2 2 4
27  
28 2 PUTBACK;
29 }
30 3 }
31  
32 #define exs_call_sv_void(sv, args) STMT_START { \
33 _EASYXS_SET_ARGS(aTHX_ NULL, args); \
34 call_sv(sv, G_DISCARD | G_VOID); \
35 FREETMPS; \
36 LEAVE; \
37 } STMT_END
38  
39 #define exs_call_method_void(object, methname, args) STMT_START { \
40 _EASYXS_SET_ARGS(aTHX_ object, args); \
41 \
42 call_method( methname, G_DISCARD | G_VOID ); \
43 \
44 FREETMPS; \
45 LEAVE; \
46 } STMT_END
47  
48 2 static inline SV* _easyxs_fetch_scalar_return (pTHX_ int count) {
49 2 dSP;
50  
51 2 SPAGAIN;
52  
53 SV* ret;
54  
55 2 ▶ if (count == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (count == 0) { 0 2 2
56 0 ret = &PL_sv_undef;
57 }
58 else {
59 2 ret = SvREFCNT_inc(POPs);
60  
61 2 ▶ while (count-- > 1) PERL_UNUSED_VAR(POPs);
Branch: 1 branch
BranchTrueFalseTotal
while (count-- > 1) PERL_UNUSED_VAR(POPs); 0 2 2
62 }
63  
64 2 PUTBACK;
65 2 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 2 0 2
66 2 LEAVE;
67  
68 2 return ret;
69 }
70  
71 static inline SV* _easyxs_call_method_scalar (pTHX_ SV* object, const char* methname, SV** args) {
72 _EASYXS_SET_ARGS(aTHX_ object, args);
73  
74 int count = call_method(methname, G_SCALAR);
75  
76 return _easyxs_fetch_scalar_return(aTHX_ count);
77 }
78  
79 #define exs_call_method_scalar(object, methname, args) \
80 _easyxs_call_method_scalar(aTHX_ object, methname, args)
81  
82 1 static inline SV* _easyxs_call_sv_scalar (pTHX_ SV* cb, SV** args) {
83 1 _EASYXS_SET_ARGS(aTHX_ NULL, args);
84  
85 1 int count = call_sv(cb, G_SCALAR);
86  
87 1 return _easyxs_fetch_scalar_return(aTHX_ count);
88 }
89  
90 #define exs_call_sv_scalar(sv, args) \
91 _easyxs_call_sv_scalar(aTHX_ sv, args)
92  
93 2 static inline SV* _easyxs_call_sv_scalar_trapped (pTHX_ SV* cb, SV** args, SV** error) {
94 2 _EASYXS_SET_ARGS(aTHX_ NULL, args);
95  
96 2 int count = call_sv(cb, G_SCALAR | G_EVAL);
97  
98 2 dSP;
99  
100 2 ▶ SV* err_tmp = ERRSV;
Branch: 1 branch
BranchTrueFalseTotal
SV* err_tmp = ERRSV; 2 0 2
101 2 ▶ if (SvTRUE(err_tmp)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvTRUE(err_tmp)) { 1 1 2
102 2 ▶ while (count--) PERL_UNUSED_VAR(POPs);
Branch: 1 branch
BranchTrueFalseTotal
while (count--) PERL_UNUSED_VAR(POPs); 1 1 2
103  
104 1 *error = err_tmp;
105  
106 1 PUTBACK;
107 1 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 1 0 1
108 1 LEAVE;
109  
110 1 return NULL;
111 }
112  
113 1 return _easyxs_fetch_scalar_return(aTHX_ count);
114 }
115  
116 #define exs_call_sv_scalar_trapped(sv, args, err_p) \
117 _easyxs_call_sv_scalar_trapped(aTHX_ sv, args, err_p)
118  
119 #endif
« easyxs/easyxs_numeric.h ↑ Summary QuickJS.xs »