| 1 | package B::Hooks::EndOfScope::PP; | ||||||||||
| 2 | # ABSTRACT: Execute code after a scope finished compilation - PP implementation | ||||||||||
| 3 | |||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 7 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 7 | our $VERSION = '0.28'; | |||||||||
| 8 | |||||||||||
| 9 | 7 | ▶ | use constant _PERL_VERSION => "$]"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 7 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
| |||||||||||
| 12 | 7 | ▶ | if (_PERL_VERSION =~ /^5\.009/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | # CBA to figure out where %^H got broken and which H::U::HH is sane enough | ||||||||||
| 14 | 0 | die "By design B::Hooks::EndOfScope does not operate in pure-perl mode on perl 5.9.X\n" | |||||||||
| 15 | } | ||||||||||
| 16 | elsif (_PERL_VERSION < '5.010') { | ||||||||||
| 17 | require B::Hooks::EndOfScope::PP::HintHash; | ||||||||||
| 18 | *on_scope_end = \&B::Hooks::EndOfScope::PP::HintHash::on_scope_end; | ||||||||||
| 19 | } | ||||||||||
| 20 | else { | ||||||||||
| 21 | 7 | require B::Hooks::EndOfScope::PP::FieldHash; | |||||||||
| 22 | 7 | *on_scope_end = \&B::Hooks::EndOfScope::PP::FieldHash::on_scope_end; | |||||||||
| 23 | } | ||||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 7 | ▶ | use Sub::Exporter::Progressive 0.001006 -setup => { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | exports => ['on_scope_end'], | ||||||||||
| 28 | groups => { default => ['on_scope_end'] }, | ||||||||||
| 29 | 7 | }; | |||||||||
| 30 | |||||||||||
| 31 | 11 | ▶ | sub __invoke_callback { | ||||||||
|
Subroutine
__invoke_callback: called CC=3 SCAR=11.0
| |||||||||||
| 32 | 11 | local $@; | |||||||||
| 33 | 11 | ▶ | eval { $_[0]->(); 1 } or do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 1 | my $err = $@; | |||||||||
| 35 | 1 | require Carp; | |||||||||
| 36 | 1 | Carp::cluck( (join ' ', | |||||||||
| 37 | 'A scope-end callback raised an exception, which can not be propagated when', | ||||||||||
| 38 | 'B::Hooks::EndOfScope operates in pure-perl mode. Your program will CONTINUE', | ||||||||||
| 39 | 'EXECUTION AS IF NOTHING HAPPENED AFTER THIS WARNING. Below is the complete', | ||||||||||
| 40 | 'exception text, followed by a stack-trace of the callback execution:', | ||||||||||
| 41 | ) . "\n\n$err\n\r" ); | ||||||||||
| 42 | |||||||||||
| 43 | 1 | ▶ | sleep 1 if -t *STDERR; # maybe a bad idea...? | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | }; | ||||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 7 | 1; | |||||||||
| 48 | |||||||||||
| 49 | __END__ | ||||||||||