XS.xs

filter: Statementstmt 93.3% 28 / 30 Branchbran 61.1% 55 / 90 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 69.1% 83 / 120 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« XS_xsgen.cc ↑ Summary blib/arch/Export/XS.pm »
1 #include <xs.h>
2 #include <xs/export.h>
3 using namespace xs;
4 using namespace xs::exp;
5  
6 5 static void throw_nopackage (const Simple& name) {
7 5 ▶ throw Simple::format("Export::XS: package '%" SVf "' doesn't exist", SVfARG(name.get()));
Branch: 1 branch
BranchTrueFalseTotal
throw Simple::format("Export::XS: package '%" SVf "' doesn't exist", SVfARG(name.get())); 5 0 5
8 }
9  
10 MODULE = Export::XS PACKAGE = Export::XS
11 PROTOTYPES: DISABLE
12  
13 void import (Simple ctx_class, ...) {
14 17 ▶ Stash caller_stash = CopSTASH(PL_curcop);
Branch: 1 branch
BranchTrueFalseTotal
Stash caller_stash = CopSTASH(PL_curcop); 17 0 17
15
16 17 bool create = false;
17 17 ▶ panda::string_view ctx_clname = ctx_class;
Branch: 1 branch
BranchTrueFalseTotal
panda::string_view ctx_clname = ctx_class; 17 0 17
18 17 ▶ if (ctx_clname == "Export::XS") create = true;
Branch: 2 branches
BranchTrueFalseTotal
if (ctx_clname == "Export::XS") create = true; 17 0 17
if (ctx_clname == "Export::XS") create = true; 8 9 17
19 9 ▶ else if (ctx_clname == "Export::XS::Auto") {
Branch: 2 branches
BranchTrueFalseTotal
else if (ctx_clname == "Export::XS::Auto") { 9 0 9
else if (ctx_clname == "Export::XS::Auto") { 2 7 9
20 2 create = true;
21 2 ▶ autoexport(caller_stash);
Branch: 2 branches
BranchTrueFalseTotal
autoexport(caller_stash); 2 0 2
autoexport(caller_stash); 2 0 2
22 }
23
24 17 ▶ if (create) {
Branch: 1 branch
BranchTrueFalseTotal
if (create) { 10 7 17
25 10 ▶ if (items < 2) XSRETURN_EMPTY;
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) XSRETURN_EMPTY; 3 7 10
26 9 ▶ if (Sv(ST(1)).is_hash_ref()) create_constants(caller_stash, ST(1));
Branch: 5 branches
BranchTrueFalseTotal
if (Sv(ST(1)).is_hash_ref()) create_constants(caller_stash, ST(1)); 7 0 7
if (Sv(ST(1)).is_hash_ref()) create_constants(caller_stash, ST(1)); 3 4 7
if (Sv(ST(1)).is_hash_ref()) create_constants(caller_stash, ST(1)); 3 0 3
if (Sv(ST(1)).is_hash_ref()) create_constants(caller_stash, ST(1)); 3 0 3
if (Sv(ST(1)).is_hash_ref()) create_constants(caller_stash, ST(1)); 2 1 3
27 5 ▶ else create_constants(caller_stash, &ST(1), items-1);
Branch: 2 branches
BranchTrueFalseTotal
else create_constants(caller_stash, &ST(1), items-1); 4 0 4
else create_constants(caller_stash, &ST(1), items-1); 3 1 4
28 }
29 else {
30 7 ▶ auto ctx_stash = Stash::from_name(ctx_class);
Branch: 1 branch
BranchTrueFalseTotal
auto ctx_stash = Stash::from_name(ctx_class); 7 0 7
31 7 ▶ if (!ctx_stash) throw_nopackage(ctx_class);
Branch: 2 branches
BranchTrueFalseTotal
if (!ctx_stash) throw_nopackage(ctx_class); 1 6 7
if (!ctx_stash) throw_nopackage(ctx_class); 0 1 1
32 6 ▶ if (items > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) { 4 2 6
33 12 ▶ for (I32 i = 1; i < items; ++i) {
Branch: 1 branch
BranchTrueFalseTotal
for (I32 i = 1; i < items; ++i) { 9 3 12
34 9 ▶ panda::string_view name = Simple(ST(i));
Branch: 2 branches
BranchTrueFalseTotal
panda::string_view name = Simple(ST(i)); 9 0 9
panda::string_view name = Simple(ST(i)); 9 0 9
35 9 ▶ if (name == ":const") export_constants(ctx_stash, caller_stash);
Branch: 4 branches
BranchTrueFalseTotal
if (name == ":const") export_constants(ctx_stash, caller_stash); 9 0 9
if (name == ":const") export_constants(ctx_stash, caller_stash); 1 8 9
if (name == ":const") export_constants(ctx_stash, caller_stash); 1 0 1
if (name == ":const") export_constants(ctx_stash, caller_stash); 1 0 1
36 9 ▶ else export_sub(ctx_stash, caller_stash, name);
Branch: 2 branches
BranchTrueFalseTotal
else export_sub(ctx_stash, caller_stash, name); 8 0 8
else export_sub(ctx_stash, caller_stash, name); 7 1 8
37 }
38 }
39 2 ▶ else export_constants(ctx_stash, caller_stash);
Branch: 2 branches
BranchTrueFalseTotal
else export_constants(ctx_stash, caller_stash); 2 0 2
else export_constants(ctx_stash, caller_stash); 2 0 2
40 7 }
41 }
42  
43 Array constants_list (Simple ctx_class) {
44 1 ▶ auto ctx_stash = Stash::from_name(ctx_class);
Branch: 1 branch
BranchTrueFalseTotal
auto ctx_stash = Stash::from_name(ctx_class); 1 0 1
45 1 ▶ if (!ctx_stash) throw_nopackage(ctx_class);
Branch: 2 branches
BranchTrueFalseTotal
if (!ctx_stash) throw_nopackage(ctx_class); 1 0 1
if (!ctx_stash) throw_nopackage(ctx_class); 0 1 1
46 0 ▶ RETVAL = constants_list(ctx_stash);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = constants_list(ctx_stash); 0 0 0
47 }
48  
49 void export_constants (Simple ctx_class, Simple trg_class) {
50 3 ▶ auto ctx_stash = Stash::from_name(ctx_class);
Branch: 1 branch
BranchTrueFalseTotal
auto ctx_stash = Stash::from_name(ctx_class); 3 0 3
51 3 ▶ if (!ctx_stash) throw_nopackage(ctx_class);
Branch: 2 branches
BranchTrueFalseTotal
if (!ctx_stash) throw_nopackage(ctx_class); 2 1 3
if (!ctx_stash) throw_nopackage(ctx_class); 0 2 2
52 1 ▶ auto trg_stash = Stash::from_name(trg_class);
Branch: 1 branch
BranchTrueFalseTotal
auto trg_stash = Stash::from_name(trg_class); 1 0 1
53 1 ▶ if (!trg_stash) throw_nopackage(trg_class);
Branch: 2 branches
BranchTrueFalseTotal
if (!trg_stash) throw_nopackage(trg_class); 1 0 1
if (!trg_stash) throw_nopackage(trg_class); 0 1 1
54
55 0 ▶ export_constants(ctx_stash, trg_stash);
Branch: 2 branches
BranchTrueFalseTotal
export_constants(ctx_stash, trg_stash); 0 0 0
export_constants(ctx_stash, trg_stash); 0 0 0
56 }
« XS_xsgen.cc ↑ Summary blib/arch/Export/XS.pm »