Add a new enum-level directive: %max "param":
* This will add an enumerator to the end of the generated C enum code with "param" as its name (prefixed by the enum's name of course) git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5482 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
eb7bd7be49
commit
2a11247d7e
|
@ -173,7 +173,15 @@ sub printEnum()
|
|||
|
||||
$$output .= "\t${$enum}{\"name\"}_${name},\n";
|
||||
|
||||
$$output .= "\n" if @values;
|
||||
$$output .= "\n" if @values or exists(${${$enum}{"qualifiers"}}{"max"});
|
||||
}
|
||||
|
||||
if (exists(${${$enum}{"qualifiers"}}{"max"}))
|
||||
{
|
||||
$$output .= "\t/**\n"
|
||||
. "\t * The number of enumerators in this enum.\n"
|
||||
. "\t */\n"
|
||||
. "\t${$enum}{\"name\"}_${${$enum}{\"qualifiers\"}}{\"max\"},\n";
|
||||
}
|
||||
|
||||
# Finish printing the enum
|
||||
|
|
|
@ -32,6 +32,18 @@ sub parseEnum
|
|||
{
|
||||
push @curComment, substr($1, 1) if $1;
|
||||
}
|
||||
# Parse struct-level qualifiers
|
||||
elsif (/^\s*%(.*)\s*$/)
|
||||
{
|
||||
die "error: Cannot give enum-level qualifiers after defining fields" if exists($curEnum{"values"});
|
||||
|
||||
$_ = $1;
|
||||
|
||||
if (/^max\s+\"([^\"]+)\"\s*;$/)
|
||||
{
|
||||
${$curEnum{"qualifiers"}}{"max"} = $1;
|
||||
}
|
||||
}
|
||||
elsif (/^\s*(\w+)\s*$/)
|
||||
{
|
||||
my %value = (name=>$1);
|
||||
|
|
Loading…
Reference in New Issue