line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HO::mixin; |
2
|
|
|
|
|
|
|
# ****************** |
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
# ********************** |
5
|
1
|
|
|
1
|
|
446
|
; use strict; use warnings |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
; use Carp () |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
8
|
1
|
|
|
1
|
|
5
|
; use Package::Subroutine () |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
14
|
|
9
|
1
|
|
|
1
|
|
5
|
; use Data::Dumper |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
4
|
; our $class |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
322
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
; sub import |
14
|
1
|
|
|
1
|
|
9
|
{ my ($self, $mixin, @args) = @_ |
15
|
1
|
|
33
|
|
|
8
|
; my $class = $HO::mixin::class || CORE::caller |
16
|
1
|
50
|
|
|
|
5
|
; unless (defined $mixin) |
17
|
0
|
|
|
|
|
0
|
{ Carp::croak("Which class do you want to mix into ${self}?") |
18
|
|
|
|
|
|
|
} |
19
|
1
|
|
|
|
|
54
|
; eval "require $mixin" |
20
|
|
|
|
|
|
|
|
21
|
1
|
50
|
|
|
|
11
|
; if($HO::class::class_args{$mixin}) |
22
|
|
|
|
|
|
|
{ $HO::class::mixin_classes{$class} = [] unless |
23
|
1
|
50
|
|
|
|
5
|
defined $HO::class::mixin_classes{$class} |
24
|
1
|
|
|
|
|
1
|
; push @{$HO::class::mixin_classes{$class}}, @{$HO::class::class_args{$mixin}} |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
; $HO::accessor::classes{$class} = [] unless |
28
|
1
|
50
|
|
|
|
4
|
defined $HO::accessor::classes{$class} |
29
|
1
|
|
|
|
|
2
|
; my $mix = $HO::accessor::classes{$mixin} |
30
|
1
|
50
|
|
|
|
4
|
; $mix = [] unless ref $mix |
31
|
1
|
|
|
|
|
2
|
; push @{$HO::accessor::classes{$class}}, @$mix |
|
1
|
|
|
|
|
3
|
|
32
|
1
|
|
|
|
|
2
|
; my %acc = @$mix |
33
|
2
|
|
66
|
|
|
12
|
; my @methods = grep { !(/^new$/ || defined($acc{$_})) } |
34
|
1
|
|
|
|
|
6
|
grep { ! $HO::class::class_methods{$mixin}{$_} } |
|
3
|
|
|
|
|
42
|
|
35
|
|
|
|
|
|
|
Package::Subroutine->findsubs( $mixin ) |
36
|
1
|
|
|
|
|
4
|
; Package::Subroutine->export_to($class)->($mixin,@methods) |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
; 1 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |