/usr/local/lib/perl5/site_perl/5.44.0/B/Hooks/EndOfScope/XS.pm

filter: Statementstmt 92.3% 24 / 26 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 91.8% 34 / 37 CC 3 SCAR 3.8
CC
3
Cov
89%
on_scope_end
2.3
__ANON__
2.0
BEGIN
1.0
CRAP 1.5
« /usr/local/lib/perl5/5.44.0/x86_64-linux/Encode/MIME/Name.pm ↑ Summary lib/Skilletor/Cache.pm »
1 package B::Hooks::EndOfScope::XS;
2 # ABSTRACT: Execute code after a scope finished compilation - XS implementation
3  
4 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 our $VERSION = '0.28';
8  
9 # Limit the Variable::Magic-based (XS) version to perl 5.8.4+
10 #
11 # Given the unorthodox stuff we do to work around the hinthash double-free
12 # might as well play it safe and only implement it in the PP version
13 # and leave it at that
14 # https://rt.perl.org/Public/Bug/Display.html?id=27040#txn-82797
15 #
16 7 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 7 ▶use Variable::Magic 0.48 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19 7 ▶use Sub::Exporter::Progressive 0.001006 -setup => {
Subroutine BEGIN: called CC=1 SCAR=0.0
20 exports => ['on_scope_end'],
21 groups => { default => ['on_scope_end'] },
22 7 };
23  
24 my $wiz = Variable::Magic::wizard
25 135 ▶ data => sub { [$_[1]] },
Subroutine __ANON__: called CC=1 SCAR=0.0
26 135 ▶ free => sub { $_->() for @{ $_[1] }; () },
Subroutine __ANON__: called CC=2 SCAR=6.9
27 # When someone localise %^H, our magic doesn't want to be copied
28 # down. We want it to be around only for the scope we've initially
29 # attached ourselves to. Merely having MGf_LOCAL and a noop svt_local
30 # callback achieves this. If anything wants to attach more magic of our
31 # kind to a localised %^H, things will continue to just work as we'll be
32 # attached with a new and empty callback list.
33 7 local => \undef
34 ;
35  
36 135 ▶sub on_scope_end (&) {
Subroutine on_scope_end: called CC=2 SCAR=8.4
Pod documented
37 135 $^H |= 0x020000;
38  
39 135 ▶ if (my $stack = Variable::Magic::getdata %^H, $wiz) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $stack = &Variable::Magic::getdata(\%^H, $wiz)) { } 0 135 135
40 0 push @{ $stack }, $_[0];
41 }
42 else {
43 135 Variable::Magic::cast %^H, $wiz, $_[0];
44 }
45 }
46  
47 7 1;
48  
49 __END__
« /usr/local/lib/perl5/5.44.0/x86_64-linux/Encode/MIME/Name.pm ↑ Summary lib/Skilletor/Cache.pm »