Changeset 14697 for dan

Show
Ignore:
Timestamp:
06/27/08 15:49:57 (5 months ago)
Author:
yappo
Message:

うまく動いてなかった、いらないサブルーチン定義の削除がうまくいかないボス毛手

Location:
dan/perl/Object-with/branches/yappo
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • dan/perl/Object-with/branches/yappo/lib/Object/with.pm

    r14692 r14697  
    3131        no strict 'refs'; 
    3232        no warnings 'redefine'; 
    33         *{$name} = $code if $code && ref $code; 
     33        my($caller, $method) = $name =~ /^(.*)::(.*)$/; 
     34        if ($code && ref $code) { 
     35            *{$name} = $code; 
     36        } else { 
     37            *{$name} = sub{}; 
     38        } 
    3439        delete $TMP_METHOD_CACHE{$name}; 
    3540    } 
     
    4752    no strict 'refs'; 
    4853    no warnings 'redefine'; 
    49  
    5054    $TMP_METHOD_CACHE{$name} = defined &{$name} ? \&{$name} : undef unless exists $TMP_METHOD_CACHE{$name}; 
    51     *{$name}                 = \&{"$class\::$method"}; 
     55    *{$name}                 = sub { unshift @_, $TMP_OBJ; goto &{"$class\::$method"} }; 
    5256} 
    5357 
  • dan/perl/Object-with/branches/yappo/test.pl

    r14692 r14697  
    2020    hello(); 
    2121}; 
     22warn "----------------"; 
     23hello(); 
    2224hello2(); 
     25warn "----------------"; 
    2326 
    2427sub hello2 { die 'end' }