/[cvs]/nfo/perl/libs/mixin.pm
ViewVC logotype

Diff of /nfo/perl/libs/mixin.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Thu Dec 12 02:47:51 2002 UTC revision 1.2 by joko, Thu Dec 12 02:48:30 2002 UTC
# Line 88  sub _mixup { Line 88  sub _mixup {
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;
# Line 98  my %Thieved = (); Line 99  my %Thieved = ();
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.'::'}) {
# Line 106  sub _thieve_public_methods { Line 107  sub _thieve_public_methods {
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;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed