X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDevel%2FDeclare.pm;h=8f16a89a86204620aef3729219e45228a795da6a;hb=82ffef055a3f0bc9c2b7bea538dc86d38033a21b;hp=e6cdea8f6eb0bbef283421d36ed5a5175e6e7a0f;hpb=cc4c6362a0abb93492790bb1a77fba4c09d5100d;p=p5sagit%2FDevel-Declare.git diff --git a/lib/Devel/Declare.pm b/lib/Devel/Declare.pm index e6cdea8..8f16a89 100644 --- a/lib/Devel/Declare.pm +++ b/lib/Devel/Declare.pm @@ -4,7 +4,7 @@ use strict; use warnings; use 5.008001; -our $VERSION = '0.004000'; +our $VERSION = '0.006001'; use constant DECLARE_NAME => 1; use constant DECLARE_PROTO => 2; @@ -580,10 +580,9 @@ These will then get rewritten as where 'method' is a subroutine that takes a code block. Spot the problem? The first one doesn't have a semicolon at the end of it! Unlike 'sub' which is a builtin, this is just a normal statement, so we need to terminate it. -Luckily, using the bastard spawn of L and some hints hash -hackery, we can do this! +Luckily, using C, we can do this! - use Scope::Guard; + use B::Hooks::EndOfScope; We'll add this to what gets 'injected' at the beginning of the method source. @@ -591,18 +590,17 @@ We'll add this to what gets 'injected' at the beginning of the method source. return ' BEGIN { MethodHandlers::inject_scope }; '; } -So at the beginning of every method, we assing a callback that will get invoked +So at the beginning of every method, we are passing a callback that will get invoked at the I of the method's compilation... i.e. exactly then the closing C<'}'> is compiled. sub inject_scope { - $^H |= 0x120000; - $^H{DD_METHODHANDLERS} = Scope::Guard->new(sub { + on_scope_end { my $linestr = Devel::Declare::get_linestr; my $offset = Devel::Declare::get_linestr_offset; substr($linestr, $offset, 0) = ';'; Devel::Declare::set_linestr($linestr); - }); + }; } =head2 Shadowing each method. @@ -651,19 +649,28 @@ L. =head1 AUTHORS -Matt S Trout - - original author +Matt S Trout - Emst@shadowcat.co.ukE - original author Company: http://www.shadowcat.co.uk/ Blog: http://chainsawblues.vox.com/ Florian Ragwitz Erafl@debian.orgE - maintainer -osfameron Eosfameron@cpan.org - first draft of documentation +osfameron Eosfameron@cpan.orgE - first draft of documentation -=head1 LICENSE +=head1 COPYRIGHT AND LICENSE This library is free software under the same terms as perl itself +Copyright (c) 2007, 2008, 2009 Matt S Trout + +Copyright (c) 2008, 2009 Florian Ragwitz + +stolen_chunk_of_toke.c based on toke.c from the perl core, which is + +Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +2000, 2001, 2002, 2003, 2004, 2005, 2006, by Larry Wall and others + =cut 1;