| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Aspect::Advice; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 21 |  |  | 21 |  | 84 | use strict; | 
|  | 21 |  |  |  |  | 30 |  | 
|  | 21 |  |  |  |  | 576 |  | 
| 4 | 21 |  |  | 21 |  | 83 | use warnings; | 
|  | 21 |  |  |  |  | 26 |  | 
|  | 21 |  |  |  |  | 442 |  | 
| 5 | 21 |  |  | 21 |  | 71 | use Carp (); | 
|  | 21 |  |  |  |  | 25 |  | 
|  | 21 |  |  |  |  | 6013 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | our $VERSION = '0.97_06'; | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | sub new { | 
| 10 | 115 |  |  | 115 | 0 | 238 | my $class = shift; | 
| 11 | 115 |  |  |  |  | 620 | my $self  = bless { | 
| 12 |  |  |  |  |  |  | @_, | 
| 13 |  |  |  |  |  |  | installed => 0, | 
| 14 |  |  |  |  |  |  | }, $class; | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | # Validate the advice and pointcut combination | 
| 17 | 115 |  |  |  |  | 475 | my $error = $self->_validate; | 
| 18 | 115 | 50 |  |  |  | 313 | Carp::croak($error) if defined $error; | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | # Install and save the lexical hook | 
| 21 | 115 |  |  |  |  | 395 | $self->{hook} = $self->_install; | 
| 22 |  |  |  |  |  |  |  | 
| 23 | 115 |  |  |  |  | 696 | 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 | 0 | 0 | $_[0]->{installed}; | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | sub DESTROY { | 
| 43 | 115 | 100 |  | 115 |  | 41695 | $_[0]->{hook}->() if $_[0]->{hook}; | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | ###################################################################### | 
| 51 |  |  |  |  |  |  | # Installation Internals | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | sub _install { | 
| 54 | 0 |  | 0 | 0 |  | 0 | my $class = ref $_[0] || $_[0]; | 
| 55 | 0 |  |  |  |  | 0 | die("Method '_install' is not implemented by class '$class'"); | 
| 56 |  |  |  |  |  |  | } | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | sub _validate { | 
| 59 | 115 |  |  | 115 |  | 185 | my $self = shift; | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | # The use of more than one highest rule in a pointcut is not supported | 
| 62 | 115 | 50 |  |  |  | 728 | if ( $self->pointcut->match_contains('Aspect::Pointcut::Highest') > 1 ) { | 
| 63 | 0 |  |  |  |  | 0 | return "Multiple highest pointcut use is not yet supported"; | 
| 64 |  |  |  |  |  |  | } | 
| 65 |  |  |  |  |  |  |  | 
| 66 | 115 |  |  |  |  | 229 | return; | 
| 67 |  |  |  |  |  |  | } | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | ###################################################################### | 
| 74 |  |  |  |  |  |  | # Optional XS Acceleration | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | BEGIN { | 
| 77 | 21 |  |  | 21 |  | 36 | local $@; | 
| 78 | 21 |  |  | 21 |  | 1404 | eval <<'END_PERL'; | 
|  | 21 |  |  |  |  | 98 |  | 
|  | 21 |  |  |  |  | 360 |  | 
|  | 21 |  |  |  |  | 163 |  | 
| 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 |  |  |  |  |  |  | 1; | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | __END__ |