[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Automake-NG] [PATCH 09/15] [ng] vars: keep track of conditionals in app
From: |
Stefano Lattarini |
Subject: |
[Automake-NG] [PATCH 09/15] [ng] vars: keep track of conditionals in appended values and comments |
Date: |
Fri, 25 May 2012 13:38:31 +0200 |
This is a refactoring only needed by later changes.
* lib/Automake/VarDef.pm: Updated methods and constructor.
* lib/Automake/Variable.pm: Callers adjusted.
Signed-off-by: Stefano Lattarini <address@hidden>
---
lib/Automake/VarDef.pm | 27 ++++++++++++++-------------
lib/Automake/Variable.pm | 6 +++---
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/lib/Automake/VarDef.pm b/lib/Automake/VarDef.pm
index c40dc16..be956f2 100644
--- a/lib/Automake/VarDef.pm
+++ b/lib/Automake/VarDef.pm
@@ -136,9 +136,10 @@ be one of C<VAR_ASIS>, C<VAR_PRETTY>.
=cut
-sub new ($$$$$$$$)
+sub new ($$$$$$$$$)
{
- my ($class, $var, $value, $comment, $location, $type, $owner, $pretty) = @_;
+ my ($class, $var, $value, $comment, $cond, $location, $type,
+ $owner, $pretty) = @_;
# A user variable must be set by either '=' or ':=', and later
# promoted to '+='.
@@ -148,28 +149,28 @@ sub new ($$$$$$$$)
}
my $self = Automake::ItemDef::new ($class, $location, $owner);
- $self->{'value_list'} = [$value];
+ $self->{'value_list'} = [ { value => $value, cond => $cond } ];
$self->{'type'} = $type;
$self->{'pretty'} = $pretty;
$self->{'seen'} = 0;
- $self->{'comment_list'} = [$comment];
+ $self->{'comment_list'} = [ { text => $comment, cond => $cond } ];
return $self;
}
-=item C<$def-E<gt>append ($value, $comment)>
+=item C<$def-E<gt>append ($value, $comment, $cond)>
-Append C<$value> and <$comment> to the existing value and comment of
-C<$def>. This is normally called on C<+=> definitions.
+Append C<$value> and C<$comment> to the existing value and comment of
+C<$def> in condition C<$cond>. This is normally called on C<+=>
+definitions.
=cut
sub append ($$$)
{
- my ($self, $value, $comment) = @_;
+ my ($self, $value, $comment, $cond) = @_;
- push @{$self->{'comment_list'}}, $comment;
-
- push @{$self->{'value_list'}}, $value;
+ push @{$self->{'comment_list'}}, { text => $comment, cond => $cond };
+ push @{$self->{'value_list'}}, { value => $value, cond => $cond };
# Turn ASIS appended variables into PRETTY variables. This is to
# cope with 'make' implementation that cannot read very long lines.
$self->{'pretty'} = VAR_PRETTY if $self->{'pretty'} == VAR_ASIS;
@@ -204,13 +205,13 @@ sub value ($)
sub comment ($)
{
my ($self) = @_;
- return join ("", @{$self->{'comment_list'}});
+ return join ("", map { $_->{text} } @{$self->{'comment_list'}});
}
sub raw_value ($)
{
my ($self) = @_;
- my @values = @{$self->{'value_list'}};
+ my @values = map { $_->{value} } @{$self->{'value_list'}};
# Strip comments from augmented variables. This is so that
# VAR = foo # com
diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm
index 0c83b66..9c51c9e 100644
--- a/lib/Automake/Variable.pm
+++ b/lib/Automake/Variable.pm
@@ -797,7 +797,7 @@ sub define ($$$$$$$$)
# 1. append (+=) to a variable defined for current condition
if ($type eq '+' && ! $new_var)
{
- $def->append ($value, $comment);
+ $def->append ($value, $comment, $cond);
# Only increase owners. A VAR_CONFIGURE variable augmented in a
# Makefile.am becomes a VAR_MAKEFILE variable.
$def->set_owner ($owner, $where->clone)
@@ -872,8 +872,8 @@ sub define ($$$$$$$$)
# Assignments to a macro set its location. We don't adjust
# locations for '+='. Ideally I suppose we would associate
# line numbers with random bits of text.
- $def = new Automake::VarDef ($var, $value, $comment, $where->clone,
- $type, $owner, $pretty);
+ $def = new Automake::VarDef ($var, $value, $comment, $cond,
+ $where->clone, $type, $owner, $pretty);
$self->set ($cond, $def);
push @_var_order, $var;
}
--
1.7.9.5
- [Automake-NG] [PATCH 05/15] [ng] tests: Automake should let us append to undefined variables (someday), (continued)
[Automake-NG] [PATCH 07/15] [ng] VarDef: store comments and values as a perl array, Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 03/15] [ng] vars: get rid of VAR_SILENT type, Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 08/15] [ng] vars: simplify logic for appending conditionally, Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 06/15] [ng] refactor: support comments only for VarDef, not for ItemDef too, Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 09/15] [ng] vars: keep track of conditionals in appended values and comments,
Stefano Lattarini <=
[Automake-NG] [PATCH 11/15] [ng] refactor: change signature of 'define_variable()', Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 13/15] [ng] rename: define_pretty_variable -> define_cond_variable(), Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 10/15] [ng] vars: get rid of VAR_ASIS / VAR_PRETTY distinction, Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 15/15] [ng] vars: remove some safety checks in Automake::Variable::define, Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 12/15] [ng] cleanup: prefer 'define_variable' over 'define_pretty_variable', Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 14/15] [ng] cosmetics: avoid redundant use of '&' in subroutine calls, Stefano Lattarini, 2012/05/25