diff options
author | Kenneth Russel <[email protected]> | 2007-02-27 22:56:30 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2007-02-27 22:56:30 +0000 |
commit | 173474fa26823a6a508344430ec0f4443e0bc8b9 (patch) | |
tree | d76af8ce28c3cc4aeeb917a79176171e42190bf6 /src/java/com/sun/gluegen | |
parent | 828dc89c33b8de399090e4d2c9a892611a3bd569 (diff) |
Incorporated fixes from Krishna Gadepalli in handling of enums
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/trunk@57 a78bb65f-1512-4460-ba86-f6dc96a7bf27
Diffstat (limited to 'src/java/com/sun/gluegen')
-rw-r--r-- | src/java/com/sun/gluegen/cgram/HeaderParser.g | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/java/com/sun/gluegen/cgram/HeaderParser.g b/src/java/com/sun/gluegen/cgram/HeaderParser.g index abb3de4..f91f146 100644 --- a/src/java/com/sun/gluegen/cgram/HeaderParser.g +++ b/src/java/com/sun/gluegen/cgram/HeaderParser.g @@ -594,13 +594,29 @@ enumList[EnumType enumeration] { enumerator[EnumType enumeration, long defaultValue] returns [long newDefaultValue] { newDefaultValue = defaultValue; } - : eName:ID ( ASSIGN eVal:expr )? { - // FIXME! Integer.parseInt() will throw if its argument is in octal or hex format. - long value = (eVal == null) ? defaultValue : Long.parseLong(eVal.getText()); + : eName:ID ( ASSIGN eVal:expr )? { + long value = 0; + if (eVal != null) { + String vTxt = eVal.getText(); + if (enumHash.containsKey(vTxt)) { + EnumType oldEnumType = (EnumType) enumHash.get(vTxt); + value = oldEnumType.getEnumValue(vTxt); + } else { + try { + value = Long.decode(vTxt).longValue(); + } catch (NumberFormatException e) { + System.err.println("NumberFormatException: " + enumerator_AST_in); + throw e; + } + } + } else { + value = defaultValue; + } + newDefaultValue = value+1; String eTxt = eName.getText(); if (enumHash.containsKey(eTxt)) { - EnumType oldEnumType = ((EnumType)enumHash.get(eTxt)); + EnumType oldEnumType = (EnumType) enumHash.get(eTxt); long oldValue = oldEnumType.getEnumValue(eTxt); System.err.println("WARNING: redefinition of enumerated value '" + eTxt + "';" + " existing definition is in enumeration '" + oldEnumType.getName() + |