| 88 |
# mixin::with" typically runs *before* the rest of the mixin's |
# mixin::with" typically runs *before* the rest of the mixin's |
| 89 |
# subroutines are declared. |
# subroutines are declared. |
| 90 |
_thieve_public_methods( $mixin, $pkg ); |
_thieve_public_methods( $mixin, $pkg ); |
| 91 |
|
_thieve_private_methods( $mixin, $pkg ); |
| 92 |
_thieve_isa( $mixin, $pkg, $with ); |
_thieve_isa( $mixin, $pkg, $with ); |
| 93 |
|
|
| 94 |
unshift @{$caller.'::ISA'}, $pkg; |
unshift @{$caller.'::ISA'}, $pkg; |
| 99 |
sub _thieve_public_methods { |
sub _thieve_public_methods { |
| 100 |
my($mixin, $pkg) = @_; |
my($mixin, $pkg) = @_; |
| 101 |
|
|
| 102 |
return if $Thieved{$mixin}++; |
return if $Thieved{$mixin . '_public'}++; |
| 103 |
|
|
| 104 |
local *glob; |
local *glob; |
| 105 |
while( my($sym, $glob) = each %{$mixin.'::'}) { |
while( my($sym, $glob) = each %{$mixin.'::'}) { |
| 107 |
next unless defined $glob; |
next unless defined $glob; |
| 108 |
*glob = *$glob; |
*glob = *$glob; |
| 109 |
*{$pkg.'::'.$sym} = *glob{CODE} if *glob{CODE}; |
*{$pkg.'::'.$sym} = *glob{CODE} if *glob{CODE}; |
| 110 |
|
} |
| 111 |
|
|
| 112 |
|
return 1; |
| 113 |
|
} |
| 114 |
|
sub _thieve_private_methods { |
| 115 |
|
my($mixin, $pkg) = @_; |
| 116 |
|
|
| 117 |
|
return if $Thieved{$mixin . '_private'}++; |
| 118 |
|
|
| 119 |
|
local *glob; |
| 120 |
|
while( my($sym, $glob) = each %{$mixin.'::'}) { |
| 121 |
|
next if $sym !~ /^_/; |
| 122 |
|
next unless defined $glob; |
| 123 |
|
*glob = *$glob; |
| 124 |
|
*{$pkg.'::'.$sym} = *glob{CODE} if *glob{CODE}; |
| 125 |
} |
} |
| 126 |
|
|
| 127 |
return 1; |
return 1; |