From: Dave Rolsky Date: Sun, 26 Sep 2010 16:25:20 +0000 (-0500) Subject: Add semi-colon in code that generates entire assignment, which makes snippets more... X-Git-Tag: 1.15~67 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=584540d9166f6651182e953c57a10d9648fea1a9;p=gitmo%2FMoose.git Add semi-colon in code that generates entire assignment, which makes snippets more flexible --- diff --git a/lib/Moose/Meta/Method/Accessor/Native/Array/clear.pm b/lib/Moose/Meta/Method/Accessor/Native/Array/clear.pm index 538ffff..1f65ae2 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Array/clear.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Array/clear.pm @@ -18,7 +18,7 @@ sub _potential_value { return '[]' } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access = [];"; + return "$slot_access = []"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Array/delete.pm b/lib/Moose/Meta/Method/Accessor/Native/Array/delete.pm index 25bed03..2577ab7 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Array/delete.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Array/delete.pm @@ -31,7 +31,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "splice \@{ $slot_access }, \$_[0], 1;"; + return "splice \@{ $slot_access }, \$_[0], 1"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Array/pop.pm b/lib/Moose/Meta/Method/Accessor/Native/Array/pop.pm index 8f24ccb..f185152 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Array/pop.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Array/pop.pm @@ -28,7 +28,7 @@ sub _inline_capture_return_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "pop \@{ $slot_access };"; + return "pop \@{ $slot_access }"; } sub _return_value { diff --git a/lib/Moose/Meta/Method/Accessor/Native/Array/push.pm b/lib/Moose/Meta/Method/Accessor/Native/Array/push.pm index 2666f03..6eadc37 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Array/push.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Array/push.pm @@ -20,7 +20,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "push \@{ $slot_access }, \@_;"; + return "push \@{ $slot_access }, \@_"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Array/set.pm b/lib/Moose/Meta/Method/Accessor/Native/Array/set.pm index def5775..d2b2d5a 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Array/set.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Array/set.pm @@ -33,7 +33,7 @@ sub _new_members { '$_[1]' } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "${slot_access}->[ \$_[0] ] = \$_[1];"; + return "${slot_access}->[ \$_[0] ] = \$_[1]"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Array/splice.pm b/lib/Moose/Meta/Method/Accessor/Native/Array/splice.pm index 8663558..78e5834 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Array/splice.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Array/splice.pm @@ -36,7 +36,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "defined \$len ? ( splice \@{ $slot_access }, \$idx, \$len, \@_ ) : ( splice \@{ $slot_access }, \$idx );"; + return "defined \$len ? ( splice \@{ $slot_access }, \$idx, \$len, \@_ ) : ( splice \@{ $slot_access }, \$idx )"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Array/unshift.pm b/lib/Moose/Meta/Method/Accessor/Native/Array/unshift.pm index d113877..b2c94cb 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Array/unshift.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Array/unshift.pm @@ -20,7 +20,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "unshift \@{ $slot_access }, \@_;"; + return "unshift \@{ $slot_access }, \@_"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Bool/set.pm b/lib/Moose/Meta/Method/Accessor/Native/Bool/set.pm index 625b4bb..2814f54 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Bool/set.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Bool/set.pm @@ -17,7 +17,7 @@ sub _potential_value { 1 } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access = 1;"; + return "$slot_access = 1"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Bool/toggle.pm b/lib/Moose/Meta/Method/Accessor/Native/Bool/toggle.pm index b554523..dd8383c 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Bool/toggle.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Bool/toggle.pm @@ -21,7 +21,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access = $slot_access ? 0 : 1;"; + return "$slot_access = $slot_access ? 0 : 1"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Bool/unset.pm b/lib/Moose/Meta/Method/Accessor/Native/Bool/unset.pm index c24263f..3fc429d 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Bool/unset.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Bool/unset.pm @@ -17,7 +17,7 @@ sub _potential_value { 0 } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access = 0;"; + return "$slot_access = 0"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Counter/dec.pm b/lib/Moose/Meta/Method/Accessor/Native/Counter/dec.pm index 6c266ef..85ab22f 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Counter/dec.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Counter/dec.pm @@ -15,13 +15,13 @@ sub _maximum_arguments {1} sub _potential_value { my ( $self, $slot_access ) = @_; - return "$slot_access - ( defined \$_[0] ? \$_[0] : 1 );"; + return "$slot_access - ( defined \$_[0] ? \$_[0] : 1 )"; } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access -= defined \$_[0] ? \$_[0] : 1;"; + return "$slot_access -= defined \$_[0] ? \$_[0] : 1"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Counter/inc.pm b/lib/Moose/Meta/Method/Accessor/Native/Counter/inc.pm index c231d8e..252fdb8 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Counter/inc.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Counter/inc.pm @@ -15,13 +15,13 @@ sub _maximum_arguments { 1 } sub _potential_value { my ( $self, $slot_access ) = @_; - return "$slot_access + ( defined \$_[0] ? \$_[0] : 1 );"; + return "$slot_access + ( defined \$_[0] ? \$_[0] : 1 )"; } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access += defined \$_[0] ? \$_[0] : 1;"; + return "$slot_access += defined \$_[0] ? \$_[0] : 1"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Counter/reset.pm b/lib/Moose/Meta/Method/Accessor/Native/Counter/reset.pm index f85d863..9528958 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Counter/reset.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Counter/reset.pm @@ -21,7 +21,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access = \$attr->default(\$self);"; + return "$slot_access = \$attr->default(\$self)"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Hash/clear.pm b/lib/Moose/Meta/Method/Accessor/Native/Hash/clear.pm index 57e2d31..0998878 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Hash/clear.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Hash/clear.pm @@ -18,7 +18,7 @@ sub _potential_value { return '{}' } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access = {};"; + return "$slot_access = {}"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Hash/delete.pm b/lib/Moose/Meta/Method/Accessor/Native/Hash/delete.pm index b5368bd..17a4f93 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Hash/delete.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Hash/delete.pm @@ -20,7 +20,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "delete \@{ $slot_access }{\@_};"; + return "delete \@{ $slot_access }{\@_}"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Hash/set.pm b/lib/Moose/Meta/Method/Accessor/Native/Hash/set.pm index 89b238b..7e35f5d 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Hash/set.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Hash/set.pm @@ -55,7 +55,7 @@ sub _new_members { '@_[ @values_idx ]' } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "\@{ $slot_access }{ \@_[ \@keys_idx] } = \@_[ \@values_idx ];"; + return "\@{ $slot_access }{ \@_[ \@keys_idx] } = \@_[ \@values_idx ]"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Number/abs.pm b/lib/Moose/Meta/Method/Accessor/Native/Number/abs.pm index 4fc3bcb..ebeb683 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Number/abs.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Number/abs.pm @@ -15,7 +15,7 @@ sub _maximum_arguments {0} sub _potential_value { my ( $self, $slot_access ) = @_; - return "abs($slot_access);"; + return "abs($slot_access)"; } sub _inline_optimized_set_new_value { diff --git a/lib/Moose/Meta/Method/Accessor/Native/Number/add.pm b/lib/Moose/Meta/Method/Accessor/Native/Number/add.pm index e3a5f3b..01b8788 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Number/add.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Number/add.pm @@ -15,13 +15,13 @@ sub _maximum_arguments {1} sub _potential_value { my ( $self, $slot_access ) = @_; - return "$slot_access + \$_[0];"; + return "$slot_access + \$_[0]"; } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access += \$_[0];"; + return "$slot_access += \$_[0]"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Number/div.pm b/lib/Moose/Meta/Method/Accessor/Native/Number/div.pm index 264ca2b..eafdb96 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Number/div.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Number/div.pm @@ -15,13 +15,13 @@ sub _maximum_arguments {1} sub _potential_value { my ( $self, $slot_access ) = @_; - return "$slot_access / \$_[0];"; + return "$slot_access / \$_[0]"; } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access /= \$_[0];"; + return "$slot_access /= \$_[0]"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Number/mod.pm b/lib/Moose/Meta/Method/Accessor/Native/Number/mod.pm index 83d2363..823c553 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Number/mod.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Number/mod.pm @@ -15,13 +15,13 @@ sub _maximum_arguments {1} sub _potential_value { my ( $self, $slot_access ) = @_; - return "$slot_access % \$_[0];"; + return "$slot_access % \$_[0]"; } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access %= \$_[0];"; + return "$slot_access %= \$_[0]"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Number/mul.pm b/lib/Moose/Meta/Method/Accessor/Native/Number/mul.pm index 482de12..b0d0704 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Number/mul.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Number/mul.pm @@ -15,13 +15,13 @@ sub _maximum_arguments {1} sub _potential_value { my ( $self, $slot_access ) = @_; - return "$slot_access * \$_[0];"; + return "$slot_access * \$_[0]"; } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access *= \$_[0];"; + return "$slot_access *= \$_[0]"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Number/set.pm b/lib/Moose/Meta/Method/Accessor/Native/Number/set.pm index 5d06b5c..b76efb3 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Number/set.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Number/set.pm @@ -17,7 +17,7 @@ sub _potential_value {'$_[0]'} sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access = \$_[0];"; + return "$slot_access = \$_[0]"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/Number/sub.pm b/lib/Moose/Meta/Method/Accessor/Native/Number/sub.pm index 31cb038..ee145f5 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Number/sub.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Number/sub.pm @@ -15,13 +15,13 @@ sub _maximum_arguments {1} sub _potential_value { my ( $self, $slot_access ) = @_; - return "$slot_access - \$_[0];"; + return "$slot_access - \$_[0]"; } sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access -= \$_[0];"; + return "$slot_access -= \$_[0]"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/String/append.pm b/lib/Moose/Meta/Method/Accessor/Native/String/append.pm index 08b3437..94bbd96 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/String/append.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/String/append.pm @@ -21,7 +21,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access .= \$_[0];"; + return "$slot_access .= \$_[0]"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/String/chomp.pm b/lib/Moose/Meta/Method/Accessor/Native/String/chomp.pm index 92495dd..24a5cb1 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/String/chomp.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/String/chomp.pm @@ -21,7 +21,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "chomp $slot_access;"; + return "chomp $slot_access"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/String/chop.pm b/lib/Moose/Meta/Method/Accessor/Native/String/chop.pm index 92d5f17..e724ab0 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/String/chop.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/String/chop.pm @@ -21,7 +21,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "chop $slot_access;"; + return "chop $slot_access"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/String/clear.pm b/lib/Moose/Meta/Method/Accessor/Native/String/clear.pm index 52bf1ea..5a4e3a5 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/String/clear.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/String/clear.pm @@ -21,7 +21,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access = q{};"; + return "$slot_access = q{}"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/String/inc.pm b/lib/Moose/Meta/Method/Accessor/Native/String/inc.pm index 23de319..9757b5a 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/String/inc.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/String/inc.pm @@ -21,7 +21,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "${slot_access}++;"; + return "${slot_access}++"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/String/prepend.pm b/lib/Moose/Meta/Method/Accessor/Native/String/prepend.pm index ab64fea..d3af464 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/String/prepend.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/String/prepend.pm @@ -21,7 +21,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "$slot_access = \$_[0] . $slot_access;"; + return "$slot_access = \$_[0] . $slot_access"; } 1; diff --git a/lib/Moose/Meta/Method/Accessor/Native/String/substr.pm b/lib/Moose/Meta/Method/Accessor/Native/String/substr.pm index 1afcc90..ab25e23 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/String/substr.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/String/substr.pm @@ -90,7 +90,7 @@ sub _potential_value { sub _inline_optimized_set_new_value { my ( $self, $inv, $new, $slot_access ) = @_; - return "substr $slot_access, \$offset, \$length, \$replacement;"; + return "substr $slot_access, \$offset, \$length, \$replacement"; } sub _return_value { diff --git a/lib/Moose/Meta/Method/Accessor/Native/Writer.pm b/lib/Moose/Meta/Method/Accessor/Native/Writer.pm index 9909524..c140acb 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Writer.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Writer.pm @@ -61,7 +61,7 @@ sub _writer_core { $inv, $potential_value, $slot_access, - ); + ) . ';'; $code .= "\n" . $self->_inline_trigger( $inv, $slot_access, '@old' ); $code .= "\n" . $self->_return_value( $slot_access, 'for writer' );