[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Automake-NG] [PATCH 06/15] [ng] refactor: support comments only for Var
From: |
Stefano Lattarini |
Subject: |
[Automake-NG] [PATCH 06/15] [ng] refactor: support comments only for VarDef, not for ItemDef too |
Date: |
Fri, 25 May 2012 13:38:28 +0200 |
Comments are actually handled and used for variable definitions only,
so no point in handling it also for rule definitions. And this will
simplify our next step where we change how variable definitions (and
related comments) are stored and displayed.
* lib/Automake/ItemDef.pm (new): Don't take a $comment argument
anymore, and don't set a $self->{comment} field in the returned
object.
(comment): Remove this accessor method.
(Pod documentation): Adjusted.
* lib/Automake/Rule.pm (define): Don't pass a $comment argument
to the Automake::RuleDef constructor anymore. No real loss here,
since we were unconditionally passing an empty comment anyway.
* lib/Automake/RuleDef.pm (new): Don't take a $comment argument
anymore, and don't pass it to the Automake::ItemDef constructor.
(Pod documentation): Adjusted.
* lib/Automake/VarDef.pm (new): Directly store the $comment
argument in the $self->{comment} field. Don't pass the
Automake::ItemDef constructor anymore.
(comment): New accessor method (it is no more inherited from
Automake::ItemDef anymore).
Signed-off-by: Stefano Lattarini <address@hidden>
---
lib/Automake/ItemDef.pm | 17 ++---------------
lib/Automake/Rule.pm | 4 ++--
lib/Automake/RuleDef.pm | 13 ++++++-------
lib/Automake/VarDef.pm | 9 ++++++++-
4 files changed, 18 insertions(+), 25 deletions(-)
diff --git a/lib/Automake/ItemDef.pm b/lib/Automake/ItemDef.pm
index 8b64562..8f0a746 100644
--- a/lib/Automake/ItemDef.pm
+++ b/lib/Automake/ItemDef.pm
@@ -33,10 +33,6 @@ Automake::ItemDef - base class for Automake::VarDef and
Automake::RuleDef
Create a new Makefile-item definition.
-C<$comment> is any comment preceding the definition. (Because
-Automake reorders items in the output, it also tries to carry comments
-around.)
-
C<$location> is the place where the definition occurred, it should be
an instance of L<Automake::Location>.
@@ -44,12 +40,11 @@ C<$owner> specifies who owns the rule.
=cut
-sub new ($$$$)
+sub new ($$$)
{
- my ($class, $comment, $location, $owner) = @_;
+ my ($class, $location, $owner) = @_;
my $self = {
- comment => $comment,
location => $location,
owner => $owner,
};
@@ -58,8 +53,6 @@ sub new ($$$$)
return $self;
}
-=item C<$def-E<gt>comment>
-
=item C<$def-E<gt>location>
=item C<$def-E<gt>owner>
@@ -69,12 +62,6 @@ documentation of C<new>'s arguments for a description of
these.
=cut
-sub comment ($)
-{
- my ($self) = @_;
- return $self->{'comment'};
-}
-
sub location ($)
{
my ($self) = @_;
diff --git a/lib/Automake/Rule.pm b/lib/Automake/Rule.pm
index c8b8111..bce8f23 100644
--- a/lib/Automake/Rule.pm
+++ b/lib/Automake/Rule.pm
@@ -786,8 +786,8 @@ sub define ($$$$$;$)
# Finally define this rule.
for my $c (@conds)
{
- my $def = new Automake::RuleDef ($target, '', $where->clone,
- $owner, $source);
+ my $def = new Automake::RuleDef ($target, $where->clone, $owner,
+ $source);
$rule->set ($c, $def);
}
diff --git a/lib/Automake/RuleDef.pm b/lib/Automake/RuleDef.pm
index 571111c..9704f4a 100644
--- a/lib/Automake/RuleDef.pm
+++ b/lib/Automake/RuleDef.pm
@@ -59,19 +59,18 @@ use constant RULE_USER => 1; # Rule defined in the
user's Makefile.am.
=over 4
-=item C<new Automake::RuleDef ($name, $comment, $location, $owner, $source)>
+=item C<new Automake::RuleDef ($name, $location, $owner, $source)>
-Create a new rule definition with target C<$name>, with associated comment
-C<$comment>, Location C<$location> and owner C<$owner>, defined in file
-C<$source>.
+Create a new rule definition with target C<$name>, Location C<$location>
+and owner C<$owner>, defined in file C<$source>.
=cut
-sub new ($$$$$)
+sub new ($$$$)
{
- my ($class, $name, $comment, $location, $owner, $source) = @_;
+ my ($class, $name, $location, $owner, $source) = @_;
- my $self = Automake::ItemDef::new ($class, $comment, $location, $owner);
+ my $self = Automake::ItemDef::new ($class, $location, $owner);
$self->{'source'} = $source;
$self->{'name'} = $name;
return $self;
diff --git a/lib/Automake/VarDef.pm b/lib/Automake/VarDef.pm
index ba48d85..e67b136 100644
--- a/lib/Automake/VarDef.pm
+++ b/lib/Automake/VarDef.pm
@@ -147,7 +147,8 @@ sub new ($$$$$$$$)
error $location, "$var must be set with '=' before using '+='";
}
- my $self = Automake::ItemDef::new ($class, $comment, $location, $owner);
+ my $self = Automake::ItemDef::new ($class, $location, $owner);
+ $self->{'comment'} = $comment;
$self->{'value'} = $value;
$self->{'type'} = $type;
$self->{'pretty'} = $pretty;
@@ -210,6 +211,12 @@ sub value ($)
return $val;
}
+sub comment ($)
+{
+ my ($self) = @_;
+ return $self->{'comment'};
+}
+
sub raw_value ($)
{
my ($self) = @_;
--
1.7.9.5
- [Automake-NG] [PATCH 04/15] [ng] tests: spy behaviour of '+=' with GNU make, (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 <=
[Automake-NG] [PATCH 09/15] [ng] vars: keep track of conditionals in appended values and comments, Stefano Lattarini, 2012/05/25
[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