IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 24, 2005, 7:20:52 AM (21 years ago)
Author:
eugene
Message:

working on images, non-flat structures, float[5][4]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libautocode/generate

    r4019 r4020  
    11#!/usr/bin/env perl
    22
     3$VERBOSE = 0;
     4if ($ARGV[0] eq "-v") { $VERBOSE = 1; shift @ARGV; }
    35if (@ARGV != 3) { die "generate (schema) (template) (output)\n"; }
    46
     
    4042
    4143        # not a simple key/value entry
    42         if ($key eq "FIELD") {
     44        if (($key eq "FIELD") || ($key eq "SUBSTRUCT") || ($key eq "SUBFIELD")) {
    4345            ($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; }
    4547            push @element, $element;
    4648            push @field,   $field;
     
    4850            push @comment, $comment;
    4951            push @unit,    $unit;
     52            push @mode,    $key;
    5053        }
    5154    }
     
    8992
    9093    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]
    9198        # add [\d\.] to match ascii-type formats
    9299        ($type, $length) = $format[$i] =~ m|^(\w+)\[(\d+)\]|;
     
    122129
    123130    for ($i = 0; $i < @field; $i++) {
     131        # skip SUBSTRUCT type of entries:
     132        if ($mode[$i] eq "SUBSTRUCT") { next; }
     133
    124134        ($type, $length) = $format[$i] =~ m|^(\w+)\[([\d\.]+)\]|;
    125135        if (!$type && !$length) { die "format must be specified for ASCII table"; }
     
    147157    print FILE "typedef struct {\n";
    148158    for ($i = 0; $i < @element; $i++) {
     159        # skip SUBFIELD entries
     160        if ($mode[$i] eq "SUBFIELD") { next; }
     161
    149162        ($type, $length) = $format[$i] =~ m|^(\w+)\[([\d\.]+)\]|;
    150163        if (!$type && !$length) { $type = $format[$i]; }
     
    169182    $N = 0;
    170183    for ($i = 0; $i < @field; $i++) {
     184        # skip SUBSTRUCT type of entries:
     185        if ($mode[$i] eq "SUBSTRUCT") { next; }
     186
    171187        ($type, $length) = $format[$i] =~ m|^(\w+)\[([\d\.]+)\]|;
    172188        if (!$type && !$length) { $type = $format[$i]; }
     
    219235    $Nbytes = 0;
    220236    for ($i = 0; $i < @field; $i++) {
     237        # skip SUBSTRUCT type of entries:
     238        if ($mode[$i] eq "SUBSTRUCT") { next; }
    221239
    222240        # add [\d\.] to match ascii-type formats
     
    250268    $Nbytes = 0;
    251269    for ($i = 0; $i < @field; $i++) {
     270        # skip SUBSTRUCT type of entries:
     271        if ($mode[$i] eq "SUBSTRUCT") { next; }
     272
    252273        ($length) = $format[$i] =~ m|^\w+\[([\d\.]+)\]|;
    253274        if ($length == 0) { die "ASCII table format requires field size"; }
Note: See TracChangeset for help on using the changeset viewer.