Aspect/Pointcut/Cflow.pm

filter: Statementstmt 98.0% 50 / 51 Branchbran 92.8% 13 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod 80.0% 4 / 5 totaltotal 96.4% 81 / 84 CC 8 SCAR 7.7
CC
8
Cov
97%
__ANON__
4.0
new
3.1
caller_info
3.0
CRAP 2.2
« Aspect/Advice.pm ↑ Summary Aspect/Library/Listenable/Event.pm »
1 package Aspect::Pointcut::Cflow;
2  
3 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 26 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 26 ▶use Params::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 26 ▶use Aspect::Pointcut ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 26 ▶use Aspect::Pointcut::Call ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 26 ▶use Aspect::Point::Static ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 26 our $VERSION = '1.04';
11 26 our @ISA = 'Aspect::Pointcut';
12  
13 26 ▶use constant KEY => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 26 ▶use constant SPEC => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16  
17  
18  
19  
20 ######################################################################
21 # Constructor Methods
22  
23 12 ▶sub new {
Subroutine new: called CC=3 SCAR=11.2
Pod documented
24 12 my $class = shift;
25  
26 # Check and default the cflow key
27 12 ▶ my $key = @_ > 1 ? shift : 'enclosing';
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 11 1 12
28 12 ▶ unless ( Params::Util::_IDENTIFIER($key) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&Params::Util::_IDENTIFIER($key)) 0 12 12
29 0 Carp::croak('Invalid runtime context key');
30 }
31  
32 # Generate it via call
33 12 my $call = Aspect::Pointcut::Call->new(shift);
34 12 return bless [ $key, @$call ], $class;
35 }
36  
37  
38  
39  
40  
41 ######################################################################
42 # Weaving Methods
43  
44 # The cflow pointcut is currently of no value at weave time, because it is
45 # actually implemented as something closer to cflowbelow.
46 12 ▶sub curry_weave {
Subroutine curry_weave: called CC=1 SCAR=0.0
Pod documented
47 12 return;
48 }
49  
50 # The cflow pointcuts do not curry at all.
51 # So they don't need to clone, and can be used directly.
52 12 ▶sub curry_runtime {
Subroutine curry_runtime: called CC=1 SCAR=0.0
Pod documented
53 12 return $_[0];
54 }
55  
56  
57  
58  
59  
60 ######################################################################
61 # Runtime Methods
62  
63 12 ▶sub compile_runtime {
Subroutine compile_runtime: called CC=1 SCAR=0.0
Pod documented
64 12 my $self = shift;
65 28 ▶ return sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
66 28 my $level = 2;
67 28 my $caller = undef;
68 28 ▶ while ( my $cc = caller_info($level++) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cc = caller_info($level++)) 66 14 80
69 66 ▶ next unless $self->[SPEC]->( $cc->{sub_name} );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->[2]->($cc->{"sub_name"}) 52 14 66
70 14 $caller = $cc;
71 14 last;
72 }
73 28 ▶ return 0 unless $caller;
Branch: 1 branch
BranchTrueFalseTotal
unless $caller 14 14 28
74 my $static = bless {
75 sub_name => $caller->{sub_name},
76 pointcut => $Aspect::POINT->{pointcut},
77 args => $caller->{args},
78 14 }, 'Aspect::Point::Static';
79 14 $Aspect::POINT->{$self->[KEY]} = $static;
80 14 return 1;
81 12 };
82 }
83  
84 80 ▶sub caller_info {
Subroutine caller_info: called CC=3 SCAR=11.0
Pod undocumented
85 80 my $level = shift;
86  
87 package DB;
88  
89 80 my %call_info;
90 80 @call_info{ qw(
91 calling_package
92 sub_name
93 has_params
94 ) } = (CORE::caller($level))[0, 3, 4];
95  
96 return defined $call_info{calling_package}
97 ? {
98 %call_info,
99 args => [
100 80 ▶ $call_info{has_params} ? @DB::args : ()
Branch: 2 branches
BranchTrueFalseTotal
defined $call_info{'calling_package'} ? : 66 14 80
$call_info{'has_params'} ? : 64 2 66
101 ],
102 } : 0;
103 }
104  
105 26 1;
106  
107 __END__
« Aspect/Advice.pm ↑ Summary Aspect/Library/Listenable/Event.pm »