In the %field hash store the field-qualifiers as an array instead of storing only a single qualifier.
This will allow for adding multiple qualifiers to the same field later on. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5379 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
0994ae8bba
commit
abad9943c6
|
@ -25,10 +25,8 @@ sub printStructFieldType
|
|||
sub preProcessField
|
||||
{
|
||||
my ($field, $comments) = @_;
|
||||
$_ = ${$field}{"qualifier"};
|
||||
$_ = "" unless $_;
|
||||
|
||||
if (/unique/)
|
||||
if (grep(/unique/, @{${$field}{"qualifiers"}}))
|
||||
{
|
||||
# Separate this notice from the rest of the comment if there's any
|
||||
push @{$comments}, "" if @{$comments};
|
||||
|
|
|
@ -95,7 +95,9 @@ sub parseStruct
|
|||
# Parse regular field declarations
|
||||
elsif (/^\s*(count|string|real|bool|IMD_model)\s+(unique\s+)?(\w+)\s*;\s*$/)
|
||||
{
|
||||
my %field = (type=>$1, qualifier=>$2, name=>$3);
|
||||
my %field = (type=>$1, name=>$3);
|
||||
|
||||
push @{$field{"qualifiers"}}, $2 if $2;
|
||||
|
||||
@{$field{"comment"}} = @curComment;
|
||||
@curComment = ();
|
||||
|
@ -105,7 +107,9 @@ sub parseStruct
|
|||
# Parse set and enum field declarations
|
||||
elsif (/^\s*(set|enum)\s+(\w+)\s+(unique\s+)?(\w+)\s*;\s*$/)
|
||||
{
|
||||
my %field = (type=>$1, enum=>$2, qualifier=>$3, name=>$4);
|
||||
my %field = (type=>$1, enum=>$2, name=>$4);
|
||||
|
||||
push @{$field{"qualifiers"}}, $3 if $3;
|
||||
|
||||
@{$field{"comment"}} = @curComment;
|
||||
@curComment = ();
|
||||
|
|
|
@ -58,20 +58,20 @@ sub printStructFields
|
|||
my $value = shift(@values);
|
||||
|
||||
$$output .= "\t${$field}{\"name\"}_${$value}{\"name\"} INTEGER NOT NULL";
|
||||
$$output .= "," if @values or @fields or @constraints or (${$field}{"qualifier"} and ${$field}{"qualifier"} =~ /unique/);
|
||||
$$output .= "," if @values or @fields or @constraints or grep(/unique/, @{${$field}{"qualifiers"}});
|
||||
$$output .= "\n";
|
||||
$unique_string .= "${$field}{\"name\"}_${$value}{\"name\"}";
|
||||
$unique_string .= ", " if @values;
|
||||
}
|
||||
|
||||
$unique_string .= ")";
|
||||
push @constraints, $unique_string if ${$field}{"qualifier"} and ${$field}{"qualifier"} =~ /unique/;
|
||||
push @constraints, $unique_string if grep(/unique/, @{${$field}{"qualifiers"}});
|
||||
}
|
||||
else
|
||||
{
|
||||
$$output .= "\t${$field}{\"name\"} ";
|
||||
printStructFieldType($output, $field);
|
||||
$$output .= " UNIQUE" if ${$field}{"qualifier"} and ${$field}{"qualifier"} =~ /unique/;
|
||||
$$output .= " UNIQUE" if grep(/unique/, @{${$field}{"qualifiers"}});
|
||||
$$output .= ",\n" if @fields or @constraints;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue