From: Matt S Trout Date: Thu, 3 May 2012 18:45:05 +0000 (+0000) Subject: pass spec down into generation code X-Git-Tag: v0.091002~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ceea0e3806c6b5e700ff9ac8d4cfb36bc1c20af9;p=gitmo%2FMoo.git pass spec down into generation code --- diff --git a/lib/Method/Generate/Accessor.pm b/lib/Method/Generate/Accessor.pm index 9d15768..5636aac 100644 --- a/lib/Method/Generate/Accessor.pm +++ b/lib/Method/Generate/Accessor.pm @@ -96,13 +96,13 @@ sub generate_method { if (my $pred = $spec->{predicate}) { $methods{$pred} = quote_sub "${into}::${pred}" => - ' '.$self->_generate_simple_has('$_[0]', $name)."\n" + ' '.$self->_generate_simple_has('$_[0]', $name, $spec)."\n" ; } if (my $cl = $spec->{clearer}) { $methods{$cl} = quote_sub "${into}::${cl}" => - $self->_generate_simple_clear('$_[0]', $name)."\n" + $self->_generate_simple_clear('$_[0]', $name, $spec)."\n" ; } if (my $hspec = $spec->{handles}) { @@ -165,13 +165,13 @@ sub has_eager_default { sub _generate_get { my ($self, $name, $spec) = @_; - my $simple = $self->_generate_simple_get('$_[0]', $name); + my $simple = $self->_generate_simple_get('$_[0]', $name, $spec); if ($self->is_simple_get($name, $spec)) { $simple; } else { 'do { '.$self->_generate_use_default( '$_[0]', $name, $spec, - $self->_generate_simple_has('$_[0]', $name), + $self->_generate_simple_has('$_[0]', $name, $spec), ).'; '.$simple.' }'; } } @@ -350,7 +350,7 @@ sub _generate_populate_set { .($spec->{trigger} ? ' ' .$self->_generate_trigger( - $name, $me, $self->_generate_simple_get($me, $name), + $name, $me, $self->_generate_simple_get($me, $name, $spec), $spec->{trigger} )." if ${test};\n" : '' @@ -376,7 +376,7 @@ sub _generate_populate_set { .($spec->{trigger} ? " " .$self->_generate_trigger( - $name, $me, $self->_generate_simple_get($me, $name), + $name, $me, $self->_generate_simple_get($me, $name, $spec), $spec->{trigger} ).";\n" : "" diff --git a/lib/Method/Generate/Constructor.pm b/lib/Method/Generate/Constructor.pm index 1aa8225..9dae34b 100644 --- a/lib/Method/Generate/Constructor.pm +++ b/lib/Method/Generate/Constructor.pm @@ -146,7 +146,7 @@ sub _assign_new { join '', ( @init ? ' '.$self->_cap_call($ag->generate_multi_set( - '$new', [ @slots ], '@{$args}{qw('.join(' ',@init).')}' + '$new', [ @slots ], '@{$args}{qw('.join(' ',@init).')}', $spec )).";\n" : '' ), map { @@ -205,7 +205,7 @@ sub _fire_triggers { my ($init, $trigger) = @{$spec->{$name}}{qw(init_arg trigger)}; next unless $init && $trigger; my ($code, $add_captures) = $acc->generate_trigger( - $name, '$new', $acc->generate_simple_get('$new', $name), $trigger + $name, '$new', $acc->generate_simple_get('$new', $name, $spec), $trigger ); @{$captures}{keys %$add_captures} = values %$add_captures; $fire .= " ${code} if exists \$args->{${\perlstring $init}};\n";