X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lib%2FPerl%2FTidy%2FIndentationItem.pm;fp=lib%2FPerl%2FTidy%2FIndentationItem.pm;h=14e00719a8940124d65cc1355d4f3e5b9d338e39;hb=57d829ae0e2c75828f8ecc9c7139579350927dbc;hp=7a6c10062f27cb654bba7114faf6f7993266e354;hpb=7f27e55dce5925b2bbe8fcfca64f385e917a52be;p=perltidy.git diff --git a/lib/Perl/Tidy/IndentationItem.pm b/lib/Perl/Tidy/IndentationItem.pm index 7a6c100..14e0071 100644 --- a/lib/Perl/Tidy/IndentationItem.pm +++ b/lib/Perl/Tidy/IndentationItem.pm @@ -8,25 +8,62 @@ package Perl::Tidy::IndentationItem; use strict; use warnings; -our $VERSION = '20200110'; +our $VERSION = '20210717'; + +BEGIN { + + # Array index names + my $i = 0; + use constant { + _spaces_ => $i++, + _level_ => $i++, + _ci_level_ => $i++, + _available_spaces_ => $i++, + _closed_ => $i++, + _comma_count_ => $i++, + _sequence_number_ => $i++, + _index_ => $i++, + _have_child_ => $i++, + _recoverable_spaces_ => $i++, + _align_paren_ => $i++, + _marked_ => $i++, + _stack_depth_ => $i++, + _starting_index_K_ => $i++, + _arrow_count_ => $i++, + }; +} + +sub AUTOLOAD { + + # Catch any undefined sub calls so that we are sure to get + # some diagnostic information. This sub should never be called + # except for a programming error. + our $AUTOLOAD; + return if ( $AUTOLOAD =~ /\bDESTROY$/ ); + my ( $pkg, $fname, $lno ) = caller(); + my $my_package = __PACKAGE__; + print STDERR < # total leading white spaces @@ -46,26 +83,28 @@ sub new { # # with an opening structure? # marked => # if visited by corrector logic # stack_depth => # indentation nesting depth - # starting_index => # first token index of this level + # starting_index_K => # first token index K of this level # arrow_count => # how many =>'s - return bless { - _spaces => $spaces, - _level => $level, - _ci_level => $ci_level, - _available_spaces => $available_spaces, - _closed => $closed, - _comma_count => $comma_count, - _sequence_number => $gnu_sequence_number, - _index => $index, - _have_child => $have_child, - _recoverable_spaces => $want_right_spaces, - _align_paren => $align_paren, - _marked => $marked, - _stack_depth => $stack_depth, - _starting_index => $starting_index, - _arrow_count => $arrow_count, - }, $class; + my $self = []; + $self->[_spaces_] = $input_hash{spaces}; + $self->[_level_] = $input_hash{level}; + $self->[_ci_level_] = $input_hash{ci_level}; + $self->[_available_spaces_] = $input_hash{available_spaces}; + $self->[_closed_] = -1; + $self->[_comma_count_] = 0; + $self->[_sequence_number_] = $input_hash{gnu_sequence_number}; + $self->[_index_] = $input_hash{index}; + $self->[_have_child_] = 0; + $self->[_recoverable_spaces_] = 0; + $self->[_align_paren_] = $input_hash{align_paren}; + $self->[_marked_] = 0; + $self->[_stack_depth_] = $input_hash{stack_depth}; + $self->[_starting_index_K_] = $input_hash{starting_index_K}; + $self->[_arrow_count_] = 0; + + bless $self, $class; + return $self; } sub permanently_decrease_available_spaces { @@ -106,149 +145,134 @@ sub tentatively_decrease_available_spaces { } sub get_stack_depth { - my $self = shift; - return $self->{_stack_depth}; + return $_[0]->[_stack_depth_]; } sub get_spaces { - my $self = shift; - return $self->{_spaces}; + return $_[0]->[_spaces_]; } sub get_marked { - my $self = shift; - return $self->{_marked}; + return $_[0]->[_marked_]; } sub set_marked { my ( $self, $value ) = @_; if ( defined($value) ) { - $self->{_marked} = $value; + $self->[_marked_] = $value; } - return $self->{_marked}; + return $self->[_marked_]; } sub get_available_spaces { - my $self = shift; - return $self->{_available_spaces}; + return $_[0]->[_available_spaces_]; } sub decrease_SPACES { my ( $self, $value ) = @_; if ( defined($value) ) { - $self->{_spaces} -= $value; + $self->[_spaces_] -= $value; } - return $self->{_spaces}; + return $self->[_spaces_]; } sub decrease_available_spaces { my ( $self, $value ) = @_; if ( defined($value) ) { - $self->{_available_spaces} -= $value; + $self->[_available_spaces_] -= $value; } - return $self->{_available_spaces}; + return $self->[_available_spaces_]; } sub get_align_paren { - my $self = shift; - return $self->{_align_paren}; + return $_[0]->[_align_paren_]; } sub get_recoverable_spaces { - my $self = shift; - return $self->{_recoverable_spaces}; + return $_[0]->[_recoverable_spaces_]; } sub set_recoverable_spaces { my ( $self, $value ) = @_; if ( defined($value) ) { - $self->{_recoverable_spaces} = $value; + $self->[_recoverable_spaces_] = $value; } - return $self->{_recoverable_spaces}; + return $self->[_recoverable_spaces_]; } sub increase_recoverable_spaces { my ( $self, $value ) = @_; if ( defined($value) ) { - $self->{_recoverable_spaces} += $value; + $self->[_recoverable_spaces_] += $value; } - return $self->{_recoverable_spaces}; + return $self->[_recoverable_spaces_]; } sub get_ci_level { - my $self = shift; - return $self->{_ci_level}; + return $_[0]->[_ci_level_]; } sub get_level { - my $self = shift; - return $self->{_level}; + return $_[0]->[_level_]; } sub get_sequence_number { - my $self = shift; - return $self->{_sequence_number}; + return $_[0]->[_sequence_number_]; } sub get_index { - my $self = shift; - return $self->{_index}; + return $_[0]->[_index_]; } -sub get_starting_index { - my $self = shift; - return $self->{_starting_index}; +sub get_starting_index_K { + return $_[0]->[_starting_index_K_]; } sub set_have_child { my ( $self, $value ) = @_; if ( defined($value) ) { - $self->{_have_child} = $value; + $self->[_have_child_] = $value; } - return $self->{_have_child}; + return $self->[_have_child_]; } sub get_have_child { - my $self = shift; - return $self->{_have_child}; + return $_[0]->[_have_child_]; } sub set_arrow_count { my ( $self, $value ) = @_; if ( defined($value) ) { - $self->{_arrow_count} = $value; + $self->[_arrow_count_] = $value; } - return $self->{_arrow_count}; + return $self->[_arrow_count_]; } sub get_arrow_count { - my $self = shift; - return $self->{_arrow_count}; + return $_[0]->[_arrow_count_]; } sub set_comma_count { my ( $self, $value ) = @_; if ( defined($value) ) { - $self->{_comma_count} = $value; + $self->[_comma_count_] = $value; } - return $self->{_comma_count}; + return $self->[_comma_count_]; } sub get_comma_count { - my $self = shift; - return $self->{_comma_count}; + return $_[0]->[_comma_count_]; } sub set_closed { my ( $self, $value ) = @_; if ( defined($value) ) { - $self->{_closed} = $value; + $self->[_closed_] = $value; } - return $self->{_closed}; + return $self->[_closed_]; } sub get_closed { - my $self = shift; - return $self->{_closed}; + return $_[0]->[_closed_]; } 1;