line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Method::ModifiersX::Override; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
26703
|
use 5.008; |
|
3
|
|
|
|
|
7
|
|
4
|
3
|
|
|
3
|
|
10
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
50
|
|
5
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
127
|
|
6
|
3
|
|
|
3
|
|
10
|
no warnings qw( once void uninitialized ); |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
152
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
3
|
|
|
3
|
|
4
|
$Class::Method::ModifiersX::Override::AUTHORITY = 'cpan:TOBYINK'; |
10
|
3
|
|
|
|
|
59
|
$Class::Method::ModifiersX::Override::VERSION = '0.003'; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
10
|
use base qw(Exporter); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
345
|
|
14
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
15
|
|
|
|
|
|
|
all => [our @EXPORT_OK = our @EXPORT = qw( override super )], |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
3
|
|
|
3
|
|
11
|
use Carp qw( croak ); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
162
|
|
19
|
3
|
|
|
3
|
|
1297
|
use Class::Method::Modifiers qw( install_modifier ); |
|
3
|
|
|
|
|
3129
|
|
|
3
|
|
|
|
|
795
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $SUPER_PACKAGE = undef; |
22
|
|
|
|
|
|
|
our $SUPER_BODY = undef; |
23
|
|
|
|
|
|
|
our @SUPER_ARGS = (); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _mk_around |
26
|
|
|
|
|
|
|
{ |
27
|
4
|
|
|
4
|
|
7
|
my ($into, $code) = @_; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
return sub { |
30
|
6
|
|
|
6
|
|
1059
|
local $SUPER_PACKAGE = $into; |
31
|
6
|
|
|
|
|
8
|
local $SUPER_BODY = shift; |
32
|
6
|
|
|
|
|
13
|
local @SUPER_ARGS = @_; |
33
|
6
|
|
|
|
|
11
|
return $code->(@_); |
34
|
|
|
|
|
|
|
} |
35
|
4
|
|
|
|
|
14
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our %OVERRIDDEN; |
38
|
|
|
|
|
|
|
sub override |
39
|
|
|
|
|
|
|
{ |
40
|
2
|
|
|
2
|
1
|
272
|
my $into = caller(0); |
41
|
2
|
|
|
|
|
3
|
my $code = pop; |
42
|
2
|
|
|
|
|
3
|
my @name = @_; |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
4
|
for my $method (@name) |
45
|
|
|
|
|
|
|
{ |
46
|
|
|
|
|
|
|
croak "Method '$method' in class '$into' overridden twice" |
47
|
2
|
50
|
|
|
|
9
|
if $OVERRIDDEN{$into}{$method}++; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
|
|
5
|
my $sub = _mk_around($into, $code); |
51
|
2
|
|
|
|
|
7
|
install_modifier($into, 'around', @name, $sub); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub super () |
55
|
|
|
|
|
|
|
{ |
56
|
6
|
50
|
|
6
|
1
|
20
|
return unless defined $SUPER_BODY; |
57
|
6
|
50
|
33
|
|
|
27
|
return if defined $SUPER_PACKAGE && $SUPER_PACKAGE ne caller; |
58
|
6
|
|
|
|
|
66
|
$SUPER_BODY->(@SUPER_ARGS); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |