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@4363 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5f00ce7606
commit
fb97158615
1 changed files with 16 additions and 8 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue