Changeset 14692
- Timestamp:
- 06/27/08 14:44:08 (5 years ago)
- Location:
- dan/perl/Object-with/branches/yappo
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
dan/perl/Object-with/branches/yappo/lib/Object/with.pm
r14553 r14692 27 27 28 28 my @ret = $code->(@_); 29 # %TMP_METHOD_CACHE を片付ける 29 30 while (my($name, $code) = each %TMP_METHOD_CACHE) { 31 no strict 'refs'; 32 no warnings 'redefine'; 33 *{$name} = $code if $code && ref $code; 34 delete $TMP_METHOD_CACHE{$name}; 35 } 30 36 31 37 @ret; … … 39 45 my $class = ref($TMP_OBJ) || $TMP_OBJ; 40 46 41 warn "$name ( $class -> $method )";42 43 47 no strict 'refs'; 44 48 no warnings 'redefine'; 45 49 46 $TMP_METHOD_CACHE{$name} = \&{$name};50 $TMP_METHOD_CACHE{$name} = defined &{$name} ? \&{$name} : undef unless exists $TMP_METHOD_CACHE{$name}; 47 51 *{$name} = \&{"$class\::$method"}; 48 use Data::Dumper;49 52 } 50 53 -
dan/perl/Object-with/branches/yappo/test.pl
r14553 r14692 3 3 sub new { bless {} } 4 4 sub hello { warn "hello" } 5 sub hello2 { warn "hello2" } 5 6 6 7 package main; … … 11 12 use Object::with; 12 13 14 13 15 my $o = MyObj->new; 14 16 15 17 with $o => sub { 16 18 hello(); 19 hello2(); 20 hello(); 17 21 }; 22 hello2(); 18 23 24 sub hello2 { die 'end' } 25 exit; 26 -
dan/perl/Object-with/branches/yappo/with.xs
r14553 r14692 9 9 10 10 OP * with_entersub(pTHX) { 11 d SP;12 SV * sv = *sp;11 dVAR; dSP; 12 SV * const name = *(PL_stack_base + TOPMARK + 1); 13 13 14 if (SvTYPE(sv) == SVt_PVGV) { 15 /* 14 if (SvTYPE(name) == SVt_PVGV) { 16 15 ENTER; 17 16 SAVETMPS; 18 17 PUSHMARK(SP); 19 XPUSHs( sv);18 XPUSHs(name); 20 19 PUTBACK; 21 */22 20 call_pv("Object::with::_entersub", G_DISCARD); 23 /*24 21 FREETMPS; 25 22 LEAVE; 26 */23 27 24 } 28 29 25 return PL_ppaddr[PL_op->op_type](aTHX); 30 26 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)