File Coverage

src/xs/basic.cc
Criterion Covered Total %
statement 23 28 82.1
branch 19 36 52.7
condition n/a
subroutine n/a
pod n/a
total 42 64 65.6


line stmt bran cond sub pod time code
1             #include
2             #include
3             #include
4             #include
5             #include
6              
7             namespace xs {
8              
9             using panda::string;
10              
11             #ifdef PERL_IMPLICIT_CONTEXT
12             PerlInterpreter* my_perl_auto_t::main_interp = PERL_GET_THX;
13             #endif
14              
15             my_perl_auto_t my_perl;
16              
17 36           static std::vector> end_cbs;
18              
19 0           void at_perl_destroy (const panda::function& f) {
20 0           end_cbs.push_back(f);
21 0           }
22              
23 36           void __call_at_perl_destroy () {
24 36 50         for (auto& f : end_cbs) f();
    0          
25 36           Sv::__at_perl_destroy();
26 36           Scalar::__at_perl_destroy();
27 36           Simple::__at_perl_destroy();
28 36           }
29              
30 0           void __call_at_thread_create () {
31             #ifdef PERL_IMPLICIT_CONTEXT
32             my_perl_auto_t::main_interp = nullptr;
33             #endif
34 0           }
35              
36 136           void __boot_module (const char* rawmod, void (*bootfunc)(pTHX_ CV*), const char* version, const char* file) {
37 272           string bs("::bootstrap");
38 272 50         string module(strlen(rawmod) + bs.length() + 1);
39 136 50         module.assign(rawmod);
40              
41 136           auto len = module.length();
42 136 50         auto ptr = module.buf();
43 2414 100         for (size_t i = 0; i < len; ++i) {
44 2278 100         if (ptr[i] != '_' || i >= len - 1 || ptr[i+1] != '_') continue;
    50          
    50          
45 204           ptr[i] = ':';
46 204           ptr[i+1] = ':';
47 204           ++i;
48             }
49              
50 272 50         auto xsname = module + bs;
51              
52 272 50         Sub sub = newXS(xsname.c_str(), bootfunc, file);
    50          
    50          
53 136 50         sub.call(Simple(module), Simple(version));
    50          
    50          
54 136           }
55              
56 144 50         }
    50