xs/vars.xs

filter: Statementstmt 87.5% 7 / 8 Branchbran 56.2% 9 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 66.6% 16 / 24 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/context_vars/context_vars_faa.h ↑ Summary xs/abi.xs »
1 # The variables: import, and the doors a test needs onto them.
2  
3 MODULE = Context::Vars PACKAGE = Context::Vars
4  
5 # use Context::Vars qw($request_id $span);
6 #
7 # Each name becomes a scalar in the package the `use` is written in. The
8 # package is the one the calling statement was compiled in, which is where
9 # perl looks the name up.
10 void
11 import(klass, ...)
12 SV *klass
13 CODE:
14 {
15 77 HV *stash = CopSTASH(PL_curcop);
16 I32 i;
17 PERL_UNUSED_VAR(klass);
18 77 ▶ if (!stash && items > 1)
Branch: 2 branches
BranchTrueFalseTotal
if (!stash && items > 1) 0 77 77
if (!stash && items > 1) 0 0 0
19 0 croak("Context::Vars: cannot tell which package to import into");
20 147 ▶ for (i = 1; i < items; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i = 1; i < items; i++) 92 55 147
21 92 context_vars_import_one(aTHX_ stash, ST(i));
22 }
23  
24 # True when the scalar is one of this module's variables.
25 int
26 _is_var(sv)
27 SV *sv
28 CODE:
29 3 ▶ RETVAL = (SvROK(sv) && context_vars_var_mg(SvRV(sv))) ? 1 : 0;
Branch: 3 branches
BranchTrueFalseTotal
RETVAL = (SvROK(sv) && context_vars_var_mg(SvRV(sv))) ? 1 : 0; 3 0 3
RETVAL = (SvROK(sv) && context_vars_var_mg(SvRV(sv))) ? 1 : 0; 1 2 3
RETVAL = (SvROK(sv) && context_vars_var_mg(SvRV(sv))) ? 1 : 0; 0 3 3
30 OUTPUT:
31 RETVAL
32  
33 # How many values `local` has displaced and not yet put back.
34 IV
35 _locals()
36 CODE:
37 {
38 dMY_CXT;
39 4 ▶ RETVAL = (IV)(av_len(MY_CXT.locals) + 1);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (IV)(av_len(MY_CXT.locals) + 1); 0 4 4
40 }
41 OUTPUT:
42 RETVAL
43  
44 # True once code outside any scope has assigned a variable.
45 int
46 _has_program()
47 CODE:
48 {
49 dMY_CXT;
50 5 ▶ RETVAL = MY_CXT.program ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = MY_CXT.program ? 1 : 0; 0 5 5
51 }
52 OUTPUT:
53 RETVAL
« include/context_vars/context_vars_faa.h ↑ Summary xs/abi.xs »