Aspect/Pointcut/Cflow.pm

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