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