diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/java/com/sun/gluegen/JavaEmitter.java | 11 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/cgram/GnuCParser.g | 4 | ||||
-rw-r--r-- | src/java/com/sun/gluegen/pcpp/PCPP.java | 2 |
3 files changed, 9 insertions, 8 deletions
diff --git a/src/java/com/sun/gluegen/JavaEmitter.java b/src/java/com/sun/gluegen/JavaEmitter.java index 0bf9702..60daf89 100644 --- a/src/java/com/sun/gluegen/JavaEmitter.java +++ b/src/java/com/sun/gluegen/JavaEmitter.java @@ -229,12 +229,12 @@ public class JavaEmitter implements GlueEmitter { try { // see if it's a double or float double dVal = Double.parseDouble(value); + double absVal = Math.abs(dVal); // if constant is small enough, store it as a float instead of a double - if (dVal > Float.MIN_VALUE && dVal < Float.MAX_VALUE) { - return new Float((float)dVal); + if (absVal < Float.MIN_VALUE || absVal > Float.MAX_VALUE) { + return new Double(dVal); } - return new Double(dVal); - + return new Float((float) dVal); } catch (NumberFormatException e2) { throw new RuntimeException( "Cannot emit define \""+name+"\": value \""+value+ @@ -281,7 +281,8 @@ public class JavaEmitter implements GlueEmitter { if (optionalComment != null && optionalComment.length() != 0) { javaWriter().println(" /** " + optionalComment + " */"); } - javaWriter().println(" public static final " + type + " " + name + " = " + value + ";"); + String suffix = (type.equals("float") ? "f" : ""); + javaWriter().println(" public static final " + type + " " + name + " = " + value + suffix + ";"); } } } diff --git a/src/java/com/sun/gluegen/cgram/GnuCParser.g b/src/java/com/sun/gluegen/cgram/GnuCParser.g index e087a5c..7de057c 100644 --- a/src/java/com/sun/gluegen/cgram/GnuCParser.g +++ b/src/java/com/sun/gluegen/cgram/GnuCParser.g @@ -777,7 +777,7 @@ protected NumberSuffix ; Number - : ( ( Digit )+ ( '.' | 'e' | 'E' ) )=> ( Digit )+ + : ( ('-')? ( Digit )+ ( '.' | 'e' | 'E' ) )=> ('-')? ( Digit )+ ( '.' ( Digit )* ( Exponent )? | Exponent ) @@ -797,7 +797,7 @@ Number ( NumberSuffix )* - | '1'..'9' ( Digit )* + | ('-')? '1'..'9' ( Digit )* ( NumberSuffix )* diff --git a/src/java/com/sun/gluegen/pcpp/PCPP.java b/src/java/com/sun/gluegen/pcpp/PCPP.java index d5d9604..e539cee 100644 --- a/src/java/com/sun/gluegen/pcpp/PCPP.java +++ b/src/java/com/sun/gluegen/pcpp/PCPP.java @@ -71,7 +71,7 @@ public class PCPP { tok.wordChars('A', 'Z'); tok.wordChars('0', '9'); tok.wordChars('_', '_'); - tok.wordChars('.', '.'); + tok.wordChars('-', '.'); tok.wordChars(128 + 32, 255); tok.whitespaceChars(0, ' '); tok.quoteChar('"'); |