DataMatrix/CharDataFiller.pm

filter: Statementstmt 78.2% 79 / 101 Branchbran 92.8% 26 / 28 Conditioncond 80.9% 34 / 42 MC/DCmcdc 52.1% 12 / 23 Subroutinesub 80.0% 8 / 10 Podpod 100% 8 / 8 totaltotal 78.7% 167 / 212 CC 29 SCAR 30.1
CC
29
Cov
81%
fill
27.9
module
3.0
corner3
2.0
CRAP 20.3
« DataMatrix/Engine.pm ↑ Summary DataMatrix/Reed.pm »
1 package Barcode::DataMatrix::CharDataFiller;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 Barcode::DataMatrix::CharDataFiller
7  
8 Handle filling character data within the data matrix array.
9  
10 The documentation for the methods in this class has been adapted from the
11 comments in
12 L<https://github.com/itext/itextpdf/blob/master/itext/src/main/java/com/itextpdf/text/pdf/BarcodeDatamatrix.java>.
13  
14 =head2 new
15  
16 Construct a C<Barcode::DataMatrix::CharDataFiller> object.
17  
18 =cut
19  
20 sub new {
21 12 ▶ my $self = bless {}, shift;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
22 12 @$self{qw( ncol nrow array )} = @_;
23 12 $self->fill();
24 12 return $self;
25 }
26  
27 =head2 module (i, j, k, l)
28  
29 Places "chr+bit" with the appropriate wrapping within the array.
30  
31 =cut
32  
33 sub module {
34 14064 ▶ my ($self,$i,$j,$k,$l) = @_;
Subroutine module: called CC=3 SCAR=11.0
Pod documented
35 14064 ▶ if($i < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 0) 287 13777 14064
36 287 $i += $self->{nrow};
37 287 $j += 4 - ($self->{nrow} + 4) % 8;
38 }
39 14064 ▶ if($j < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 0) 369 13695 14064
40 369 $j += $self->{ncol};
41 369 $i += 4 - ($self->{ncol} + 4) % 8;
42 }
43 14064 $self->{array}->[$i * $self->{ncol} + $j] = 10 * $k + $l;
44 14064 return;
45 }
46  
47 =head2 utah (i, j, k)
48  
49 Places the 8 bits of a utah-shaped symbol character.
50  
51 =cut
52  
53 sub utah {
54 1754 ▶ my ($self,$i,$j,$k) = @_;
Subroutine utah: called CC=1 SCAR=0.0
Pod documented
55 1754 $self->module($i - 2, $j - 2, $k, 1);
56 1754 $self->module($i - 2, $j - 1, $k, 2);
57 1754 $self->module($i - 1, $j - 2, $k, 3);
58 1754 $self->module($i - 1, $j - 1, $k, 4);
59 1754 $self->module($i - 1, $j, $k, 5);
60 1754 $self->module($i, $j - 2, $k, 6);
61 1754 $self->module($i, $j - 1, $k, 7);
62 1754 $self->module($i, $j, $k, 8);
63 1754 return;
64 }
65  
66 =head2 corner1 (i)
67  
68 Places 8 bits of the first of the four special corner cases.
69  
70 =cut
71  
72 sub corner1 {
73 3 ▶ my ($self,$i) = @_;
Subroutine corner1: called CC=1 SCAR=0.0
Pod documented
74 3 my ($ncol,$nrow) = @$self{qw( ncol nrow )};
75 3 $self->module($nrow - 1, 0, $i, 1);
76 3 $self->module($nrow - 1, 1, $i, 2);
77 3 $self->module($nrow - 1, 2, $i, 3);
78 3 $self->module(0, $ncol - 2, $i, 4);
79 3 $self->module(0, $ncol - 1, $i, 5);
80 3 $self->module(1, $ncol - 1, $i, 6);
81 3 $self->module(2, $ncol - 1, $i, 7);
82 3 $self->module(3, $ncol - 1, $i, 8);
83 3 return;
84 }
85  
86 =head2 corner2 (i)
87  
88 Places 8 bits of the second of the four special corner cases.
89  
90 =cut
91  
92 sub corner2 { #(int i)
93 1 ▶ my ($self,$i) = @_;
Subroutine corner2: called CC=1 SCAR=0.0
Pod documented
94 1 my ($ncol,$nrow) = @$self{qw( ncol nrow )};
95 1 $self->module($nrow - 3, 0, $i, 1);
96 1 $self->module($nrow - 2, 0, $i, 2);
97 1 $self->module($nrow - 1, 0, $i, 3);
98 1 $self->module(0, $ncol - 4, $i, 4);
99 1 $self->module(0, $ncol - 3, $i, 5);
100 1 $self->module(0, $ncol - 2, $i, 6);
101 1 $self->module(0, $ncol - 1, $i, 7);
102 1 $self->module(1, $ncol - 1, $i, 8);
103 1 return;
104 }
105  
106 =head2 corner3 (i)
107  
108 Places 8 bits of the third of the four special corner cases.
109  
110 =cut
111  
112 sub corner3 { #(int i)
113 0 ▶ my ($self,$i) = @_;
Subroutine corner3: not called CC=1 SCAR=6.9
Pod documented
114 0 my ($ncol,$nrow) = @$self{qw( ncol nrow )};
115 0 $self->module($nrow - 3, 0, $i, 1);
116 0 $self->module($nrow - 2, 0, $i, 2);
117 0 $self->module($nrow - 1, 0, $i, 3);
118 0 $self->module(0, $ncol - 2, $i, 4);
119 0 $self->module(0, $ncol - 1, $i, 5);
120 0 $self->module(1, $ncol - 1, $i, 6);
121 0 $self->module(2, $ncol - 1, $i, 7);
122 0 $self->module(3, $ncol - 1, $i, 8);
123 0 return;
124 }
125  
126 =head2 corner4 (i)
127  
128 Places 8 bits of the fourth of the four special corner cases.
129  
130 =cut
131  
132 sub corner4 { #(int i)
133 0 ▶ my ($self,$i) = @_;
Subroutine corner4: not called CC=1 SCAR=6.9
Pod documented
134 0 my ($ncol,$nrow) = @$self{qw( ncol nrow )};
135 0 $self->module($nrow - 1, 0, $i, 1);
136 0 $self->module($nrow - 1, $ncol - 1, $i, 2);
137 0 $self->module(0, $ncol - 3, $i, 3);
138 0 $self->module(0, $ncol - 2, $i, 4);
139 0 $self->module(0, $ncol - 1, $i, 5);
140 0 $self->module(1, $ncol - 3, $i, 6);
141 0 $self->module(1, $ncol - 2, $i, 7);
142 0 $self->module(1, $ncol - 1, $i, 8);
143 0 return;
144 }
145  
146 =head2 fill
147  
148 Fills an nrow x ncol array with appropriate values.
149  
150 =cut
151  
152 sub fill { # (int ncol; int nrow; int array;) : void
153 12 ▶ my $self = shift;
Subroutine fill: called CC=27 SCAR=33.3
Pod documented
154 12 my ($ncol,$nrow,$array) = @$self{qw( ncol nrow array )};
155 12 my $i = 1;
156 12 my $j = 4;
157 12 my $k = 0;
158 12 ▶ for(my $l = 0; $l < $nrow; $l++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l < $nrow) 350 12 362
159 350 ▶ for(my $i1 = 0; $i1 < $ncol; $i1++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i1 < $ncol) 14076 350 14426
160 14076 $array->[$l * $ncol + $i1] = 0;
161 }
162 }
163 12 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$j < $nrow || $k < $ncol and do { do { $self->corner1($i++) if $j == $nrow and $k == 0; $self->corner2($i++) if $j == $nrow - 2 and $k == 0 and $ncol % 4 != 0; $self->corner3($i++) if $j == $nrow - 2 and $k == 0 and $ncol % 8 == 4; $self->corner4($i++) if $j == $nrow + 4 and $k == 2 and $ncol % 8 == 0; do { $self->utah($j, $k, $i++) if $j < $nrow and $k >= 0 and $$array[$j * $ncol + $k] == 0; $j -= 2; $k += 2 } while $j >= 0 and $k < $ncol; ++$j; $k += 3; do { $self->utah($j, $k, $i++) if $j >= 0 and $k < $ncol and $$array[$j * $ncol + $k] == 0; $j += 2; $k -= 2 } while $j < $nrow and $k >= 0; $j += 3; ++$k } } 77 12 89
Condition100%3/3
$j < $nrow or $k < $ncol
l!l&&r!l&&!r
304712
MC/DC100%2/2
$j < $nrow or $k < $ncol
$j < $nrow $k < $ncol
Truth table100%3/3
A or B
A= $j < $nrowB= $k < $ncol
ABresult
1X1
011
000
164 89 ▶ $self->corner1($i++) if $j == $nrow && $k == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $j == $nrow and $k == 0 3 86 89
Condition66%2/3
$j == $nrow and $k == 0
!ll&&!rl&&r
8603
MC/DC50%1/2
$j == $nrow and $k == 0
$j == $nrow $k == 0
Truth table66%2/3
A and B
A= $j == $nrowB= $k == 0
ABresult
0X0
100
111
165 89 ▶ $self->corner2($i++) if $j == $nrow - 2 && $k == 0 && $ncol % 4 != 0;
Branch: 1 branch
BranchTrueFalseTotal
if $j == $nrow - 2 and $k == 0 and $ncol % 4 != 0 1 88 89
Condition66%4/6
$j == $nrow - 2 and $k == 0 and $ncol % 4 != 0
!ll&&!rl&&r
8801
$j == $nrow - 2 and $k == 0
!ll&&!rl&&r
8801
MC/DC33%1/3
$j == $nrow - 2 and $k == 0 and $ncol % 4 != 0
$j == $nrow - 2 $k == 0 $ncol % 4 != 0
Truth table50%2/4
A and B and C
A= $j == $nrow - 2B= $k == 0C= $ncol % 4 != 0
ABCresult
0XX0
10X0
1100
1111
166 89 ▶ $self->corner3($i++) if $j == $nrow - 2 && $k == 0 && $ncol % 8 == 4;
Branch: 1 branch
BranchTrueFalseTotal
if $j == $nrow - 2 and $k == 0 and $ncol % 8 == 4 0 89 89
Condition66%4/6
$j == $nrow - 2 and $k == 0 and $ncol % 8 == 4
!ll&&!rl&&r
8810
$j == $nrow - 2 and $k == 0
!ll&&!rl&&r
8801
MC/DC0%0/3
$j == $nrow - 2 and $k == 0 and $ncol % 8 == 4
$j == $nrow - 2 $k == 0 $ncol % 8 == 4
Truth table50%2/4
A and B and C
A= $j == $nrow - 2B= $k == 0C= $ncol % 8 == 4
ABCresult
0XX0
10X0
1100
1111
167 89 ▶ $self->corner4($i++) if $j == $nrow + 4 && $k == 2 && $ncol % 8 == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $j == $nrow + 4 and $k == 2 and $ncol % 8 == 0 0 89 89
Condition83%5/6
$j == $nrow + 4 and $k == 2 and $ncol % 8 == 0
!ll&&!rl&&r
8810
$j == $nrow + 4 and $k == 2
!ll&&!rl&&r
47411
MC/DC0%0/3
$j == $nrow + 4 and $k == 2 and $ncol % 8 == 0
$j == $nrow + 4 $k == 2 $ncol % 8 == 0
Truth table75%3/4
A and B and C
A= $j == $nrow + 4B= $k == 2C= $ncol % 8 == 0
ABCresult
0XX0
10X0
1100
1111
168 89 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$j >= 0 and $k < $ncol and do { do { $self->utah($j, $k, $i++) if $j < $nrow and $k >= 0 and $$array[$j * $ncol + $k] == 0; $j -= 2; $k += 2 } } 921 89 1010
Condition100%3/3
$j >= 0 and $k < $ncol
!ll&&!rl&&r
4247921
MC/DC100%2/2
$j >= 0 and $k < $ncol
$j >= 0 $k < $ncol
Truth table100%3/3
A and B
A= $j >= 0B= $k < $ncol
ABresult
0X0
100
111
169 1010 ▶ $self->utah($j, $k, $i++) if $j < $nrow && $k >= 0 && $array->[$j * $ncol + $k] == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $j < $nrow and $k >= 0 and $$array[$j * $ncol + $k] == 0 878 132 1010
Condition83%5/6
$j < $nrow and $k >= 0 and $$array[$j * $ncol + $k] == 0
!ll&&!rl&&r
1302878
$j < $nrow and $k >= 0
!ll&&!rl&&r
1300880
MC/DC66%2/3
$j < $nrow and $k >= 0 and $$array[$j * $ncol + $k] == 0
$j < $nrow $k >= 0 $$array[$j * $ncol + $k] == 0
Truth table75%3/4
A and B and C
A= $j < $nrowB= $k >= 0C= $$array[$j * $ncol + $k] == 0
ABCresult
0XX0
10X0
1100
1111
170 1010 $j -= 2;
171 1010 $k += 2;
172 } while($j >= 0 && $k < $ncol);
173 89 $j++;
174 89 $k += 3;
175 89 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$j < $nrow and $k >= 0 and do { do { $self->utah($j, $k, $i++) if $j >= 0 and $k < $ncol and $$array[$j * $ncol + $k] == 0; $j += 2; $k -= 2 } } 921 89 1010
Condition100%3/3
$j < $nrow and $k >= 0
!ll&&!rl&&r
5435921
MC/DC100%2/2
$j < $nrow and $k >= 0
$j < $nrow $k >= 0
Truth table100%3/3
A and B
A= $j < $nrowB= $k >= 0
ABresult
0X0
100
111
176 1010 ▶ $self->utah($j, $k, $i++) if $j >= 0 && $k < $ncol && $array->[$j * $ncol + $k] == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $j >= 0 and $k < $ncol and $$array[$j * $ncol + $k] == 0 876 134 1010
Condition83%5/6
$j >= 0 and $k < $ncol and $$array[$j * $ncol + $k] == 0
!ll&&!rl&&r
1340876
$j >= 0 and $k < $ncol
!ll&&!rl&&r
4292876
MC/DC66%2/3
$j >= 0 and $k < $ncol and $$array[$j * $ncol + $k] == 0
$j >= 0 $k < $ncol $$array[$j * $ncol + $k] == 0
Truth table75%3/4
A and B and C
A= $j >= 0B= $k < $ncolC= $$array[$j * $ncol + $k] == 0
ABCresult
0XX0
10X0
1100
1111
177 1010 $j += 2;
178 1010 $k -= 2;
179 } while($j < $nrow && $k >= 0);
180 89 $j += 3;
181 89 $k++;
182 } while($j < $nrow || $k < $ncol);
183 12 ▶ $array->[$nrow * $ncol - 1] = $array->[($nrow - 1) * $ncol - 2] = 1
Branch: 1 branch
BranchTrueFalseTotal
if $$array[$nrow * $ncol - 1] == 0 3 9 12
184 if($array->[$nrow * $ncol - 1] == 0);
185 12 return;
186 }
187  
188 2 1;
« DataMatrix/Engine.pm ↑ Summary DataMatrix/Reed.pm »