| 1 | package Aspect::Pointcut::Throwing; | ||||||||||
| 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::Not (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 21 | ▶ | use Aspect::Pointcut::Returning (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 21 | our $VERSION = '0.97_06'; | |||||||||
| 12 | 21 | our @ISA = 'Aspect::Pointcut'; | |||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | |||||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | ###################################################################### | ||||||||||
| 19 | # Constructor | ||||||||||
| 20 | |||||||||||
| 21 | sub new { | ||||||||||
| 22 | 16 | ▶ | my $class = shift; | ||||||||
|
Subroutine
new: called CC=4 SCAR=22.6
Pod
documented
| |||||||||||
| 23 | 16 | my $spec = shift; | |||||||||
| 24 | |||||||||||
| 25 | # Handle the any exception case | ||||||||||
| 26 | 16 | ▶ | unless ( defined $spec ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 16 | return bless [ | |||||||||
| 28 | $spec, | ||||||||||
| 29 | "\$_->{exception}", | ||||||||||
| 30 | ], $class; | ||||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | # Handle a specific die message | ||||||||||
| 34 | 0 | ▶ | if ( Params::Util::_STRING($spec) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | return bless [ | |||||||||
| 36 | $spec, | ||||||||||
| 37 | "Params::Util::_INSTANCE(\$_->{exception}, '$spec')", | ||||||||||
| 38 | ], $class; | ||||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | # Handle a specific exception class | ||||||||||
| 42 | 0 | ▶ | if ( Params::Util::_REGEX($spec) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | my $regex = "/$spec/"; | |||||||||
| 44 | 0 | $regex =~ s|^/\(\?([xism]*)-[xism]*:(.*)\)/\z|/$2/$1|s; | |||||||||
| 45 | 0 | return bless [ | |||||||||
| 46 | $spec, | ||||||||||
| 47 | "defined \$_->{exception} and not ref \$_->{exception} and \$_->{exception} =~ $regex", | ||||||||||
| 48 | ], $class; | ||||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 0 | Carp::croak("Invalid throwing pointcut specification"); | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | |||||||||||
| 56 | |||||||||||
| 57 | |||||||||||
| 58 | ###################################################################### | ||||||||||
| 59 | # Weaving Methods | ||||||||||
| 60 | |||||||||||
| 61 | # Exception pointcuts always match at weave time and should curry away | ||||||||||
| 62 | sub curry_weave { | ||||||||||
| 63 | 16 | ▶ | return; | ||||||||
|
Subroutine
curry_weave: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | # Throwing pointcuts do not curry. | ||||||||||
| 67 | # (But maybe they should, when used with say a before {} block) | ||||||||||
| 68 | sub curry_runtime { | ||||||||||
| 69 | 16 | ▶ | return $_[0]; | ||||||||
|
Subroutine
curry_runtime: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | sub compile_runtime { | ||||||||||
| 73 | $_[0]->[1]; | ||||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | |||||||||||
| 77 | |||||||||||
| 78 | |||||||||||
| 79 | |||||||||||
| 80 | ###################################################################### | ||||||||||
| 81 | # Optional XS Acceleration | ||||||||||
| 82 | |||||||||||
| 83 | BEGIN { | ||||||||||
| 84 | 21 | ▶ | local $@; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 85 | 21 | ▶ | eval <<'END_PERL'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 86 | use Class::XSAccessor::Array 1.08 { | ||||||||||
| 87 | replace => 1, | ||||||||||
| 88 | getters => { | ||||||||||
| 89 | 'compile_runtime' => 1, | ||||||||||
| 90 | }, | ||||||||||
| 91 | }; | ||||||||||
| 92 | END_PERL | ||||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | 21 | 1; | |||||||||
| 96 | |||||||||||
| 97 | __END__ | ||||||||||