From: Stefano Lattarini Date: Wed, 2 May 2012 23:08:29 +0000 (+0200) Subject: [ng] refactor: support comments only for VarDef, not for ItemDef too X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cec1b21efba4556267776609e0c308181426387c;p=thirdparty%2Fautomake.git [ng] refactor: support comments only for VarDef, not for ItemDef too 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 --- diff --git a/lib/Automake/ItemDef.pm b/lib/Automake/ItemDef.pm index 8b6456220..8f0a74684 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. @@ -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-Ecomment> - =item C<$def-Elocation> =item C<$def-Eowner> @@ -69,12 +62,6 @@ documentation of C'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 c8b811149..bce8f2323 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 571111cfe..9704f4a50 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 +=item C -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 ba48d8532..e67b136fa 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) = @_;