Changeset 4020 for trunk/Ohana/src/libautocode/generate
- Timestamp:
- May 24, 2005, 7:20:52 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libautocode/generate (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libautocode/generate
r4019 r4020 1 1 #!/usr/bin/env perl 2 2 3 $VERBOSE = 0; 4 if ($ARGV[0] eq "-v") { $VERBOSE = 1; shift @ARGV; } 3 5 if (@ARGV != 3) { die "generate (schema) (template) (output)\n"; } 4 6 … … 40 42 41 43 # not a simple key/value entry 42 if ($key eq "FIELD") {44 if (($key eq "FIELD") || ($key eq "SUBSTRUCT") || ($key eq "SUBFIELD")) { 43 45 ($element, $field, $format, $comment, $unit) = split (/,\s+/, $value, 5); 44 # print "$element : $field : $format : $comment : $unit\n"; 46 if ($VERBOSE) { printf "%-20s %-20s %-15s %-35s %-10s\n", $element, $field, $format, $comment, $unit; } 45 47 push @element, $element; 46 48 push @field, $field; … … 48 50 push @comment, $comment; 49 51 push @unit, $unit; 52 push @mode, $key; 50 53 } 51 54 } … … 89 92 90 93 for ($i = 0; $i < @field; $i++) { 94 # skip SUBSTRUCT type of entries: 95 if ($mode[$i] eq "SUBSTRUCT") { next; } 96 97 # need to handle all structures like: float poly[5][4] 91 98 # add [\d\.] to match ascii-type formats 92 99 ($type, $length) = $format[$i] =~ m|^(\w+)\[(\d+)\]|; … … 122 129 123 130 for ($i = 0; $i < @field; $i++) { 131 # skip SUBSTRUCT type of entries: 132 if ($mode[$i] eq "SUBSTRUCT") { next; } 133 124 134 ($type, $length) = $format[$i] =~ m|^(\w+)\[([\d\.]+)\]|; 125 135 if (!$type && !$length) { die "format must be specified for ASCII table"; } … … 147 157 print FILE "typedef struct {\n"; 148 158 for ($i = 0; $i < @element; $i++) { 159 # skip SUBFIELD entries 160 if ($mode[$i] eq "SUBFIELD") { next; } 161 149 162 ($type, $length) = $format[$i] =~ m|^(\w+)\[([\d\.]+)\]|; 150 163 if (!$type && !$length) { $type = $format[$i]; } … … 169 182 $N = 0; 170 183 for ($i = 0; $i < @field; $i++) { 184 # skip SUBSTRUCT type of entries: 185 if ($mode[$i] eq "SUBSTRUCT") { next; } 186 171 187 ($type, $length) = $format[$i] =~ m|^(\w+)\[([\d\.]+)\]|; 172 188 if (!$type && !$length) { $type = $format[$i]; } … … 219 235 $Nbytes = 0; 220 236 for ($i = 0; $i < @field; $i++) { 237 # skip SUBSTRUCT type of entries: 238 if ($mode[$i] eq "SUBSTRUCT") { next; } 221 239 222 240 # add [\d\.] to match ascii-type formats … … 250 268 $Nbytes = 0; 251 269 for ($i = 0; $i < @field; $i++) { 270 # skip SUBSTRUCT type of entries: 271 if ($mode[$i] eq "SUBSTRUCT") { next; } 272 252 273 ($length) = $format[$i] =~ m|^\w+\[([\d\.]+)\]|; 253 274 if ($length == 0) { die "ASCII table format requires field size"; }
Note:
See TracChangeset
for help on using the changeset viewer.
