| 1 | package Aspect::Advice; | ||||||||||||||||||||
| 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 | |||||||||||||||||||||
| 7 | 21 | our $VERSION = '0.97_06'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | sub new { | ||||||||||||||||||||
| 10 | 115 | ▶ | my $class = shift; | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||
| 11 | 115 | my $self = bless { | |||||||||||||||||||
| 12 | @_, | ||||||||||||||||||||
| 13 | installed => 0, | ||||||||||||||||||||
| 14 | }, $class; | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | # Validate the advice and pointcut combination | ||||||||||||||||||||
| 17 | 115 | my $error = $self->_validate; | |||||||||||||||||||
| 18 | 115 | ▶ | Carp::croak($error) if defined $error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | # Install and save the lexical hook | ||||||||||||||||||||
| 21 | 115 | $self->{hook} = $self->_install; | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 115 | return $self; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | sub code { | ||||||||||||||||||||
| 27 | $_[0]->{code}; | ||||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | sub pointcut { | ||||||||||||||||||||
| 31 | $_[0]->{pointcut}; | ||||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | sub lexical { | ||||||||||||||||||||
| 35 | $_[0]->{lexical}; | ||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | sub installed { | ||||||||||||||||||||
| 39 | 0 | ▶ | $_[0]->{installed}; | ||||||||||||||||||
|
Subroutine
installed: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | sub DESTROY { | ||||||||||||||||||||
| 43 | 115 | ▶ | $_[0]->{hook}->() if $_[0]->{hook}; | ||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | ###################################################################### | ||||||||||||||||||||
| 51 | # Installation Internals | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | sub _install { | ||||||||||||||||||||
| 54 | 0 | ▶ | my $class = ref $_[0] || $_[0]; | ||||||||||||||||||
|
Subroutine
_install: not called CC=2 SCAR=17.9
Condition0%0/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||
| 55 | 0 | die("Method '_install' is not implemented by class '$class'"); | |||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | sub _validate { | ||||||||||||||||||||
| 59 | 115 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
_validate: called CC=2 SCAR=7.6
| |||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | # The use of more than one highest rule in a pointcut is not supported | ||||||||||||||||||||
| 62 | 115 | ▶ | if ( $self->pointcut->match_contains('Aspect::Pointcut::Highest') > 1 ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | 0 | return "Multiple highest pointcut use is not yet supported"; | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 115 | return; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | ###################################################################### | ||||||||||||||||||||
| 74 | # Optional XS Acceleration | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | BEGIN { | ||||||||||||||||||||
| 77 | 21 | ▶ | local $@; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 78 | 21 | ▶ | eval <<'END_PERL'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 79 | use Class::XSAccessor 1.08 { | ||||||||||||||||||||
| 80 | replace => 1, | ||||||||||||||||||||
| 81 | getters => { | ||||||||||||||||||||
| 82 | 'code' => 'code', | ||||||||||||||||||||
| 83 | 'pointcut' => 'pointcut', | ||||||||||||||||||||
| 84 | 'lexical' => 'lexical', | ||||||||||||||||||||
| 85 | }, | ||||||||||||||||||||
| 86 | }; | ||||||||||||||||||||
| 87 | END_PERL | ||||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 21 | 1; | |||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | __END__ | ||||||||||||||||||||