[Bast-commits] r4977 - in Devel-Declare/1.000/trunk:
lib/Devel/Declare/Context lib/Devel/Declare/MethodInstaller t
rhesa at dev.catalyst.perl.org
rhesa at dev.catalyst.perl.org
Sat Oct 25 11:32:32 BST 2008
Author: rhesa
Date: 2008-10-25 11:32:32 +0100 (Sat, 25 Oct 2008)
New Revision: 4977
Modified:
Devel-Declare/1.000/trunk/lib/Devel/Declare/Context/Simple.pm
Devel-Declare/1.000/trunk/lib/Devel/Declare/MethodInstaller/Simple.pm
Devel-Declare/1.000/trunk/t/methinstaller-simple.t
Log:
using :lvalue subs breaks the debugger, so I added a inc_offset method to Context::Simple
Modified: Devel-Declare/1.000/trunk/lib/Devel/Declare/Context/Simple.pm
===================================================================
--- Devel-Declare/1.000/trunk/lib/Devel/Declare/Context/Simple.pm 2008-10-25 10:16:32 UTC (rev 4976)
+++ Devel-Declare/1.000/trunk/lib/Devel/Declare/Context/Simple.pm 2008-10-25 10:32:32 UTC (rev 4977)
@@ -13,20 +13,32 @@
sub init {
my $self = shift;
@{$self}{ qw(Declarator Offset) } = @_;
- $self;
+ return $self;
}
-sub offset : lvalue { shift->{Offset}; }
-sub declarator { shift->{Declarator} }
+sub offset {
+ my $self = shift;
+ return $self->{Offset}
+}
+sub inc_offset {
+ my $self = shift;
+ $self->{Offset} += shift;
+}
+
+sub declarator {
+ my $self = shift;
+ return $self->{Declarator}
+}
+
sub skip_declarator {
my $self = shift;
- $self->offset += Devel::Declare::toke_move_past_token( $self->offset );
+ $self->inc_offset(Devel::Declare::toke_move_past_token($self->offset));
}
sub skipspace {
my $self = shift;
- $self->offset += Devel::Declare::toke_skipspace( $self->offset );
+ $self->inc_offset(Devel::Declare::toke_skipspace($self->offset));
}
sub get_linestr {
@@ -87,7 +99,7 @@
}
sub shadow {
- my $self = shift;
+ my $self = shift;
my $pack = $self->get_curstash_name;
Devel::Declare::shadow_sub( $pack . '::' . $self->declarator, $_[0] );
}
Modified: Devel-Declare/1.000/trunk/lib/Devel/Declare/MethodInstaller/Simple.pm
===================================================================
--- Devel-Declare/1.000/trunk/lib/Devel/Declare/MethodInstaller/Simple.pm 2008-10-25 10:16:32 UTC (rev 4976)
+++ Devel-Declare/1.000/trunk/lib/Devel/Declare/MethodInstaller/Simple.pm 2008-10-25 10:32:32 UTC (rev 4977)
@@ -26,36 +26,34 @@
my $self = shift;
$self->skipspace;
- my $Offset = $self->offset;
my $linestr = Devel::Declare::get_linestr;
my $attrs = '';
- if (substr($linestr, $Offset, 1) eq ':') {
- while (substr($linestr, $Offset, 1) ne '{') {
- if (substr($linestr, $Offset, 1) eq ':') {
- substr($linestr, $Offset, 1) = '';
+ if (substr($linestr, $self->offset, 1) eq ':') {
+ while (substr($linestr, $self->offset, 1) ne '{') {
+ if (substr($linestr, $self->offset, 1) eq ':') {
+ substr($linestr, $self->offset, 1) = '';
Devel::Declare::set_linestr($linestr);
$attrs .= ':';
}
$self->skipspace;
- $Offset = $self->offset;
$linestr = Devel::Declare::get_linestr();
- if (my $len = Devel::Declare::toke_scan_word($Offset, 0)) {
- my $name = substr($linestr, $Offset, $len);
- substr($linestr, $Offset, $len) = '';
+ if (my $len = Devel::Declare::toke_scan_word($self->offset, 0)) {
+ my $name = substr($linestr, $self->offset, $len);
+ substr($linestr, $self->offset, $len) = '';
Devel::Declare::set_linestr($linestr);
$attrs .= " ${name}";
- if (substr($linestr, $Offset, 1) eq '(') {
- my $length = Devel::Declare::toke_scan_str($Offset);
+ if (substr($linestr, $self->offset, 1) eq '(') {
+ my $length = Devel::Declare::toke_scan_str($self->offset);
my $arg = Devel::Declare::get_lex_stuff();
Devel::Declare::clear_lex_stuff();
$linestr = Devel::Declare::get_linestr();
- substr($linestr, $Offset, $length) = '';
+ substr($linestr, $self->offset, $length) = '';
Devel::Declare::set_linestr($linestr);
$attrs .= "(${arg})";
Modified: Devel-Declare/1.000/trunk/t/methinstaller-simple.t
===================================================================
--- Devel-Declare/1.000/trunk/t/methinstaller-simple.t 2008-10-25 10:16:32 UTC (rev 4976)
+++ Devel-Declare/1.000/trunk/t/methinstaller-simple.t 2008-10-25 10:32:32 UTC (rev 4977)
@@ -66,7 +66,7 @@
@test_list = (method { 1 }, sub { 2 }, method () { 3 }, sub { 4 });
- method leftie :lvalue { $self->{attributes} };
+ method leftie($left) : method { $self->{left} ||= $left; $self->{left} };
}
use Test::More 'no_plan';
@@ -81,7 +81,7 @@
is($o->main, 'main', 'declaration of package named method ok');
-$o->leftie = 'attributes work';
+$o->leftie( 'attributes work' );
is($o->leftie, 'attributes work', 'code attributes intact');
$o->upgrade;
More information about the Bast-commits
mailing list