From: Florian Ragwitz Date: Mon, 13 Apr 2009 17:08:45 +0000 (+0000) Subject: Port the docs from Scope::Guard + %^H to B::Hooks::EndOfScope. X-Git-Tag: 0.005000~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-Declare.git;a=commitdiff_plain;h=6c1cecd449028fd933d983a5451048fa12d6041e Port the docs from Scope::Guard + %^H to B::Hooks::EndOfScope. --- diff --git a/lib/Devel/Declare.pm b/lib/Devel/Declare.pm index e6cdea8..00422de 100644 --- a/lib/Devel/Declare.pm +++ b/lib/Devel/Declare.pm @@ -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. @@ -596,13 +595,12 @@ 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.