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:
William S Fulton 2009-11-17 19:31:13 +00:00
commit 7cb4e902d5
5 changed files with 58 additions and 5 deletions

View file

@ -8,6 +8,7 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance1;
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance2;
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance3;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
%inline %{
@ -64,7 +65,7 @@ typedef struct _iFoo
enum {
Phoo = +50,
Char = 'a'
} e;
} e;
} iFoo;
%}
#else
@ -77,5 +78,20 @@ struct iFoo
};
};
%}
#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};
%}

View file

@ -5,3 +5,19 @@ enums.bar2(1)
enums.bar3(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

View file

@ -5,3 +5,15 @@ _enums.bar2(1)
_enums.bar3(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