]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] refactor: support comments only for VarDef, not for ItemDef too
authorStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 2 May 2012 23:08:29 +0000 (01:08 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 25 May 2012 08:58:29 +0000 (10:58 +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 <stefano.lattarini@gmail.com>
lib/Automake/ItemDef.pm
lib/Automake/Rule.pm
lib/Automake/RuleDef.pm
lib/Automake/VarDef.pm

index 8b64562202a012832c163bfd891dc93d73225a74..8f0a746841fbf5e169e02d1f1fd1e29a6f124e67 100644 (file)
@@ -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) = @_;
index c8b8111490f305f704e4430490b3c229a977eba0..bce8f2323c11f9a9dcf32e2b7a1142dd81f0b576 100644 (file)
@@ -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);
     }
 
index 571111cfe43be5913a48590c226e0d14f5a2a1e6..9704f4a50471fdcdf3c10e6fb46648a3d6d49bf3 100644 (file)
@@ -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;
index ba48d8532ed19547493ad59d20efbbcb08dc14af..e67b136fabc675d2a6548faf2a76512d47be71da 100644 (file)
@@ -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) = @_;