blib/lib/signatures.pm

filter: Statementstmt 98.5% 66 / 67 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 16 / 16 Podpod 60.0% 3 / 5 totaltotal 93.7% 90 / 96 CC 5 SCAR 6.4
CC
5
Cov
95%
__ANON__
5.7
__ANON__
2.0
proto_unwrap
2.0
CRAP 1.9
↑ Summary signatures.xs »
1 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package signatures; # git description: v0.13-13-gf19ea86
4 # ABSTRACT: Subroutine signatures with no source filter
5  
6 8 our $VERSION = '0.14';
7  
8 8 ▶use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use B::Hooks::Parser 0.12;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 8 ▶use B::Hooks::OP::Check 0.17;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 ▶use B::Hooks::OP::PPAddr 0.03;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 8 ▶use B::Hooks::EndOfScope 0.08 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 8 XSLoader::load(
15 __PACKAGE__,
16 $VERSION,
17 );
18  
19 {
20 8 my %pkgs;
21  
22 14 ▶ sub import {
Subroutine import: called CC=1 SCAR=0.0
23 14 my ($class) = @_;
24 14 my $caller = caller();
25 14 $pkgs{$caller} = $class->setup_for($caller);
26 14 return;
27 }
28  
29 2 ▶ sub unimport {
Subroutine unimport: called CC=1 SCAR=0.0
30 2 my ($class) = @_;
31 2 my $caller = caller();
32 2 $class->teardown_for(delete $pkgs{$caller});
33 2 return;
34 }
35 }
36  
37 8 ▶sub setup_for {
Subroutine setup_for: called CC=1 SCAR=0.1
Pod undocumented
38 14 my ($class, $caller) = @_;
39 14 my $ret = $class->setup($caller);
40  
41 14 $^H{"${class}::enabled"} = 1;
42  
43 14 my $old_warn = $SIG{__WARN__};
44 20 ▶ $SIG{__WARN__} = sub {
Subroutine __ANON__: called CC=3 SCAR=17.3
45 20 ▶ if ($_[0] !~ /^(?:(?:Illegal character in prototype)|(?:Prototype after '.')) for /) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $_[0] =~ /^(?:(?:Illegal character in prototype)|(?:Prototype after '.')) for /) 0 20 20
46 0 ▶ $old_warn ? $old_warn->(@_) : warn @_;
Branch: 1 branch
BranchTrueFalseTotal
$old_warn ? : 0 0 0
47 }
48 14 };
49  
50 14 my $unregister;
51 {
52 14 my $called = 0;
53 30 ▶ $unregister = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
54 30 ▶ return if $called++;
Branch: 1 branch
BranchTrueFalseTotal
if $called++ 16 14 30
55 14 $class->teardown_for([$ret, $unregister]);
56 14 $SIG{__WARN__} = $old_warn;
57 14 };
58 }
59  
60 14 &B::Hooks::EndOfScope::on_scope_end($unregister);
61  
62 14 return [$ret, $unregister];
63 }
64  
65 16 ▶sub teardown_for {
Subroutine teardown_for: called CC=1 SCAR=0.0
Pod undocumented
66 16 my ($class, $data) = @_;
67 16 delete $^H{"${class}::enabled"};
68 16 $class->teardown($data->[0]);
69 16 $data->[1]->();
70 16 return;
71 }
72  
73 18 ▶sub callback {
Subroutine callback: called CC=1 SCAR=0.0
Pod documented
74 18 my ($class, $offset, $proto) = @_;
75 18 my $inject = $class->proto_unwrap($proto);
76 18 $class->inject($offset, $inject);
77 18 return;
78 }
79  
80 17 ▶sub proto_unwrap {
Subroutine proto_unwrap: called CC=2 SCAR=6.9
Pod documented
81 17 my ($class, $proto) = @_;
82 17 ▶ return '' unless length $proto;
Branch: 1 branch
BranchTrueFalseTotal
unless length $proto 1 16 17
83 16 return "my ($proto) = \@_;";
84 }
85  
86 18 ▶sub inject {
Subroutine inject: called CC=1 SCAR=0.0
Pod documented
87 18 my ($class, $offset, $inject) = @_;
88 18 my $linestr = B::Hooks::Parser::get_linestr();
89 18 substr($linestr, $offset + 1, 0) = $inject;
90 18 B::Hooks::Parser::set_linestr($linestr);
91 18 return;
92 }
93  
94 8 1;
95  
96 __END__
↑ Summary signatures.xs »