| 1 | package Aspect::Pointcut::Call; | ||||||||||
| 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 | |||||||||||
| 9 | 21 | our $VERSION = '0.97_06'; | |||||||||
| 10 | 21 | our @ISA = 'Aspect::Pointcut'; | |||||||||
| 11 | |||||||||||
| 12 | 21 | ▶ | use constant ORIGINAL => 0; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 21 | ▶ | use constant COMPILE_CODE => 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 21 | ▶ | use constant RUNTIME_CODE => 2; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 21 | ▶ | use constant COMPILE_EVAL => 3; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 21 | ▶ | use constant RUNTIME_EVAL => 4; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | ###################################################################### | ||||||||||
| 23 | # Constructor Methods | ||||||||||
| 24 | |||||||||||
| 25 | # The constructor stores three values. | ||||||||||
| 26 | # $self->[0] is the original specification provided to the constructor | ||||||||||
| 27 | # $self->[1] is a function form of the condition that has a sub name passed | ||||||||||
| 28 | # in and returns true if matching or false if not. | ||||||||||
| 29 | # $self->[2] is a either a string that is a fragment of Perl that can be eval'ed | ||||||||||
| 30 | # with $_ set to a join point object, or a function in the style of | ||||||||||
| 31 | # the $self->[1] param above and taking the sub name param. Returns | ||||||||||
| 32 | # true if matching or false if not. | ||||||||||
| 33 | sub new { | ||||||||||
| 34 | 154 | ▶ | my $class = shift; | ||||||||
|
Subroutine
new: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||
| 35 | 154 | my $spec = shift; | |||||||||
| 36 | 154 | ▶ | if ( Params::Util::_STRING($spec) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 112 | my $string = '"' . quotemeta($spec) . '"'; | |||||||||
| 38 | 112 | return bless [ | |||||||||
| 39 | $spec, | ||||||||||
| 40 | eval "sub () { \$_[0] eq $string }", | ||||||||||
| 41 | eval "sub () { \$_ eq $string }", | ||||||||||
| 42 | eval "sub () { \$_->{sub_name} eq $string }", | ||||||||||
| 43 | "\$_ eq $string", | ||||||||||
| 44 | "\$_->{sub_name} eq $string", | ||||||||||
| 45 | ], $class; | ||||||||||
| 46 | } | ||||||||||
| 47 | 42 | ▶ | if ( Params::Util::_CODELIKE($spec) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | return bless [ | ||||||||||
| 49 | $spec, | ||||||||||
| 50 | $spec, | ||||||||||
| 51 | 0 | ▶ | sub { $spec->($_) }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 52 | 0 | ▶ | sub { $spec->($_->{sub_name}) }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 53 | 2 | ▶ | sub { $spec->($_) }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 54 | 2 | ▶ | sub { $spec->($_->{sub_name}) }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 55 | 1 | ], $class; | |||||||||
| 56 | } | ||||||||||
| 57 | 41 | ▶ | if ( Params::Util::_REGEX($spec) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | # Special case serialisation of regexs | ||||||||||
| 59 | # In Perl 5.13.6 the format of a serialised regex changed | ||||||||||
| 60 | # incompatibly. Worse, the optimisation trick that worked | ||||||||||
| 61 | # before no longer works after, as there are now modifiers | ||||||||||
| 62 | # that are ONLY value inside and can't be moved to the end. | ||||||||||
| 63 | # So we first serialise to a form that will be valid code | ||||||||||
| 64 | # under the new system, and then do the replace that will | ||||||||||
| 65 | # only match (and only be valid) under the old system. | ||||||||||
| 66 | 41 | my $regex = "/$spec/"; | |||||||||
| 67 | 41 | $regex =~ s|^/\(\?([xism]*)-[xism]*:(.*)\)/\z|/$2/$1|s; | |||||||||
| 68 | 41 | return bless [ | |||||||||
| 69 | $spec, | ||||||||||
| 70 | eval "sub () { \$_[0] =~ $regex }", | ||||||||||
| 71 | eval "sub () { $regex }", | ||||||||||
| 72 | eval "sub () { \$_->{sub_name} =~ $regex }", | ||||||||||
| 73 | $regex, | ||||||||||
| 74 | "\$_->{sub_name} =~ $regex", | ||||||||||
| 75 | ], $class; | ||||||||||
| 76 | } | ||||||||||
| 77 | 0 | Carp::croak("Invalid function call specification"); | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | |||||||||||
| 83 | |||||||||||
| 84 | ###################################################################### | ||||||||||
| 85 | # Weaving Methods | ||||||||||
| 86 | |||||||||||
| 87 | sub match_runtime { | ||||||||||
| 88 | 47 | ▶ | return 0; | ||||||||
|
Subroutine
match_runtime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | # Call pointcuts are the primary thing used at weave time | ||||||||||
| 92 | sub curry_weave { | ||||||||||
| 93 | 126 | ▶ | return $_[0]; | ||||||||
|
Subroutine
curry_weave: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 94 | } | ||||||||||
| 95 | |||||||||||
| 96 | # Call pointcuts curry away to null, because they are the basis | ||||||||||
| 97 | # for which methods to hook in the first place. Any method called | ||||||||||
| 98 | # at run-time has already been checked. | ||||||||||
| 99 | sub curry_runtime { | ||||||||||
| 100 | 141 | ▶ | return; | ||||||||
|
Subroutine
curry_runtime: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 101 | } | ||||||||||
| 102 | |||||||||||
| 103 | # Compiled string form of the pointcut | ||||||||||
| 104 | sub compile_weave { | ||||||||||
| 105 | $_[0]->[4]; | ||||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | # Compiled string form of the pointcut | ||||||||||
| 109 | sub compile_runtime { | ||||||||||
| 110 | $_[0]->[5]; | ||||||||||
| 111 | } | ||||||||||
| 112 | |||||||||||
| 113 | |||||||||||
| 114 | |||||||||||
| 115 | |||||||||||
| 116 | |||||||||||
| 117 | ###################################################################### | ||||||||||
| 118 | # Optional XS Acceleration | ||||||||||
| 119 | |||||||||||
| 120 | BEGIN { | ||||||||||
| 121 | 21 | ▶ | local $@; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 122 | 21 | ▶ | eval <<'END_PERL'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 123 | use Class::XSAccessor::Array 1.08 { | ||||||||||
| 124 | replace => 1, | ||||||||||
| 125 | getters => { | ||||||||||
| 126 | 'compile_weave' => 4, | ||||||||||
| 127 | 'compile_runtime' => 5, | ||||||||||
| 128 | }, | ||||||||||
| 129 | }; | ||||||||||
| 130 | END_PERL | ||||||||||
| 131 | } | ||||||||||
| 132 | |||||||||||
| 133 | 21 | 1; | |||||||||
| 134 | |||||||||||
| 135 | __END__ | ||||||||||