| 1 | package CLI::MixedArray; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use CLI::Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | @ISA = ("CLI::Base"); | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use CLI qw(parse_string typeStr); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use CLI::Var; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | 0 | my $proto = shift; | |||||||||||||||||||||||||||
| 13 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 16 | 0 | my $types = shift; | |||||||||||||||||||||||||||
| 17 | 0 | my $vals = shift; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 0 | my $self = { | |||||||||||||||||||||||||||
| 20 | NAME => $name, | ||||||||||||||||||||||||||||
| 21 | TYPE => undef, | ||||||||||||||||||||||||||||
| 22 | VALUE => [], | ||||||||||||||||||||||||||||
| 23 | FUNC => undef, | ||||||||||||||||||||||||||||
| 24 | MIN => undef, | ||||||||||||||||||||||||||||
| 25 | MAX => undef | ||||||||||||||||||||||||||||
| 26 | }; | ||||||||||||||||||||||||||||
| 27 | 0 | bless ($self, $class); | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | foreach my $type (@$types) { | |||||||||||||||||||||||||||
| 30 | 0 | push @{$self->{VALUE}}, new CLI::Var($name, $type, shift @{$vals}); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | return $self; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub TIEARRAY { | ||||||||||||||||||||||||||
|
Subroutine
TIEARRAY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 37 | 0 | return new(@_); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub value { | ||||||||||||||||||||||||||
|
Subroutine
value: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 42 | 0 | my $index = shift; | |||||||||||||||||||||||||||
| 43 | 0 | my $value = shift; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if (!defined $index) { # Return the whole lot as a list | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 0 | my @return = (); | |||||||||||||||||||||||||||
| 47 | 0 | foreach (@{$self->{VALUE}}) { | |||||||||||||||||||||||||||
| 48 | 0 | push @return, $_->value(); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | 0 | return @return; | |||||||||||||||||||||||||||
| 51 | } else { | ||||||||||||||||||||||||||||
| 52 | # Verify the index value | ||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($index<0 || $index>=scalar(@{$self->{VALUE}})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$index < 0 or $index >= scalar @{$self->{"VALUE"};}
MC/DC0%0/2
$index < 0 or $index >= scalar @{$self->{"VALUE"};}
$index < 0
$index >= scalar @{$self->{"VALUE"};}
Truth table0%0/3
A or B
A= $index < 0B= $index >= scalar @{$self->{"VALUE"};}
| |||||||||||||||||||||||||||||
| 54 | 0 | carp "Index $index out of range"; | |||||||||||||||||||||||||||
| 55 | 0 | return undef; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if (!defined $value) { # Return a value | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | return $self->{VALUE}[$index]->value(); | |||||||||||||||||||||||||||
| 60 | } else { # Save the value | ||||||||||||||||||||||||||||
| 61 | 0 | return $self->{VALUE}[$index]->value($value); | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub FETCH { | ||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 67 | 0 | return value(@_); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub STORE { | ||||||||||||||||||||||||||
|
Subroutine
STORE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 71 | 0 | value(@_); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub parse { | ||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 76 | 0 | my $string = shift; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if (defined $string) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | my $value; | |||||||||||||||||||||||||||
| 80 | 0 | foreach my $val (@{$self->{VALUE}}) { | |||||||||||||||||||||||||||
| 81 | 0 | $value = parse_string($val->type(), $string); | |||||||||||||||||||||||||||
| 82 | 0 | ▶ | if (! defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 0 | carp "Bad value \"$string\" for type ", typeStr($val->type()), "\n"; | |||||||||||||||||||||||||||
| 84 | 0 | return; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | $val->value($value); | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | return if (!defined $string); # End of list | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | } else { # Print out the values in the list | ||||||||||||||||||||||||||||
| 92 | 0 | print $self->name(); | |||||||||||||||||||||||||||
| 93 | 0 | foreach my $val (@{$self->{VALUE}}) { | |||||||||||||||||||||||||||
| 94 | 0 | print ' ', $val->svalue(); | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if (defined $string) { # Some characters left over | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 0 | carp "Ignoring \"$string\"\n"; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 1 | 1; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||