enumvalue attribute always has a value now. If there is no explicit value set

in the code being wrapped, then a value is constructed which is
1+ the previous enum value. For example:
enum numbers { zero, one, seven=7, eight};
has enumvalue attributes of '0', 'zero+1', '7' and 'seven+1'

Based on patch by Heiner Petith.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4363 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2003-02-19 23:06:10 +00:00
commit 2579240289

View file

@ -4061,17 +4061,25 @@ ename : ID { $$ = $1; }
/* SWIG enum list */
enumlist : enumlist COMMA edecl {
Node *n = Getattr($1,"_last");
if (!n) {
set_nextSibling($1,$3);
Setattr($1,"_last",$3);
} else {
set_nextSibling(n,$3);
Setattr($1,"_last",$3);
Node *leftSibling = Getattr($1,"_last");
if (!leftSibling) {
leftSibling=$1;
}
set_nextSibling(leftSibling,$3);
Setattr($1,"_last",$3);
if ($3 && !Getattr($3, "enumvalue")) {
/* There is no explicit enum value given, so make one. */
Setattr($3,"enumvalue", NewStringf("%s+1", Getattr(leftSibling,"name")));
}
$$ = $1;
}
| edecl { $$ = $1; }
| edecl {
$$ = $1;
if (!Getattr($1, "enumvalue")) {
/* first enum item value defaults to 0 */
Setattr($1,"enumvalue", "0");
}
}
;
edecl : ID {