blib/lib/GDS2.pm

filter: Statementstmt 45.4% 859 / 1891 Branchbran 32.2% 298 / 924 Conditioncond 33.3% 79 / 237 MC/DCmcdc 21.7% 28 / 129 Subroutinesub 41.6% 105 / 252 Podpod 75.5% 130 / 172 totaltotal 41.5% 1499 / 3605 SCAR 110.5
CC
545
Cov
40%
saveGds2Record
1806.0
printText
1260.0
returnRecordAsPerl
756.0
CRAP 63118.0
↑ Summary
1 package GDS2;
2 {
3 6 require 5.008001;
4 6 $GDS2::VERSION = '3.33';
5 ## Note: '@ ( # )' used by the what command E.g. what GDS2.pm
6 6 $GDS2::revision = '@(#) $Id: GDS2.pm,v $ $Revision: 3.33 $ $Date: 2014-09-15 03:27:57-06 $';
7 #
8  
9 =pod
10  
11 =head1 NAME
12  
13 GDS2 - GDS2 stream module
14  
15 =head1 SYNOPSIS
16  
17 This is GDS2, a module for creating programs to read and/or write GDS2 files.
18  
19 Send feedback/suggestions to
20 perl -le '$_=q(Zpbhgnpe@pvnt.uxa);$_=~tr/n-sa-gt-zh-mZ/a-zS/;print;'
21  
22 =head1 COPYRIGHT
23  
24 Author: Ken Schumack (c) 1999-2014. All rights reserved.
25 This module is free software. It may be used, redistributed
26 and/or modified under the terms of the Perl Artistic License.
27 ( see http://www.perl.com/pub/a/language/misc/Artistic.html )
28 Have fun, Ken
29  
30 =head1 DESCRIPTION
31  
32 GDS2 allows you to read and write GDS2 files record by record in a
33 stream fashion which inherently uses little memory. It is capable but
34 not fast. If you have large files you may be happier using
35 http://sourceforge.net/projects/gds2/
36  
37 =cut
38  
39 #
40 # Contributor Modification: Toby Schaffer 2004-01-21
41 # returnUnitsAsArray() added which returns user units and database
42 # units as a 2 element array.
43 #
44 # Contributor Modification: Peter Baumbach 2002-01-11
45 # returnRecordAsPerl() was created to facilitate the creation of
46 # parameterized gds2 data with perl. -Years later Andreas Pawlak
47 # pointed out a endian problem that needed to be addressed.
48 #
49 # POD documentation is sprinkled throughout the file in an
50 # attempt at Literate Programming style (which Perl partly supports ...
51 # see http://www.literateprogramming.com/ )
52 # Search for the strings '=head' or run perldoc on this file.
53  
54 # You can run this file through either pod2man or pod2html to produce
55 # documentation in manual or html file format
56  
57 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 BEGIN
60 {
61 6 ▶ use constant TRUE => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 6 ▶ use constant FALSE => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 6 ▶ use constant UNKNOWN => -1;
Subroutine BEGIN: called CC=1 SCAR=0.0
64  
65 6 ▶ use constant HAVE_FLOCK => TRUE; ## some systems still may not have this...manually change
Subroutine BEGIN: called CC=1 SCAR=0.0
66 6 ▶ use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
67 6 ▶ use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 }
69  
70 6 if (HAVE_FLOCK)
71 {
72 6 ▶ use Fcntl q(:flock); # import LOCK_* constants
Subroutine BEGIN: called CC=1 SCAR=0.0
73 }
74  
75 6 ▶no strict qw( refs );
Subroutine BEGIN: called CC=1 SCAR=0.0
76  
77 6 my $isLittleEndian = FALSE; #default - was developed on a BigEndian machine
78 6 ▶$isLittleEndian = TRUE if ($Config{'byteorder'} =~ m/^1/); ## Linux mswin32 cygwin vms
Branch: 1 branch
BranchTrueFalseTotal
if $GDS2::Config{"byteorder"} =~ /^1/ 6 0 6
79  
80 ################################################################################
81 ## GDS2 STREAM RECORD DATATYPES
82 6 ▶use constant NO_REC_DATA => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
83 6 ▶use constant BIT_ARRAY => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 6 ▶use constant INTEGER_2 => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
85 6 ▶use constant INTEGER_4 => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
86 6 ▶use constant REAL_4 => 4; ## NOT supported, should not be found in any GDS2
Subroutine BEGIN: called CC=1 SCAR=0.0
87 6 ▶use constant REAL_8 => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
88 6 ▶use constant ACSII_STRING => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
89 ################################################################################
90  
91 ################################################################################
92 ## GDS2 STREAM RECORD TYPES
93 6 ▶use constant HEADER => 0; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
94 6 ▶use constant BGNLIB => 1; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
95 6 ▶use constant LIBNAME => 2; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
96 6 ▶use constant UNITS => 3; ## 8-byte Real
Subroutine BEGIN: called CC=1 SCAR=0.0
97 6 ▶use constant ENDLIB => 4; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
98 6 ▶use constant BGNSTR => 5; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
99 6 ▶use constant STRNAME => 6; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
100 6 ▶use constant ENDSTR => 7; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
101 6 ▶use constant BOUNDARY => 8; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
102 6 ▶use constant PATH => 9; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
103 6 ▶use constant SREF => 10; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
104 6 ▶use constant AREF => 11; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
105 6 ▶use constant TEXT => 12; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
106 6 ▶use constant LAYER => 13; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
107 6 ▶use constant DATATYPE => 14; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
108 6 ▶use constant WIDTH => 15; ## 4-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
109 6 ▶use constant XY => 16; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
110 6 ▶use constant ENDEL => 17; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
111 6 ▶use constant SNAME => 18; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
112 6 ▶use constant COLROW => 19; ## 2 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
113 6 ▶use constant TEXTNODE => 20; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
114 6 ▶use constant NODE => 21; ## no data present
Subroutine BEGIN: called CC=1 SCAR=0.0
115 6 ▶use constant TEXTTYPE => 22; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
116 6 ▶use constant PRESENTATION => 23; ## Bit Array
Subroutine BEGIN: called CC=1 SCAR=0.0
117 6 ▶use constant SPACING => 24; ## discontinued
Subroutine BEGIN: called CC=1 SCAR=0.0
118 6 ▶use constant STRING => 25; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
119 6 ▶use constant STRANS => 26; ## Bit Array
Subroutine BEGIN: called CC=1 SCAR=0.0
120 6 ▶use constant MAG => 27; ## 8-byte Real
Subroutine BEGIN: called CC=1 SCAR=0.0
121 6 ▶use constant ANGLE => 28; ## 8-byte Real
Subroutine BEGIN: called CC=1 SCAR=0.0
122 6 ▶use constant UINTEGER => 29; ## UNKNOWN User int, used only in Calma V2.0
Subroutine BEGIN: called CC=1 SCAR=0.0
123 6 ▶use constant USTRING => 30; ## UNKNOWN User string, used only in Calma V2.0
Subroutine BEGIN: called CC=1 SCAR=0.0
124 6 ▶use constant REFLIBS => 31; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
125 6 ▶use constant FONTS => 32; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
126 6 ▶use constant PATHTYPE => 33; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
127 6 ▶use constant GENERATIONS => 34; ## 2-byte Signed Integer
Subroutine BEGIN: called CC=1 SCAR=0.0
128 6 ▶use constant ATTRTABLE => 35; ## ASCII String
Subroutine BEGIN: called CC=1 SCAR=0.0
129 6 ▶use constant STYPTABLE => 36; ## ASCII String "Unreleased feature"
Subroutine BEGIN: called CC=1 SCAR=0.0
130 6 ▶use constant STRTYPE => 37; ## 2-byte Signed Integer "Unreleased feature"
Subroutine BEGIN: called CC=1 SCAR=0.0
131 6 ▶use constant EFLAGS => 38; ## BIT_ARRAY Flags for template and exterior data. bits 15 to 0, l to r 0=template,
Subroutine BEGIN: called CC=1 SCAR=0.0
132 ## 1=external data, others unused
133 6 ▶use constant ELKEY => 39; ## INTEGER_4 "Unreleased feature"
Subroutine BEGIN: called CC=1 SCAR=0.0
134 6 ▶use constant LINKTYPE => 40; ## UNKNOWN "Unreleased feature"
Subroutine BEGIN: called CC=1 SCAR=0.0
135 6 ▶use constant LINKKEYS => 41; ## UNKNOWN "Unreleased feature"
Subroutine BEGIN: called CC=1 SCAR=0.0
136 6 ▶use constant NODETYPE => 42; ## INTEGER_2 Nodetype specification. On Calma this could be 0 to 63, GDSII allows 0 to 255.
Subroutine BEGIN: called CC=1 SCAR=0.0
137 ## Of course a 2 byte integer allows up to 65535...
138 6 ▶use constant PROPATTR => 43; ## INTEGER_2 Property number.
Subroutine BEGIN: called CC=1 SCAR=0.0
139 6 ▶use constant PROPVALUE => 44; ## STRING Property value. On GDSII, 128 characters max, unless an SREF, AREF, or NODE,
Subroutine BEGIN: called CC=1 SCAR=0.0
140 ## which may have 512 characters.
141 6 ▶use constant BOX => 45; ## NO_DATA The beginning of a BOX element.
Subroutine BEGIN: called CC=1 SCAR=0.0
142 6 ▶use constant BOXTYPE => 46; ## INTEGER_2 Boxtype specification.
Subroutine BEGIN: called CC=1 SCAR=0.0
143 6 ▶use constant PLEX => 47; ## INTEGER_4 Plex number and plexhead flag. The least significant bit of the most significant
Subroutine BEGIN: called CC=1 SCAR=0.0
144 ## byte is the plexhead flag.
145 6 ▶use constant BGNEXTN => 48; ## INTEGER_4 Path extension beginning for pathtype 4 in Calma CustomPlus. In database units,
Subroutine BEGIN: called CC=1 SCAR=0.0
146 ## may be negative.
147 6 ▶use constant ENDEXTN => 49; ## INTEGER_4 Path extension end for pathtype 4 in Calma CustomPlus. In database units, may be negative.
Subroutine BEGIN: called CC=1 SCAR=0.0
148 6 ▶use constant TAPENUM => 50; ## INTEGER_2 Tape number for multi-reel stream file.
Subroutine BEGIN: called CC=1 SCAR=0.0
149 6 ▶use constant TAPECODE => 51; ## INTEGER_2 Tape code to verify that the reel is from the proper set. 12 bytes that are
Subroutine BEGIN: called CC=1 SCAR=0.0
150 ## supposed to form a unique tape code.
151 6 ▶use constant STRCLASS => 52; ## BIT_ARRAY Calma use only.
Subroutine BEGIN: called CC=1 SCAR=0.0
152 6 ▶use constant RESERVED => 53; ## INTEGER_4 Used to be NUMTYPES per Calma GDSII Stream Format Manual, v6.0.
Subroutine BEGIN: called CC=1 SCAR=0.0
153 6 ▶use constant FORMAT => 54; ## INTEGER_2 Archive or Filtered flag. 0: Archive 1: filtered
Subroutine BEGIN: called CC=1 SCAR=0.0
154 6 ▶use constant MASK => 55; ## STRING Only in filtered streams. Layers and datatypes used for mask in a filtered
Subroutine BEGIN: called CC=1 SCAR=0.0
155 ## stream file. A string giving ranges of layers and datatypes separated by a semicolon.
156 ## There may be more than one mask in a stream file.
157 6 ▶use constant ENDMASKS => 56; ## NO_DATA The end of mask descriptions.
Subroutine BEGIN: called CC=1 SCAR=0.0
158 6 ▶use constant LIBDIRSIZE => 57; ## INTEGER_2 Number of pages in library director, a GDSII thing, it seems to have only been
Subroutine BEGIN: called CC=1 SCAR=0.0
159 ## used when Calma INFORM was creating a new library.
160 6 ▶use constant SRFNAME => 58; ## STRING Calma "Sticks"(c) rule file name.
Subroutine BEGIN: called CC=1 SCAR=0.0
161 6 ▶use constant LIBSECUR => 59; ## INTEGER_2 Access control list stuff for CalmaDOS, ancient. INFORM used this when creating
Subroutine BEGIN: called CC=1 SCAR=0.0
162 ## a new library. Had 1 to 32 entries with group numbers, user numbers and access rights.
163 #################################################################################################
164 6 ▶use vars '$StrSpace';
Subroutine BEGIN: called CC=1 SCAR=0.0
165 6 ▶use vars '$ElmSpace';
Subroutine BEGIN: called CC=1 SCAR=0.0
166 6 $StrSpace='';
167 6 $ElmSpace='';
168  
169 6 my %RecordTypeNumbers=(
170 'HEADER' => HEADER,
171 'BGNLIB' => BGNLIB,
172 'LIBNAME' => LIBNAME,
173 'UNITS' => UNITS,
174 'ENDLIB' => ENDLIB,
175 'BGNSTR' => BGNSTR,
176 'STRNAME' => STRNAME,
177 'ENDSTR' => ENDSTR,
178 'BOUNDARY' => BOUNDARY,
179 'PATH' => PATH,
180 'SREF' => SREF,
181 'AREF' => AREF,
182 'TEXT' => TEXT,
183 'LAYER' => LAYER,
184 'DATATYPE' => DATATYPE,
185 'WIDTH' => WIDTH,
186 'XY' => XY,
187 'ENDEL' => ENDEL,
188 'SNAME' => SNAME,
189 'COLROW' => COLROW,
190 'TEXTNODE' => TEXTNODE,
191 'NODE' => NODE,
192 'TEXTTYPE' => TEXTTYPE,
193 'PRESENTATION'=> PRESENTATION,
194 'SPACING' => SPACING,
195 'STRING' => STRING,
196 'STRANS' => STRANS,
197 'MAG' => MAG,
198 'ANGLE' => ANGLE,
199 'UINTEGER' => UINTEGER,
200 'USTRING' => USTRING,
201 'REFLIBS' => REFLIBS,
202 'FONTS' => FONTS,
203 'PATHTYPE' => PATHTYPE,
204 'GENERATIONS' => GENERATIONS,
205 'ATTRTABLE' => ATTRTABLE,
206 'STYPTABLE' => STYPTABLE,
207 'STRTYPE' => STRTYPE,
208 'EFLAGS' => EFLAGS,
209 'ELKEY' => ELKEY,
210 'LINKTYPE' => LINKTYPE,
211 'LINKKEYS' => LINKKEYS,
212 'NODETYPE' => NODETYPE,
213 'PROPATTR' => PROPATTR,
214 'PROPVALUE' => PROPVALUE,
215 'BOX' => BOX,
216 'BOXTYPE' => BOXTYPE,
217 'PLEX' => PLEX,
218 'BGNEXTN' => BGNEXTN,
219 'ENDEXTN' => ENDEXTN,
220 'TAPENUM' => TAPENUM,
221 'TAPECODE' => TAPECODE,
222 'STRCLASS' => STRCLASS,
223 'RESERVED' => RESERVED,
224 'FORMAT' => FORMAT,
225 'MASK' => MASK,
226 'ENDMASKS' => ENDMASKS,
227 'LIBDIRSIZE' => LIBDIRSIZE,
228 'SRFNAME' => SRFNAME,
229 'LIBSECUR' => LIBSECUR,
230 );
231  
232 6 my @RecordTypeStrings=( ## for ascii print of GDS
233 'HEADER',
234 'BGNLIB',
235 'LIBNAME',
236 'UNITS',
237 'ENDLIB',
238 'BGNSTR',
239 'STRNAME',
240 'ENDSTR',
241 'BOUNDARY',
242 'PATH',
243 'SREF',
244 'AREF',
245 'TEXT',
246 'LAYER',
247 'DATATYPE',
248 'WIDTH',
249 'XY',
250 'ENDEL',
251 'SNAME',
252 'COLROW',
253 'TEXTNODE',
254 'NODE',
255 'TEXTTYPE',
256 'PRESENTATION',
257 'SPACING',
258 'STRING',
259 'STRANS',
260 'MAG',
261 'ANGLE',
262 'UINTEGER',
263 'USTRING',
264 'REFLIBS',
265 'FONTS',
266 'PATHTYPE',
267 'GENERATIONS',
268 'ATTRTABLE',
269 'STYPTABLE',
270 'STRTYPE',
271 'EFLAGS',
272 'ELKEY',
273 'LINKTYPE',
274 'LINKKEYS',
275 'NODETYPE',
276 'PROPATTR',
277 'PROPVALUE',
278 'BOX',
279 'BOXTYPE',
280 'PLEX',
281 'BGNEXTN',
282 'ENDEXTN',
283 'TAPENUM',
284 'TAPECODE',
285 'STRCLASS',
286 'RESERVED',
287 'FORMAT',
288 'MASK',
289 'ENDMASKS',
290 'LIBDIRSIZE',
291 'SRFNAME',
292 'LIBSECUR',
293 );
294 6 my @CompactRecordTypeStrings=( ## for compact ascii print of GDS (GDT format) see http://sourceforge.net/projects/gds2/
295 'gds2{', #HEADER
296 '', #BGNLIB
297 'lib', #LIBNAME
298 '', #UNITS
299 '}', #ENDLIB
300 'cell{', #BGNSTR
301 '', #STRNAME
302 '}', #ENDSTR
303 'b{', #BOUNDARY
304 'p{', #PATH
305 's{', #SREF
306 'a{', #AREF
307 't{', #TEXT
308 '', #LAYER
309 ' dt', #DATATYPE
310 ' w', #WIDTH
311 ' xy(', #XY #)
312 '}', #ENDEL
313 '', #SNAME
314 ' cr', #COLROW
315 ' tn', #TEXTNODE
316 ' no', #NODE
317 ' tt', #TEXTTYPE
318 '', #PRESENTATION'
319 ' sp', #SPACING
320 '', #STRING
321 '', #STRANS
322 ' m', #MAG
323 ' a', #ANGLE
324 ' ui', #UINTEGER
325 ' us', #USTRING
326 ' rl', #REFLIBS
327 ' f', #FONTS
328 ' pt', #PATHTYPE
329 ' gen', #GENERATIONS
330 ' at', #ATTRTABLE
331 ' st', #STYPTABLE
332 ' strt', #STRTYPE
333 ' ef', #EFLAGS
334 ' ek', #ELKEY
335 ' lt', #LINKTYPE
336 ' lk', #LINKKEYS
337 ' nt', #NODETYPE
338 ' ptr', #PROPATTR
339 ' pv', #PROPVALUE
340 ' bx', #BOX
341 ' bt', #BOXTYPE
342 ' px', #PLEX
343 ' bx', #BGNEXTN
344 ' ex', #ENDEXTN
345 ' tnum', #TAPENUM
346 ' tcode', #TAPECODE
347 ' strc', #STRCLASS
348 ' resv', #RESERVED
349 ' fmt', #FORMAT
350 ' msk', #MASK
351 ' emsk', #ENDMASKS
352 ' lds', #LIBDIRSIZE
353 ' srfn', #SRFNAME
354 ' libs', #LIBSECUR
355 );
356  
357 ###################################################
358 6 my %RecordTypeData=(
359 'HEADER' => INTEGER_2,
360 'BGNLIB' => INTEGER_2,
361 'LIBNAME' => ACSII_STRING,
362 'UNITS' => REAL_8,
363 'ENDLIB' => NO_REC_DATA,
364 'BGNSTR' => INTEGER_2,
365 'STRNAME' => ACSII_STRING,
366 'ENDSTR' => NO_REC_DATA,
367 'BOUNDARY' => NO_REC_DATA,
368 'PATH' => NO_REC_DATA,
369 'SREF' => NO_REC_DATA,
370 'AREF' => NO_REC_DATA,
371 'TEXT' => NO_REC_DATA,
372 'LAYER' => INTEGER_2,
373 'DATATYPE' => INTEGER_2,
374 'WIDTH' => INTEGER_4,
375 'XY' => INTEGER_4,
376 'ENDEL' => NO_REC_DATA,
377 'SNAME' => ACSII_STRING,
378 'COLROW' => INTEGER_2,
379 'TEXTNODE' => NO_REC_DATA,
380 'NODE' => NO_REC_DATA,
381 'TEXTTYPE' => INTEGER_2,
382 'PRESENTATION' => BIT_ARRAY,
383 'SPACING' => UNKNOWN, #INTEGER_4, discontinued
384 'STRING' => ACSII_STRING,
385 'STRANS' => BIT_ARRAY,
386 'MAG' => REAL_8,
387 'ANGLE' => REAL_8,
388 'UINTEGER' => UNKNOWN, #INTEGER_4, no longer used
389 'USTRING' => UNKNOWN, #ACSII_STRING, no longer used
390 'REFLIBS' => ACSII_STRING,
391 'FONTS' => ACSII_STRING,
392 'PATHTYPE' => INTEGER_2,
393 'GENERATIONS' => INTEGER_2,
394 'ATTRTABLE' => ACSII_STRING,
395 'STYPTABLE' => ACSII_STRING, # unreleased feature
396 'STRTYPE' => INTEGER_2, #INTEGER_2, unreleased feature
397 'EFLAGS' => BIT_ARRAY,
398 'ELKEY' => INTEGER_4, #INTEGER_4, unreleased feature
399 'LINKTYPE' => INTEGER_2, #unreleased feature
400 'LINKKEYS' => INTEGER_4, #unreleased feature
401 'NODETYPE' => INTEGER_2,
402 'PROPATTR' => INTEGER_2,
403 'PROPVALUE' => ACSII_STRING,
404 'BOX' => NO_REC_DATA,
405 'BOXTYPE' => INTEGER_2,
406 'PLEX' => INTEGER_4,
407 'BGNEXTN' => INTEGER_4,
408 'ENDEXTN' => INTEGER_4,
409 'TAPENUM' => INTEGER_2,
410 'TAPECODE' => INTEGER_2,
411 'STRCLASS' => UNKNOWN,
412 'RESERVED' => INTEGER_4,
413 'FORMAT' => INTEGER_2,
414 'MASK' => ACSII_STRING,
415 'ENDMASKS' => NO_REC_DATA,
416 'LIBDIRSIZE' => UNKNOWN, #INTEGER_2
417 'SRFNAME' => ACSII_STRING,
418 'LIBSECUR' => UNKNOWN, #INTEGER_2,
419 );
420  
421 # This is the default class for the GDS2 object to use when all else fails.
422 6 ▶$GDS2::DefaultClass = 'GDS2' unless defined $GDS2::DefaultClass;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $GDS2::DefaultClass 6 0 6
423  
424 6 my $G_gdtString="";
425 6 my $G_epsilon="0.001"; ## to take care of floating point representation problems
426 6 my $G_fltLen=3;
427 { #it's own name space...
428 6 my $fltLenTmp = sprintf("%0.99f",(1.0/3.0)); $fltLenTmp=~s/^0.(3+).*/$1/; $fltLenTmp = length($fltLenTmp) - 10;
429 6 ▶ if ($fltLenTmp > length($G_epsilon)) # try to make smaller if we can...
Branch: 1 branch
BranchTrueFalseTotal
if ($fltLenTmp > length $G_epsilon) 6 0 6
430 {
431 6 $G_epsilon = sprintf("%0.${fltLenTmp}f1",0);
432 6 $G_fltLen = $fltLenTmp;
433 }
434 }
435 6 $G_epsilon *= 1; #ensure it's a number
436  
437 ################################################################################
438  
439 =head1 Examples
440  
441 Layer change:
442 here's a bare bones script to change all layer 59 to 66 given a file to
443 read and a new file to create.
444 #!/usr/bin/perl -w
445 use strict;
446 use GDS2;
447 my $fileName1 = $ARGV[0];
448 my $fileName2 = $ARGV[1];
449 my $gds2File1 = new GDS2(-fileName => $fileName1);
450 my $gds2File2 = new GDS2(-fileName => ">$fileName2");
451 while (my $record = $gds2File1 -> readGds2Record)
452 {
453 if ($gds2File1 -> returnLayer == 59)
454 {
455 $gds2File2 -> printLayer(-num=>66);
456 }
457 else
458 {
459 $gds2File2 -> printRecord(-data=>$record);
460 }
461 }
462  
463  
464 Gds2 dump:
465 here's a complete program to dump the contents of a stream file.
466 #!/usr/bin/perl -w
467 use GDS2;
468 $\="\n";
469 my $gds2File = new GDS2(-fileName=>$ARGV[0]);
470 while ($gds2File -> readGds2Record)
471 {
472 print $gds2File -> returnRecordAsString;
473 }
474  
475  
476 Gds2 dump in GDT format: which is smaller and easier to parse - http://sourceforge.net/projects/gds2/
477 #!/usr/bin/perl -w
478 use GDS2;
479 my $gds2File = new GDS2(-fileName=>$ARGV[0]);
480 while ($gds2File -> readGds2Record)
481 {
482 print $gds2File -> returnRecordAsString(-compact=>1);
483 }
484  
485 Dump from the command line of a bzip2 compressed file:
486 perl -MGDS2 -MFileHandle -MIPC::Open3 -e '$f1=new FileHandle;$f0=new FileHandle;open3($f0,$f1,$f1,"bzcat test.gds.bz2");$gds=new GDS2(-fileHandle=>$f1);while($gds->readGds2Record){print $gds->returnRecordAsString(-compact=>1)}'
487  
488 Create a complete GDS2 stream file from scratch:
489 #!/usr/bin/perl -w
490 use GDS2;
491 my $gds2File = new GDS2(-fileName=>'>test.gds');
492 $gds2File -> printInitLib(-name=>'testlib');
493 $gds2File -> printBgnstr(-name=>'test');
494 $gds2File -> printPath(
495 -layer=>6,
496 -pathType=>0,
497 -width=>2.4,
498 -xy=>[0,0, 10.5,0, 10.5,3.3],
499 );
500 $gds2File -> printSref(
501 -name=>'contact',
502 -xy=>[4,5.5],
503 );
504 $gds2File -> printAref(
505 -name=>'contact',
506 -columns=>2,
507 -rows=>3,
508 -xy=>[0,0, 10,0, 0,15],
509 );
510 $gds2File -> printEndstr;
511 $gds2File -> printBgnstr(-name => 'contact');
512 $gds2File -> printBoundary(
513 -layer=>10,
514 -xy=>[0,0, 1,0, 1,1, 0,1],
515 );
516 $gds2File -> printEndstr;
517 $gds2File -> printEndlib();
518  
519 ################################################################################
520  
521 =head1 METHODS
522  
523 =head2 new - open gds2 file
524  
525 usage:
526 my $gds2File = new GDS2(-fileName => "filename.gds2"); ## to read
527 my $gds2File2 = new GDS2(-fileName => ">filename.gds2"); ## to write
528  
529 -or- provide your own fileHandle:
530  
531 my $gds2File = new GDS2(-fileHandle => $fh); ## e.g. to attach to a compression/decompression pipe
532  
533 =cut
534  
535 sub new
536 {
537 8 ▶ my($class,%arg) = @_;
Subroutine new: called CC=18 SCAR=32.5
Pod documented
538 8 my $self = {};
539 8 ▶ bless $self,$class || ref $class || $GDS2::DefaultClass;
Condition33%2/6
$class || ref $class || $GDS2::DefaultClass
l!l&&r!l&&!r
800
$class or ref $class
l!l&&r!l&&!r
800
MC/DC0%0/3
$class || ref $class || $GDS2::DefaultClass
$class ref $class $GDS2::DefaultClass
Truth table25%1/4
A or B || C
A= $classB= ref $classC= $GDS2::DefaultClass
ABCresult
1XX1
01X1
0011
0000
540  
541 8 my $fileName = $arg{'-fileName'};
542 8 ▶ $fileName = "" unless (defined $fileName);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fileName 0 8 8
543  
544 8 my $fileHandle = $arg{'-fileHandle'};
545 8 ▶ $fileHandle = "" unless (defined $fileHandle);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fileHandle 8 0 8
546
547 8 ▶ if ($fileName && $fileHandle)
Branch: 1 branch
BranchTrueFalseTotal
if ($fileName and $fileHandle) 0 8 8
Condition33%1/3
$fileName and $fileHandle
!ll&&!rl&&r
080
MC/DC0%0/2
$fileName and $fileHandle
$fileName $fileHandle
Truth table33%1/3
A and B
A= $fileNameB= $fileHandle
ABresult
0X0
100
111
548 {
549 0 die "new expects a gds2 file name -OR- a file handle. Do not give both.";
550 }
551 8 ▶ unless ($fileName || $fileHandle)
Branch: 1 branch
BranchTrueFalseTotal
unless ($fileName or $fileHandle) 0 8 8
Condition33%1/3
$fileName or $fileHandle
l!l&&r!l&&!r
800
MC/DC0%0/2
$fileName or $fileHandle
$fileName $fileHandle
Truth table33%1/3
A or B
A= $fileNameB= $fileHandle
ABresult
1X1
011
000
552 {
553 0 die "new expects a -fileName => 'name' OR and -fileHandle => fh $!";
554 }
555 8 my $lockMode = LOCK_SH; ## default
556 8 ▶ if ($fileName)
Branch: 1 branch
BranchTrueFalseTotal
if ($fileName) 8 0 8
557 {
558 8 my $openModStr = substr($fileName,0,2); ### looking for > or >>
559 8 $openModStr =~ s|^\s+||;
560 8 $openModStr =~ s|[^\+>]+||g;
561 8 my $openModeNum = O_RDONLY;
562 8 ▶ if ($openModStr =~ m|^\+|)
Branch: 1 branch
BranchTrueFalseTotal
if ($openModStr =~ /^\+/) 0 8 8
563 {
564 0 warn("Ignoring '+' in open mode"); ## not handling this yet...
565 0 $openModStr =~ s|\++||;
566 }
567 8 ▶ if ($openModStr eq '>')
Branch: 2 branches
BranchTrueFalseTotal
if ($openModStr eq '>') { } 5 3 8
elsif ($openModStr eq '>>') { } 0 3 3
568 {
569 5 $openModeNum = O_WRONLY|O_CREAT;
570 5 $lockMode = LOCK_EX;
571 5 $fileName =~ s|^$openModStr||;
572 }
573 elsif ($openModStr eq '>>')
574 {
575 0 $openModeNum = O_WRONLY|O_APPEND;
576 0 $lockMode = LOCK_EX;
577 0 $fileName =~ s|^$openModStr||;
578 }
579 8 $fileHandle = new IO::File;
580 8 ▶ $fileHandle -> open("$fileName",$openModeNum) or die "Unable to open $fileName because $!";
Branch: 1 branch
BranchTrueFalseTotal
$fileHandle->open("$fileName", $openModeNum) or die "Unable to open $fileName because $!" 0 8 8
581 8 if (HAVE_FLOCK)
582 {
583 8 ▶ flock($fileHandle,$lockMode) or die "File lock on $fileName failed because $!";
Branch: 1 branch
BranchTrueFalseTotal
flock $fileHandle, $lockMode or die "File lock on $fileName failed because $!" 0 8 8
584 }
585 }
586 8 my $resolution = $arg{'-resolution'};
587 8 ▶ unless (defined $resolution)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $resolution) 8 0 8
588 {
589 8 $resolution=1000;
590 }
591 8 ▶ die "new expects a positive integer resolution. ($resolution) $!" if (($resolution <= 0) || ($resolution !~ m|^\d+$|));
Branch: 1 branch
BranchTrueFalseTotal
if $resolution <= 0 or not $resolution =~ /^\d+$/ 0 8 8
Condition33%1/3
$resolution <= 0 or not $resolution =~ /^\d+$/
l!l&&r!l&&!r
008
MC/DC0%0/2
$resolution <= 0 or not $resolution =~ /^\d+$/
$resolution <= 0 not $resolution =~ /^\d+$/
Truth table33%1/3
A or not(B)
A= $resolution <= 0B= not $resolution =~ /^\d+$/
ABresult
1X1
011
000
592 8 binmode $fileHandle,':raw';
593 8 $self -> {'Fd'} = $fileHandle -> fileno;
594 8 $self -> {'FileHandle'} = $fileHandle;
595 8 $self -> {'FileName'} = $fileName; ## the gds2 filename
596 8 $self -> {'BytesDone'} = 0; ## total file size so far
597 8 $self -> {'EOLIB'} = FALSE; ## end of library flag
598 8 $self -> {'INHEADER'} = UNKNOWN; ## in header? flag TRUE | FALSE | UNKNOWN
599 8 $self -> {'INDATA'} = FALSE; ## in data? flag TRUE | FALSE
600 8 $self -> {'Length'} = 0; ## length of data
601 8 $self -> {'DataType'} = UNKNOWN; ## one of 7 gds datatypes
602 8 $self -> {'UUnits'} = -1.0; ## for gds2 file e.g. 0.001
603 8 $self -> {'DBUnits'} = -1.0; ## for gds2 file e.g. 1e-9
604 8 $self -> {'Record'} = ''; ## the whole record as found in gds2 file
605 8 $self -> {'RecordType'} = UNKNOWN;
606 8 $self -> {'DataIndex'} = 0;
607 8 $self -> {'RecordData'} = ();
608 8 $self -> {'CurrentDataList'} = '';
609 8 $self -> {'InBoundary'} = FALSE; ##
610 8 $self -> {'InTxt'} = FALSE; ##
611 8 $self -> {'DateFld'} = 0; ##
612 8 $self -> {'Resolution'} = $resolution;
613 8 $self -> {'UsingPrettyPrint'} = FALSE; ## print as string ...
614 8 $self;
615 }
616 ################################################################################
617  
618 #######
619 #private method to check how accurately users perl can do math
620 sub getG_epsilon
621 {
622 4 ▶ my($self,%arg) = @_;
Subroutine getG_epsilon: called CC=1 SCAR=0.0
Pod undocumented
623 4 $G_epsilon;
624 }
625 ################################################################################
626  
627 #######
628 #private method to check how accurately users perl can do math
629 sub getG_fltLen
630 {
631 4 ▶ my($self,%arg) = @_;
Subroutine getG_fltLen: called CC=1 SCAR=0.0
Pod undocumented
632 4 $G_fltLen;
633 }
634 ################################################################################
635  
636 #######
637 #private method to report Endianness
638 sub endianness
639 {
640 2 ▶ my($self,%arg) = @_;
Subroutine endianness: called CC=1 SCAR=0.0
Pod undocumented
641 2 $isLittleEndian;
642 }
643 ################################################################################
644  
645 #######
646 #private method to clean up number
647 sub cleanExpNum($)
648 {
649 3 ▶ my $num = shift;
Subroutine cleanExpNum: called CC=1 SCAR=0.0
Pod undocumented
650 3 $num = sprintf("%0.${G_fltLen}e",$num);
651 3 $num =~ s/([1-9])0+e/$1e/;
652 3 $num =~ s/(\d)\.0+e/$1e/;
653 3 $num;
654 }
655 ################################################################################
656  
657 #######
658 #private method to clean up number
659 sub cleanFloatNum($)
660 {
661 189 ▶ my $num = shift;
Subroutine cleanFloatNum: called CC=1 SCAR=0.0
Pod undocumented
662 189 $num = sprintf("%0.${G_fltLen}f",$num);
663 189 $num =~ s/([1-9])0+$/$1/;
664 189 $num =~ s/(\d)\.0+$/$1/;
665 189 $num;
666 }
667 ################################################################################
668  
669 =head2 fileNum - file number...
670  
671 usage:
672  
673 =cut
674  
675 sub fileNum
676 {
677 0 ▶ my($self,%arg) = @_;
Subroutine fileNum: not called CC=1 SCAR=6.9
Pod documented
678 0 int($self -> {'Fd'});
679 }
680 ################################################################################
681  
682 =head2 close - close gds2 file
683  
684 usage:
685 $gds2File -> close;
686 -or-
687 $gds2File -> close(-markEnd=>1); ## -- some systems have trouble closing files
688 $gds2File -> close(-pad=>2048); ## -- pad end with \0's till file size is a
689 ## multiple of number. Note: old reel to reel tapes on Calma
690 ## systems used 2048 byte blocks
691  
692 =cut
693  
694 sub close
695 {
696 5 ▶ my($self,%arg) = @_;
Subroutine close: called CC=7 SCAR=20.6
Pod documented
697 5 my $markEnd = $arg{'-markEnd'};
698 5 my $pad = $arg{'-pad'};
699 5 ▶ if ((defined $markEnd)&&($markEnd))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $markEnd and $markEnd) 0 5 5
Condition33%1/3
defined $markEnd and $markEnd
!ll&&!rl&&r
500
MC/DC0%0/2
defined $markEnd and $markEnd
defined $markEnd $markEnd
Truth table33%1/3
A and B
A= defined $markEndB= $markEnd
ABresult
0X0
100
111
700 {
701 0 my $fh = $self -> {'FileHandle'};
702 0 print $fh "\x1a\x04"; # a ^Z and a ^D
703 0 $self -> {'BytesDone'} += 2;
704 }
705 5 ▶ if ((defined $pad)&&($pad > 0))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pad and $pad > 0) 1 4 5
Condition66%2/3
defined $pad and $pad > 0
!ll&&!rl&&r
401
MC/DC50%1/2
defined $pad and $pad > 0
defined $pad $pad > 0
Truth table66%2/3
A and B
A= defined $padB= $pad > 0
ABresult
0X0
100
111
706 {
707 1 my $fh = $self -> {'FileHandle'};
708 1 $fh -> flush;
709 1 seek($fh,0,SEEK_END);
710 1 my $fileSize = tell($fh);
711 1 my $padSize = $pad - ($fileSize % $pad);
712 1 ▶ $padSize=0 if ($padSize == $pad);
Branch: 1 branch
BranchTrueFalseTotal
if $padSize == $pad 0 1 1
713 1 ▶ for (my $i=0; $i < $padSize; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $padSize) 1702 1 1703
714 {
715 1702 print $fh "\0"; ## a null
716 }
717 }
718 5 $self -> {'FileHandle'} -> close;
719 }
720 ################################################################################
721  
722 ################################################################################
723  
724 =head1 High Level Write Methods
725  
726 =cut
727  
728 ################################################################################
729  
730 =head2 printInitLib() - Does all the things needed to start a library, writes HEADER,BGNLIB,LIBNAME,and UNITS records
731  
732 The default is to create a library with a default unit of 1 micron that has a resolution of 1000. To get this set uUnit to 0.001 (1/1000) and the dbUnit to 1/1000th of a micron (1e-9).
733 usage:
734 $gds2File -> printInitLib(-name => "testlib", ## required
735 -isoDate => 0|1 ## (optional) use ISO 4 digit date 2001 vs 101
736 -uUnit => real number ## (optional) default is 0.001
737 -dbUnit => real number ## (optional) default is 1e-9
738 );
739  
740 ## defaults to current date for library date
741  
742 note:
743 remember to close library with printEndlib()
744  
745 =cut
746  
747 sub printInitLib
748 {
749 2 ▶ my($self,%arg) = @_;
Subroutine printInitLib: called CC=7 SCAR=21.0
Pod documented
750 2 my $libName = $arg{'-name'};
751 2 ▶ unless (defined $libName)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $libName) 0 2 2
752 {
753 0 die "printInitLib expects a library name. Missing -name => 'name' $!";
754 }
755 #################################################
756 2 my $isoDate = $arg{'-isoDate'};
757 2 ▶ if (! defined $isoDate)
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $isoDate) { } 2 0 2
elsif ($isoDate != 0) { } 0 0 0
758 {
759 2 $isoDate = FALSE;
760 }
761 elsif ($isoDate != 0)
762 {
763 0 $isoDate = TRUE;
764 }
765  
766 #################################################
767 2 my $uUnit = $arg{'-uUnit'};
768 2 ▶ if (! defined $uUnit)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $uUnit) { } 2 0 2
769 {
770 2 $uUnit = 0.001;
771 }
772 else
773 {
774 0 $self -> {'Resolution'} = cleanFloatNum(1 / $uUnit); ## default is 1000 - already set in new()
775 }
776 2 $self -> {'UUnits'} = $uUnit;
777  
778 #################################################
779 2 my $dbUnit = $arg{'-dbUnit'};
780 2 ▶ $dbUnit = 1e-9 unless (defined $dbUnit);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dbUnit 2 0 2
781 2 $self -> {'DBUnits'} = $dbUnit;
782 #################################################
783  
784 2 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
785 2 $mon++;
786 2 ▶ $year += 1900 if ($isoDate); ## Cadence likes year left "as is". GDS format supports year number up to 65535 -- 101 vs 2001
Branch: 1 branch
BranchTrueFalseTotal
if $isoDate 0 2 2
787 2 $self -> printGds2Record(-type => 'HEADER',-data => 3); ## GDS2 HEADER
788 2 $self -> printGds2Record(-type => 'BGNLIB',-data => [$year,$mon,$mday,$hour,$min,$sec,$year,$mon,$mday,$hour,$min,$sec]);
789 2 $self -> printGds2Record(-type => 'LIBNAME',-data => $libName);
790 2 $self -> printGds2Record(-type => 'UNITS',-data => [$uUnit,$dbUnit]);
791 }
792 ################################################################################
793  
794 =head2 printBgnstr - Does all the things needed to start a structure definition
795  
796 usage:
797 $gds2File -> printBgnstr(-name => "nand3" ## writes BGNSTR and STRNAME records
798 -isoDate => 1|0 ## (optional) use ISO 4 digit date 2001 vs 101
799 );
800  
801 note:
802 remember to close with printEndstr()
803  
804 =cut
805  
806 sub printBgnstr
807 {
808 4 ▶ my($self,%arg) = @_;
Subroutine printBgnstr: called CC=7 SCAR=22.1
Pod documented
809  
810 4 my $strName = $arg{'-name'};
811 4 ▶ unless (defined $strName)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $strName) 0 4 4
812 {
813 0 die "bgnStr expects a structure name. Missing -name => 'name' $!";
814 }
815 4 my $createTime = $arg{'-createTime'};
816 4 my $isoDate = $arg{'-isoDate'};
817 4 ▶ if (! defined $isoDate)
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $isoDate) { } 4 0 4
elsif ($isoDate != 0) { } 0 0 0
818 {
819 4 $isoDate = FALSE;
820 }
821 elsif ($isoDate != 0)
822 {
823 0 $isoDate = TRUE;
824 }
825 4 my ($csec,$cmin,$chour,$cmday,$cmon,$cyear,$cwday,$cyday,$cisdst);
826 4 ▶ if (defined $createTime)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $createTime) { } 0 4 4
827 {
828 0 ($csec,$cmin,$chour,$cmday,$cmon,$cyear,$cwday,$cyday,$cisdst) = localtime($createTime);
829 }
830 else
831 {
832 4 ($csec,$cmin,$chour,$cmday,$cmon,$cyear,$cwday,$cyday,$cisdst) = localtime(time);
833 }
834 4 $cmon++;
835  
836 4 my $modTime = $arg{'-modTime'};
837 4 my ($msec,$mmin,$mhour,$mmday,$mmon,$myear,$mwday,$myday,$misdst);
838 4 ▶ if (defined $modTime)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $modTime) { } 0 4 4
839 {
840 0 ($msec,$mmin,$mhour,$mmday,$mmon,$myear,$mwday,$myday,$misdst) = localtime($modTime);
841 }
842 else
843 {
844 4 ($msec,$mmin,$mhour,$mmday,$mmon,$myear,$mwday,$myday,$misdst) = localtime(time);
845 }
846 4 $mmon++;
847  
848 4 ▶ if ($isoDate)
Branch: 1 branch
BranchTrueFalseTotal
if ($isoDate) 0 4 4
849 {
850 0 $cyear += 1900; ## 2001 vs 101
851 0 $myear += 1900;
852 }
853 4 $self -> printGds2Record(-type => 'BGNSTR',-data => [$cyear,$cmon,$cmday,$chour,$cmin,$csec,$myear,$mmon,$mmday,$mhour,$mmin,$msec]);
854 4 $self -> printGds2Record(-type => 'STRNAME',-data => $strName);
855 }
856 ################################################################################
857  
858 =head2 printPath - prints a gds2 path
859  
860 usage:
861 $gds2File -> printPath(
862 -layer=>#,
863 -dataType=>#, ##optional
864 -pathType=>#,
865 -width=>#.#,
866 -unitWidth=>#, ## (optional) directly specify width in data base units (vs -width which is multipled by resolution)
867  
868 -xy=>\@array, ## array of reals
869 # -or-
870 -xyInt=>\@array, ## array of internal ints (optional -wks better if you are modifying an existing GDS2 file)
871 );
872  
873 note:
874 layer defaults to 0 if -layer not used
875 pathType defaults to 0 if -pathType not used
876 pathType 0 = square end
877 1 = round end
878 2 = square - extended 1/2 width
879 4 = custom plus variable path extension...
880 width defaults to 0.0 if -width not used
881  
882 =cut
883  
884 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
885 # <path>::= PATH [ELFLAGS] [PLEX] LAYER DATATYPE [PATHTYPE] [WIDTH] XY
886 sub printPath
887 {
888 2 ▶ my($self,%arg) = @_;
Subroutine printPath: called CC=38 SCAR=60.2
Pod documented
889 2 my $resolution = $self -> {'Resolution'};
890 2 my $layer = $arg{'-layer'};
891 2 ▶ $layer=0 unless ( defined $layer);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $layer 0 2 2
892  
893 2 my $dataType = $arg{'-dataType'};
894 2 ▶ $dataType=0 unless (defined $dataType);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dataType 2 0 2
895  
896 2 my $pathType = $arg{'-pathType'};
897 2 ▶ $pathType=0 unless (defined $pathType);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pathType 0 2 2
898  
899 2 my $bgnExtn = $arg{'-bgnExtn'};
900 2 ▶ $bgnExtn=0 unless (defined $bgnExtn);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bgnExtn 2 0 2
901  
902 2 my $endExtn = $arg{'-endExtn'};
903 2 ▶ $endExtn=0 unless (defined $endExtn);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $endExtn 2 0 2
904  
905 2 my $unitWidth = $arg{'-unitWidth'};
906 2 my $widthReal = $arg{'-width'};
907 2 my $width = 0;
908 2 ▶ if ((defined $unitWidth)&&($unitWidth >= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $unitWidth and $unitWidth >= 0) 0 2 2
Condition33%1/3
defined $unitWidth and $unitWidth >= 0
!ll&&!rl&&r
200
MC/DC0%0/2
defined $unitWidth and $unitWidth >= 0
defined $unitWidth $unitWidth >= 0
Truth table33%1/3
A and B
A= defined $unitWidthB= $unitWidth >= 0
ABresult
0X0
100
111
909 {
910 0 $width=int($unitWidth);
911 }
912 2 ▶ if ((defined $widthReal)&&($widthReal >= 0.0))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $widthReal and $widthReal >= 0) 2 0 2
Condition33%1/3
defined $widthReal and $widthReal >= 0
!ll&&!rl&&r
002
MC/DC0%0/2
defined $widthReal and $widthReal >= 0
defined $widthReal $widthReal >= 0
Truth table33%1/3
A and B
A= defined $widthRealB= $widthReal >= 0
ABresult
0X0
100
111
913 {
914 2 $width = int(($widthReal*$resolution)+$G_epsilon);
915 }
916 #### -xyInt most useful if reading and modifying... -xy if creating from scratch
917 2 my $xyInt = $arg{'-xyInt'}; ## $xyInt should be a reference to an array of internal GDS2 format integers
918 2 my $xy = $arg{'-xy'}; ## $xy should be a reference to an array of reals
919 2 my @xyTmp=(); ##don't pollute array passed in
920 2 ▶ if (! ((defined $xy) || (defined $xyInt)))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $xy or defined $xyInt) 0 2 2
Condition33%1/3
defined $xy or defined $xyInt
l!l&&r!l&&!r
200
MC/DC0%0/2
defined $xy or defined $xyInt
defined $xy defined $xyInt
Truth table33%1/3
A or B
A= defined $xyB= defined $xyInt
ABresult
1X1
011
000
921 {
922 0 die "printPath expects an xy array reference. Missing -xy => \\\@array $!";
923 }
924 2 ▶ if (defined $xyInt)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xyInt) 0 2 2
925 {
926 0 $xy = $xyInt;
927 0 $resolution=1;
928 }
929 2 $self -> printGds2Record(-type => 'PATH');
930 2 $self -> printGds2Record(-type => 'LAYER',-data => $layer);
931 2 $self -> printGds2Record(-type => 'DATATYPE',-data => $dataType);
932 2 ▶ $self -> printGds2Record(-type => 'PATHTYPE',-data => $pathType) if ($pathType);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType 0 2 2
933 2 ▶ $self -> printGds2Record(-type => 'WIDTH',-data => $width) if ($width);
Branch: 1 branch
BranchTrueFalseTotal
if $width 2 0 2
934 2 ▶ if ($pathType == 4)
Branch: 1 branch
BranchTrueFalseTotal
if ($pathType == 4) 0 2 2
935 {
936 0 $self -> printGds2Record(-type => 'BGNEXTN',-data => $bgnExtn); ## int used with resolution
937 0 $self -> printGds2Record(-type => 'ENDEXTN',-data => $endExtn); ## int used with resolution
938 }
939 2 ▶ for(my $i=0;$i<=$#$xy;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $xy->$#*) 12 2 14
940 {
941 12 ▶ if ($xy -> [$i] >= 0) { push @xyTmp,int((($xy -> [$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[$i] >= 0) { } 12 0 12
942 0 else { push @xyTmp,int((($xy -> [$i])*$resolution)-$G_epsilon);}
943 }
944 2 ▶ if ($bgnExtn || $endExtn) ## we have to convert
Branch: 1 branch
BranchTrueFalseTotal
if ($bgnExtn or $endExtn) 0 2 2
Condition33%1/3
$bgnExtn or $endExtn
l!l&&r!l&&!r
002
MC/DC0%0/2
$bgnExtn or $endExtn
$bgnExtn $endExtn
Truth table33%1/3
A or B
A= $bgnExtnB= $endExtn
ABresult
1X1
011
000
945 {
946 0 my $bgnX1 = $xyTmp[0];
947 0 my $bgnY1 = $xyTmp[1];
948 0 my $bgnX2 = $xyTmp[2];
949 0 my $bgnY2 = $xyTmp[3];
950 0 my $endX1 = $xyTmp[$#xyTmp - 1];
951 0 my $endY1 = $xyTmp[$#xyTmp];
952 0 my $endX2 = $xyTmp[$#xyTmp - 3];
953 0 my $endY2 = $xyTmp[$#xyTmp - 2];
954 0 ▶ if ($bgnExtn)
Branch: 1 branch
BranchTrueFalseTotal
if ($bgnExtn) 0 0 0
955 {
956 0 ▶ if ($bgnX1 == $bgnX2) #vertical ...modify 1st Y
Branch: 2 branches
BranchTrueFalseTotal
if ($bgnX1 == $bgnX2) { } 0 0 0
elsif ($bgnY1 == $bgnY2) { } 0 0 0
957 {
958 0 ▶ if ($bgnY1 < $bgnY2) ## points down
Branch: 1 branch
BranchTrueFalseTotal
if ($bgnY1 < $bgnY2) { } 0 0 0
959 {
960 0 $xyTmp[1] -= $bgnExtn;
961 0 ▶ $xyTmp[1] += int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
962 }
963 else ## points up
964 {
965 0 $xyTmp[1] += $bgnExtn;
966 0 ▶ $xyTmp[1] -= int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
967 }
968 }
969 elsif ($bgnY1 == $bgnY2) #horizontal ...modify 1st X
970 {
971 0 ▶ if ($bgnX1 < $bgnX2) ## points left
Branch: 1 branch
BranchTrueFalseTotal
if ($bgnX1 < $bgnX2) { } 0 0 0
972 {
973 0 $xyTmp[0] -= $bgnExtn;
974 0 ▶ $xyTmp[0] += int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
975 }
976 else ## points up
977 {
978 0 $xyTmp[0] += $bgnExtn;
979 0 ▶ $xyTmp[0] -= int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
980 }
981 }
982 }
983  
984 0 ▶ if ($endExtn)
Branch: 1 branch
BranchTrueFalseTotal
if ($endExtn) 0 0 0
985 {
986 0 ▶ if ($endX1 == $endX2) #vertical ...modify last Y
Branch: 2 branches
BranchTrueFalseTotal
if ($endX1 == $endX2) { } 0 0 0
elsif ($endY1 == $endY2) { } 0 0 0
987 {
988 0 ▶ if ($endY1 < $endY2) ## points down
Branch: 1 branch
BranchTrueFalseTotal
if ($endY1 < $endY2) { } 0 0 0
989 {
990 0 $xyTmp[$#xyTmp] -= $endExtn;
991 0 ▶ $xyTmp[$#xyTmp] += int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
992 }
993 else ## points up
994 {
995 0 $xyTmp[$#xyTmp] += $endExtn;
996 0 ▶ $xyTmp[$#xyTmp] -= int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
997 }
998 }
999 elsif ($endY1 == $endY2) #horizontal ...modify last X
1000 {
1001 0 ▶ if ($endX1 < $endX2) ## points left
Branch: 1 branch
BranchTrueFalseTotal
if ($endX1 < $endX2) { } 0 0 0
1002 {
1003 0 $xyTmp[$#xyTmp - 1] -= $endExtn;
1004 0 ▶ $xyTmp[$#xyTmp - 1] += int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
1005 }
1006 else ## points up
1007 {
1008 0 $xyTmp[$#xyTmp - 1] += $endExtn;
1009 0 ▶ $xyTmp[$#xyTmp - 1] -= int($width/2) if ($pathType != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType != 0 0 0 0
1010 }
1011 }
1012 }
1013 }
1014 2 $self -> printGds2Record(-type => 'XY',-data => \@xyTmp);
1015 2 $self -> printGds2Record(-type => 'ENDEL');
1016 }
1017 ################################################################################
1018  
1019 =head2 printBoundary - prints a gds2 boundary
1020  
1021 usage:
1022 $gds2File -> printBoundary(
1023 -layer=>#,
1024 -dataType=>#,
1025  
1026 -xy=>\@array, ## ref to array of reals
1027 # -or-
1028 -xyInt=>\@array, ## ref to array of internal ints (optional -wks better if you are modifying an existing GDS2 file)
1029 );
1030  
1031 note:
1032 layer defaults to 0 if -layer not used
1033 dataType defaults to 0 if -dataType not used
1034  
1035 =cut
1036  
1037 # <boundary>::= BOUNDARY [ELFLAGS] [PLEX] LAYER DATATYPE XY
1038 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1039 sub printBoundary
1040 {
1041 2 ▶ my($self,%arg) = @_;
Subroutine printBoundary: called CC=13 SCAR=29.9
Pod documented
1042 2 my $resolution = $self -> {'Resolution'};
1043 2 my $layer = $arg{'-layer'};
1044 2 ▶ $layer=0 unless (defined $layer);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $layer 0 2 2
1045 2 my $dataType = $arg{'-dataType'};
1046 2 ▶ $dataType=0 unless (defined $dataType);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dataType 2 0 2
1047 #### -xyInt most useful if reading and modifying... -xy if creating from scratch
1048 2 my $xyInt = $arg{'-xyInt'}; ## $xyInt should be a reference to an array of internal GDS2 format integers
1049 2 my $xy = $arg{'-xy'}; ## $xy should be a reference to an array of reals
1050 2 my @xyTmp=(); ##don't pollute array passed in
1051 2 ▶ unless (defined($xy) || defined($xyInt))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $xy or defined $xyInt) 0 2 2
Condition33%1/3
defined $xy or defined $xyInt
l!l&&r!l&&!r
200
MC/DC0%0/2
defined $xy or defined $xyInt
defined $xy defined $xyInt
Truth table33%1/3
A or B
A= defined $xyB= defined $xyInt
ABresult
1X1
011
000
1052 {
1053 0 die "printBoundary expects an xy array reference. Missing -xy => \\\@array $!";
1054 }
1055 2 ▶ if (defined $xyInt)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xyInt) 0 2 2
1056 {
1057 0 $xy = $xyInt;
1058 0 $resolution=1;
1059 }
1060 2 $self -> printGds2Record(-type => 'BOUNDARY');
1061 2 $self -> printGds2Record(-type => 'LAYER',-data => $layer);
1062 2 $self -> printGds2Record(-type => 'DATATYPE',-data => $dataType);
1063 2 ▶ if (my $numPoints=$#$xy+1 < 6)
Branch: 1 branch
BranchTrueFalseTotal
if (my $numPoints = $xy->$#* + 1 < 6) 0 2 2
1064 {
1065 0 die "printBoundary expects an xy array of at leasts 3 coordinates $!";
1066 }
1067 2 ▶ for(my $i=0;$i<=$#$xy;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $xy->$#*) 16 2 18
1068 {
1069 16 ▶ if ($xy -> [$i] >= 0) {push @xyTmp,int((($xy -> [$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[$i] >= 0) { } 16 0 16
1070 0 else {push @xyTmp,int((($xy -> [$i])*$resolution)-$G_epsilon);}
1071 }
1072 ## gds expects square to have 5 coords (closure)
1073 2 ▶ if (($xy -> [0] != ($xy -> [($#$xy - 1)])) || ($xy -> [1] != ($xy -> [$#$xy])))
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[0] != $$xy[$xy->$#* - 1] or $xy->[1] != $$xy[$xy->$#*]) 2 0 2
Condition33%1/3
$xy->[0] != $$xy[$xy->$#* - 1] or $xy->[1] != $$xy[$xy->$#*]
l!l&&r!l&&!r
020
MC/DC0%0/2
$xy->[0] != $$xy[$xy->$#* - 1] or $xy->[1] != $$xy[$xy->$#*]
$xy->[0] != $$xy[$xy->$#* - 1] $xy->[1] != $$xy[$xy->$#*]
Truth table33%1/3
A or B
A= $xy->[0] != $$xy[$xy->$#* - 1]B= $xy->[1] != $$xy[$xy->$#*]
ABresult
1X1
011
000
1074 {
1075 2 ▶ if ($xy -> [0] >= 0) {push @xyTmp,int((($xy -> [0])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[0] >= 0) { } 2 0 2
1076 0 else {push @xyTmp,int((($xy -> [0])*$resolution)-$G_epsilon);}
1077 2 ▶ if ($xy -> [1] >= 0) {push @xyTmp,int((($xy -> [1])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[1] >= 0) { } 2 0 2
1078 0 else {push @xyTmp,int((($xy -> [1])*$resolution)-$G_epsilon);}
1079 }
1080 2 $self -> printGds2Record(-type => 'XY',-data => \@xyTmp);
1081 2 $self -> printGds2Record(-type => 'ENDEL');
1082 }
1083 ################################################################################
1084  
1085 =head2 printSref - prints a gds2 Structure REFerence
1086  
1087 usage:
1088 $gds2File -> printSref(
1089 -name=>string, ## Name of structure
1090  
1091 -xy=>\@array, ## ref to array of reals
1092 # -or-
1093 -xyInt=>\@array, ## ref to array of internal ints (optional -wks better than -xy if you are modifying an existing GDS2 file)
1094  
1095 -angle=>#.#, ## (optional) Default is 0.0
1096 -mag=>#.#, ## (optional) Default is 1.0
1097 -reflect=>0|1 ## (optional)
1098 );
1099  
1100 note:
1101 best not to specify angle or mag if not needed
1102  
1103 =cut
1104  
1105 #<SREF>::= SREF [ELFLAGS] [PLEX] SNAME [<strans>] XY
1106 # <strans>::= STRANS [MAG] [ANGLE]
1107 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1108 sub printSref
1109 {
1110 2 ▶ my($self,%arg) = @_;
Subroutine printSref: called CC=15 SCAR=35.8
Pod documented
1111 2 my $useSTRANS=FALSE;
1112 2 my $resolution = $self -> {'Resolution'};
1113 2 my $sname = $arg{'-name'};
1114 2 ▶ unless (defined $sname)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sname) 0 2 2
1115 {
1116 0 die "printSref expects a name string. Missing -name => 'text' $!";
1117 }
1118 #### -xyInt most useful if reading and modifying... -xy if creating from scratch
1119 2 my $xyInt = $arg{'-xyInt'}; ## $xyInt should be a reference to an array of internal GDS2 format integers
1120 2 my $xy = $arg{'-xy'}; ## $xy should be a reference to an array of reals
1121 2 ▶ unless (defined($xy) || defined($xyInt))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $xy or defined $xyInt) 0 2 2
Condition33%1/3
defined $xy or defined $xyInt
l!l&&r!l&&!r
200
MC/DC0%0/2
defined $xy or defined $xyInt
defined $xy defined $xyInt
Truth table33%1/3
A or B
A= defined $xyB= defined $xyInt
ABresult
1X1
011
000
1122 {
1123 0 die "printSref expects an xy array reference. Missing -xy => \\\@array $!";
1124 }
1125 2 ▶ if (defined $xyInt)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xyInt) 0 2 2
1126 {
1127 0 $xy = $xyInt;
1128 0 $resolution=1;
1129 }
1130 2 $self -> printGds2Record(-type => 'SREF');
1131 2 $self -> printGds2Record(-type => 'SNAME',-data => $sname);
1132 2 my $reflect = $arg{'-reflect'};
1133 2 ▶ if ((! defined $reflect)||($reflect <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $reflect or $reflect <= 0) { } 2 0 2
Condition33%1/3
not defined $reflect or $reflect <= 0
l!l&&r!l&&!r
200
MC/DC0%0/2
not defined $reflect or $reflect <= 0
not defined $reflect $reflect <= 0
Truth table33%1/3
not(A) or B
A= not defined $reflectB= $reflect <= 0
ABresult
1X1
011
000
1134 {
1135 2 $reflect=0;
1136 }
1137 else
1138 {
1139 0 $reflect=1;
1140 0 $useSTRANS=TRUE;
1141 }
1142 2 my $mag = $arg{'-mag'};
1143 2 ▶ if ((! defined $mag)||($mag <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $mag or $mag <= 0) { } 2 0 2
Condition33%1/3
not defined $mag or $mag <= 0
l!l&&r!l&&!r
200
MC/DC0%0/2
not defined $mag or $mag <= 0
not defined $mag $mag <= 0
Truth table33%1/3
not(A) or B
A= not defined $magB= $mag <= 0
ABresult
1X1
011
000
1144 {
1145 2 $mag=0;
1146 }
1147 else
1148 {
1149 0 $mag = cleanFloatNum($mag);
1150 0 $useSTRANS=TRUE;
1151 }
1152 2 my $angle = $arg{'-angle'};
1153 2 ▶ if (! defined $angle)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $angle) { } 2 0 2
1154 {
1155 2 $angle = -1; #not really... just means not specified
1156 }
1157 else
1158 {
1159 0 $angle=posAngle($angle);
1160 0 $useSTRANS=TRUE;
1161 }
1162 2 ▶ if ($useSTRANS)
Branch: 1 branch
BranchTrueFalseTotal
if ($useSTRANS) 0 2 2
1163 {
1164 0 my $data=$reflect.'0'x15; ## 16 'bit' string
1165 0 $self -> printGds2Record(-type => 'STRANS',-data => $data);
1166 0 ▶ $self -> printGds2Record(-type => 'MAG',-data => $mag) if ($mag);
Branch: 1 branch
BranchTrueFalseTotal
if $mag 0 0 0
1167 0 ▶ $self -> printGds2Record(-type => 'ANGLE',-data => $angle) if ($angle >= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $angle >= 0 0 0 0
1168 }
1169 2 my @xyTmp=(); ##don't pollute array passed in
1170 2 ▶ for(my $i=0;$i<=$#$xy;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $xy->$#*) 4 2 6
1171 {
1172 4 ▶ if ($xy -> [$i] >= 0) {push @xyTmp,int((($xy -> [$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[$i] >= 0) { } 4 0 4
1173 0 else {push @xyTmp,int((($xy -> [$i])*$resolution)-$G_epsilon);}
1174 }
1175 2 $self -> printGds2Record(-type => 'XY',-data => \@xyTmp);
1176 2 $self -> printGds2Record(-type => 'ENDEL');
1177 }
1178 ################################################################################
1179  
1180 =head2 printAref - prints a gds2 Array REFerence
1181  
1182 usage:
1183 $gds2File -> printAref(
1184 -name=>string, ## Name of structure
1185 -columns=>#, ## Default is 1
1186 -rows=>#, ## Default is 1
1187  
1188 -xy=>\@array, ## ref to array of reals
1189 # -or-
1190 -xyInt=>\@array, ## ref to array of internal ints (optional -wks better if you are modifying an existing GDS2 file)
1191  
1192 -angle=>#.#, ## (optional) Default is 0.0
1193 -mag=>#.#, ## (optional) Default is 1.0
1194 -reflect=>0|1 ## (optional)
1195 );
1196  
1197 note:
1198 best not to specify angle or mag if not needed
1199 xyList: 1st coord: origin, 2nd coord: X of col * xSpacing + origin, 3rd coord: Y of row * ySpacing + origin
1200  
1201 =cut
1202  
1203 #<AREF>::= AREF [ELFLAGS] [PLEX] SNAME [<strans>] COLROW XY
1204 # <strans>::= STRANS [MAG] [ANGLE]
1205 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1206 sub printAref
1207 {
1208 2 ▶ my($self,%arg) = @_;
Subroutine printAref: called CC=19 SCAR=39.3
Pod documented
1209 2 my $useSTRANS=FALSE;
1210 2 my $resolution = $self -> {'Resolution'};
1211 2 my $sname = $arg{'-name'};
1212 2 ▶ unless (defined $sname)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sname) 0 2 2
1213 {
1214 0 die "printAref expects a sname string. Missing -name => 'text' $!";
1215 }
1216 #### -xyInt most useful if reading and modifying... -xy if creating from scratch
1217 2 my $xyInt = $arg{'-xyInt'}; ## $xyInt should be a reference to an array of internal GDS2 format integers
1218 2 my $xy = $arg{'-xy'}; ## $xy should be a reference to an array of reals
1219 2 ▶ unless (defined($xy) || defined($xyInt))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $xy or defined $xyInt) 0 2 2
Condition33%1/3
defined $xy or defined $xyInt
l!l&&r!l&&!r
200
MC/DC0%0/2
defined $xy or defined $xyInt
defined $xy defined $xyInt
Truth table33%1/3
A or B
A= defined $xyB= defined $xyInt
ABresult
1X1
011
000
1220 {
1221 0 die "printAref expects an xy array reference. Missing -xy => \\\@array $!";
1222 }
1223 2 ▶ if (defined $xyInt)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xyInt) 0 2 2
1224 {
1225 0 $xy = $xyInt;
1226 0 $resolution=1;
1227 }
1228 2 $self -> printGds2Record(-type => 'AREF');
1229 2 $self -> printGds2Record(-type => 'SNAME',-data => $sname);
1230 2 my $reflect = $arg{'-reflect'};
1231 2 ▶ if ((! defined $reflect)||($reflect <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $reflect or $reflect <= 0) { } 2 0 2
Condition33%1/3
not defined $reflect or $reflect <= 0
l!l&&r!l&&!r
200
MC/DC0%0/2
not defined $reflect or $reflect <= 0
not defined $reflect $reflect <= 0
Truth table33%1/3
not(A) or B
A= not defined $reflectB= $reflect <= 0
ABresult
1X1
011
000
1232 {
1233 2 $reflect=0;
1234 }
1235 else
1236 {
1237 0 $reflect=1;
1238 0 $useSTRANS=TRUE;
1239 }
1240 2 my $mag = $arg{'-mag'};
1241 2 ▶ if ((! defined $mag)||($mag <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $mag or $mag <= 0) { } 2 0 2
Condition33%1/3
not defined $mag or $mag <= 0
l!l&&r!l&&!r
200
MC/DC0%0/2
not defined $mag or $mag <= 0
not defined $mag $mag <= 0
Truth table33%1/3
not(A) or B
A= not defined $magB= $mag <= 0
ABresult
1X1
011
000
1242 {
1243 2 $mag=0;
1244 }
1245 else
1246 {
1247 0 $mag = cleanFloatNum($mag);
1248 0 $useSTRANS=TRUE;
1249 }
1250 2 my $angle = $arg{'-angle'};
1251 2 ▶ if (! defined $angle)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $angle) { } 2 0 2
1252 {
1253 2 $angle = -1; #not really... just means not specified
1254 }
1255 else
1256 {
1257 0 $angle=posAngle($angle);
1258 0 $useSTRANS=TRUE;
1259 }
1260 2 ▶ if ($useSTRANS)
Branch: 1 branch
BranchTrueFalseTotal
if ($useSTRANS) 0 2 2
1261 {
1262 0 my $data=$reflect.'0'x15; ## 16 'bit' string
1263 0 $self -> printGds2Record(-type => 'STRANS',-data => $data);
1264 0 ▶ $self -> printGds2Record(-type => 'MAG',-data => $mag) if ($mag);
Branch: 1 branch
BranchTrueFalseTotal
if $mag 0 0 0
1265 0 ▶ $self -> printGds2Record(-type => 'ANGLE',-data => $angle) if ($angle >= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $angle >= 0 0 0 0
1266 }
1267 2 my $columns = $arg{'-columns'};
1268 2 ▶ if ((! defined $columns)||($columns <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $columns or $columns <= 0) { } 0 2 2
Condition33%1/3
not defined $columns or $columns <= 0
l!l&&r!l&&!r
002
MC/DC0%0/2
not defined $columns or $columns <= 0
not defined $columns $columns <= 0
Truth table33%1/3
not(A) or B
A= not defined $columnsB= $columns <= 0
ABresult
1X1
011
000
1269 {
1270 0 $columns=1;
1271 }
1272 else
1273 {
1274 2 $columns = int($columns);
1275 }
1276 2 my $rows = $arg{'-rows'};
1277 2 ▶ if ((! defined $rows)||($rows <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $rows or $rows <= 0) { } 0 2 2
Condition33%1/3
not defined $rows or $rows <= 0
l!l&&r!l&&!r
002
MC/DC0%0/2
not defined $rows or $rows <= 0
not defined $rows $rows <= 0
Truth table33%1/3
not(A) or B
A= not defined $rowsB= $rows <= 0
ABresult
1X1
011
000
1278 {
1279 0 $rows=1;
1280 }
1281 else
1282 {
1283 2 $rows = int($rows);
1284 }
1285 2 $self -> printGds2Record(-type => 'COLROW',-data => [$columns,$rows]);
1286 2 my @xyTmp=(); ##don't pollute array passed in
1287 2 ▶ for(my $i=0;$i<=$#$xy;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $xy->$#*) 8 2 10
1288 {
1289 8 ▶ if ($xy -> [$i] >= 0) {push @xyTmp,int((($xy -> [$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[$i] >= 0) { } 8 0 8
1290 0 else {push @xyTmp,int((($xy -> [$i])*$resolution)-$G_epsilon);}
1291 }
1292 2 $self -> printGds2Record(-type => 'XY',-data => \@xyTmp);
1293 2 $self -> printGds2Record(-type => 'ENDEL');
1294 }
1295 ################################################################################
1296  
1297 =head2 printText - prints a gds2 Text
1298  
1299 usage:
1300 $gds2File -> printText(
1301 -string=>string,
1302 -layer=>#, ## Default is 0
1303 -textType=>#, ## Default is 0
1304 -font=>#, ## 0-3
1305 -top, or -middle, -bottom, ##optional vertical presentation
1306 -left, or -center, or -right, ##optional horizontal presentation
1307  
1308 -xy=>\@array, ## ref to array of reals
1309 # -or-
1310 -xyInt=>\@array, ## ref to array of internal ints (optional -wks better if you are modifying an existing GDS2 file)
1311  
1312 -x=>#.#, ## optional way of passing in x value
1313 -y=>#.#, ## optional way of passing in y value
1314 -angle=>#.#, ## (optional) Default is 0.0
1315 -mag=>#.#, ## (optional) Default is 1.0
1316 -reflect=>#, ## (optional) Default is 0
1317 );
1318  
1319 note:
1320 best not to specify reflect, angle or mag if not needed
1321  
1322 =cut
1323  
1324 #<text>::= TEXT [ELFLAGS] [PLEX] LAYER <textbody>
1325 # <textbody>::= TEXTTYPE [PRESENTATION] [PATHTYPE] [WIDTH] [<strans>] XY STRING
1326 # <strans>::= STRANS [MAG] [ANGLE]
1327 ################################################################################
1328 sub printText
1329 {
1330 0 ▶ my($self,%arg) = @_;
Subroutine printText: not called CC=35 SCAR=71.4
Pod documented
1331 0 my $useSTRANS=FALSE;
1332 0 my $string = $arg{'-string'};
1333 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
1334 {
1335 0 die "printText expects a string. Missing -string => 'text' $!";
1336 }
1337 0 my $resolution = $self -> {'Resolution'};
1338 0 my $x = $arg{'-x'};
1339 0 my $y = $arg{'-y'};
1340 #### -xyInt most useful if reading and modifying... -xy if creating from scratch
1341 0 my $xyInt = $arg{'-xyInt'}; ## $xyInt should be a reference to an array of internal GDS2 format integers
1342 0 my $xy = $arg{'-xy'}; ## $xy should be a reference to an array of reals
1343 0 ▶ if (defined $xyInt)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xyInt) 0 0 0
1344 {
1345 0 $xy = $xyInt;
1346 0 $resolution=1;
1347 }
1348 0 ▶ if (defined $xy)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xy) 0 0 0
1349 {
1350 0 $x = $xy -> [0];
1351 0 $y = $xy -> [1];
1352 }
1353  
1354 0 my $x2 = $arg{'-x'};
1355 0 ▶ if (defined $x2)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $x2) 0 0 0
1356 {
1357 0 $x = $x2;
1358 }
1359 0 ▶ unless (defined $x)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $x) 0 0 0
1360 {
1361 0 die "printText expects a x coord. Missing -xy=>\@array or -x => 'num' $!";
1362 }
1363 0 ▶ if ($x>=0) {$x = int(($x*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($x >= 0) { } 0 0 0
1364 0 else {$x = int(($x*$resolution)-$G_epsilon);}
1365  
1366 0 my $y2 = $arg{'-y'};
1367 0 ▶ if (defined $y2)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $y2) 0 0 0
1368 {
1369 0 $y = $y2;
1370 }
1371 0 ▶ unless (defined $y)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $y) 0 0 0
1372 {
1373 0 die "printText expects a y coord. Missing -xy=>\@array or -y => 'num' $!";
1374 }
1375 0 ▶ if ($y>=0) {$y = int(($y*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($y >= 0) { } 0 0 0
1376 0 else {$y = int(($y*$resolution)-$G_epsilon);}
1377  
1378 0 my $layer = $arg{'-layer'};
1379 0 ▶ $layer=0 unless (defined $layer);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $layer 0 0 0
1380 0 my $textType = $arg{'-textType'};
1381 0 ▶ $textType=0 unless (defined $textType);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $textType 0 0 0
1382 0 my $reflect = $arg{'-reflect'};
1383 0 ▶ if ((! defined $reflect)||($reflect <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $reflect or $reflect <= 0) { } 0 0 0
Condition0%0/3
not defined $reflect or $reflect <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $reflect or $reflect <= 0
not defined $reflect $reflect <= 0
Truth table0%0/3
not(A) or B
A= not defined $reflectB= $reflect <= 0
ABresult
1X1
011
000
1384 {
1385 0 $reflect=0;
1386 }
1387 else
1388 {
1389 0 $reflect=1;
1390 0 $useSTRANS=TRUE;
1391 }
1392  
1393 0 my $font = $arg{'-font'};
1394 0 ▶ if ((! defined $font) || ($font < 0) || ($font > 3))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $font or $font < 0 or $font > 3) 0 0 0
Condition0%0/6
not defined $font or $font < 0 or $font > 3
l!l&&r!l&&!r
000
not defined $font or $font < 0
l!l&&r!l&&!r
000
MC/DC0%0/3
not defined $font or $font < 0 or $font > 3
not defined $font $font < 0 $font > 3
Truth table0%0/4
not(A) or B or C
A= not defined $fontB= $font < 0C= $font > 3
ABCresult
1XX1
01X1
0011
0000
1395 {
1396 0 $font=0;
1397 }
1398 0 $font = sprintf("%02d",$font);
1399  
1400 0 my $vertical;
1401 0 my $top = $arg{'-top'};
1402 0 my $middle = $arg{'-middle'};
1403 0 my $bottom = $arg{'-bottom'};
1404 0 ▶ if (defined $top) {$vertical = '00';}
Branch: 2 branches
BranchTrueFalseTotal
if (defined $top) { } 0 0 0
elsif (defined $bottom) { } 0 0 0
1405 0 elsif (defined $bottom) {$vertical = '10';}
1406 0 else {$vertical = '01';} ## middle
1407 0 my $horizontal;
1408 0 my $left = $arg{'-left'};
1409 0 my $center = $arg{'-center'};
1410 0 my $right = $arg{'-right'};
1411 0 ▶ if (defined $left) {$horizontal = '00';}
Branch: 2 branches
BranchTrueFalseTotal
if (defined $left) { } 0 0 0
elsif (defined $right) { } 0 0 0
1412 0 elsif (defined $right) {$horizontal = '10';}
1413 0 else {$horizontal = '01';} ## center
1414 0 my $presString = '0'x10;
1415 0 $presString .= "$font$vertical$horizontal";
1416  
1417 0 my $mag = $arg{'-mag'};
1418 0 ▶ if ((! defined $mag)||($mag <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $mag or $mag <= 0) { } 0 0 0
Condition0%0/3
not defined $mag or $mag <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $mag or $mag <= 0
not defined $mag $mag <= 0
Truth table0%0/3
not(A) or B
A= not defined $magB= $mag <= 0
ABresult
1X1
011
000
1419 {
1420 0 $mag=0;
1421 }
1422 else
1423 {
1424 0 $mag = cleanFloatNum($mag);
1425 }
1426 0 my $angle = $arg{'-angle'};
1427 0 ▶ if (! defined $angle)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $angle) { } 0 0 0
1428 {
1429 0 $angle = -1; #not really... just means not specified
1430 }
1431 else
1432 {
1433 0 $angle=posAngle($angle);
1434 }
1435 0 $self -> printGds2Record(-type=>'TEXT');
1436 0 $self -> printGds2Record(-type=>'LAYER',-data=>$layer);
1437 0 $self -> printGds2Record(-type=>'TEXTTYPE',-data=>$textType);
1438 0 ▶ $self -> printGds2Record(-type => 'PRESENTATION',-data => $presString) if (defined $font || defined $top || defined $middle || defined $bottom || defined $bottom || defined $left || defined $center || defined $right);
Branch: 1 branch
BranchTrueFalseTotal
if defined $font or defined $top or defined $middle or defined $bottom or defined $bottom or defined $left or defined $center or defined $right 0 0 0
Condition0%0/21
defined $font or defined $top or defined $middle or defined $bottom or defined $bottom or defined $left or defined $center or defined $right
l!l&&r!l&&!r
000
defined $font or defined $top or defined $middle or defined $bottom or defined $bottom or defined $left or defined $center
l!l&&r!l&&!r
000
defined $font or defined $top or defined $middle or defined $bottom or defined $bottom or defined $left
l!l&&r!l&&!r
000
defined $font or defined $top or defined $middle or defined $bottom or defined $bottom
l!l&&r!l&&!r
000
defined $font or defined $top or defined $middle or defined $bottom
l!l&&r!l&&!r
000
defined $font or defined $top or defined $middle
l!l&&r!l&&!r
000
defined $font or defined $top
l!l&&r!l&&!r
000
MC/DC0%0/8
defined $font or defined $top or defined $middle or defined $bottom or defined $bottom or defined $left or defined $center or defined $right
defined $font defined $top defined $middle defined $bottom defined $bottom defined $left defined $center defined $right
Truth table0%0/9
A or B or C or D or E or F or G or H
A= defined $fontB= defined $topC= defined $middleD= defined $bottomE= defined $bottomF= defined $leftG= defined $centerH= defined $right
ABCDEFGHresult
1XXXXXXX1
01XXXXXX1
001XXXXX1
0001XXXX1
00001XXX1
000001XX1
0000001X1
000000011
000000000
1439 0 ▶ if ($useSTRANS)
Branch: 1 branch
BranchTrueFalseTotal
if ($useSTRANS) 0 0 0
1440 {
1441 0 my $data=$reflect.'0'x15; ## 16 'bit' string
1442 0 $self -> printGds2Record(-type=>'STRANS',-data=>$data);
1443 }
1444 0 ▶ $self -> printGds2Record(-type=>'MAG',-data=>$mag) if ($mag);
Branch: 1 branch
BranchTrueFalseTotal
if $mag 0 0 0
1445 0 ▶ $self -> printGds2Record(-type=>'ANGLE',-data=>$angle) if ($angle >= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $angle >= 0 0 0 0
1446 0 $self -> printGds2Record(-type=>'XY',-data=>[$x,$y]);
1447 0 $self -> printGds2Record(-type=>'STRING',-data=>$string);
1448 0 $self -> printGds2Record(-type=>'ENDEL');
1449 }
1450 ################################################################################
1451  
1452 =head1 Low Level Generic Write Methods
1453  
1454 =cut
1455  
1456 ################################################################################
1457  
1458 =head2 saveGds2Record() - low level method to create a gds2 record given record type
1459 and data (if required). Data of more than one item should be given as a list.
1460  
1461 NOTE: THIS ONLY USES GDS2 OBJECT TO GET RESOLUTION
1462  
1463 usage:
1464 saveGds2Record(
1465 -type=>string,
1466 -data=>data_If_Needed, ##optional for some types
1467 -scale=>#.#, ##optional number to scale data to. I.E -scale=>0.5 #default is NOT to scale
1468 -snap=>#.#, ##optional number to snap data to I.E. -snap=>0.005 #default is 1 resolution unit, typically 0.001
1469 );
1470  
1471 examples:
1472 my $gds2File = new GDS2(-fileName => ">$fileName");
1473 my $record = $gds2File -> saveGds2Record(-type=>'header',-data=>3);
1474 $gds2FileOut -> printGds2Record(-type=>'record',-data=>$record);
1475  
1476  
1477 =cut
1478  
1479 sub saveGds2Record
1480 {
1481 0 ▶ my ($self,%arg) = @_;
Subroutine saveGds2Record: not called CC=42 SCAR=75.0
Pod documented
1482 0 my $record='';
1483  
1484 0 my $type = $arg{'-type'};
1485 0 ▶ if (! defined $type)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $type) { } 0 0 0
1486 {
1487 0 die "saveGds2Record expects a type name. Missing -type => 'name' $!";
1488 }
1489 else
1490 {
1491 0 $type = uc $type;
1492 }
1493  
1494 0 my $saveEnd=$\;
1495 0 $\='';
1496  
1497 0 my @data = $arg{'-data'};
1498 0 my $dataString = $arg{'-asciiData'};
1499 0 ▶ die "saveGds2Record can not handle both -data and -asciiData options $!" if ((defined $dataString)&&((defined $data[0])&&($data[0] ne '')));
Branch: 1 branch
BranchTrueFalseTotal
if defined $dataString and (defined $data[0] and $data[0] ne "") 0 0 0
Condition0%0/6
defined $dataString and (defined $data[0] and $data[0] ne "")
!ll&&!rl&&r
000
defined $data[0] and $data[0] ne ""
!ll&&!rl&&r
000
MC/DC0%0/3
defined $dataString and (defined $data[0] and $data[0] ne "")
defined $dataString defined $data[0] $data[0] ne ""
Truth table0%0/4
A and B and C
A= defined $dataStringB= defined $data[0]C= $data[0] ne ""
ABCresult
0XX0
10X0
1100
1111
1500  
1501 0 my $data = '';
1502 0 ▶ if ($type eq 'RECORD') ## special case...
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'RECORD') { } 0 0 0
1503 {
1504 0 return $data[0];
1505 }
1506 else
1507 {
1508 0 my $numDataElements = 0;
1509 0 my $resolution = $self -> {'Resolution'};
1510  
1511 0 my $scale = $arg{'-scale'};
1512 0 ▶ if (! defined $scale)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $scale) 0 0 0
1513 {
1514 0 $scale=1;
1515 }
1516 0 ▶ if ($scale <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($scale <= 0) 0 0 0
1517 {
1518 0 die "saveGds2Record expects a positive scale -scale => $scale $!";
1519 }
1520  
1521 0 my $snap = $arg{'-snap'};
1522 0 ▶ if (! defined $snap) ## default is one resolution unit
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $snap) { } 0 0 0
1523 {
1524 0 $snap = 1;
1525 }
1526 else
1527 {
1528 0 $snap = $snap*$resolution; ## i.e. 0.001 -> 1
1529 }
1530 0 ▶ if ($snap < 1)
Branch: 1 branch
BranchTrueFalseTotal
if ($snap < 1) 0 0 0
1531 {
1532 0 die "saveGds2Record expects a snap >= 1/resolution -snap => $snap $!";
1533 }
1534  
1535 0 ▶ if ((defined $data[0])&&($data[0] ne ''))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data[0] and $data[0] ne "") 0 0 0
Condition0%0/3
defined $data[0] and $data[0] ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $data[0] and $data[0] ne ""
defined $data[0] $data[0] ne ""
Truth table0%0/3
A and B
A= defined $data[0]B= $data[0] ne ""
ABresult
0X0
100
111
1536 {
1537 0 $data = $data[0];
1538 0 $numDataElements = @$data;
1539 0 ▶ if ($numDataElements) ## passed in anonymous array
Branch: 1 branch
BranchTrueFalseTotal
if ($numDataElements) { } 0 0 0
1540 {
1541 0 @data = @$data; ## deref
1542 }
1543 else
1544 {
1545 0 $numDataElements = @data;
1546 }
1547 }
1548  
1549 0 my $recordDataType = $RecordTypeData{$type};
1550 0 ▶ if (defined $dataString)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dataString) 0 0 0
1551 {
1552 0 $dataString=~s|^\s+||; ## clean-up
1553 0 $dataString=~s|\s+$||;
1554 0 ▶ $dataString=~s|\s+| |g if ($dataString !~ m|'|); ## don't compress spaces in strings...
Branch: 1 branch
BranchTrueFalseTotal
unless $dataString =~ /'/ 0 0 0
1555 0 $dataString=~s|'$||; #'for strings
1556 0 $dataString=~s|^'||; #'for strings
1557 0 ▶ if (($recordDataType == BIT_ARRAY)||($recordDataType == ACSII_STRING))
Branch: 1 branch
BranchTrueFalseTotal
if ($recordDataType == 1 or $recordDataType == 6) { } 0 0 0
Condition0%0/3
$recordDataType == 1 or $recordDataType == 6
l!l&&r!l&&!r
000
MC/DC0%0/2
$recordDataType == 1 or $recordDataType == 6
$recordDataType == 1 $recordDataType == 6
Truth table0%0/3
A or B
A= $recordDataType == 1B= $recordDataType == 6
ABresult
1X1
011
000
1558 {
1559 0 $data = $dataString;
1560 }
1561 else
1562 {
1563 0 $dataString=~s|\s*[\s,;:/\\]+\s*| |g; ## incase commas etc... (non-std) were added by hand
1564 0 @data = split(' ',$dataString);
1565 0 $numDataElements = @data;
1566 0 ▶ if ($recordDataType == INTEGER_4)
Branch: 1 branch
BranchTrueFalseTotal
if ($recordDataType == 3) 0 0 0
1567 {
1568 0 my @xyTmp=();
1569 0 ▶ for(my $i=0;$i<$numDataElements;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $numDataElements) 0 0 0
1570 {
1571 0 ▶ if ($data[$i]>=0) {push @xyTmp,int((($data[$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($data[$i] >= 0) { } 0 0 0
1572 0 else {push @xyTmp,int((($data[$i])*$resolution)-$G_epsilon);}
1573 }
1574 0 @data=@xyTmp;
1575 }
1576 }
1577 }
1578 0 my $byte;
1579 0 my $length = 0;
1580 0 ▶ if ($recordDataType == BIT_ARRAY)
Branch: 5 branches
BranchTrueFalseTotal
if ($recordDataType == 1) { } 0 0 0
elsif ($recordDataType == 2) { } 0 0 0
elsif ($recordDataType == 3) { } 0 0 0
elsif ($recordDataType == 5) { } 0 0 0
elsif ($recordDataType == 6) { } 0 0 0
1581 {
1582 0 $length = 2;
1583 }
1584 elsif ($recordDataType == INTEGER_2)
1585 {
1586 0 $length = 2 * $numDataElements;
1587 }
1588 elsif ($recordDataType == INTEGER_4)
1589 {
1590 0 $length = 4 * $numDataElements;
1591 }
1592 elsif ($recordDataType == REAL_8)
1593 {
1594 0 $length = 8 * $numDataElements;
1595 }
1596 elsif ($recordDataType == ACSII_STRING)
1597 {
1598 0 my $slen = length $data;
1599 0 $length = $slen + ($slen % 2); ## needs to be an even number
1600 }
1601  
1602 0 my $recordLength = pack 'S',($length + 4); #1 2 bytes for length 3rd for recordType 4th for dataType
1603 0 $record .= $recordLength;
1604 0 my $recordType = pack 'C',$RecordTypeNumbers{$type};
1605 0 $record .= $recordType;
1606  
1607 0 my $dataType = pack 'C',$RecordTypeData{$type};
1608 0 $record .= $dataType;
1609  
1610 0 ▶ if ($recordDataType == BIT_ARRAY) ## bit array
Branch: 5 branches
BranchTrueFalseTotal
if ($recordDataType == 1) { } 0 0 0
elsif ($recordDataType == 2) { } 0 0 0
elsif ($recordDataType == 3) { } 0 0 0
elsif ($recordDataType == 5) { } 0 0 0
elsif ($recordDataType == 6) { } 0 0 0
1611 {
1612 0 my $bitLength = $length * 8;
1613 0 $record .= pack("B$bitLength",$data);
1614 }
1615 elsif ($recordDataType == INTEGER_2) ## 2 byte signed integer
1616 {
1617 0 foreach my $num (@data)
1618 {
1619 0 $record .= pack('s',$num);
1620 }
1621 }
1622 elsif ($recordDataType == INTEGER_4) ## 4 byte signed integer
1623 {
1624 0 foreach my $num (@data)
1625 {
1626 0 ▶ $num = scaleNum($num,$scale) if ($scale != 1);
Branch: 1 branch
BranchTrueFalseTotal
if $scale != 1 0 0 0
1627 0 ▶ $num = snapNum($num,$snap) if ($snap != 1);
Branch: 1 branch
BranchTrueFalseTotal
if $snap != 1 0 0 0
1628 0 $record .= pack('i',$num);
1629 }
1630 }
1631 elsif ($recordDataType == REAL_8) ## 8 byte real
1632 {
1633 0 foreach my $num (@data)
1634 {
1635 0 my $real = $num;
1636 0 my $negative = FALSE;
1637 0 ▶ if($num < 0.0)
Branch: 1 branch
BranchTrueFalseTotal
if ($num < 0) 0 0 0
1638 {
1639 0 $negative = TRUE;
1640 0 $real = 0 - $num;
1641 }
1642  
1643 0 my $exponent = 0;
1644 0 ▶ while($real >= 1.0)
Branch: 1 branch
BranchTrueFalseTotal
if ($real >= 1) 0 0 0
1645 {
1646 0 $exponent++;
1647 0 $real = ($real / 16.0);
1648 }
1649  
1650 0 ▶ if ($real != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($real != 0) 0 0 0
1651 {
1652 0 ▶ while($real < 0.0625)
Branch: 1 branch
BranchTrueFalseTotal
if ($real < "0.0625") 0 0 0
1653 {
1654 0 --$exponent;
1655 0 $real = ($real * 16.0);
1656 }
1657 }
1658  
1659 0 ▶ if($negative) { $exponent += 192; }
Branch: 1 branch
BranchTrueFalseTotal
if ($negative) { } 0 0 0
1660 0 else { $exponent += 64; }
1661 0 $record .= pack('C',$exponent);
1662  
1663 0 ▶ for (my $i=1; $i<=7; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= 7) 0 0 0
1664 {
1665 0 ▶ if ($real>=0) {$byte = int(($real*256.0)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($real >= 0) { } 0 0 0
1666 0 else {$byte = int(($real*256.0)-$G_epsilon);}
1667 0 $record .= pack('C',$byte);
1668 0 $real = $real * 256.0 - ($byte + 0.0);
1669 }
1670 }
1671 }
1672 elsif ($recordDataType == ACSII_STRING) ## ascii string (null padded)
1673 {
1674 0 $record .= pack("a$length",$data);
1675 }
1676 }
1677 0 $\=$saveEnd;
1678 0 $record;
1679 }
1680 ################################################################################
1681  
1682 =head2 printGds2Record() - low level method to print a gds2 record given record type
1683 and data (if required). Data of more than one item should be given as a list.
1684  
1685 usage:
1686 printGds2Record(
1687 -type=>string,
1688 -data=>data_If_Needed, ##optional for some types
1689 -scale=>#.#, ##optional number to scale data to. I.E -scale=>0.5 #default is NOT to scale
1690 -snap=>#.#, ##optional number to snap data to I.E. -snap=>0.005 #default is 1 resolution unit, typically 0.001
1691 );
1692  
1693 examples:
1694 my $gds2File = new GDS2(-fileName => ">$fileName");
1695  
1696 $gds2File -> printGds2Record(-type=>'header',-data=>3);
1697 $gds2File -> printGds2Record(-type=>'bgnlib',-data=>[99,12,1,22,33,0,99,12,1,22,33,9]);
1698 $gds2File -> printGds2Record(-type=>'libname',-data=>"testlib");
1699 $gds2File -> printGds2Record(-type=>'units',-data=>[0.001, 1e-9]);
1700 $gds2File -> printGds2Record(-type=>'bgnstr',-data=>[99,12,1,22,33,0,99,12,1,22,33,9]);
1701 ...
1702 $gds2File -> printGds2Record(-type=>'endstr');
1703 $gds2File -> printGds2Record(-type=>'endlib');
1704  
1705 Note: the special record type of 'record' can be used to copy a complete record
1706 just read in:
1707 while (my $record = $gds2FileIn -> readGds2Record())
1708 {
1709 $gds2FileOut -> printGds2Record(-type=>'record',-data=>$record);
1710 }
1711  
1712 =cut
1713  
1714 sub printGds2Record
1715 {
1716 317 ▶ my ($self,%arg) = @_;
Subroutine printGds2Record: called CC=62 SCAR=55.0
Pod documented
1717  
1718 317 my $type = $arg{'-type'};
1719 317 ▶ unless (defined $type)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type) { } 317 0 317
1720 {
1721 0 die "printGds2Record expects a type name. Missing -type => 'name' $!";
1722 }
1723 else
1724 {
1725 317 $type = uc $type;
1726 }
1727 317 my @data = $arg{'-data'};
1728 317 my $dataString = $arg{'-asciiData'};
1729 317 ▶ die "printGds2Record can not handle both -data and -asciiData options $!" if ((defined $dataString)&&((defined $data[0])&&($data[0] ne '')));
Branch: 1 branch
BranchTrueFalseTotal
if defined $dataString and (defined $data[0] and $data[0] ne "") 0 317 317
Condition50%3/6
defined $dataString and (defined $data[0] and $data[0] ne "")
!ll&&!rl&&r
622550
defined $data[0] and $data[0] ne ""
!ll&&!rl&&r
25500
MC/DC0%0/3
defined $dataString and (defined $data[0] and $data[0] ne "")
defined $dataString defined $data[0] $data[0] ne ""
Truth table25%1/4
A and B and C
A= defined $dataStringB= defined $data[0]C= $data[0] ne ""
ABCresult
0XX0
10X0
1100
1111
1730  
1731 317 my $fh = $self -> {'FileHandle'};
1732 317 my $saveEnd=$\;
1733 317 $\='';
1734  
1735 317 my $data = '';
1736 317 ▶ @data = () unless (defined $data[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data[0] 277 40 317
1737 317 my $recordLength; ## 1st 2 bytes for length 3rd for recordType 4th for dataType
1738 317 ▶ if ($type eq 'RECORD') ## special case...
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'RECORD') { } 0 317 317
1739 {
1740 0 ▶ if ($isLittleEndian)
Branch: 1 branch
BranchTrueFalseTotal
if ($isLittleEndian) { } 0 0 0
1741 {
1742 0 my $length = substr($data[0],0,2);
1743 0 $recordLength = unpack 'v',$length;
1744 0 $self -> {'BytesDone'} += $recordLength;
1745 0 $length = reverse $length;
1746 0 print($fh $length);
1747  
1748 0 my $recordType = substr($data[0],2,1);
1749 0 print($fh $recordType);
1750 0 $recordType = unpack 'C',$recordType;
1751 0 $type = $RecordTypeStrings[$recordType]; ## will use code below.....
1752  
1753 0 my $dataType = substr($data[0],3,1);
1754 0 print($fh $dataType);
1755 0 $dataType = unpack 'C',$dataType;
1756 0 ▶ if ($recordLength > 4)
Branch: 1 branch
BranchTrueFalseTotal
if ($recordLength > 4) 0 0 0
1757 {
1758 0 my $lengthLeft = $recordLength - 4; ## length left
1759 0 my $recordDataType = $RecordTypeData{$type};
1760  
1761 0 ▶ if (($recordDataType == INTEGER_2) || ($recordDataType == BIT_ARRAY))
Branch: 5 branches
BranchTrueFalseTotal
if ($recordDataType == 2 or $recordDataType == 1) { } 0 0 0
elsif ($recordDataType == 3) { } 0 0 0
elsif ($recordDataType == 5) { } 0 0 0
elsif ($recordDataType == 6) { } 0 0 0
elsif ($recordDataType == 4) { } 0 0 0
Condition0%0/3
$recordDataType == 2 or $recordDataType == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$recordDataType == 2 or $recordDataType == 1
$recordDataType == 2 $recordDataType == 1
Truth table0%0/3
A or B
A= $recordDataType == 2B= $recordDataType == 1
ABresult
1X1
011
000
1762 {
1763 0 my $binData = unpack 'b*',$data[0];
1764 0 my $intData = substr($binData,32); #skip 1st 4 bytes (length, recordType dataType)
1765  
1766 0 my ($byteInt2String,$byte2);
1767 0 ▶ for(my $i=0; $i<($lengthLeft/2); $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $lengthLeft / 2) 0 0 0
1768 {
1769 0 $byteInt2String = reverse(substr($intData,0,16,''));
1770 0 $byte2=pack 'B16',reverse($byteInt2String);
1771 0 print($fh $byte2);
1772 }
1773 }
1774 elsif ($recordDataType == INTEGER_4)
1775 {
1776 0 my $binData = unpack 'b*',$data[0];
1777 0 my $intData = substr($binData,32); #skip 1st 4 bytes (length, recordType dataType)
1778 0 my ($byteInt4String,$byte4);
1779 0 ▶ for(my $i=0; $i<($lengthLeft/4); $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $lengthLeft / 4) 0 0 0
1780 {
1781 0 $byteInt4String = reverse(substr($intData,0,32,''));
1782 0 $byte4=pack 'B32',reverse($byteInt4String);
1783 0 print($fh $byte4);
1784 }
1785 }
1786 elsif ($recordDataType == REAL_8)
1787 {
1788 0 my $binData = unpack 'b*',$data[0];
1789 0 my $realData = substr($binData,32); #skip 1st 4 bytes (length, recordType dataType)
1790 0 my ($bit64String,$mantissa,$byteString,$byte);
1791 0 ▶ for(my $i=0; $i<($lengthLeft/8); $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $lengthLeft / 8) 0 0 0
1792 {
1793 0 $bit64String = substr($realData,($i*64),64);
1794 0 print($fh pack 'b8',$bit64String);
1795 0 $mantissa = substr($bit64String,8,56);
1796 0 ▶ for(my $j=0; $j<7; $j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 7) 0 0 0
1797 {
1798 0 $byteString = substr($mantissa,($j*8),8);
1799 0 $byte=pack 'b8',$byteString;
1800 0 print($fh $byte);
1801 }
1802 }
1803 }
1804 elsif ($recordDataType == ACSII_STRING) ## ascii string (null padded)
1805 {
1806 0 print($fh pack("a$lengthLeft",substr($data[0],4)));
1807 }
1808 elsif ($recordDataType == REAL_4) ## 4 byte real
1809 {
1810 0 die "4-byte reals are not supported $!";
1811 }
1812 }
1813 }
1814 else
1815 {
1816 0 print($fh $data[0]);
1817 0 $recordLength = length $data[0];
1818 0 $self -> {'BytesDone'} += $recordLength;
1819 }
1820 }
1821 else #if ($type ne 'RECORD')
1822 {
1823 317 my $numDataElements = 0;
1824 317 my $resolution = $self -> {'Resolution'};
1825 317 my $uUnits = $self -> {'UUnits'};
1826  
1827 317 my $scale = $arg{'-scale'};
1828 317 ▶ if (! defined $scale)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $scale) 317 0 317
1829 {
1830 317 $scale=1;
1831 }
1832 317 ▶ if ($scale <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($scale <= 0) 0 317 317
1833 {
1834 0 die "printGds2Record expects a positive scale -scale => $scale $!";
1835 }
1836  
1837 317 my $snap = $arg{'-snap'};
1838 317 ▶ if (! defined $snap) ## default is one resolution unit
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $snap) { } 317 0 317
1839 {
1840 317 $snap = 1;
1841 }
1842 else
1843 {
1844 0 $snap = int(($snap*$resolution)+$G_epsilon); ## i.e. 0.001 -> 1
1845 }
1846 317 ▶ if ($snap < 1)
Branch: 1 branch
BranchTrueFalseTotal
if ($snap < 1) 0 317 317
1847 {
1848 0 die "printGds2Record expects a snap >= 1/resolution -snap => $snap $!";
1849 }
1850  
1851 317 ▶ if ((defined $data[0])&&($data[0] ne ''))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data[0] and $data[0] ne "") 40 277 317
Condition66%2/3
defined $data[0] and $data[0] ne ""
!ll&&!rl&&r
277040
MC/DC50%1/2
defined $data[0] and $data[0] ne ""
defined $data[0] $data[0] ne ""
Truth table66%2/3
A and B
A= defined $data[0]B= $data[0] ne ""
ABresult
0X0
100
111
1852 {
1853 40 $data = $data[0];
1854 40 $numDataElements = @$data;
1855 40 ▶ if ($numDataElements) ## passed in anonymous array
Branch: 1 branch
BranchTrueFalseTotal
if ($numDataElements) { } 18 22 40
1856 {
1857 18 @data = @$data; ## deref
1858 }
1859 else
1860 {
1861 22 $numDataElements = @data;
1862 }
1863 }
1864  
1865 317 my $recordDataType = $RecordTypeData{$type};
1866  
1867 317 ▶ if (defined $dataString)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dataString) 255 62 317
1868 {
1869 255 $dataString=~s|^\s+||; ## clean-up
1870 255 $dataString=~s|\s+$||;
1871 255 ▶ $dataString=~s|\s+| |g if ($dataString !~ m|'|); ## don't compress spaces in strings...
Branch: 1 branch
BranchTrueFalseTotal
unless $dataString =~ /'/ 225 30 255
1872 255 $dataString=~s|'$||; #'# for strings
1873 255 $dataString=~s|^'||; #'# for strings
1874 255 ▶ if (($recordDataType == BIT_ARRAY)||($recordDataType == ACSII_STRING))
Branch: 1 branch
BranchTrueFalseTotal
if ($recordDataType == 1 or $recordDataType == 6) { } 57 198 255
Condition100%3/3
$recordDataType == 1 or $recordDataType == 6
l!l&&r!l&&!r
2730198
MC/DC100%2/2
$recordDataType == 1 or $recordDataType == 6
$recordDataType == 1 $recordDataType == 6
Truth table100%3/3
A or B
A= $recordDataType == 1B= $recordDataType == 6
ABresult
1X1
011
000
1875 {
1876 57 $data = $dataString;
1877 }
1878 else
1879 {
1880 198 $dataString=~s|\s*[\s,;:/\\]+\s*| |g; ## in case commas etc... (non-std) were added by hand
1881 198 @data = split(' ',$dataString);
1882 198 $numDataElements = @data;
1883 198 ▶ if ($recordDataType == INTEGER_4)
Branch: 1 branch
BranchTrueFalseTotal
if ($recordDataType == 3) 33 165 198
1884 {
1885 33 my @xyTmp=();
1886 33 ▶ for(my $i=0;$i<$numDataElements;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $numDataElements) 165 33 198
1887 {
1888 165 ▶ if ($data[$i]>=0) {push @xyTmp,int((($data[$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($data[$i] >= 0) { } 126 39 165
1889 39 else {push @xyTmp,int((($data[$i])*$resolution)-$G_epsilon);}
1890 }
1891 33 @data=@xyTmp;
1892 }
1893 }
1894 }
1895 317 my $byte;
1896 317 my $length = 0;
1897 317 ▶ if ($recordDataType == BIT_ARRAY)
Branch: 5 branches
BranchTrueFalseTotal
if ($recordDataType == 1) { } 27 290 317
elsif ($recordDataType == 2) { } 87 203 290
elsif ($recordDataType == 3) { } 43 160 203
elsif ($recordDataType == 5) { } 26 134 160
elsif ($recordDataType == 6) { } 40 94 134
1898 {
1899 27 $length = 2;
1900 }
1901 elsif ($recordDataType == INTEGER_2)
1902 {
1903 87 $length = 2 * $numDataElements;
1904 }
1905 elsif ($recordDataType == INTEGER_4)
1906 {
1907 43 $length = 4 * $numDataElements;
1908 }
1909 elsif ($recordDataType == REAL_8)
1910 {
1911 26 $length = 8 * $numDataElements;
1912 }
1913 elsif ($recordDataType == ACSII_STRING)
1914 {
1915 40 my $slen = length $data;
1916 40 $length = $slen + ($slen % 2); ## needs to be an even number
1917 }
1918 317 $self -> {'BytesDone'} += $length;
1919 317 ▶ if ($isLittleEndian)
Branch: 1 branch
BranchTrueFalseTotal
if ($isLittleEndian) { } 317 0 317
1920 {
1921 317 $recordLength = pack 'v',($length + 4);
1922 317 $recordLength = reverse $recordLength;
1923 }
1924 else
1925 {
1926 0 $recordLength = pack 'S',($length + 4);
1927 }
1928 317 print($fh $recordLength);
1929  
1930 317 my $recordType = pack 'C',$RecordTypeNumbers{$type};
1931 317 ▶ $recordType = reverse $recordType if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 317 0 317
1932 317 print($fh $recordType);
1933  
1934 317 my $dataType = pack 'C',$RecordTypeData{$type};
1935 317 ▶ $dataType = reverse $dataType if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 317 0 317
1936 317 print($fh $dataType);
1937  
1938 317 ▶ if ($recordDataType == BIT_ARRAY) ## bit array
Branch: 5 branches
BranchTrueFalseTotal
if ($recordDataType == 1) { } 27 290 317
elsif ($recordDataType == 2) { } 87 203 290
elsif ($recordDataType == 3) { } 43 160 203
elsif ($recordDataType == 5) { } 26 134 160
elsif ($recordDataType == 6) { } 40 94 134
1939 {
1940 27 my $bitLength = $length * 8;
1941 27 my $value = pack("B$bitLength",$data);
1942 27 print($fh $value);
1943 }
1944 elsif ($recordDataType == INTEGER_2) ## 2 byte signed integer
1945 {
1946 87 my $value;
1947 87 foreach my $num (@data)
1948 {
1949 287 $value = pack('s',$num);
1950 287 ▶ $value = reverse $value if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 287 0 287
1951 287 print($fh $value);
1952 }
1953 }
1954 elsif ($recordDataType == INTEGER_4) ## 4 byte signed integer
1955 {
1956 43 my $value;
1957 43 foreach my $num (@data)
1958 {
1959 211 ▶ $num = scaleNum($num,$scale) if ($scale != 1);
Branch: 1 branch
BranchTrueFalseTotal
if $scale != 1 0 211 211
1960 211 ▶ $num = snapNum($num,$snap) if ($snap != 1);
Branch: 1 branch
BranchTrueFalseTotal
if $snap != 1 0 211 211
1961 211 $value = pack('i',$num);
1962 211 ▶ $value = reverse $value if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 211 0 211
1963 211 print($fh $value);
1964 }
1965 }
1966 elsif ($recordDataType == REAL_8) ## 8 byte real
1967 {
1968 26 my ($real,$negative,$exponent,$value);
1969 26 foreach my $num (@data)
1970 {
1971 31 $real = $num;
1972 31 $negative = FALSE;
1973 31 ▶ if($num < 0.0)
Branch: 1 branch
BranchTrueFalseTotal
if ($num < 0) 0 31 31
1974 {
1975 0 $negative = TRUE;
1976 0 $real = 0 - $num;
1977 }
1978  
1979 31 $exponent = 0;
1980 31 ▶ while($real >= 1.0)
Branch: 1 branch
BranchTrueFalseTotal
if ($real >= 1) 15 31 46
1981 {
1982 15 $exponent++;
1983 15 $real = ($real / 16.0);
1984 }
1985  
1986 31 ▶ if ($real != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($real != 0) 31 0 31
1987 {
1988 31 ▶ while($real < 0.0625)
Branch: 1 branch
BranchTrueFalseTotal
if ($real < "0.0625") 45 31 76
1989 {
1990 45 --$exponent;
1991 45 $real = ($real * 16.0);
1992 }
1993 }
1994 31 ▶ if($negative) { $exponent += 192; }
Branch: 1 branch
BranchTrueFalseTotal
if ($negative) { } 0 31 31
1995 31 else { $exponent += 64; }
1996 31 $value = pack('C',$exponent);
1997 31 ▶ $value = reverse $value if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 31 0 31
1998 31 print($fh $value);
1999  
2000 31 ▶ for (my $i=1; $i<=7; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= 7) 217 31 248
2001 {
2002 217 ▶ if ($real>=0) {$byte = int(($real*256.0)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($real >= 0) { } 217 0 217
2003 0 else {$byte = int(($real*256.0)-$G_epsilon);}
2004 217 my $value = pack('C',$byte);
2005 217 ▶ $value = reverse $value if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 217 0 217
2006 217 print($fh $value);
2007 217 $real = $real * 256.0 - ($byte + 0.0);
2008 }
2009 }
2010 }
2011 elsif ($recordDataType == ACSII_STRING) ## ascii string (null padded)
2012 {
2013 40 print($fh pack("a$length",$data));
2014 }
2015 }
2016 317 $\=$saveEnd;
2017 }
2018 ################################################################################
2019  
2020 =head2 printRecord - prints a record just read
2021  
2022 usage:
2023 $gds2File -> printRecord(
2024 -data => $record
2025 );
2026  
2027 =cut
2028  
2029 sub printRecord
2030 {
2031 0 ▶ my ($self,%arg) = @_;
Subroutine printRecord: not called CC=3 SCAR=24.8
Pod documented
2032 0 my $record = $arg{'-data'};
2033 0 ▶ if (! defined $record)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $record) 0 0 0
2034 {
2035 0 die "printGds2Record expects a data record. Missing -data => \$record $!";
2036 }
2037 0 my $type = $arg{'-type'};
2038 0 ▶ if (defined $type)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type) 0 0 0
2039 {
2040 0 die "printRecord does not take -type. Perhaps you meant to use printGds2Record? $!";
2041 }
2042 0 $self -> printGds2Record(-type=>'record',-data=>$record);
2043 }
2044 ################################################################################
2045  
2046 ################################################################################
2047  
2048 =head1 Low Level Generic Read Methods
2049  
2050 =cut
2051  
2052 ################################################################################
2053  
2054 =head2 readGds2Record - reads record header and data section
2055  
2056 usage:
2057 while ($gds2File -> readGds2Record)
2058 {
2059 if ($gds2File -> returnRecordTypeString eq 'LAYER')
2060 {
2061 $layersFound[$gds2File -> layer] = 1;
2062 }
2063 }
2064  
2065 =cut
2066  
2067 sub readGds2Record
2068 {
2069 172 ▶ my $self = shift;
Subroutine readGds2Record: called CC=2 SCAR=6.9
Pod documented
2070 172 ▶ return "" if ($self -> {'EOLIB'});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"EOLIB"} 2 170 172
2071 170 $self -> readGds2RecordHeader();
2072 170 $self -> readGds2RecordData();
2073 170 $self -> {'INHEADER'} = FALSE;
2074 170 $self -> {'INDATA'} = TRUE; ## actually just done w/ it
2075 170 $self -> {'Record'};
2076 }
2077 ################################################################################
2078  
2079 =head2 readGds2RecordHeader - only reads gds2 record header section (2 bytes)
2080  
2081 slightly faster if you just want a certain thing...
2082 usage:
2083 while ($gds2File -> readGds2RecordHeader)
2084 {
2085 if ($gds2File -> returnRecordTypeString eq 'LAYER')
2086 {
2087 $gds2File -> readGds2RecordData;
2088 $layersFound[$gds2File -> returnLayer] = 1;
2089 }
2090 }
2091  
2092 =cut
2093  
2094 sub readGds2RecordHeader
2095 {
2096 256 ▶ my $self = shift;
Subroutine readGds2RecordHeader: called CC=24 SCAR=31.8
Pod documented
2097  
2098 256 ▶ $self -> skipGds2RecordData() if ((! $self -> {'INDATA'}) && ($self -> {'INHEADER'} != UNKNOWN)) ; # need to read record data before header unless 1st time
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"INDATA"} and $self->{"INHEADER"} != -1 24 232 256
Condition100%3/3
not $self->{"INDATA"} and $self->{"INHEADER"} != -1
!ll&&!rl&&r
229324
MC/DC100%2/2
not $self->{"INDATA"} and $self->{"INHEADER"} != -1
not $self->{"INDATA"} $self->{"INHEADER"} != -1
Truth table100%3/3
not(A) and B
A= not $self->{"INDATA"}B= $self->{"INHEADER"} != -1
ABresult
0X0
100
111
2099 256 $self -> {'Record'} = '';
2100 256 $self -> {'RecordType'} = UNKNOWN;
2101 256 $self -> {'INHEADER'} = TRUE; ## will actually be just just done with it by the time we can check this ...
2102 256 $self -> {'INDATA'} = FALSE;
2103 256 ▶ return '' if ($self -> {'EOLIB'}); ## no sense reading null padding..
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"EOLIB"} 1 255 256
2104  
2105 255 my $buffer = '';
2106 255 ▶ return 0 if (! read($self -> {'FileHandle'},$buffer,4));
Branch: 1 branch
BranchTrueFalseTotal
unless read $self->{"FileHandle"}, $buffer, 4 0 255 255
2107 255 my $data;
2108 #if (read($self -> {'FileHandle'},$data,2)) ### length
2109 255 $data = substr($buffer,0,2);
2110 {
2111 255 ▶ $data = reverse $data if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 255 0 255
2112 255 $self -> {'Record'} = $data;
2113 255 $self -> {'Length'} = unpack 'S',$data;
2114 255 $self -> {'BytesDone'} += $self -> {'Length'};
2115 }
2116  
2117 #if (read($self -> {'FileHandle'},$data,1)) ## record type
2118 255 $data = substr($buffer,2,1);
2119 {
2120 255 ▶ $data = reverse $data if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 255 0 255
2121 255 $self -> {'Record'} .= $data;
2122 255 $self -> {'RecordType'} = unpack 'C',$data;
2123 255 ▶ $self -> {'EOLIB'} = TRUE if (($self -> {'RecordType'}) == ENDLIB);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 4 3 252 255
2124  
2125 255 ▶ if ($self -> {'UsingPrettyPrint'})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"UsingPrettyPrint"}) 252 3 255
2126 {
2127 252 ▶ putStrSpace('') if (($self -> {'RecordType'}) == ENDSTR);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 7 9 243 252
2128 252 ▶ putStrSpace(' ') if (($self -> {'RecordType'}) == BGNSTR);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 5 9 243 252
2129  
2130 putElmSpace(' ') if ((($self -> {'RecordType'}) == TEXT) || (($self -> {'RecordType'}) == PATH) ||
2131 (($self -> {'RecordType'}) == BOUNDARY) || (($self -> {'RecordType'}) == SREF) ||
2132 252 ▶ (($self -> {'RecordType'}) == AREF));
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 9 222 231
Condition91%11/12
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
l!l&&r!l&&!r
300222
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10
l!l&&r!l&&!r
219222
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8
l!l&&r!l&&!r
129231
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9
l!l&&r!l&&!r
93240
MC/DC80%4/5
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
$self->{"RecordType"} == 12 $self->{"RecordType"} == 9 $self->{"RecordType"} == 8 $self->{"RecordType"} == 10 $self->{"RecordType"} == 11
Truth table83%5/6
A or B or C or D or E
A= $self->{"RecordType"} == 12B= $self->{"RecordType"} == 9C= $self->{"RecordType"} == 8D= $self->{"RecordType"} == 10E= $self->{"RecordType"} == 11
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
2133 252 ▶ if (($self -> {'RecordType'}) == ENDEL)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"RecordType"} == 17) 30 222 252
2134 {
2135 30 putElmSpace('');
2136 30 $self -> {'InTxt'} = FALSE;
2137 30 $self -> {'InBoundary'} = FALSE;
2138 }
2139 252 ▶ $self -> {'InTxt'} = TRUE if (($self -> {'RecordType'}) == TEXT);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 12 9 243 252
2140 252 ▶ $self -> {'InBoundary'} = TRUE if (($self -> {'RecordType'}) == BOUNDARY);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 8 9 243 252
2141 252 ▶ if ((($self -> {'RecordType'}) == LIBNAME) || (($self -> {'RecordType'}) == STRNAME))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"RecordType"} == 2 or $self->{"RecordType"} == 6) 12 240 252
Condition100%3/3
$self->{"RecordType"} == 2 or $self->{"RecordType"} == 6
l!l&&r!l&&!r
39240
MC/DC100%2/2
$self->{"RecordType"} == 2 or $self->{"RecordType"} == 6
$self->{"RecordType"} == 2 $self->{"RecordType"} == 6
Truth table100%3/3
A or B
A= $self->{"RecordType"} == 2B= $self->{"RecordType"} == 6
ABresult
1X1
011
000
2142  
2143 {
2144 12 $self -> {'DateFld'} = 0;
2145 }
2146 252 ▶ $self -> {'DateFld'} = 1 if ((($self -> {'RecordType'}) == BGNLIB) || (($self -> {'RecordType'}) == BGNSTR));
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} == 1 or $self->{"RecordType"} == 5 12 240 252
Condition100%3/3
$self->{"RecordType"} == 1 or $self->{"RecordType"} == 5
l!l&&r!l&&!r
39240
MC/DC100%2/2
$self->{"RecordType"} == 1 or $self->{"RecordType"} == 5
$self->{"RecordType"} == 1 $self->{"RecordType"} == 5
Truth table100%3/3
A or B
A= $self->{"RecordType"} == 1B= $self->{"RecordType"} == 5
ABresult
1X1
011
000
2147 }
2148 }
2149  
2150 #if (read($self -> {'FileHandle'},$data,1)) ## data type
2151 255 $data = substr($buffer,3,1);
2152 {
2153 255 ▶ $data = reverse $data if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 255 0 255
2154 255 $self -> {'Record'} .= $data;
2155 255 $self -> {'DataType'} = unpack 'C',$data;
2156 }
2157 #printf("P:Length=%-5d RecordType=%-2d DataType=%-2d\n",$self -> {'Length'},$self -> {'RecordType'},$self -> {'DataType'}); ##DEBUG
2158 255 return 1;
2159 }
2160 ################################################################################
2161  
2162 =head2 readGds2RecordData - only reads record data section
2163  
2164 slightly faster if you just want a certain thing...
2165 usage:
2166 while ($gds2File -> readGds2RecordHeader)
2167 {
2168 if ($gds2File -> returnRecordTypeString eq 'LAYER')
2169 {
2170 $gds2File -> readGds2RecordData;
2171 $layersFound[$gds2File -> returnLayer] = 1;
2172 }
2173 }
2174  
2175 =cut
2176  
2177 sub readGds2RecordData
2178 {
2179 255 ▶ my $self = shift;
Subroutine readGds2RecordData: called CC=22 SCAR=31.1
Pod documented
2180  
2181 255 ▶ $self -> readGds2RecordHeader() if ($self -> {'INHEADER'} != TRUE); # program did not read HEADER - needs to...
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"INHEADER"} != 1 0 255 255
2182 255 ▶ return $self -> {'Record'} if ($self -> {'DataType'} == NO_REC_DATA); # no sense going on...
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"DataType"} == 0 72 183 255
2183 183 $self -> {'INHEADER'} = FALSE; # not in HEADER - need to read HEADER next time around...
2184 183 $self -> {'INDATA'} = TRUE; # rather in DATA - actually will be at the end of data by the time we test this...
2185 183 $self -> {'RecordData'} = '';
2186 183 $self -> {'RecordData'} = ();
2187 183 $self -> {'CurrentDataList'} = '';
2188 183 my $bytesLeft = $self -> {'Length'} - 4; ## 4 should have been just read by readGds2RecordHeader
2189 183 my $data;
2190 183 ▶ if ($self -> {'DataType'} == BIT_ARRAY) ## bit array
Branch: 6 branches
BranchTrueFalseTotal
if ($self->{'DataType'} == 1) { } 27 156 183
elsif ($self->{'DataType'} == 2) { } 69 87 156
elsif ($self->{'DataType'} == 3) { } 33 54 87
elsif ($self->{'DataType'} == 4) { } 0 54 54
elsif ($self->{'DataType'} == 5) { } 24 30 54
elsif ($self->{'DataType'} == 6) { } 30 0 30
2191 {
2192 27 $self -> {'DataIndex'}=0;
2193 27 read($self -> {'FileHandle'},$data,$bytesLeft);
2194 27 ▶ $data = reverse $data if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 27 0 27
2195 27 my $bitsLeft = $bytesLeft * 8;
2196 27 $self -> {'Record'} .= $data;
2197 27 $self -> {'RecordData'}[0] = unpack "B$bitsLeft",$data;
2198 27 $self -> {'CurrentDataList'} = ($self -> {'RecordData'}[0]);
2199 }
2200 elsif ($self -> {'DataType'} == INTEGER_2) ## 2 byte signed integer
2201 {
2202 69 my $tmpListString = '';
2203 69 my $i = 0;
2204 69 ▶ while ($bytesLeft)
Branch: 1 branch
BranchTrueFalseTotal
if ($bytesLeft) 201 69 270
2205 {
2206 201 read($self -> {'FileHandle'},$data,2);
2207 201 ▶ $data = reverse $data if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 201 0 201
2208 201 $self -> {'Record'} .= $data;
2209 201 $self -> {'RecordData'}[$i] = unpack 's',$data;
2210 201 $tmpListString .= ',';
2211 201 $tmpListString .= $self -> {'RecordData'}[$i];
2212 201 $i++;
2213 201 $bytesLeft -= 2;
2214 }
2215 69 $self -> {'DataIndex'} = $i - 1;
2216 69 $self -> {'CurrentDataList'} = $tmpListString;
2217 }
2218 elsif ($self -> {'DataType'} == INTEGER_4) ## 4 byte signed integer
2219 {
2220 33 my $tmpListString = '';
2221 33 my $i = 0;
2222 33 my $buffer = '';
2223 33 read($self -> {'FileHandle'},$buffer,$bytesLeft); ## try fewer reads
2224 33 ▶ for(my $start=0; $start < $bytesLeft; $start += 4)
Branch: 1 branch
BranchTrueFalseTotal
if ($start < $bytesLeft) 165 33 198
2225 {
2226 165 $data = substr($buffer,$start,4);
2227 165 ▶ $data = reverse $data if ($isLittleEndian);
Branch: 1 branch
BranchTrueFalseTotal
if $isLittleEndian 165 0 165
2228 165 $self -> {'Record'} .= $data;
2229 165 $self -> {'RecordData'}[$i] = unpack 'i',$data;
2230 165 $tmpListString .= ',';
2231 165 $tmpListString .= $self -> {'RecordData'}[$i];
2232 165 $i++;
2233 }
2234 33 $self -> {'DataIndex'} = $i - 1;
2235 33 $self -> {'CurrentDataList'} = $tmpListString;
2236 }
2237 elsif ($self -> {'DataType'} == REAL_4) ## 4 byte real
2238 {
2239 0 die "4-byte reals are not supported $!";
2240 }
2241 elsif ($self -> {'DataType'} == REAL_8) ## 8 byte real - UNITS, MAG, ANGLE
2242 {
2243 24 my $resolution = $self -> {'Resolution'};
2244 24 my $tmpListString = '';
2245 24 my $i = 0;
2246 24 my ($negative,$exponent,$mantdata,$byteString,$byte,$mantissa,$real);
2247 24 ▶ while ($bytesLeft)
Branch: 1 branch
BranchTrueFalseTotal
if ($bytesLeft) 27 24 51
2248 {
2249 27 read($self -> {'FileHandle'},$data,1); ## sign bit and 7 exponent bits
2250 27 $self -> {'Record'} .= $data;
2251 27 $negative = unpack 'B',$data; ## sign bit
2252 27 $exponent = unpack 'C',$data;
2253 27 ▶ if ($negative)
Branch: 1 branch
BranchTrueFalseTotal
if ($negative) { } 0 27 27
2254 {
2255 0 $exponent -= 192; ## 128 + 64
2256 }
2257 else
2258 {
2259 27 $exponent -= 64;
2260 }
2261 27 read($self -> {'FileHandle'},$data,7); ## mantissa bits
2262 27 $mantdata = unpack 'b*',$data;
2263 27 $self -> {'Record'} .= $data;
2264 27 $mantissa = 0.0;
2265 27 ▶ for(my $j=0; $j<7; $j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 7) 189 27 216
2266 {
2267 189 $byteString = substr($mantdata,0,8,'');
2268 189 $byte = pack 'b*',$byteString;
2269 189 $byte = unpack 'C',$byte;
2270 189 $mantissa += $byte / (256.0**($j+1));
2271 }
2272 27 $real = $mantissa * (16**$exponent);
2273 27 ▶ $real = (0 - $real) if ($negative);
Branch: 1 branch
BranchTrueFalseTotal
if $negative 0 27 27
2274 27 ▶ if ($RecordTypeStrings[$self -> {'RecordType'}] eq 'UNITS')
Branch: 1 branch
BranchTrueFalseTotal
if ($RecordTypeStrings[$self->{'RecordType'}] eq 'UNITS') { } 6 21 27
2275 {
2276 6 ▶ if ($self -> {'UUnits'} == -1.0)
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'UUnits'} == -1.0) { } 3 3 6
elsif ($self->{'DBUnits'} == -1.0) { } 3 0 3
2277 {
2278 3 $self -> {'UUnits'} = $real;
2279 }
2280 elsif ($self -> {'DBUnits'} == -1.0)
2281 {
2282 3 $self -> {'DBUnits'} = $real;
2283 }
2284 }
2285 else
2286 {
2287 ### this works because UUnits and DBUnits are 1st reals in GDS2 file
2288 21 ▶ $real = int(($real+($self -> {'UUnits'}/$resolution))/$self -> {'UUnits'})*$self -> {'UUnits'} if ($self -> {'UUnits'} != 0); ## "rounds" off
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"UUnits"} != 0 21 0 21
2289 }
2290 27 $self -> {'RecordData'}[$i] = $real;
2291 27 $tmpListString .= ',';
2292 27 $tmpListString .= $self -> {'RecordData'}[$i];
2293 27 $i++;
2294 27 $bytesLeft -= 8;
2295 }
2296 24 $self -> {'DataIndex'} = $i - 1;
2297 24 $self -> {'CurrentDataList'} = $tmpListString;
2298 }
2299 elsif ($self -> {'DataType'} == ACSII_STRING) ## ascii string (null padded)
2300 {
2301 30 $self -> {'DataIndex'} = 0;
2302 30 read($self -> {'FileHandle'},$data,$bytesLeft);
2303 30 $self -> {'Record'} .= $data;
2304 30 $self -> {'RecordData'}[0] = unpack "a$bytesLeft",$data;
2305 30 $self -> {'RecordData'}[0] =~ s|\0||g; ## take off ending nulls
2306 30 $self -> {'CurrentDataList'} = ($self -> {'RecordData'}[0]);
2307 }
2308 183 return 1;
2309 }
2310 ################################################################################
2311  
2312 =head1 Low Level Generic Evaluation Methods
2313  
2314 =cut
2315  
2316 ################################################################################
2317  
2318 =head2 returnRecordType - returns current (read) record type as integer
2319  
2320 usage:
2321 if ($gds2File -> returnRecordType == 6)
2322 {
2323 print "found STRNAME";
2324 }
2325  
2326 =cut
2327  
2328 sub returnRecordType
2329 {
2330 0 ▶ my $self = shift;
Subroutine returnRecordType: not called CC=1 SCAR=6.9
Pod documented
2331 0 $self -> {'RecordType'};
2332 }
2333 ################################################################################
2334  
2335 =head2 returnRecordTypeString - returns current (read) record type as string
2336  
2337 usage:
2338 if ($gds2File -> returnRecordTypeString eq 'LAYER')
2339 {
2340 code goes here...
2341 }
2342  
2343 =cut
2344  
2345 sub returnRecordTypeString
2346 {
2347 0 ▶ my $self = shift;
Subroutine returnRecordTypeString: not called CC=1 SCAR=6.9
Pod documented
2348 0 $RecordTypeStrings[($self -> {'RecordType'})];
2349 }
2350 ################################################################################
2351  
2352 =head2 returnRecordAsString - returns current (read) record as a string
2353  
2354 usage:
2355 while ($gds2File -> readGds2Record)
2356 {
2357 print $gds2File -> returnRecordAsString(-compact=>1);
2358 }
2359  
2360 =cut
2361  
2362 sub returnRecordAsString()
2363 {
2364 255 ▶ my($self,%arg) = @_;
Subroutine returnRecordAsString: called CC=62 SCAR=41.5
Pod documented
2365 255 my $compact = $arg{'-compact'};
2366 255 ▶ $compact = FALSE if (! defined $compact);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $compact 170 85 255
2367 255 my $string = '';
2368 255 $self -> {'UsingPrettyPrint'} = TRUE;
2369 255 my $inText = $self -> {'InTxt'};
2370 255 my $inBoundary = $self -> {'InBoundary'};
2371 255 my $dateFld = $self -> {'DateFld'};
2372 255 ▶ if (! $compact)
Branch: 1 branch
BranchTrueFalseTotal
unless ($compact) 170 85 255
2373 {
2374 170 ▶ $string .= getStrSpace() if ($self -> {'RecordType'} != BGNSTR);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} != 5 164 6 170
2375 $string .= getElmSpace() if (!(
2376 ($self -> {'RecordType'} == BOUNDARY) ||
2377 ($self -> {'RecordType'} == PATH) ||
2378 ($self -> {'RecordType'} == TEXT) ||
2379 ($self -> {'RecordType'} == SREF) ||
2380 170 ▶ ($self -> {'RecordType'} == AREF)
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"RecordType"} == 8 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 12 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 150 20 170
Condition91%11/12
$self->{"RecordType"} == 8 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 12 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
l!l&&r!l&&!r
200150
$self->{"RecordType"} == 8 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 12 or $self->{"RecordType"} == 10
l!l&&r!l&&!r
146150
$self->{"RecordType"} == 8 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 12
l!l&&r!l&&!r
86156
$self->{"RecordType"} == 8 or $self->{"RecordType"} == 9
l!l&&r!l&&!r
62162
MC/DC80%4/5
$self->{"RecordType"} == 8 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 12 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
$self->{"RecordType"} == 8 $self->{"RecordType"} == 9 $self->{"RecordType"} == 12 $self->{"RecordType"} == 10 $self->{"RecordType"} == 11
Truth table83%5/6
A or B or C or D or E
A= $self->{"RecordType"} == 8B= $self->{"RecordType"} == 9C= $self->{"RecordType"} == 12D= $self->{"RecordType"} == 10E= $self->{"RecordType"} == 11
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
2381 ));
2382 }
2383 255 my $recordType = $RecordTypeStrings[$self -> {'RecordType'}];
2384 255 ▶ if ($compact)
Branch: 1 branch
BranchTrueFalseTotal
if ($compact) { } 85 170 255
2385 {
2386 85 $string .= $CompactRecordTypeStrings[$self -> {'RecordType'}];
2387 }
2388 else
2389 {
2390 170 $string .= $recordType;
2391 }
2392 255 my $i = 0;
2393 255 ▶ while ($i <= $self -> {'DataIndex'})
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $self->{"DataIndex"}) 716 255 971
2394 {
2395 716 ▶ if ($self -> {'DataType'} == BIT_ARRAY)
Branch: 5 branches
BranchTrueFalseTotal
if ($self->{'DataType'} == 1) { } 27 689 716
elsif ($self->{'DataType'} == 2) { } 201 488 689
elsif ($self->{'DataType'} == 3) { } 165 323 488
elsif ($self->{'DataType'} == 5) { } 27 296 323
elsif ($self->{'DataType'} == 6) { } 30 266 296
2396 {
2397 27 my $bitString = $self -> {'RecordData'}[$i];
2398 27 ▶ if ($isLittleEndian)
Branch: 1 branch
BranchTrueFalseTotal
if ($isLittleEndian) 27 0 27
2399 {
2400 27 $bitString =~ m|(........)(........)|;
2401 27 $bitString = "$2$1";
2402 }
2403 27 ▶ if ($compact)
Branch: 1 branch
BranchTrueFalseTotal
if ($compact) { } 9 18 27
2404 {
2405 9 ▶ $string .= ' fx' if($bitString =~ m/^1/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /^1/ 2 7 9
2406 9 ▶ if ($inText && ($self -> {'RecordType'} != STRANS))
Branch: 1 branch
BranchTrueFalseTotal
if ($inText and $self->{"RecordType"} != 26) 3 6 9
Condition100%3/3
$inText and $self->{"RecordType"} != 26
!ll&&!rl&&r
333
MC/DC100%2/2
$inText and $self->{"RecordType"} != 26
$inText $self->{"RecordType"} != 26
Truth table100%3/3
A and B
A= $inTextB= $self->{"RecordType"} != 26
ABresult
0X0
100
111
2407 {
2408 3 $string .= ' f';
2409 3 ▶ $string .= '0' if ($bitString =~ m/00....$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /00....$/ 3 0 3
2410 3 ▶ $string .= '1' if ($bitString =~ m/01....$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /01....$/ 0 3 3
2411 3 ▶ $string .= '2' if ($bitString =~ m/10....$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /10....$/ 0 3 3
2412 3 ▶ $string .= '3' if ($bitString =~ m/11....$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /11....$/ 0 3 3
2413 3 ▶ $string .= ' t' if ($bitString =~ m/00..$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /00..$/ 0 3 3
2414 3 ▶ $string .= ' m' if ($bitString =~ m/01..$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /01..$/ 0 3 3
2415 3 ▶ $string .= ' b' if ($bitString =~ m/10..$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /10..$/ 3 0 3
2416 3 ▶ $string .= 'l' if ($bitString =~ m/00$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /00$/ 2 1 3
2417 3 ▶ $string .= 'c' if ($bitString =~ m/01$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /01$/ 0 3 3
2418 3 ▶ $string .= 'r' if ($bitString =~ m/10$/);
Branch: 1 branch
BranchTrueFalseTotal
if $bitString =~ /10$/ 1 2 3
2419 }
2420 }
2421 else
2422 {
2423 18 $string .= ' '.$bitString;
2424 }
2425 }
2426 elsif ($self -> {'DataType'} == INTEGER_2)
2427 {
2428 201 ▶ if ($compact)
Branch: 1 branch
BranchTrueFalseTotal
if ($compact) { } 67 134 201
2429 {
2430 67 ▶ if ($dateFld)
Branch: 1 branch
BranchTrueFalseTotal
if ($dateFld) { } 48 19 67
2431 {
2432 48 my $num = $self -> {'RecordData'}[$i];
2433 48 ▶ if ($dateFld =~ m/^[17]$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($dateFld =~ /^[17]$/) 8 40 48
2434 {
2435 8 ▶ if ($dateFld eq '1')
Branch: 2 branches
BranchTrueFalseTotal
if ($dateFld eq '1') { } 4 4 8
elsif ($dateFld eq '7') { } 4 0 4
2436 {
2437 4 ▶ if ($recordType eq 'BGNLIB')
Branch: 1 branch
BranchTrueFalseTotal
if ($recordType eq 'BGNLIB') { } 1 3 4
2438 {
2439 1 $string .= 'm=';
2440 }
2441 else
2442 {
2443 3 $string .= 'c=';
2444 }
2445 }
2446 elsif ($dateFld eq '7')
2447 {
2448 4 ▶ if ($recordType eq 'BGNLIB')
Branch: 1 branch
BranchTrueFalseTotal
if ($recordType eq 'BGNLIB') { } 1 3 4
2449 {
2450 1 $string .= ' a=';
2451 }
2452 else
2453 {
2454 3 $string .= ' m=';
2455 }
2456 }
2457 8 ▶ $num += 1900 if ($num < 1900);
Branch: 1 branch
BranchTrueFalseTotal
if $num < 1900 8 0 8
2458 }
2459 48 $num = sprintf("%02d",$num);
2460 48 ▶ $string .= '-' if ($dateFld =~ m/^[2389]/);
Branch: 1 branch
BranchTrueFalseTotal
if $dateFld =~ /^[2389]/ 16 32 48
2461 48 ▶ $string .= ':' if ($dateFld =~ m/^[56]/);
Branch: 1 branch
BranchTrueFalseTotal
if $dateFld =~ /^[56]/ 8 40 48
2462 48 ▶ $string .= ':' if ($dateFld =~ m/^1[12]/);
Branch: 1 branch
BranchTrueFalseTotal
if $dateFld =~ /^1[12]/ 8 40 48
2463 48 ▶ $string .= ' ' if (($dateFld eq '4') || ($dateFld eq '10'));
Branch: 1 branch
BranchTrueFalseTotal
if $dateFld eq 4 or $dateFld eq 10 8 40 48
Condition100%3/3
$dateFld eq 4 or $dateFld eq 10
l!l&&r!l&&!r
4440
MC/DC100%2/2
$dateFld eq 4 or $dateFld eq 10
$dateFld eq 4 $dateFld eq 10
Truth table100%3/3
A or B
A= $dateFld eq 4B= $dateFld eq 10
ABresult
1X1
011
000
2464 48 $string .= $num;
2465 }
2466 else
2467 {
2468 19 ▶ $string .= ' ' unless ($string =~ m/ (a|m|pt|dt|tt)$/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $string =~ / (a|m|pt|dt|tt)$/i 8 11 19
2469 19 $string .= $self -> {'RecordData'}[$i];
2470 }
2471 }
2472 else
2473 {
2474 134 $string .= ' ';
2475 134 $string .= $self -> {'RecordData'}[$i];
2476 }
2477 201 ▶ if ($recordType eq 'UNITS')
Branch: 1 branch
BranchTrueFalseTotal
if ($recordType eq "UNITS") 0 201 201
2478 {
2479 0 $string =~ s|(\d)\.e|$1e|; ## perl on Cygwin prints "1.e-9" others "1e-9"
2480 0 $string =~ s|(\d)e\-0+|$1e-|; ## different perls print 1e-9 1e-09 1e-009 etc... standardize to 1e-9
2481 }
2482 }
2483 elsif ($self -> {'DataType'} == INTEGER_4)
2484 {
2485 165 ▶ if ($compact)
Branch: 1 branch
BranchTrueFalseTotal
if ($compact) { } 55 110 165
2486 {
2487 55 ▶ $string .= ' ' if ($i);
Branch: 1 branch
BranchTrueFalseTotal
if $i 44 11 55
2488 }
2489 else
2490 {
2491 110 $string .= ' ';
2492 }
2493 165 $string .= cleanFloatNum($self -> {'RecordData'}[$i]*($self -> {'UUnits'}));
2494 165 ▶ if ($compact && $i && ($i == $#{$self -> {'RecordData'}}))
Branch: 1 branch
BranchTrueFalseTotal
if ($compact and $i and $i == $#{$$self{"RecordData"};}) 10 155 165
Condition100%6/6
$compact and $i and $i == $#{$$self{"RecordData"};}
!ll&&!rl&&r
1213410
$compact and $i
!ll&&!rl&&r
1101144
MC/DC100%3/3
$compact and $i and $i == $#{$$self{"RecordData"};}
$compact $i $i == $#{$$self{"RecordData"};}
Truth table100%4/4
A and B and C
A= $compactB= $iC= $i == $#{$$self{"RecordData"};}
ABCresult
0XX0
10X0
1100
1111
2495 {
2496 10 ▶ $string =~ s/ +[\d\.\-]+ +[\d\.\-]+$// if ($inBoundary); #remove last point
Branch: 1 branch
BranchTrueFalseTotal
if $inBoundary 3 7 10
2497 10 $string .= ')';
2498 }
2499 }
2500 elsif ($self -> {'DataType'} == REAL_8)
2501 {
2502 27 ▶ if ($compact)
Branch: 1 branch
BranchTrueFalseTotal
if ($compact) { } 9 18 27
2503 {
2504 9 ▶ $string .= ' ' unless ($string =~ m/ (a|m|pt|dt|tt)$/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $string =~ / (a|m|pt|dt|tt)$/i 2 7 9
2505 }
2506 else
2507 {
2508 18 $string .= ' ';
2509 }
2510 27 my $num = $self -> {'RecordData'}[$i];
2511 27 ▶ if ($num =~ m/e/i)
Branch: 1 branch
BranchTrueFalseTotal
if ($num =~ /e/i) { } 3 24 27
2512 {
2513 3 $num = cleanExpNum($num);
2514 }
2515 else
2516 {
2517 24 $num = cleanFloatNum($num);
2518 }
2519 27 $string .= $num;
2520 27 ▶ if ($recordType eq 'UNITS')
Branch: 1 branch
BranchTrueFalseTotal
if ($recordType eq "UNITS") 6 21 27
2521 {
2522 6 $string =~ s|(\d)\.e|$1e|; ## perl on Cygwin prints "1.e-9" others "1e-9"
2523 6 $string =~ s|(\d)e\-0+|$1e-|; ## different perls print 1e-9 1e-09 1e-009 etc... standardize to shorter 1e-9
2524 }
2525 }
2526 elsif ($self -> {'DataType'} == ACSII_STRING)
2527 {
2528 30 ▶ $string .= ' ' if (! $compact);
Branch: 1 branch
BranchTrueFalseTotal
unless $compact 20 10 30
2529 30 $string .= " '".$self -> {'RecordData'}[$i]."'";
2530 }
2531 716 $i++;
2532 716 ▶ $dateFld++ if ($dateFld);
Branch: 1 branch
BranchTrueFalseTotal
if $dateFld 144 572 716
2533 }
2534  
2535 255 ▶ if ($compact)
Branch: 1 branch
BranchTrueFalseTotal
if ($compact) 85 170 255
2536 {
2537 85 $G_gdtString .= $string;
2538 85 ▶ if (($G_gdtString =~ m/}$/ || $G_gdtString =~ m/^(gds2|lib|m).*\d$/) || ($G_gdtString =~ m/^cell.*'$/))
Branch: 1 branch
BranchTrueFalseTotal
if ($G_gdtString =~ /}$/ or $G_gdtString =~ /^(gds2|lib|m).*\d$/ or $G_gdtString =~ /^cell.*'$/) { } 20 65 85
Condition100%6/6
$G_gdtString =~ /}$/ or $G_gdtString =~ /^(gds2|lib|m).*\d$/ or $G_gdtString =~ /^cell.*'$/
l!l&&r!l&&!r
17365
$G_gdtString =~ /}$/ or $G_gdtString =~ /^(gds2|lib|m).*\d$/
l!l&&r!l&&!r
14368
MC/DC100%3/3
$G_gdtString =~ /}$/ or $G_gdtString =~ /^(gds2|lib|m).*\d$/ or $G_gdtString =~ /^cell.*'$/
$G_gdtString =~ /}$/ $G_gdtString =~ /^(gds2|lib|m).*\d$/ $G_gdtString =~ /^cell.*'$/
Truth table100%4/4
A or B or C
A= $G_gdtString =~ /}$/B= $G_gdtString =~ /^(gds2|lib|m).*\d$/C= $G_gdtString =~ /^cell.*'$/
ABCresult
1XX1
01X1
0011
0000
2539 {
2540 20 $string = "$G_gdtString\n";
2541 20 $string =~ s/{ /{/; #a little more compact
2542 20 $string =~ s/(dt0|pt0|tt0|m1|w0|f0) //g; #these are all default in true GDT format
2543 20 $G_gdtString = "";
2544 }
2545 else
2546 {
2547 65 $string = "";
2548 }
2549 }
2550  
2551 255 $string;
2552 }
2553 ################################################################################
2554  
2555 =head2 returnXyAsArray - returns current (read) XY record as an array
2556  
2557 usage:
2558 $gds2File -> returnXyAsArray(
2559 -asInteger => 0|1 ## (optional) default is true. Return integer
2560 ## array or if false return array of reals.
2561 -withClosure => 0|1 ## (optional) default is true. Whether to
2562 ##return a rectangle with 5 or 4 points.
2563 );
2564  
2565 example:
2566 while ($gds2File -> readGds2Record)
2567 {
2568 my @xy = $gds2File -> returnXyAsArray if ($gds2File -> isXy);
2569 }
2570  
2571 =cut
2572  
2573 sub returnXyAsArray()
2574 {
2575 0 ▶ my($self,%arg) = @_;
Subroutine returnXyAsArray: not called CC=8 SCAR=42.8
Pod documented
2576 0 my $asInteger = $arg{'-asInteger'};
2577 0 ▶ $asInteger = TRUE unless (defined $asInteger);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $asInteger 0 0 0
2578 0 my $withClosure = $arg{'-withClosure'};
2579 0 ▶ $withClosure = TRUE unless (defined $withClosure);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $withClosure 0 0 0
2580 0 my @xys=();
2581 0 ▶ if ($self -> isXy)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isXy) 0 0 0
2582 {
2583 0 my $i = 0;
2584 0 my $stopPoint = $self -> {'DataIndex'};
2585 0 ▶ if ($withClosure)
Branch: 1 branch
BranchTrueFalseTotal
if ($withClosure) { } 0 0 0
2586 {
2587 0 ▶ return @{$self -> {'RecordData'}} if ($asInteger);
Branch: 1 branch
BranchTrueFalseTotal
if $asInteger 0 0 0
2588 }
2589 else
2590 {
2591 0 $stopPoint -= 2;
2592 }
2593 0 my $num=0;
2594 0 ▶ while ($i <= $stopPoint)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $stopPoint) 0 0 0
2595 {
2596 0 ▶ if ($asInteger)
Branch: 1 branch
BranchTrueFalseTotal
if ($asInteger) { } 0 0 0
2597 {
2598 0 $num = $self -> {'RecordData'}[$i];
2599 }
2600 else
2601 {
2602 0 $num = cleanFloatNum($self -> {'RecordData'}[$i]*($self -> {'UUnits'}));
2603 }
2604 0 push @xys,$num;
2605 0 $i++;
2606 }
2607 }
2608 0 @xys;
2609 }
2610 ################################################################################
2611  
2612  
2613 =head2 returnRecordAsPerl - returns current (read) record as a perl command to facilitate the creation of parameterized gds2 data with perl.
2614  
2615 usage:
2616 #!/usr/local/bin/perl
2617 use GDS2;
2618 my $gds2File = new GDS2(-fileName=>"test.gds");
2619 while ($gds2File -> readGds2Record)
2620 {
2621 print $gds2File -> returnRecordAsPerl;
2622 }
2623  
2624 =cut
2625  
2626 sub returnRecordAsPerl()
2627 {
2628 0 ▶ my($self,%arg) = @_;
Subroutine returnRecordAsPerl: not called CC=27 SCAR=66.3
Pod documented
2629  
2630 0 my $gds2File = $arg{'-gds2File'};
2631 0 ▶ $gds2File = '$gds2File' unless (defined $gds2File);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $gds2File 0 0 0
2632  
2633 0 my $PGR = $arg{'-printGds2Record'};
2634 0 ▶ $PGR = 'printGds2Record' unless (defined $PGR);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $PGR 0 0 0
2635  
2636 0 my $string = '';
2637 0 $self -> {'UsingPrettyPrint'} = TRUE;
2638 0 ▶ $string .= getStrSpace() if ($self -> {'RecordType'} != BGNSTR);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RecordType"} != 5 0 0 0
2639 $string .= getElmSpace() if (!(
2640 ($self -> {'RecordType'} == TEXT) ||
2641 ($self -> {'RecordType'} == PATH) ||
2642 ($self -> {'RecordType'} == BOUNDARY) ||
2643 ($self -> {'RecordType'} == SREF) ||
2644 0 ▶ ($self -> {'RecordType'} == AREF)
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 0 0 0
Condition0%0/12
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9
l!l&&r!l&&!r
000
MC/DC0%0/5
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
$self->{"RecordType"} == 12 $self->{"RecordType"} == 9 $self->{"RecordType"} == 8 $self->{"RecordType"} == 10 $self->{"RecordType"} == 11
Truth table0%0/6
A or B or C or D or E
A= $self->{"RecordType"} == 12B= $self->{"RecordType"} == 9C= $self->{"RecordType"} == 8D= $self->{"RecordType"} == 10E= $self->{"RecordType"} == 11
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
2645 ));
2646 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 12 or $self->{'RecordType'} == 9 or $self->{'RecordType'} == 8 or $self->{'RecordType'} == 10 or $self->{'RecordType'} == 11 or $self->{'RecordType'} == 17 or $self->{'RecordType'} == 7 or $self->{'RecordType'} == 4) { } 0 0 0
Condition0%0/21
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 or $self->{"RecordType"} == 17 or $self->{"RecordType"} == 7 or $self->{"RecordType"} == 4
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 or $self->{"RecordType"} == 17 or $self->{"RecordType"} == 7
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 or $self->{"RecordType"} == 17
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8
l!l&&r!l&&!r
000
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9
l!l&&r!l&&!r
000
MC/DC0%0/8
$self->{"RecordType"} == 12 or $self->{"RecordType"} == 9 or $self->{"RecordType"} == 8 or $self->{"RecordType"} == 10 or $self->{"RecordType"} == 11 or $self->{"RecordType"} == 17 or $self->{"RecordType"} == 7 or $self->{"RecordType"} == 4
$self->{"RecordType"} == 12 $self->{"RecordType"} == 9 $self->{"RecordType"} == 8 $self->{"RecordType"} == 10 $self->{"RecordType"} == 11 $self->{"RecordType"} == 17 $self->{"RecordType"} == 7 $self->{"RecordType"} == 4
Truth table0%0/9
A or B or C or D or E or F or G or H
A= $self->{"RecordType"} == 12B= $self->{"RecordType"} == 9C= $self->{"RecordType"} == 8D= $self->{"RecordType"} == 10E= $self->{"RecordType"} == 11F= $self->{"RecordType"} == 17G= $self->{"RecordType"} == 7H= $self->{"RecordType"} == 4
ABCDEFGHresult
1XXXXXXX1
01XXXXXX1
001XXXXX1
0001XXXX1
00001XXX1
000001XX1
0000001X1
000000011
000000000
2647 ($self -> {'RecordType'} == TEXT) ||
2648 ($self -> {'RecordType'} == PATH) ||
2649 ($self -> {'RecordType'} == BOUNDARY) ||
2650 ($self -> {'RecordType'} == SREF) ||
2651 ($self -> {'RecordType'} == AREF) ||
2652 ($self -> {'RecordType'} == ENDEL) ||
2653 ($self -> {'RecordType'} == ENDSTR) ||
2654 ($self -> {'RecordType'} == ENDLIB)
2655 )
2656 {
2657 0 $string .= $gds2File.'->'.$PGR.'(-type=>'."'".$RecordTypeStrings[$self -> {'RecordType'}]."'".');';
2658 }
2659 else
2660 {
2661 0 $string .= $gds2File.'->'.$PGR.'(-type=>'."'".$RecordTypeStrings[$self -> {'RecordType'}]."',-data=>";
2662 0 my $i = 0;
2663 0 my $maxi = $self -> {'DataIndex'};
2664 0 ▶ if ($maxi >= 1) {$string .= '['}
Branch: 1 branch
BranchTrueFalseTotal
if ($maxi >= 1) 0 0 0
2665 0 ▶ while ($i <= $maxi)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $maxi) 0 0 0
2666 {
2667 0 ▶ if ($self -> {'DataType'} == BIT_ARRAY)
Branch: 5 branches
BranchTrueFalseTotal
if ($self->{'DataType'} == 1) { } 0 0 0
elsif ($self->{'DataType'} == 2) { } 0 0 0
elsif ($self->{'DataType'} == 3) { } 0 0 0
elsif ($self->{'DataType'} == 5) { } 0 0 0
elsif ($self->{'DataType'} == 6) { } 0 0 0
2668 {
2669 0 my $bitString = $self -> {'RecordData'}[$i];
2670 0 ▶ if ($isLittleEndian)
Branch: 1 branch
BranchTrueFalseTotal
if ($isLittleEndian) 0 0 0
2671 {
2672 0 $bitString =~ m|(........)(........)|;
2673 0 $bitString = "$2$1";
2674 }
2675 0 $string .= "'$bitString'";
2676 }
2677 elsif ($self -> {'DataType'} == INTEGER_2)
2678 {
2679 0 $string .= $self -> {'RecordData'}[$i];
2680 }
2681 elsif ($self -> {'DataType'} == INTEGER_4)
2682 {
2683 0 $string .= $self -> {'RecordData'}[$i];
2684 }
2685 elsif ($self -> {'DataType'} == REAL_8)
2686 {
2687 0 $string .= $self -> {'RecordData'}[$i];
2688 }
2689 elsif ($self -> {'DataType'} == ACSII_STRING)
2690 {
2691 0 $string .= "'".$self -> {'RecordData'}[$i]."'";
2692 }
2693 0 ▶ if ($i < $maxi) {$string .= ', '}
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $maxi) 0 0 0
2694 0 $i++;
2695 }
2696 0 ▶ if ($maxi >= 1) {$string .= ']'}
Branch: 1 branch
BranchTrueFalseTotal
if ($maxi >= 1) 0 0 0
2697 0 $string .= ');';
2698 }
2699 0 $string;
2700 }
2701 ################################################################################
2702  
2703  
2704 =head1 Low Level Specific Write Methods
2705  
2706 =cut
2707  
2708 ################################################################################
2709  
2710 =head2 printAngle - prints ANGLE record
2711  
2712 usage:
2713 $gds2File -> printAngle(-num=>#.#);
2714  
2715 =cut
2716  
2717 sub printAngle
2718 {
2719 0 ▶ my($self,%arg) = @_;
Subroutine printAngle: not called CC=3 SCAR=24.8
Pod documented
2720 0 my $angle = $arg{'-num'};
2721 0 ▶ if (defined $angle)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $angle) { } 0 0 0
2722 {
2723 0 $angle=posAngle($angle);
2724 }
2725 else
2726 {
2727 0 $angle = -1; #not really... just means not specified
2728 }
2729 0 ▶ $self -> printGds2Record(-type => 'ANGLE',-data => $angle) if ($angle >= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $angle >= 0 0 0 0
2730 }
2731 ################################################################################
2732  
2733 =head2 printAttrtable - prints ATTRTABLE record
2734  
2735 usage:
2736 $gds2File -> printAttrtable(-string=>$string);
2737  
2738 =cut
2739  
2740 sub printAttrtable
2741 {
2742 0 ▶ my($self,%arg) = @_;
Subroutine printAttrtable: not called CC=2 SCAR=17.9
Pod documented
2743 0 my $string = $arg{'-string'};
2744 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
2745 {
2746 0 die "printAttrtable expects a string. Missing -string => 'text' $!";
2747 }
2748 0 $self -> printGds2Record(-type => 'ATTRTABLE',-data => $string);
2749 }
2750 ################################################################################
2751  
2752 =head2 printBgnextn - prints BGNEXTN record
2753  
2754 usage:
2755 $gds2File -> printBgnextn(-num=>#.#);
2756  
2757 =cut
2758  
2759 sub printBgnextn
2760 {
2761 0 ▶ my($self,%arg) = @_;
Subroutine printBgnextn: not called CC=3 SCAR=24.8
Pod documented
2762 0 my $num = $arg{'-num'};
2763 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
2764 {
2765 0 die "printBgnextn expects a extension number. Missing -num => #.# $!";
2766 }
2767 0 my $resolution = $self -> {'Resolution'};
2768 0 ▶ if ($num >= 0) {$num = int(($num*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($num >= 0) { } 0 0 0
2769 0 else {$num = int(($num*$resolution)-$G_epsilon);}
2770 0 $self -> printGds2Record(-type => 'BGNEXTN',-data => $num);
2771 }
2772 ################################################################################
2773  
2774 =head2 printBgnlib - prints BGNLIB record
2775  
2776 usage:
2777 $gds2File -> printBgnlib(
2778 -isoDate => 0|1 ## (optional) use ISO 4 digit date 2001 vs 101
2779 );
2780  
2781 =cut
2782  
2783 sub printBgnlib
2784 {
2785 0 ▶ my($self,%arg) = @_;
Subroutine printBgnlib: not called CC=4 SCAR=30.0
Pod documented
2786 0 my $isoDate = $arg{'-isoDate'};
2787 0 ▶ if (! defined $isoDate)
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $isoDate) { } 0 0 0
elsif ($isoDate != 0) { } 0 0 0
2788 {
2789 0 $isoDate = 0;
2790 }
2791 elsif ($isoDate != 0)
2792 {
2793 0 $isoDate = 1;
2794 }
2795 0 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
2796 0 $mon++;
2797 0 ▶ $year += 1900 if ($isoDate); ## Cadence likes year left "as is". GDS format supports year number up to 65535 -- 101 vs 2001
Branch: 1 branch
BranchTrueFalseTotal
if $isoDate 0 0 0
2798 0 $self -> printGds2Record(-type=>'BGNLIB',-data=>[$year,$mon,$mday,$hour,$min,$sec,$year,$mon,$mday,$hour,$min,$sec]);
2799 }
2800 ################################################################################
2801  
2802 =head2 printBox - prints BOX record
2803  
2804 usage:
2805 $gds2File -> printBox;
2806  
2807 =cut
2808  
2809 sub printBox
2810 {
2811 0 ▶ my $self = shift;
Subroutine printBox: not called CC=1 SCAR=6.9
Pod documented
2812 0 $self -> printGds2Record(-type => 'BOX');
2813 }
2814 ################################################################################
2815  
2816 =head2 printBoxtype - prints BOXTYPE record
2817  
2818 usage:
2819 $gds2File -> printBoxtype(-num=>#);
2820  
2821 =cut
2822  
2823 sub printBoxtype
2824 {
2825 0 ▶ my($self,%arg) = @_;
Subroutine printBoxtype: not called CC=2 SCAR=17.9
Pod documented
2826 0 my $num = $arg{'-num'};
2827 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
2828 {
2829 0 die "printBoxtype expects a number. Missing -num => # $!";
2830 }
2831 0 $self -> printGds2Record(-type => 'BOXTYPE',-data => $num);
2832 }
2833 ################################################################################
2834  
2835 =head2 printColrow - prints COLROW record
2836  
2837 usage:
2838 $gds2File -> printBoxtype(-columns=>#, -rows=>#);
2839  
2840 =cut
2841  
2842 sub printColrow
2843 {
2844 0 ▶ my($self,%arg) = @_;
Subroutine printColrow: not called CC=5 SCAR=34.0
Pod documented
2845 0 my $columns = $arg{'-columns'};
2846 0 ▶ if ((! defined $columns)||($columns <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $columns or $columns <= 0) { } 0 0 0
Condition0%0/3
not defined $columns or $columns <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $columns or $columns <= 0
not defined $columns $columns <= 0
Truth table0%0/3
not(A) or B
A= not defined $columnsB= $columns <= 0
ABresult
1X1
011
000
2847 {
2848 0 $columns=1;
2849 }
2850 else
2851 {
2852 0 $columns=int($columns);
2853 }
2854 0 my $rows = $arg{'-rows'};
2855 0 ▶ if ((! defined $rows)||($rows <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $rows or $rows <= 0) { } 0 0 0
Condition0%0/3
not defined $rows or $rows <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $rows or $rows <= 0
not defined $rows $rows <= 0
Truth table0%0/3
not(A) or B
A= not defined $rowsB= $rows <= 0
ABresult
1X1
011
000
2856 {
2857 0 $rows=1;
2858 }
2859 else
2860 {
2861 0 $rows=int($rows);
2862 }
2863 0 $self -> printGds2Record(-type => 'COLROW',-data => [$columns,$rows]);
2864 }
2865 ################################################################################
2866  
2867 =head2 printDatatype - prints DATATYPE record
2868  
2869 usage:
2870 $gds2File -> printDatatype(-num=>#);
2871  
2872 =cut
2873  
2874 sub printDatatype
2875 {
2876 0 ▶ my($self,%arg) = @_;
Subroutine printDatatype: not called CC=2 SCAR=17.9
Pod documented
2877 0 my $dataType = $arg{'-num'};
2878 0 ▶ $dataType=0 unless (defined $dataType);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dataType 0 0 0
2879 0 $self -> printGds2Record(-type => 'DATATYPE',-data => $dataType);
2880 }
2881 ################################################################################
2882  
2883 sub printEflags
2884 {
2885 0 ▶ my $self = shift;
Subroutine printEflags: not called CC=1 SCAR=6.9
Pod undocumented
2886 0 die "EFLAGS type not supported $!";
2887 }
2888 ################################################################################
2889  
2890 =head2 printElkey - prints ELKEY record
2891  
2892 usage:
2893 $gds2File -> printElkey(-num=>#);
2894  
2895 =cut
2896  
2897 sub printElkey
2898 {
2899 0 ▶ my($self,%arg) = @_;
Subroutine printElkey: not called CC=2 SCAR=17.9
Pod documented
2900 0 my $num = $arg{'-num'};
2901 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
2902 {
2903 0 die "printElkey expects a number. Missing -num => #.# $!";
2904 }
2905 0 $self -> printGds2Record(-type => 'ELKEY',-data => $num);
2906 }
2907 ################################################################################
2908  
2909 =head2 printEndel - closes an element definition
2910  
2911 =cut
2912  
2913 sub printEndel
2914 {
2915 0 ▶ my $self = shift;
Subroutine printEndel: not called CC=1 SCAR=6.9
Pod documented
2916 0 $self -> printGds2Record(-type => 'ENDEL');
2917 }
2918 ################################################################################
2919  
2920 =head2 printEndextn - prints path end extension record
2921  
2922 usage:
2923 $gds2File printEndextn -> (-num=>#.#);
2924  
2925 =cut
2926  
2927 sub printEndextn
2928 {
2929 0 ▶ my($self,%arg) = @_;
Subroutine printEndextn: not called CC=3 SCAR=24.8
Pod documented
2930 0 my $num = $arg{'-num'};
2931 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
2932 {
2933 0 die "printEndextn expects a extension number. Missing -num => #.# $!";
2934 }
2935 0 my $resolution = $self -> {'Resolution'};
2936 0 ▶ if ($num >= 0) {$num = int(($num*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($num >= 0) { } 0 0 0
2937 0 else {$num = int(($num*$resolution)-$G_epsilon);}
2938 0 $self -> printGds2Record(-type => 'ENDEXTN',-data => $num);
2939 }
2940 ################################################################################
2941  
2942 =head2 printEndlib - closes a library definition
2943  
2944 =cut
2945  
2946 sub printEndlib
2947 {
2948 2 ▶ my $self = shift;
Subroutine printEndlib: called CC=1 SCAR=0.0
Pod documented
2949 2 $self -> printGds2Record(-type => 'ENDLIB');
2950 }
2951 ################################################################################
2952  
2953 =head2 printEndstr - closes a structure definition
2954  
2955 =cut
2956  
2957 sub printEndstr
2958 {
2959 4 ▶ my $self = shift;
Subroutine printEndstr: called CC=1 SCAR=0.0
Pod documented
2960 4 $self -> printGds2Record(-type => 'ENDSTR');
2961 }
2962 ################################################################################
2963  
2964 =head2 printEndmasks - prints a ENDMASKS
2965  
2966 =cut
2967  
2968 sub printEndmasks
2969 {
2970 0 ▶ my $self = shift;
Subroutine printEndmasks: not called CC=1 SCAR=6.9
Pod documented
2971 0 $self -> printGds2Record(-type => 'ENDMASKS');
2972 }
2973 ################################################################################
2974  
2975 =head2 printFonts - prints a FONTS record
2976  
2977 usage:
2978 $gds2File -> printFonts(-string=>'names_of_font_files');
2979  
2980 =cut
2981  
2982 sub printFonts
2983 {
2984 0 ▶ my($self,%arg) = @_;
Subroutine printFonts: not called CC=2 SCAR=17.9
Pod documented
2985 0 my $string = $arg{'-string'};
2986 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
2987 {
2988 0 die "printFonts expects a string. Missing -string => 'text' $!";
2989 }
2990 0 $self -> printGds2Record(-type => 'FONTS',-data => $string);
2991 }
2992 ################################################################################
2993  
2994 sub printFormat
2995 {
2996 0 ▶ my($self,%arg) = @_;
Subroutine printFormat: not called CC=2 SCAR=17.9
Pod undocumented
2997 0 my $num = $arg{'-num'};
2998 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
2999 {
3000 0 die "printFormat expects a number. Missing -num => #.# $!";
3001 }
3002 0 $self -> printGds2Record(-type => 'FORMAT',-data => $num);
3003 }
3004 ################################################################################
3005  
3006 sub printGenerations
3007 {
3008 0 ▶ my $self = shift;
Subroutine printGenerations: not called CC=1 SCAR=6.9
Pod undocumented
3009 0 $self -> printGds2Record(-type => 'GENERATIONS');
3010 }
3011 ################################################################################
3012  
3013 =head2 printHeader - Prints a rev 3 header
3014  
3015 usage:
3016 $gds2File -> printHeader(
3017 -num => # ## optional, defaults to 3. valid revs are 0,3,4,5,and 600
3018 );
3019  
3020 =cut
3021  
3022 sub printHeader
3023 {
3024 0 ▶ my($self,%arg) = @_;
Subroutine printHeader: not called CC=2 SCAR=17.9
Pod documented
3025 0 my $rev = $arg{'-num'};
3026 0 ▶ unless (defined $rev)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rev) 0 0 0
3027 {
3028 0 $rev=3;
3029 }
3030 0 $self -> printGds2Record(-type=>'HEADER',-data=>$rev);
3031 }
3032 ################################################################################
3033  
3034 =head2 printLayer - prints a LAYER number
3035  
3036 usage:
3037 $gds2File -> printLayer(
3038 -num => # ## optional, defaults to 0.
3039 );
3040  
3041 =cut
3042  
3043 sub printLayer
3044 {
3045 0 ▶ my($self,%arg) = @_;
Subroutine printLayer: not called CC=2 SCAR=17.9
Pod documented
3046 0 my $layer = $arg{'-num'};
3047 0 ▶ $layer = 0 unless (defined $layer);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $layer 0 0 0
3048 0 $self -> printGds2Record(-type => 'LAYER',-data => $layer);
3049 }
3050 ################################################################################
3051  
3052 sub printLibdirsize
3053 {
3054 0 ▶ my $self = shift;
Subroutine printLibdirsize: not called CC=1 SCAR=6.9
Pod undocumented
3055 0 $self -> printGds2Record(-type => 'LIBDIRSIZE');
3056 }
3057 ################################################################################
3058  
3059 =head2 printLibname - Prints library name
3060  
3061 usage:
3062 printLibname(-name=>$name);
3063  
3064 =cut
3065  
3066 sub printLibname
3067 {
3068 0 ▶ my($self,%arg) = @_;
Subroutine printLibname: not called CC=2 SCAR=17.9
Pod documented
3069 0 my $libName = $arg{'-name'};
3070 0 ▶ unless (defined $libName)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $libName) 0 0 0
3071 {
3072 0 die "printLibname expects a library name. Missing -name => 'name' $!";
3073 }
3074 0 $self -> printGds2Record(-type => 'LIBNAME',-data => $libName);
3075 }
3076 ################################################################################
3077  
3078 sub printLibsecur
3079 {
3080 0 ▶ my $self = shift;
Subroutine printLibsecur: not called CC=1 SCAR=6.9
Pod undocumented
3081 0 $self -> printGds2Record(-type => 'LIBSECUR');
3082 }
3083 ################################################################################
3084  
3085 sub printLinkkeys
3086 {
3087 0 ▶ my($self,%arg) = @_;
Subroutine printLinkkeys: not called CC=2 SCAR=17.9
Pod undocumented
3088 0 my $num = $arg{'-num'};
3089 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3090 {
3091 0 die "printLinkkeys expects a number. Missing -num => #.# $!";
3092 }
3093 0 $self -> printGds2Record(-type => 'LINKKEYS',-data => $num);
3094 }
3095 ################################################################################
3096  
3097 sub printLinktype
3098 {
3099 0 ▶ my($self,%arg) = @_;
Subroutine printLinktype: not called CC=2 SCAR=17.9
Pod undocumented
3100 0 my $num = $arg{'-num'};
3101 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3102 {
3103 0 die "printLinktype expects a number. Missing -num => #.# $!";
3104 }
3105 0 $self -> printGds2Record(-type => 'LINKTYPE',-data => $num);
3106 }
3107 ################################################################################
3108  
3109 =head2 printPathtype - prints a PATHTYPE number
3110  
3111 usage:
3112 $gds2File -> printPathtype(
3113 -num => # ## optional, defaults to 0.
3114 );
3115  
3116 =cut
3117  
3118 sub printPathtype
3119 {
3120 0 ▶ my($self,%arg) = @_;
Subroutine printPathtype: not called CC=3 SCAR=24.8
Pod documented
3121 0 my $pathType = $arg{'-num'};
3122 0 ▶ $pathType=0 if (! defined $pathType);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pathType 0 0 0
3123 0 ▶ $self -> printGds2Record(-type => 'PATHTYPE',-data => $pathType) if ($pathType);
Branch: 1 branch
BranchTrueFalseTotal
if $pathType 0 0 0
3124 }
3125 ################################################################################
3126  
3127 =head2 printMag - prints a MAG number
3128  
3129 usage:
3130 $gds2File -> printMag(
3131 -num => #.# ## optional, defaults to 0.0
3132 );
3133  
3134 =cut
3135  
3136 sub printMag
3137 {
3138 0 ▶ my($self,%arg) = @_;
Subroutine printMag: not called CC=4 SCAR=30.0
Pod documented
3139 0 my $mag = $arg{'-num'};
3140 0 ▶ $mag=0 if ((! defined $mag)||($mag <= 0));
Branch: 1 branch
BranchTrueFalseTotal
if not defined $mag or $mag <= 0 0 0 0
Condition0%0/3
not defined $mag or $mag <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $mag or $mag <= 0
not defined $mag $mag <= 0
Truth table0%0/3
not(A) or B
A= not defined $magB= $mag <= 0
ABresult
1X1
011
000
3141 0 $mag = cleanFloatNum($mag);
3142 0 ▶ $self -> printGds2Record(-type => 'MAG',-data => $mag) if ($mag);
Branch: 1 branch
BranchTrueFalseTotal
if $mag 0 0 0
3143 }
3144 ################################################################################
3145  
3146 sub printMask
3147 {
3148 0 ▶ my($self,%arg) = @_;
Subroutine printMask: not called CC=2 SCAR=17.9
Pod undocumented
3149 0 my $string = $arg{'-string'};
3150 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
3151 {
3152 0 die "printMask expects a string. Missing -string => 'text' $!";
3153 }
3154 0 $self -> printGds2Record(-type => 'MASK',-data => $string);
3155 }
3156 ################################################################################
3157  
3158 sub printNode
3159 {
3160 0 ▶ my $self = shift;
Subroutine printNode: not called CC=1 SCAR=6.9
Pod undocumented
3161 0 $self -> printGds2Record(-type => 'NODE');
3162 }
3163 ################################################################################
3164  
3165 =head2 printNodetype - prints a NODETYPE number
3166  
3167 usage:
3168 $gds2File -> printNodetype(
3169 -num => #
3170 );
3171  
3172 =cut
3173  
3174 sub printNodetype
3175 {
3176 0 ▶ my($self,%arg) = @_;
Subroutine printNodetype: not called CC=2 SCAR=17.9
Pod documented
3177 0 my $num = $arg{'-num'};
3178 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3179 {
3180 0 die "printNodetype expects a number. Missing -num => # $!";
3181 }
3182 0 $self -> printGds2Record(-type => 'NODETYPE',-data => $num);
3183 }
3184 ################################################################################
3185  
3186 sub printPlex
3187 {
3188 0 ▶ my($self,%arg) = @_;
Subroutine printPlex: not called CC=2 SCAR=17.9
Pod undocumented
3189 0 my $num = $arg{'-num'};
3190 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3191 {
3192 0 die "printPlex expects a number. Missing -num => #.# $!";
3193 }
3194 0 $self -> printGds2Record(-type => 'PLEX',-data => $num);
3195 }
3196 ################################################################################
3197  
3198 =head2 printPresentation - prints a text presentation record
3199  
3200 usage:
3201 $gds2File -> printPresentation(
3202 -font => #, ##optional, defaults to 0, valid numbers are 0-3
3203 -top, ||-middle, || -bottom, ## vertical justification
3204 -left, ||-center, || -right, ## horizontal justification
3205 );
3206  
3207 example:
3208 gds2File -> printPresentation(-font=>0,-top,-left);
3209  
3210 =cut
3211  
3212 sub printPresentation
3213 {
3214 0 ▶ my($self,%arg) = @_;
Subroutine printPresentation: not called CC=8 SCAR=42.8
Pod documented
3215 0 my $font = $arg{'-font'};
3216 0 ▶ if ((! defined $font) || ($font < 0) || ($font > 3))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $font or $font < 0 or $font > 3) 0 0 0
Condition0%0/6
not defined $font or $font < 0 or $font > 3
l!l&&r!l&&!r
000
not defined $font or $font < 0
l!l&&r!l&&!r
000
MC/DC0%0/3
not defined $font or $font < 0 or $font > 3
not defined $font $font < 0 $font > 3
Truth table0%0/4
not(A) or B or C
A= not defined $fontB= $font < 0C= $font > 3
ABCresult
1XX1
01X1
0011
0000
3217 {
3218 0 $font=0;
3219 }
3220 0 $font = sprintf("%02d",$font);
3221  
3222 0 my $vertical;
3223 0 my $top = $arg{'-top'};
3224 0 my $middle = $arg{'-middle'};
3225 0 my $bottom = $arg{'-bottom'};
3226 0 ▶ if (defined $top) {$vertical = '00';}
Branch: 2 branches
BranchTrueFalseTotal
if (defined $top) { } 0 0 0
elsif (defined $bottom) { } 0 0 0
3227 0 elsif (defined $bottom) {$vertical = '10';}
3228 0 else {$vertical = '01';} ## middle
3229 0 my $horizontal;
3230 0 my $left = $arg{'-left'};
3231 0 my $center = $arg{'-center'};
3232 0 my $right = $arg{'-right'};
3233 0 ▶ if (defined $left) {$horizontal = '00';}
Branch: 2 branches
BranchTrueFalseTotal
if (defined $left) { } 0 0 0
elsif (defined $right) { } 0 0 0
3234 0 elsif (defined $right) {$horizontal = '10';}
3235 0 else {$horizontal = '01';} ## center
3236  
3237 0 my $bitstring = '0'x10;
3238 0 $bitstring .= "$font$vertical$horizontal";
3239 0 $self -> printGds2Record(-type => 'PRESENTATION',-data => $bitstring);
3240 }
3241 ################################################################################
3242  
3243 =head2 printPropattr - prints a property id number
3244  
3245 usage:
3246 $gds2File -> printPropattr( -num => # );
3247  
3248 =cut
3249  
3250 sub printPropattr
3251 {
3252 0 ▶ my($self,%arg) = @_;
Subroutine printPropattr: not called CC=2 SCAR=17.9
Pod documented
3253 0 my $num = $arg{'-num'};
3254 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3255 {
3256 0 die "printPropattr expects a number. Missing -num => # $!";
3257 }
3258 0 $self -> printGds2Record(-type => 'PROPATTR',-data => $num);
3259 }
3260 ################################################################################
3261  
3262 =head2 printPropvalue - prints a property value string
3263  
3264 usage:
3265 $gds2File -> printPropvalue( -string => $string );
3266  
3267 =cut
3268  
3269 sub printPropvalue
3270 {
3271 0 ▶ my($self,%arg) = @_;
Subroutine printPropvalue: not called CC=2 SCAR=17.9
Pod documented
3272 0 my $string = $arg{'-string'};
3273 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
3274 {
3275 0 die "printPropvalue expects a string. Missing -string => 'text' $!";
3276 }
3277 0 $self -> printGds2Record(-type => 'PROPVALUE',-data => $string);
3278 }
3279 ################################################################################
3280  
3281 sub printReflibs
3282 {
3283 0 ▶ my($self,%arg) = @_;
Subroutine printReflibs: not called CC=2 SCAR=17.9
Pod undocumented
3284 0 my $string = $arg{'-string'};
3285 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
3286 {
3287 0 die "printReflibs expects a string. Missing -string => 'text' $!";
3288 }
3289 0 $self -> printGds2Record(-type => 'REFLIBS',-data => $string);
3290 }
3291 ################################################################################
3292  
3293 sub printReserved
3294 {
3295 0 ▶ my($self,%arg) = @_;
Subroutine printReserved: not called CC=2 SCAR=17.9
Pod undocumented
3296 0 my $num = $arg{'-num'};
3297 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3298 {
3299 0 die "printReserved expects a number. Missing -num => #.# $!";
3300 }
3301 0 $self -> printGds2Record(-type => 'RESERVED',-data => $num);
3302 }
3303 ################################################################################
3304  
3305 =head2 printSname - prints a SNAME string
3306  
3307 usage:
3308 $gds2File -> printSname( -name => $cellName );
3309  
3310 =cut
3311  
3312 sub printSname
3313 {
3314 0 ▶ my($self,%arg) = @_;
Subroutine printSname: not called CC=2 SCAR=17.9
Pod documented
3315 0 my $string = $arg{'-name'};
3316 0 ▶ if (! defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
3317 {
3318 0 die "printSname expects a cell name. Missing -name => 'text' $!";
3319 }
3320 0 $self -> printGds2Record(-type => 'SNAME',-data => $string);
3321 }
3322 ################################################################################
3323  
3324 sub printSpacing
3325 {
3326 0 ▶ my $self = shift;
Subroutine printSpacing: not called CC=1 SCAR=6.9
Pod undocumented
3327 0 die "SPACING type not supported $!";
3328 }
3329 ################################################################################
3330  
3331 sub printSrfname
3332 {
3333 0 ▶ my $self = shift;
Subroutine printSrfname: not called CC=1 SCAR=6.9
Pod undocumented
3334 0 $self -> printGds2Record(-type => 'SRFNAME');
3335 }
3336 ################################################################################
3337  
3338 =head2 printStrans - prints a STRANS record
3339  
3340 usage:
3341 $gds2File -> printStrans( -reflect );
3342  
3343 =cut
3344  
3345 sub printStrans
3346 {
3347 0 ▶ my($self,%arg) = @_;
Subroutine printStrans: not called CC=3 SCAR=24.8
Pod documented
3348 0 my $reflect = $arg{'-reflect'};
3349 0 ▶ if ((! defined $reflect)||($reflect <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $reflect or $reflect <= 0) { } 0 0 0
Condition0%0/3
not defined $reflect or $reflect <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $reflect or $reflect <= 0
not defined $reflect $reflect <= 0
Truth table0%0/3
not(A) or B
A= not defined $reflectB= $reflect <= 0
ABresult
1X1
011
000
3350 {
3351 0 $reflect=0;
3352 }
3353 else
3354 {
3355 0 $reflect=1;
3356 }
3357 0 my $data=$reflect.'0'x15; ## 16 'bit' string
3358 0 $self -> printGds2Record(-type => 'STRANS',-data => $data);
3359 }
3360 ################################################################################
3361  
3362 sub printStrclass
3363 {
3364 0 ▶ my $self = shift;
Subroutine printStrclass: not called CC=1 SCAR=6.9
Pod undocumented
3365 0 $self -> printGds2Record(-type => 'STRCLASS');
3366 }
3367 ################################################################################
3368  
3369 =head2 printString - prints a STRING record
3370  
3371 usage:
3372 $gds2File -> printSname( -string => $text );
3373  
3374 =cut
3375  
3376 sub printString
3377 {
3378 0 ▶ my($self,%arg) = @_;
Subroutine printString: not called CC=2 SCAR=17.9
Pod documented
3379 0 my $string = $arg{'-string'};
3380 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
3381 {
3382 0 die "printString expects a string. Missing -string => 'text' $!";
3383 }
3384 0 $self -> printGds2Record(-type => 'STRING',-data => $string);
3385 }
3386 ################################################################################
3387  
3388 =head2 printStrname - prints a structure name string
3389  
3390 usage:
3391 $gds2File -> printStrname( -name => $cellName );
3392  
3393 =cut
3394  
3395 sub printStrname
3396 {
3397 0 ▶ my($self,%arg) = @_;
Subroutine printStrname: not called CC=2 SCAR=17.9
Pod documented
3398 0 my $strName = $arg{'-name'};
3399 0 ▶ unless (defined $strName)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $strName) 0 0 0
3400 {
3401 0 die "printStrname expects a structure name. Missing -name => 'name' $!";
3402 }
3403 0 $self -> printGds2Record(-type => 'STRNAME',-data => $strName);
3404 }
3405 ################################################################################
3406  
3407 sub printStrtype
3408 {
3409 0 ▶ my $self = shift;
Subroutine printStrtype: not called CC=1 SCAR=6.9
Pod undocumented
3410 0 die "STRTYPE type not supported $!";
3411 }
3412 ################################################################################
3413  
3414 sub printStyptable
3415 {
3416 0 ▶ my($self,%arg) = @_;
Subroutine printStyptable: not called CC=2 SCAR=17.9
Pod undocumented
3417 0 my $string = $arg{'-string'};
3418 0 ▶ unless (defined $string)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $string) 0 0 0
3419 {
3420 0 die "printStyptable expects a string. Missing -string => 'text' $!";
3421 }
3422 0 $self -> printGds2Record(-type => 'STYPTABLE',-data => $string);
3423 }
3424 ################################################################################
3425  
3426 sub printTapecode
3427 {
3428 0 ▶ my($self,%arg) = @_;
Subroutine printTapecode: not called CC=2 SCAR=17.9
Pod undocumented
3429 0 my $num = $arg{'-num'};
3430 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3431 {
3432 0 die "printTapecode expects a number. Missing -num => #.# $!";
3433 }
3434 0 $self -> printGds2Record(-type => 'TAPECODE',-data => $num);
3435 }
3436 ################################################################################
3437  
3438 sub printTapenum
3439 {
3440 0 ▶ my($self,%arg) = @_;
Subroutine printTapenum: not called CC=2 SCAR=17.9
Pod undocumented
3441 0 my $num = $arg{'-num'};
3442 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3443 {
3444 0 die "printTapenum expects a number. Missing -num => #.# $!";
3445 }
3446 0 $self -> printGds2Record(-type => 'TAPENUM',-data => $num);
3447 }
3448 ################################################################################
3449  
3450 sub printTextnode
3451 {
3452 0 ▶ my $self = shift;
Subroutine printTextnode: not called CC=1 SCAR=6.9
Pod undocumented
3453 0 $self -> printGds2Record(-type => 'TEXTNODE');
3454 }
3455 ################################################################################
3456  
3457 =head2 printTexttype - prints a text type number
3458  
3459 usage:
3460 $gds2File -> printTexttype( -num => # );
3461  
3462 =cut
3463  
3464 sub printTexttype
3465 {
3466 0 ▶ my($self,%arg) = @_;
Subroutine printTexttype: not called CC=3 SCAR=24.8
Pod documented
3467 0 my $num = $arg{'-num'};
3468 0 ▶ unless (defined $num)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $num) 0 0 0
3469 {
3470 0 die "printTexttype expects a number. Missing -num => # $!";
3471 }
3472 0 ▶ $num = 0 if ($num < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $num < 0 0 0 0
3473 0 $self -> printGds2Record(-type => 'TEXTTYPE',-data => $num);
3474 }
3475 ################################################################################
3476  
3477 sub printUinteger
3478 {
3479 0 ▶ my $self = shift;
Subroutine printUinteger: not called CC=1 SCAR=6.9
Pod undocumented
3480 0 die "UINTEGER type not supported $!";
3481 }
3482 ################################################################################
3483  
3484 =head2 printUnits - Prints units record.
3485  
3486 options:
3487 -uUnit => real number ## (optional) default is 0.001
3488 -dbUnit => real number ## (optional) default is 1e-9
3489  
3490 =cut
3491  
3492 sub printUnits
3493 {
3494 0 ▶ my($self,%arg) = @_;
Subroutine printUnits: not called CC=3 SCAR=24.8
Pod documented
3495  
3496 0 my $uUnit = $arg{'-uUnit'};
3497 0 ▶ if (! defined $uUnit)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $uUnit) { } 0 0 0
3498 {
3499 0 $uUnit = 0.001;
3500 }
3501 else
3502 {
3503 0 $self -> {'Resolution'} = (1 / $uUnit); ## default is 1000 - already set in new()
3504 }
3505 0 $self -> {'UUnits'} = $uUnit;
3506 #################################################
3507 0 my $dbUnit = $arg{'-dbUnit'};
3508 0 ▶ unless (defined $dbUnit)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $dbUnit) 0 0 0
3509 {
3510 0 $dbUnit = 1e-9;
3511 }
3512 0 $self -> {'DBUnits'} = $dbUnit;
3513 #################################################
3514  
3515 0 $self -> printGds2Record(-type => 'UNITS',-data => [$uUnit,$dbUnit]);
3516 }
3517 ################################################################################
3518  
3519 sub printUstring
3520 {
3521 0 ▶ my $self = shift;
Subroutine printUstring: not called CC=1 SCAR=6.9
Pod undocumented
3522 0 die "USTRING type not supported $!";
3523 }
3524 ################################################################################
3525  
3526 =head2 printWidth - prints a width number
3527  
3528 usage:
3529 $gds2File -> printWidth( -num => # );
3530  
3531 =cut
3532  
3533 sub printWidth
3534 {
3535 0 ▶ my($self,%arg) = @_;
Subroutine printWidth: not called CC=4 SCAR=30.0
Pod documented
3536 0 my $width = $arg{'-num'};
3537 0 ▶ if ((! defined $width)||($width <= 0))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $width or $width <= 0) 0 0 0
Condition0%0/3
not defined $width or $width <= 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $width or $width <= 0
not defined $width $width <= 0
Truth table0%0/3
not(A) or B
A= not defined $widthB= $width <= 0
ABresult
1X1
011
000
3538 {
3539 0 $width=0;
3540 }
3541 0 ▶ $self -> printGds2Record(-type => 'WIDTH',-data => $width) if ($width);
Branch: 1 branch
BranchTrueFalseTotal
if $width 0 0 0
3542 }
3543 ################################################################################
3544  
3545 =head2 printXy - prints an XY array
3546  
3547 usage:
3548 $gds2File -> printXy( -xyInt => \@arrayGds2Ints );
3549 -or-
3550 $gds2File -> printXy( -xy => \@arrayReals );
3551  
3552 -xyInt most useful if reading and modifying... -xy if creating from scratch
3553  
3554 =cut
3555  
3556 sub printXy
3557 {
3558 0 ▶ my($self,%arg) = @_;
Subroutine printXy: not called CC=6 SCAR=37.4
Pod documented
3559 #### -xyInt most useful if reading and modifying... -xy if creating from scratch
3560 0 my $xyInt = $arg{'-xyInt'}; ## $xyInt should be a reference to an array of internal GDS2 format integers
3561 0 my $xy = $arg{'-xy'}; ## $xy should be a reference to an array of reals
3562 0 my $resolution = $self -> {'Resolution'};
3563 0 ▶ if (! ((defined $xy) || (defined $xyInt)))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $xy or defined $xyInt) 0 0 0
Condition0%0/3
defined $xy or defined $xyInt
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $xy or defined $xyInt
defined $xy defined $xyInt
Truth table0%0/3
A or B
A= defined $xyB= defined $xyInt
ABresult
1X1
011
000
3564 {
3565 0 die "printXy expects an xy array reference. Missing -xy => \\\@array $!";
3566 }
3567 0 ▶ if (defined $xyInt)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xyInt) 0 0 0
3568 {
3569 0 $xy = $xyInt;
3570 0 $resolution=1;
3571 }
3572 0 my @xyTmp=(); ##don't pollute array passed in
3573 0 ▶ for(my $i=0;$i<=$#$xy;$i++) ## e.g. 3.4 in -> 3400 out
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $xy->$#*) 0 0 0
3574 {
3575 0 ▶ if ($xy -> [$i] >= 0) {push @xyTmp,int((($xy -> [$i])*$resolution)+$G_epsilon);}
Branch: 1 branch
BranchTrueFalseTotal
if ($xy->[$i] >= 0) { } 0 0 0
3576 0 else {push @xyTmp,int((($xy -> [$i])*$resolution)-$G_epsilon);}
3577 }
3578 0 $self -> printGds2Record(-type => 'XY',-data => \@xyTmp);
3579 }
3580 ################################################################################
3581  
3582  
3583 =head1 Low Level Specific Evaluation Methods
3584  
3585 =cut
3586  
3587 =head2 returnFilePosition - return current byte position (NOT zero based)
3588  
3589 usage:
3590 my $position = $gds2File -> returnFilePosition;
3591  
3592 =cut
3593  
3594 sub returnFilePosition()
3595 {
3596 0 ▶ my $self = shift;
Subroutine returnFilePosition: not called CC=1 SCAR=6.9
Pod documented
3597 0 $self -> {'BytesDone'};
3598 }
3599 ################################################################################
3600  
3601 sub tellSize() ## old name
3602 {
3603 0 ▶ my $self = shift;
Subroutine tellSize: not called CC=1 SCAR=6.9
Pod undocumented
3604 0 $self -> {'BytesDone'};
3605 }
3606 ################################################################################
3607  
3608  
3609 =head2 returnBgnextn - returns bgnextn if record is BGNEXTN else returns 0
3610  
3611 usage:
3612  
3613 =cut
3614  
3615 sub returnBgnextn
3616 {
3617 0 ▶ my $self = shift;
Subroutine returnBgnextn: not called CC=2 SCAR=17.9
Pod documented
3618 ## 2 byte signed integer
3619 0 ▶ if ($self -> isBgnextn) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isBgnextn) { } 0 0 0
3620 0 else { 0; }
3621 }
3622 ################################################################################
3623  
3624 =head2 returnDatatype - returns datatype # if record is DATATYPE else returns -1
3625  
3626 usage:
3627 $dataTypesFound[$gds2File -> returnDatatype] = 1;
3628  
3629 =cut
3630  
3631 sub returnDatatype
3632 {
3633 0 ▶ my $self = shift;
Subroutine returnDatatype: not called CC=2 SCAR=17.9
Pod documented
3634 ## 2 byte signed integer
3635 0 ▶ if ($self -> isDatatype) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isDatatype) { } 0 0 0
3636 0 else { UNKNOWN; }
3637 }
3638 ################################################################################
3639  
3640 =head2 returnEndextn- returns endextn if record is ENDEXTN else returns 0
3641  
3642 usage:
3643  
3644 =cut
3645  
3646 sub returnEndextn
3647 {
3648 0 ▶ my $self = shift;
Subroutine returnEndextn: not called CC=2 SCAR=17.9
Pod undocumented
3649 ## 2 byte signed integer
3650 0 ▶ if ($self -> isEndextn) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isEndextn) { } 0 0 0
3651 0 else { 0; }
3652 }
3653 ################################################################################
3654  
3655  
3656 =head2 returnLayer - returns layer # if record is LAYER else returns -1
3657  
3658 usage:
3659 $layersFound[$gds2File -> returnLayer] = 1;
3660  
3661 =cut
3662  
3663 sub returnLayer
3664 {
3665 0 ▶ my $self = shift;
Subroutine returnLayer: not called CC=2 SCAR=17.9
Pod documented
3666 ## 2 byte signed integer
3667 0 ▶ if ($self -> isLayer) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isLayer) { } 0 0 0
3668 0 else { UNKNOWN; }
3669 }
3670 ################################################################################
3671  
3672 =head2 returnPathtype - returns pathtype # if record is PATHTYPE else returns -1
3673  
3674 usage:
3675  
3676 =cut
3677  
3678 sub returnPathtype
3679 {
3680 0 ▶ my $self = shift;
Subroutine returnPathtype: not called CC=2 SCAR=17.9
Pod documented
3681 ## 2 byte signed integer
3682 0 ▶ if ($self -> isPathtype) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isPathtype) { } 0 0 0
3683 0 else { UNKNOWN; }
3684 }
3685 ################################################################################
3686  
3687 =head2 returnPropattr - returns propattr # if record is PROPATTR else returns -1
3688  
3689 usage:
3690  
3691 =cut
3692  
3693 sub returnPropattr
3694 {
3695 0 ▶ my $self = shift;
Subroutine returnPropattr: not called CC=2 SCAR=17.9
Pod documented
3696 ## 2 byte signed integer
3697 0 ▶ if ($self -> isPropattr) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isPropattr) { } 0 0 0
3698 0 else { UNKNOWN; }
3699 }
3700 ################################################################################
3701  
3702 =head2 returnPropvalue - returns propvalue string if record is PROPVALUE else returns ''
3703  
3704 usage:
3705  
3706 =cut
3707  
3708 sub returnPropvalue
3709 {
3710 0 ▶ my $self = shift;
Subroutine returnPropvalue: not called CC=2 SCAR=17.9
Pod documented
3711 0 ▶ if ($self -> isPropvalue) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isPropvalue) { } 0 0 0
3712 0 else { ''; }
3713 }
3714 ################################################################################
3715  
3716 =head2 returnSname - return string if record type is SNAME else ''
3717  
3718 =cut
3719  
3720 sub returnSname
3721 {
3722 0 ▶ my $self = shift;
Subroutine returnSname: not called CC=2 SCAR=17.9
Pod documented
3723 0 ▶ if ($self -> isSname) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isSname) { } 0 0 0
3724 0 else { ''; }
3725 }
3726 ################################################################################
3727  
3728 =head2 returnString - return string if record type is STRING else ''
3729  
3730 =cut
3731  
3732 sub returnString
3733 {
3734 0 ▶ my $self = shift;
Subroutine returnString: not called CC=2 SCAR=17.9
Pod documented
3735 0 ▶ if ($self -> isString) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isString) { } 0 0 0
3736 0 else { ''; }
3737 }
3738 ################################################################################
3739  
3740 =head2 returnStrname - return string if record type is STRNAME else ''
3741  
3742 =cut
3743  
3744 sub returnStrname
3745 {
3746 0 ▶ my $self = shift;
Subroutine returnStrname: not called CC=2 SCAR=17.9
Pod documented
3747 0 ▶ if ($self -> isStrname) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isStrname) { } 0 0 0
3748 0 else { ''; }
3749 }
3750 ################################################################################
3751  
3752 =head2 returnTexttype - returns texttype # if record is TEXTTYPE else returns -1
3753  
3754 usage:
3755 $TextTypesFound[$gds2File -> returnTexttype] = 1;
3756  
3757 =cut
3758  
3759 sub returnTexttype
3760 {
3761 0 ▶ my $self = shift;
Subroutine returnTexttype: not called CC=2 SCAR=17.9
Pod documented
3762 ## 2 byte signed integer
3763 0 ▶ if ($self -> isTexttype) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isTexttype) { } 0 0 0
3764 0 else { UNKNOWN; }
3765 }
3766 ################################################################################
3767  
3768 =head2 returnWidth - returns width # if record is WIDTH else returns -1
3769  
3770 usage:
3771  
3772 =cut
3773  
3774 sub returnWidth
3775 {
3776 0 ▶ my $self = shift;
Subroutine returnWidth: not called CC=2 SCAR=17.9
Pod documented
3777 ## 4 byte signed integer
3778 0 ▶ if ($self -> isWidth) { $self -> {'RecordData'}[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isWidth) { } 0 0 0
3779 0 else { UNKNOWN; }
3780 }
3781 ################################################################################
3782  
3783 ################################################################################
3784  
3785 =head1 Low Level Specific Boolean Methods
3786  
3787 =cut
3788  
3789 ################################################################################
3790  
3791 =head2 isAref - return 0 or 1 depending on whether current record is an aref
3792  
3793 =cut
3794  
3795 sub isAref
3796 {
3797 0 ▶ my $self = shift;
Subroutine isAref: not called CC=2 SCAR=17.9
Pod documented
3798 0 ▶ if ($self -> {'RecordType'} == AREF) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 11) { } 0 0 0
3799 0 else { 0; }
3800 }
3801 ################################################################################
3802  
3803 =head2 isBgnlib - return 0 or 1 depending on whether current record is a bgnlib
3804  
3805 =cut
3806  
3807 sub isBgnlib
3808 {
3809 0 ▶ my $self = shift;
Subroutine isBgnlib: not called CC=2 SCAR=17.9
Pod documented
3810 0 ▶ if ($self -> {'RecordType'} == BGNLIB) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 1) { } 0 0 0
3811 0 else { 0; }
3812 }
3813 ################################################################################
3814  
3815 =head2 isBgnstr - return 0 or 1 depending on whether current record is a bgnstr
3816  
3817 =cut
3818  
3819 sub isBgnstr
3820 {
3821 0 ▶ my $self = shift;
Subroutine isBgnstr: not called CC=2 SCAR=17.9
Pod documented
3822 0 ▶ if ($self -> {'RecordType'} == BGNSTR) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 5) { } 0 0 0
3823 0 else { 0; }
3824 }
3825 ################################################################################
3826  
3827 =head2 isBoundary - return 0 or 1 depending on whether current record is a boundary
3828  
3829 =cut
3830  
3831 sub isBoundary
3832 {
3833 0 ▶ my $self = shift;
Subroutine isBoundary: not called CC=2 SCAR=17.9
Pod documented
3834 0 ▶ if ($self -> {'RecordType'} == BOUNDARY) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 8) { } 0 0 0
3835 0 else { 0; }
3836 }
3837 ################################################################################
3838  
3839 =head2 isDatatype - return 0 or 1 depending on whether current record is datatype
3840  
3841 =cut
3842  
3843 sub isDatatype
3844 {
3845 0 ▶ my $self = shift;
Subroutine isDatatype: not called CC=2 SCAR=17.9
Pod documented
3846 0 ▶ if ($self -> {'RecordType'} == DATATYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 14) { } 0 0 0
3847 0 else { 0; }
3848 }
3849 ################################################################################
3850  
3851 =head2 isEndlib - return 0 or 1 depending on whether current record is endlib
3852  
3853 =cut
3854  
3855 sub isEndlib
3856 {
3857 0 ▶ my $self = shift;
Subroutine isEndlib: not called CC=2 SCAR=17.9
Pod documented
3858 0 ▶ if ($self -> {'RecordType'} == ENDLIB) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 4) { } 0 0 0
3859 0 else { 0; }
3860 }
3861 ################################################################################
3862  
3863 =head2 isEndel - return 0 or 1 depending on whether current record is endel
3864  
3865 =cut
3866  
3867 sub isEndel
3868 {
3869 0 ▶ my $self = shift;
Subroutine isEndel: not called CC=2 SCAR=17.9
Pod documented
3870 0 ▶ if ($self -> {'RecordType'} == ENDEL) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 17) { } 0 0 0
3871 0 else { 0; }
3872 }
3873 ################################################################################
3874  
3875 =head2 isEndstr - return 0 or 1 depending on whether current record is endstr
3876  
3877 =cut
3878  
3879 sub isEndstr
3880 {
3881 0 ▶ my $self = shift;
Subroutine isEndstr: not called CC=2 SCAR=17.9
Pod documented
3882 0 ▶ if ($self -> {'RecordType'} == ENDSTR) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 7) { } 0 0 0
3883 0 else { 0; }
3884 }
3885 ################################################################################
3886  
3887  
3888 =head2 isHeader - return 0 or 1 depending on whether current record is a header
3889  
3890 =cut
3891  
3892 sub isHeader
3893 {
3894 0 ▶ my $self = shift;
Subroutine isHeader: not called CC=2 SCAR=17.9
Pod documented
3895 0 ▶ if ($self -> {'RecordType'} == HEADER) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 0) { } 0 0 0
3896 0 else { 0; }
3897 }
3898 ################################################################################
3899  
3900 =head2 isLibname - return 0 or 1 depending on whether current record is a libname
3901  
3902 =cut
3903  
3904 sub isLibname
3905 {
3906 0 ▶ my $self = shift;
Subroutine isLibname: not called CC=2 SCAR=17.9
Pod documented
3907 0 ▶ if ($self -> {'RecordType'} == LIBNAME) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 2) { } 0 0 0
3908 0 else { 0; }
3909 }
3910 ################################################################################
3911  
3912 =head2 isPath - return 0 or 1 depending on whether current record is a path
3913  
3914 =cut
3915  
3916 sub isPath
3917 {
3918 0 ▶ my $self = shift;
Subroutine isPath: not called CC=2 SCAR=17.9
Pod documented
3919 0 ▶ if ($self -> {'RecordType'} == PATH) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 9) { } 0 0 0
3920 0 else { 0; }
3921 }
3922 ################################################################################
3923  
3924 =head2 isSref - return 0 or 1 depending on whether current record is an sref
3925  
3926 =cut
3927  
3928 sub isSref
3929 {
3930 0 ▶ my $self = shift;
Subroutine isSref: not called CC=2 SCAR=17.9
Pod documented
3931 0 ▶ if ($self -> {'RecordType'} == SREF) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 10) { } 0 0 0
3932 0 else { 0; }
3933 }
3934 ################################################################################
3935  
3936 =head2 isSrfname - return 0 or 1 depending on whether current record is an srfname
3937  
3938 =cut
3939  
3940 sub isSrfname
3941 {
3942 0 ▶ my $self = shift;
Subroutine isSrfname: not called CC=2 SCAR=17.9
Pod documented
3943 0 ▶ if ($self -> {'RecordType'} == SRFNAME) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 58) { } 0 0 0
3944 0 else { 0; }
3945 }
3946 ################################################################################
3947  
3948 =head2 isText - return 0 or 1 depending on whether current record is a text
3949  
3950 =cut
3951  
3952 sub isText
3953 {
3954 0 ▶ my $self = shift;
Subroutine isText: not called CC=2 SCAR=17.9
Pod documented
3955 0 ▶ if ($self -> {'RecordType'} == TEXT) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 12) { } 0 0 0
3956 0 else { 0; }
3957 }
3958 ################################################################################
3959  
3960 =head2 isUnits - return 0 or 1 depending on whether current record is units
3961  
3962 =cut
3963  
3964 sub isUnits
3965 {
3966 0 ▶ my $self = shift;
Subroutine isUnits: not called CC=2 SCAR=17.9
Pod documented
3967 0 ▶ if ($self -> {'RecordType'} == UNITS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 3) { } 0 0 0
3968 0 else { 0; }
3969 }
3970 ################################################################################
3971  
3972 =head2 isLayer - return 0 or 1 depending on whether current record is layer
3973  
3974 =cut
3975  
3976 sub isLayer
3977 {
3978 0 ▶ my $self = shift;
Subroutine isLayer: not called CC=2 SCAR=17.9
Pod documented
3979 0 ▶ if ($self -> {'RecordType'} == LAYER) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 13) { } 0 0 0
3980 0 else { 0; }
3981 }
3982 ################################################################################
3983  
3984 =head2 isStrname - return 0 or 1 depending on whether current record is strname
3985  
3986 =cut
3987  
3988 sub isStrname
3989 {
3990 0 ▶ my $self = shift;
Subroutine isStrname: not called CC=2 SCAR=17.9
Pod documented
3991 0 ▶ if ($self -> {'RecordType'} == STRNAME) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 6) { } 0 0 0
3992 0 else { 0; }
3993 }
3994 ################################################################################
3995  
3996 =head2 isWidth - return 0 or 1 depending on whether current record is width
3997  
3998 =cut
3999  
4000 sub isWidth
4001 {
4002 0 ▶ my $self = shift;
Subroutine isWidth: not called CC=2 SCAR=17.9
Pod documented
4003 0 ▶ if ($self -> {'RecordType'} == WIDTH) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 15) { } 0 0 0
4004 0 else { 0; }
4005 }
4006 ################################################################################
4007  
4008 =head2 isXy - return 0 or 1 depending on whether current record is xy
4009  
4010 =cut
4011  
4012 sub isXy
4013 {
4014 0 ▶ my $self = shift;
Subroutine isXy: not called CC=2 SCAR=17.9
Pod documented
4015 0 ▶ if ($self -> {'RecordType'} == XY) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 16) { } 0 0 0
4016 0 else { 0; }
4017 }
4018 ################################################################################
4019  
4020 =head2 isSname - return 0 or 1 depending on whether current record is sname
4021  
4022 =cut
4023  
4024 sub isSname
4025 {
4026 0 ▶ my $self = shift;
Subroutine isSname: not called CC=2 SCAR=17.9
Pod documented
4027 0 ▶ if ($self -> {'RecordType'} == SNAME) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 18) { } 0 0 0
4028 0 else { 0; }
4029 }
4030 ################################################################################
4031  
4032 =head2 isColrow - return 0 or 1 depending on whether current record is colrow
4033  
4034 =cut
4035  
4036 sub isColrow
4037 {
4038 0 ▶ my $self = shift;
Subroutine isColrow: not called CC=2 SCAR=17.9
Pod documented
4039 0 ▶ if ($self -> {'RecordType'} == COLROW) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 19) { } 0 0 0
4040 0 else { 0; }
4041 }
4042 ################################################################################
4043  
4044 =head2 isTextnode - return 0 or 1 depending on whether current record is a textnode
4045  
4046 =cut
4047  
4048 sub isTextnode
4049 {
4050 0 ▶ my $self = shift;
Subroutine isTextnode: not called CC=2 SCAR=17.9
Pod documented
4051 0 ▶ if ($self -> {'RecordType'} == TEXTNODE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 20) { } 0 0 0
4052 0 else { 0; }
4053 }
4054 ################################################################################
4055  
4056 =head2 isNode - return 0 or 1 depending on whether current record is a node
4057  
4058 =cut
4059  
4060 sub isNode
4061 {
4062 0 ▶ my $self = shift;
Subroutine isNode: not called CC=2 SCAR=17.9
Pod documented
4063 0 ▶ if ($self -> {'RecordType'} == NODE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 21) { } 0 0 0
4064 0 else { 0; }
4065 }
4066 ################################################################################
4067  
4068 =head2 isTexttype - return 0 or 1 depending on whether current record is a texttype
4069  
4070 =cut
4071  
4072 sub isTexttype
4073 {
4074 0 ▶ my $self = shift;
Subroutine isTexttype: not called CC=2 SCAR=17.9
Pod documented
4075 0 ▶ if ($self -> {'RecordType'} == TEXTTYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 22) { } 0 0 0
4076 0 else { 0; }
4077 }
4078 ################################################################################
4079  
4080 =head2 isPresentation - return 0 or 1 depending on whether current record is a presentation
4081  
4082 =cut
4083  
4084 sub isPresentation
4085 {
4086 0 ▶ my $self = shift;
Subroutine isPresentation: not called CC=2 SCAR=17.9
Pod documented
4087 0 ▶ if ($self -> {'RecordType'} == PRESENTATION) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 23) { } 0 0 0
4088 0 else { 0; }
4089 }
4090 ################################################################################
4091  
4092 =head2 isSpacing - return 0 or 1 depending on whether current record is a spacing
4093  
4094 =cut
4095  
4096 sub isSpacing
4097 {
4098 0 ▶ my $self = shift;
Subroutine isSpacing: not called CC=2 SCAR=17.9
Pod documented
4099 0 ▶ if ($self -> {'RecordType'} == SPACING) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 24) { } 0 0 0
4100 0 else { 0; }
4101 }
4102 ################################################################################
4103  
4104 =head2 isString - return 0 or 1 depending on whether current record is a string
4105  
4106 =cut
4107  
4108 sub isString
4109 {
4110 0 ▶ my $self = shift;
Subroutine isString: not called CC=2 SCAR=17.9
Pod documented
4111 0 ▶ if ($self -> {'RecordType'} == STRING) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 25) { } 0 0 0
4112 0 else { 0; }
4113 }
4114 ################################################################################
4115  
4116 =head2 isStrans - return 0 or 1 depending on whether current record is a strans
4117  
4118 =cut
4119  
4120 sub isStrans
4121 {
4122 0 ▶ my $self = shift;
Subroutine isStrans: not called CC=2 SCAR=17.9
Pod documented
4123 0 ▶ if ($self -> {'RecordType'} == STRANS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 26) { } 0 0 0
4124 0 else { 0; }
4125 }
4126 ################################################################################
4127  
4128 =head2 isMag - return 0 or 1 depending on whether current record is a mag
4129  
4130 =cut
4131  
4132 sub isMag
4133 {
4134 0 ▶ my $self = shift;
Subroutine isMag: not called CC=2 SCAR=17.9
Pod documented
4135 0 ▶ if ($self -> {'RecordType'} == MAG) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 27) { } 0 0 0
4136 0 else { 0; }
4137 }
4138 ################################################################################
4139  
4140 =head2 isAngle - return 0 or 1 depending on whether current record is a angle
4141  
4142 =cut
4143  
4144 sub isAngle
4145 {
4146 0 ▶ my $self = shift;
Subroutine isAngle: not called CC=2 SCAR=17.9
Pod documented
4147 0 ▶ if ($self -> {'RecordType'} == ANGLE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 28) { } 0 0 0
4148 0 else { 0; }
4149 }
4150 ################################################################################
4151  
4152 =head2 isUinteger - return 0 or 1 depending on whether current record is a uinteger
4153  
4154 =cut
4155  
4156 sub isUinteger
4157 {
4158 0 ▶ my $self = shift;
Subroutine isUinteger: not called CC=2 SCAR=17.9
Pod documented
4159 0 ▶ if ($self -> {'RecordType'} == UINTEGER) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 29) { } 0 0 0
4160 0 else { 0; }
4161 }
4162 ################################################################################
4163  
4164 =head2 isUstring - return 0 or 1 depending on whether current record is a ustring
4165  
4166 =cut
4167  
4168 sub isUstring
4169 {
4170 0 ▶ my $self = shift;
Subroutine isUstring: not called CC=2 SCAR=17.9
Pod documented
4171 0 ▶ if ($self -> {'RecordType'} == USTRING) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 30) { } 0 0 0
4172 0 else { 0; }
4173 }
4174 ################################################################################
4175  
4176 =head2 isReflibs - return 0 or 1 depending on whether current record is a reflibs
4177  
4178 =cut
4179  
4180 sub isReflibs
4181 {
4182 0 ▶ my $self = shift;
Subroutine isReflibs: not called CC=2 SCAR=17.9
Pod documented
4183 0 ▶ if ($self -> {'RecordType'} == REFLIBS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 31) { } 0 0 0
4184 0 else { 0; }
4185 }
4186 ################################################################################
4187  
4188 =head2 isFonts - return 0 or 1 depending on whether current record is a fonts
4189  
4190 =cut
4191  
4192 sub isFonts
4193 {
4194 0 ▶ my $self = shift;
Subroutine isFonts: not called CC=2 SCAR=17.9
Pod documented
4195 0 ▶ if ($self -> {'RecordType'} == FONTS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 32) { } 0 0 0
4196 0 else { 0; }
4197 }
4198 ################################################################################
4199  
4200 =head2 isPathtype - return 0 or 1 depending on whether current record is a pathtype
4201  
4202 =cut
4203  
4204 sub isPathtype
4205 {
4206 0 ▶ my $self = shift;
Subroutine isPathtype: not called CC=2 SCAR=17.9
Pod documented
4207 0 ▶ if ($self -> {'RecordType'} == PATHTYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 33) { } 0 0 0
4208 0 else { 0; }
4209 }
4210 ################################################################################
4211  
4212 =head2 isGenerations - return 0 or 1 depending on whether current record is a generations
4213  
4214 =cut
4215  
4216 sub isGenerations
4217 {
4218 0 ▶ my $self = shift;
Subroutine isGenerations: not called CC=2 SCAR=17.9
Pod documented
4219 0 ▶ if ($self -> {'RecordType'} == GENERATIONS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 34) { } 0 0 0
4220 0 else { 0; }
4221 }
4222 ################################################################################
4223  
4224 =head2 isAttrtable - return 0 or 1 depending on whether current record is a attrtable
4225  
4226 =cut
4227  
4228 sub isAttrtable
4229 {
4230 0 ▶ my $self = shift;
Subroutine isAttrtable: not called CC=2 SCAR=17.9
Pod documented
4231 0 ▶ if ($self -> {'RecordType'} == ATTRTABLE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 35) { } 0 0 0
4232 0 else { 0; }
4233 }
4234 ################################################################################
4235  
4236 =head2 isStyptable - return 0 or 1 depending on whether current record is a styptable
4237  
4238 =cut
4239  
4240 sub isStyptable
4241 {
4242 0 ▶ my $self = shift;
Subroutine isStyptable: not called CC=2 SCAR=17.9
Pod documented
4243 0 ▶ if ($self -> {'RecordType'} == STYPTABLE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 36) { } 0 0 0
4244 0 else { 0; }
4245 }
4246 ################################################################################
4247  
4248 =head2 isStrtype - return 0 or 1 depending on whether current record is a strtype
4249  
4250 =cut
4251  
4252 sub isStrtype
4253 {
4254 0 ▶ my $self = shift;
Subroutine isStrtype: not called CC=2 SCAR=17.9
Pod documented
4255 0 ▶ if ($self -> {'RecordType'} == STRTYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 37) { } 0 0 0
4256 0 else { 0; }
4257 }
4258 ################################################################################
4259  
4260 =head2 isEflags - return 0 or 1 depending on whether current record is a eflags
4261  
4262 =cut
4263  
4264 sub isEflags
4265 {
4266 0 ▶ my $self = shift;
Subroutine isEflags: not called CC=2 SCAR=17.9
Pod documented
4267 0 ▶ if ($self -> {'RecordType'} == EFLAGS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 38) { } 0 0 0
4268 0 else { 0; }
4269 }
4270 ################################################################################
4271  
4272 =head2 isElkey - return 0 or 1 depending on whether current record is a elkey
4273  
4274 =cut
4275  
4276 sub isElkey
4277 {
4278 0 ▶ my $self = shift;
Subroutine isElkey: not called CC=2 SCAR=17.9
Pod documented
4279 0 ▶ if ($self -> {'RecordType'} == ELKEY) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 39) { } 0 0 0
4280 0 else { 0; }
4281 }
4282 ################################################################################
4283  
4284 =head2 isLinktype - return 0 or 1 depending on whether current record is a linktype
4285  
4286 =cut
4287  
4288 sub isLinktype
4289 {
4290 0 ▶ my $self = shift;
Subroutine isLinktype: not called CC=2 SCAR=17.9
Pod documented
4291 0 ▶ if ($self -> {'RecordType'} == LINKTYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 40) { } 0 0 0
4292 0 else { 0; }
4293 }
4294 ################################################################################
4295  
4296 =head2 isLinkkeys - return 0 or 1 depending on whether current record is a linkkeys
4297  
4298 =cut
4299  
4300 sub isLinkkeys
4301 {
4302 0 ▶ my $self = shift;
Subroutine isLinkkeys: not called CC=2 SCAR=17.9
Pod documented
4303 0 ▶ if ($self -> {'RecordType'} == LINKKEYS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 41) { } 0 0 0
4304 0 else { 0; }
4305 }
4306 ################################################################################
4307  
4308 =head2 isNodetype - return 0 or 1 depending on whether current record is a nodetype
4309  
4310 =cut
4311  
4312 sub isNodetype
4313 {
4314 0 ▶ my $self = shift;
Subroutine isNodetype: not called CC=2 SCAR=17.9
Pod documented
4315 0 ▶ if ($self -> {'RecordType'} == NODETYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 42) { } 0 0 0
4316 0 else { 0; }
4317 }
4318 ################################################################################
4319  
4320 =head2 isPropattr - return 0 or 1 depending on whether current record is a propattr
4321  
4322 =cut
4323  
4324 sub isPropattr
4325 {
4326 0 ▶ my $self = shift;
Subroutine isPropattr: not called CC=2 SCAR=17.9
Pod documented
4327 0 ▶ if ($self -> {'RecordType'} == PROPATTR) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 43) { } 0 0 0
4328 0 else { 0; }
4329 }
4330 ################################################################################
4331  
4332 =head2 isPropvalue - return 0 or 1 depending on whether current record is a propvalue
4333  
4334 =cut
4335  
4336 sub isPropvalue
4337 {
4338 0 ▶ my $self = shift;
Subroutine isPropvalue: not called CC=2 SCAR=17.9
Pod documented
4339 0 ▶ if ($self -> {'RecordType'} == PROPVALUE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 44) { } 0 0 0
4340 0 else { 0; }
4341 }
4342 ################################################################################
4343  
4344 =head2 isBox - return 0 or 1 depending on whether current record is a box
4345  
4346 =cut
4347  
4348 sub isBox
4349 {
4350 0 ▶ my $self = shift;
Subroutine isBox: not called CC=2 SCAR=17.9
Pod documented
4351 0 ▶ if ($self -> {'RecordType'} == BOX) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 45) { } 0 0 0
4352 0 else { 0; }
4353 }
4354 ################################################################################
4355  
4356 =head2 isBoxtype - return 0 or 1 depending on whether current record is a boxtype
4357  
4358 =cut
4359  
4360 sub isBoxtype
4361 {
4362 0 ▶ my $self = shift;
Subroutine isBoxtype: not called CC=2 SCAR=17.9
Pod documented
4363 0 ▶ if ($self -> {'RecordType'} == BOXTYPE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 46) { } 0 0 0
4364 0 else { 0; }
4365 }
4366 ################################################################################
4367  
4368 =head2 isPlex - return 0 or 1 depending on whether current record is a plex
4369  
4370 =cut
4371  
4372 sub isPlex
4373 {
4374 0 ▶ my $self = shift;
Subroutine isPlex: not called CC=2 SCAR=17.9
Pod documented
4375 0 ▶ if ($self -> {'RecordType'} == PLEX) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 47) { } 0 0 0
4376 0 else { 0; }
4377 }
4378 ################################################################################
4379  
4380 =head2 isBgnextn - return 0 or 1 depending on whether current record is a bgnextn
4381  
4382 =cut
4383  
4384 sub isBgnextn
4385 {
4386 0 ▶ my $self = shift;
Subroutine isBgnextn: not called CC=2 SCAR=17.9
Pod documented
4387 0 ▶ if ($self -> {'RecordType'} == BGNEXTN) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 48) { } 0 0 0
4388 0 else { 0; }
4389 }
4390 ################################################################################
4391  
4392 =head2 isEndextn - return 0 or 1 depending on whether current record is a endextn
4393  
4394 =cut
4395  
4396 sub isEndextn
4397 {
4398 0 ▶ my $self = shift;
Subroutine isEndextn: not called CC=2 SCAR=17.9
Pod documented
4399 0 ▶ if ($self -> {'RecordType'} == ENDEXTN) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 49) { } 0 0 0
4400 0 else { 0; }
4401 }
4402 ################################################################################
4403  
4404 =head2 isTapenum - return 0 or 1 depending on whether current record is a tapenum
4405  
4406 =cut
4407  
4408 sub isTapenum
4409 {
4410 0 ▶ my $self = shift;
Subroutine isTapenum: not called CC=2 SCAR=17.9
Pod documented
4411 0 ▶ if ($self -> {'RecordType'} == TAPENUM) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 50) { } 0 0 0
4412 0 else { 0; }
4413 }
4414 ################################################################################
4415  
4416 =head2 isTapecode - return 0 or 1 depending on whether current record is a tapecode
4417  
4418 =cut
4419  
4420 sub isTapecode
4421 {
4422 0 ▶ my $self = shift;
Subroutine isTapecode: not called CC=2 SCAR=17.9
Pod documented
4423 0 ▶ if ($self -> {'RecordType'} == TAPECODE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 51) { } 0 0 0
4424 0 else { 0; }
4425 }
4426 ################################################################################
4427  
4428 =head2 isStrclass - return 0 or 1 depending on whether current record is a strclass
4429  
4430 =cut
4431  
4432 sub isStrclass
4433 {
4434 0 ▶ my $self = shift;
Subroutine isStrclass: not called CC=2 SCAR=17.9
Pod documented
4435 0 ▶ if ($self -> {'RecordType'} == STRCLASS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 52) { } 0 0 0
4436 0 else { 0; }
4437 }
4438 ################################################################################
4439  
4440 =head2 isReserved - return 0 or 1 depending on whether current record is a reserved
4441  
4442 =cut
4443  
4444 sub isReserved
4445 {
4446 0 ▶ my $self = shift;
Subroutine isReserved: not called CC=2 SCAR=17.9
Pod documented
4447 0 ▶ if ($self -> {'RecordType'} == RESERVED) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 53) { } 0 0 0
4448 0 else { 0; }
4449 }
4450 ################################################################################
4451  
4452 =head2 isFormat - return 0 or 1 depending on whether current record is a format
4453  
4454 =cut
4455  
4456 sub isFormat
4457 {
4458 0 ▶ my $self = shift;
Subroutine isFormat: not called CC=2 SCAR=17.9
Pod documented
4459 0 ▶ if ($self -> {'RecordType'} == FORMAT) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 54) { } 0 0 0
4460 0 else { 0; }
4461 }
4462 ################################################################################
4463  
4464 =head2 isMask - return 0 or 1 depending on whether current record is a mask
4465  
4466 =cut
4467  
4468 sub isMask
4469 {
4470 0 ▶ my $self = shift;
Subroutine isMask: not called CC=2 SCAR=17.9
Pod documented
4471 0 ▶ if ($self -> {'RecordType'} == MASK) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 55) { } 0 0 0
4472 0 else { 0; }
4473 }
4474 ################################################################################
4475  
4476 =head2 isEndmasks - return 0 or 1 depending on whether current record is a endmasks
4477  
4478 =cut
4479  
4480 sub isEndmasks
4481 {
4482 0 ▶ my $self = shift;
Subroutine isEndmasks: not called CC=2 SCAR=17.9
Pod documented
4483 0 ▶ if ($self -> {'RecordType'} == ENDMASKS) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 56) { } 0 0 0
4484 0 else { 0; }
4485 }
4486 ################################################################################
4487  
4488 =head2 isLibdirsize - return 0 or 1 depending on whether current record is a libdirsize
4489  
4490 =cut
4491  
4492 sub isLibdirsize
4493 {
4494 0 ▶ my $self = shift;
Subroutine isLibdirsize: not called CC=2 SCAR=17.9
Pod documented
4495 0 ▶ if ($self -> {'RecordType'} == LIBDIRSIZE) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 57) { } 0 0 0
4496 0 else { 0; }
4497 }
4498 ################################################################################
4499  
4500 =head2 isLibsecur - return 0 or 1 depending on whether current record is a libsecur
4501  
4502 =cut
4503  
4504 sub isLibsecur
4505 {
4506 0 ▶ my $self = shift;
Subroutine isLibsecur: not called CC=2 SCAR=17.9
Pod documented
4507 0 ▶ if ($self -> {'RecordType'} == LIBSECUR) { 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 59) { } 0 0 0
4508 0 else { 0; }
4509 }
4510 ################################################################################
4511  
4512 ################################################################################
4513 ## support functions
4514  
4515 sub getRecordData
4516 {
4517 0 ▶ my $self = shift;
Subroutine getRecordData: not called CC=6 SCAR=37.4
Pod undocumented
4518 0 my $dt = $self -> {'DataType'};
4519 0 ▶ if ($dt==NO_REC_DATA)
Branch: 3 branches
BranchTrueFalseTotal
if ($dt == 0) { } 0 0 0
elsif ($dt == 2 or $dt == 3 or $dt == 5) { } 0 0 0
elsif ($dt == 6) { } 0 0 0
4520 {
4521 0 return '';
4522 }
4523 ▶ elsif ($dt==INTEGER_2 || $dt==INTEGER_4 || $dt==REAL_8)
Condition0%0/6
$dt == 2 or $dt == 3 or $dt == 5
l!l&&r!l&&!r
000
$dt == 2 or $dt == 3
l!l&&r!l&&!r
000
MC/DC0%0/3
$dt == 2 or $dt == 3 or $dt == 5
$dt == 2 $dt == 3 $dt == 5
Truth table0%0/4
A or B or C
A= $dt == 2B= $dt == 3C= $dt == 5
ABCresult
1XX1
01X1
0011
0000
4524 {
4525 0 my $stuff = $self -> {'CurrentDataList'};
4526 0 $stuff =~ s|^,||;
4527 0 return(split(/,/,$stuff));
4528 }
4529 elsif ($dt==ACSII_STRING)
4530 {
4531 0 my $stuff = $self -> {'CurrentDataList'};
4532 0 $stuff =~ s|\0||g;
4533 0 return($stuff);
4534 }
4535 else ## bit_array
4536 {
4537 0 return ($self -> {'CurrentDataList'});
4538 }
4539 }
4540 ################################################################################
4541  
4542 sub readRecordTypeAndData
4543 {
4544 0 ▶ my $self = shift;
Subroutine readRecordTypeAndData: not called CC=1 SCAR=6.9
Pod undocumented
4545 0 return ($RecordTypeStrings[$self -> {'RecordType'}],$self -> {'RecordData'});
4546 }
4547 ################################################################################
4548  
4549 sub skipGds2RecordData
4550 {
4551 24 ▶ my $self = shift;
Subroutine skipGds2RecordData: called CC=2 SCAR=7.0
Pod undocumented
4552 24 ▶ $self -> readGds2RecordHeader() if ($self -> {'INHEADER'} != TRUE); ## safety - need to read HEADER if INHEADER == UNKNOWN or FALSE
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"INHEADER"} != 1 0 24 24
4553 24 $self -> {'INHEADER'} = FALSE;
4554 24 $self -> {'INDATA'} = TRUE; # in DATA - actually will be at the end of data by the time we test this...
4555 ## 4 should have been just read by readGds2RecordHeader
4556 24 seek($self -> {'FileHandle'},$self -> {'Length'} - 4,SEEK_CUR); ## seek seems to run a little faster than read
4557 24 $self -> {'DataIndex'} = UNKNOWN;
4558 24 return 1;
4559 }
4560 ################################################################################
4561  
4562 ### return number of XY coords if XY record
4563 sub returnNumCoords
4564 {
4565 0 ▶ my $self = shift;
Subroutine returnNumCoords: not called CC=2 SCAR=17.9
Pod undocumented
4566 0 ▶ if ($self -> {'RecordType'} == XY) ## 4 byte signed integer
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'RecordType'} == 16) { } 0 0 0
4567 {
4568 0 int(($self -> {'Length'} - 4) / 8);
4569 }
4570 else
4571 {
4572 0 0;
4573 }
4574 }
4575 ################################################################################
4576  
4577 sub roundNum
4578 {
4579 0 ▶ my $self = shift;
Subroutine roundNum: not called CC=1 SCAR=6.9
Pod undocumented
4580 0 my $num = shift;
4581 0 my $places = shift;
4582 0 sprintf("%.${places}f",$num);
4583 }
4584 ################################################################################
4585  
4586 sub scaleNum($$)
4587 {
4588 0 ▶ my $num=shift;
Subroutine scaleNum: not called CC=3 SCAR=24.8
Pod undocumented
4589 0 my $scale=shift;
4590 0 ▶ die "1st number passed into scaleNum() must be an integer $!" if ($num !~ m|^-?\d+|);
Branch: 1 branch
BranchTrueFalseTotal
unless $num =~ /^-?\d+/ 0 0 0
4591 0 $num = $num * $scale;
4592 0 ▶ $num = int($num+0.5) if ($num =~ m|\.|);
Branch: 1 branch
BranchTrueFalseTotal
if $num =~ /\./ 0 0 0
4593 0 $num;
4594 }
4595 ################################################################################
4596  
4597 sub snapNum($$)
4598 {
4599 0 ▶ my $num=shift;
Subroutine snapNum: not called CC=5 SCAR=34.0
Pod undocumented
4600 0 ▶ die "1st number passed into snapNum() must be an integer $!" if ($num !~ m|^-?\d+$|);
Branch: 1 branch
BranchTrueFalseTotal
unless $num =~ /^-?\d+$/ 0 0 0
4601 0 my $snap=shift;
4602 0 my $snapLength = length("$snap");
4603 0 my $lean=1; ##init
4604 0 ▶ $lean = -1 if($num < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $num < 0 0 0 0
4605 ## snap to grid..
4606 0 my $littlePart=substr($num,-$snapLength,$snapLength);
4607 0 ▶ if($num<0)
Branch: 1 branch
BranchTrueFalseTotal
if ($num < 0) 0 0 0
4608 {
4609 0 $littlePart = -$littlePart;
4610 }
4611 0 $littlePart = int(($littlePart/$snap)+(0.5*$lean))*$snap;
4612 0 my $bigPart=substr($num,0,-$snapLength);
4613 0 ▶ if ($bigPart =~ m|^[-]?$|)
Branch: 1 branch
BranchTrueFalseTotal
if ($bigPart =~ /^[-]?$/) { } 0 0 0
4614 {
4615 0 $bigPart=0;
4616 }
4617 else
4618 {
4619 0 $bigPart *= 10**$snapLength;
4620 }
4621 0 $num = $bigPart + $littlePart;
4622 0 $num;
4623 }
4624 ################################################################################
4625  
4626 sub DESTROY
4627 {
4628 8 ▶ my $self = shift;
Subroutine DESTROY: called CC=1 SCAR=0.0
4629 #warn "DESTROYing $self";
4630 }
4631 ################################################################################
4632  
4633 ################################################################################
4634 ## some vendor tools have trouble w/ negative angles and angles >= 360
4635 ## so we normalize to positive equivalent
4636 ################################################################################
4637 sub posAngle($)
4638 {
4639 0 ▶ my $angle = shift;
Subroutine posAngle: not called CC=3 SCAR=24.8
Pod undocumented
4640 0 ▶ $angle += 360.0 while ($angle < 0.0);
Branch: 1 branch
BranchTrueFalseTotal
$angle < 0 and do { $angle += 360 } 0 0 0
4641 0 ▶ $angle -= 360.0 while ($angle >= 360.0);
Branch: 1 branch
BranchTrueFalseTotal
$angle >= 360 and do { $angle -= 360 } 0 0 0
4642 0 $angle = cleanFloatNum($angle);
4643 0 $angle;
4644 }
4645 ################################################################################
4646  
4647 =head2 recordSize - return current record size
4648  
4649 usage:
4650 my $len = $gds2File -> recordSize;
4651  
4652  
4653 =cut
4654  
4655 sub recordSize()
4656 {
4657 0 ▶ my $self = shift;
Subroutine recordSize: not called CC=1 SCAR=6.9
Pod documented
4658 0 $self -> {'Length'};
4659 }
4660 ################################################################################
4661  
4662 =head2 dataSize - return current record size - 4 (length of data)
4663  
4664 usage:
4665 my $dataLen = $gds2File -> dataSize;
4666  
4667  
4668 =cut
4669  
4670 sub dataSize()
4671 {
4672 0 ▶ my $self = shift;
Subroutine dataSize: not called CC=1 SCAR=6.9
Pod documented
4673 0 $self -> {'Length'} - 4;
4674 }
4675 ################################################################################
4676  
4677 =head2 returnUnitsAsArray - return user units and database units as a 2 element array
4678  
4679 usage:
4680 my ($uu,$dbu) = $gds2File -> returnUnitsAsArray;
4681  
4682  
4683 =cut
4684  
4685 sub returnUnitsAsArray
4686 {
4687 0 ▶ my $self = shift;
Subroutine returnUnitsAsArray: not called CC=2 SCAR=17.9
Pod documented
4688 0 ▶ if ($self -> isUnits) { ($self -> {'UUnits'}, $self -> {'DBUnits'}); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isUnits) { } 0 0 0
4689 0 else { () }
4690 }
4691 ################################################################################
4692  
4693 #######
4694 sub subbyte() ## GDS2::version();
4695 {
4696 0 ▶ my($what,$where,$howmuch) = @_;
Subroutine subbyte: not called CC=1 SCAR=6.9
Pod undocumented
4697 0 unpack("x$where C$howmuch", $what);
4698 }
4699 ################################################################################
4700  
4701 =head2 version - return GDS2 module version string
4702  
4703 =cut
4704  
4705 #######
4706 sub version() ## GDS2::version();
4707 {
4708 0 ▶ return $GDS2::VERSION;
Subroutine version: not called CC=1 SCAR=6.9
Pod documented
4709 }
4710 ################################################################################
4711  
4712 =head2 version - return GDS2 module revision string
4713  
4714 =cut
4715  
4716 #######
4717 sub revision() ## GDS2::revision();
4718 {
4719 0 ▶ return $GDS2::revision;
Subroutine revision: not called CC=1 SCAR=6.9
Pod documented
4720 }
4721 ################################################################################
4722  
4723 sub getElmSpace
4724 {
4725 150 ▶ return $ElmSpace;
Subroutine getElmSpace: called CC=1 SCAR=0.0
Pod undocumented
4726 }
4727 ################################################################################
4728  
4729 sub putElmSpace
4730 {
4731 60 ▶ $ElmSpace = shift;
Subroutine putElmSpace: called CC=1 SCAR=0.0
Pod undocumented
4732 }
4733 ################################################################################
4734  
4735 sub getStrSpace
4736 {
4737 164 ▶ return $StrSpace;
Subroutine getStrSpace: called CC=1 SCAR=0.0
Pod undocumented
4738 }
4739 ################################################################################
4740  
4741 sub putStrSpace
4742 {
4743 18 ▶ $StrSpace = shift;
Subroutine putStrSpace: called CC=1 SCAR=0.0
Pod undocumented
4744 }
4745 ################################################################################
4746  
4747 6 1;
4748 }
4749  
4750 __END__
↑ Summary