my $ut;
my $utf;
my $fc;
+ my $fn;
if ($t eq '_common_') {
$ff = $f;
$ut = '';
$utf = ucfirst $t;
$fc = $event->getFieldComment($f);
}
+ $fn = ucfirst $ff->{name};
+ my @a = ($fn =~ /_(.)/g);
+ while (@a) { my $c = uc shift @a; $fn =~ s/_(.)/$c/; }
if ($ff->{codes}) {
gen qq{
! /** $fc */
-! enum ${utf}Code \{
+! enum ${utf}${fn}Code \{
};
for (@{$ff->{codes}}) {
gen qq{
my $c = "${fn}"; # code
my $enum = "enum edg_wll\_$c"; # enum name
my $char = "edg_wll\_${fn}Names"; # char name
+ my $null = $f->{null} ? $f->{null} : 0;
# static const char:
gen qq{
/**
my $c = "$t${fn}"; # code
my $enum = "enum edg_wll\_$c"; # enum name
my $char = "edg_wll\_$t${fn}Names"; # char name
+ my $null = $f->{null} ? $f->{null} : 0;
# static const char:
gen qq{
/**
unsigned int i;
for (i=1; i<sizeof($char)/sizeof(${char}\[0\]); i++)
- if (strcasecmp(${char}\[i\],name) == 0) return ($enum) i;
+ if (strcasecmp(${char}\[i\],name) == 0) return ($enum) i + ($null);
return ($enum) EDG_WLL_${tu}UNDEFINED;
\}
\n};
*/
char *edg_wll\_${c}ToString($enum code)
\{
- if ((int)code < 0 || code >= sizeof($char)/sizeof(${char}\[0\])) return NULL;
- return strdup(${char}\[code\]);
+ if ((int)code - ($null) < 0 || code - ($null) >= sizeof($char)/sizeof(${char}\[0\])) return NULL;
+ return strdup(${char}\[code - ($null)\]);
\}
\n\n};