aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/JavaEmitter.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-03-25 12:45:41 +0100
committerSven Gothel <[email protected]>2015-03-25 12:45:41 +0100
commitd30a3ea54e26978d6ff199cba0fd79c5c0cef483 (patch)
treee772b1e8acf627e2e7ad4bec56148f75dd5e7d7b /src/java/com/jogamp/gluegen/JavaEmitter.java
parent6058af19f2929a39deb0dbcc48040a4bb53bb559 (diff)
Bug 1149: Fix parsing of hexadecimal w/ binary exponent floats in regexp-constant and java-parser. (Due to PCPP -> JCPP)
Lack of parsing binary exponent floats is exposed due to using JCPP and correct constant-definitions. - JavaParser.g: - Add support for hexadecimal w/ binary exponent floats - TAB -> 4 spaces - ConstantDefinition.java: - Add RegExp 'fpRegexp', patternDecimalNumber: decimal number w/ support for hexadecimal w/ binary exponent floats. - isDecimalNumber(..): Use patternDecimalNumber instead of try-and-error (NumberFormatException) - patternCPPOperand: exclude patternDecimalNumber! - JavaEmitter.java: - Respect explicit suffix [dD] for double type. - Drop floating point suffixes [fF] - Test: Added tests for hexadecimal w/ binary exponent floats
Diffstat (limited to 'src/java/com/jogamp/gluegen/JavaEmitter.java')
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index ae4ed2a..5fb281f 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -384,7 +384,7 @@ public class JavaEmitter implements GlueEmitter {
final double dVal = Double.parseDouble(value);
final double absVal = Math.abs(dVal);
// if constant is small enough, store it as a float instead of a double
- if (absVal < Float.MIN_VALUE || absVal > Float.MAX_VALUE) {
+ if (absVal < Float.MIN_VALUE || absVal > Float.MAX_VALUE || lastChar == 'd' || lastChar == 'D' ) {
return new Double(dVal);
}
return new Float((float) dVal);
@@ -448,10 +448,11 @@ public class JavaEmitter implements GlueEmitter {
javaWriter().println(" /** " + optionalComment + " */");
}
String suffix = "";
- if(!value.endsWith(")")) {
- if (type.equals("float") && !value.endsWith("f")) {
+ final char lastChar = value.charAt(value.length()-1);
+ if( lastChar != ')' ) {
+ if (type.equals("float") && lastChar != 'f' && lastChar != 'F' ) {
suffix = "f";
- }else if(value.endsWith("u") || value.endsWith("U")) {
+ }else if( lastChar == 'u' || lastChar == 'U' ) {
value = value.substring(0, value.length()-1);
}
}