Fix parsing of enum declaration and initialization
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11752 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f62c54c0f6
commit
7cb4e902d5
5 changed files with 58 additions and 5 deletions
|
|
@ -1,6 +1,15 @@
|
||||||
Version 1.3.41 (in progress)
|
Version 1.3.41 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2009-11-17: wsfulton
|
||||||
|
Fix parsing of enum declaration and initialization, for example:
|
||||||
|
|
||||||
|
enum ABC {
|
||||||
|
a,
|
||||||
|
b,
|
||||||
|
c
|
||||||
|
} A = a, *pC = &C, array[3] = {a, b, c};
|
||||||
|
|
||||||
2009-11-17: wsfulton
|
2009-11-17: wsfulton
|
||||||
Fix parsing of struct declaration and initialization, for example:
|
Fix parsing of struct declaration and initialization, for example:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance1;
|
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance1;
|
||||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance2;
|
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance2;
|
||||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance3;
|
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance3;
|
||||||
|
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
||||||
|
|
@ -64,7 +65,7 @@ typedef struct _iFoo
|
||||||
enum {
|
enum {
|
||||||
Phoo = +50,
|
Phoo = +50,
|
||||||
Char = 'a'
|
Char = 'a'
|
||||||
} e;
|
} e;
|
||||||
} iFoo;
|
} iFoo;
|
||||||
%}
|
%}
|
||||||
#else
|
#else
|
||||||
|
|
@ -77,5 +78,20 @@ struct iFoo
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
%}
|
%}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// enum declaration and initialization
|
||||||
|
%inline %{
|
||||||
|
enum Exclamation {
|
||||||
|
goodness,
|
||||||
|
gracious,
|
||||||
|
me
|
||||||
|
} enumInstance = me;
|
||||||
|
|
||||||
|
enum ContainYourself {
|
||||||
|
slap = 10,
|
||||||
|
my,
|
||||||
|
thigh
|
||||||
|
} Slap = slap, My = my, Thigh = thigh, *pThigh = &Thigh, arrayContainYourself[3] = {slap, my, thigh};
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,19 @@ enums.bar2(1)
|
||||||
enums.bar3(1)
|
enums.bar3(1)
|
||||||
enums.bar1(1)
|
enums.bar1(1)
|
||||||
|
|
||||||
|
if (enums.cvar.enumInstance != 2)
|
||||||
|
error
|
||||||
|
endif
|
||||||
|
|
||||||
|
if (enums.cvar.Slap != 10)
|
||||||
|
error
|
||||||
|
endif
|
||||||
|
|
||||||
|
if (enums.cvar.My != 11)
|
||||||
|
error
|
||||||
|
endif
|
||||||
|
|
||||||
|
if (enums.cvar.Thigh != 12)
|
||||||
|
error
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,15 @@ _enums.bar2(1)
|
||||||
_enums.bar3(1)
|
_enums.bar3(1)
|
||||||
_enums.bar1(1)
|
_enums.bar1(1)
|
||||||
|
|
||||||
|
if _enums.cvar.enumInstance != 2:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if _enums.cvar.Slap != 10:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if _enums.cvar.My != 11:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if _enums.cvar.Thigh != 12:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3132,7 +3132,7 @@ c_enum_decl : storage_class ENUM ename LBRACE enumlist RBRACE SEMI {
|
||||||
add_symbols($$); /* Add to tag space */
|
add_symbols($$); /* Add to tag space */
|
||||||
add_symbols($5); /* Add enum values to id space */
|
add_symbols($5); /* Add enum values to id space */
|
||||||
}
|
}
|
||||||
| storage_class ENUM ename LBRACE enumlist RBRACE declarator c_decl_tail {
|
| storage_class ENUM ename LBRACE enumlist RBRACE declarator initializer c_decl_tail {
|
||||||
Node *n;
|
Node *n;
|
||||||
SwigType *ty = 0;
|
SwigType *ty = 0;
|
||||||
String *unnamed = 0;
|
String *unnamed = 0;
|
||||||
|
|
@ -3174,8 +3174,8 @@ c_enum_decl : storage_class ENUM ename LBRACE enumlist RBRACE SEMI {
|
||||||
SetFlag(n,"unnamedinstance");
|
SetFlag(n,"unnamedinstance");
|
||||||
Delete(cty);
|
Delete(cty);
|
||||||
}
|
}
|
||||||
if ($8) {
|
if ($9) {
|
||||||
Node *p = $8;
|
Node *p = $9;
|
||||||
set_nextSibling(n,p);
|
set_nextSibling(n,p);
|
||||||
while (p) {
|
while (p) {
|
||||||
SwigType *cty = Copy(ty);
|
SwigType *cty = Copy(ty);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue