summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/com/jogamp/gluegen/pcpp/PCPP.java40
-rw-r--r--test/junit/com/jogamp/gluegen/PCPPTest.java13
-rw-r--r--test/junit/com/jogamp/gluegen/pcpptest.h74
3 files changed, 109 insertions, 18 deletions
diff --git a/src/java/com/jogamp/gluegen/pcpp/PCPP.java b/src/java/com/jogamp/gluegen/pcpp/PCPP.java
index 8ab1d28..907f36f 100644
--- a/src/java/com/jogamp/gluegen/pcpp/PCPP.java
+++ b/src/java/com/jogamp/gluegen/pcpp/PCPP.java
@@ -746,10 +746,10 @@ public class PCPP {
// Next token is the name of the #ifdef
String symbolName = nextWord();
- boolean enabledStatusBefore = enabled(); // condition or true
+ boolean enabledStatusWhole = enabled(); // whole block
boolean symbolIsDefined = defineMap.get(symbolName) != null;
- debugPrint(false, "#" + (isIfdef ? "ifdef " : "ifndef ") + symbolName + ", enabledBefore " + enabledStatusBefore + ", isDefined " + symbolIsDefined + ", file \"" + filename() + " line " + lineNumber());
+ debugPrint(false, "#" + (isIfdef ? "ifdef " : "ifndef ") + symbolName + ", enabledWhole " + enabledStatusWhole + ", isDefined " + symbolIsDefined + ", file \"" + filename() + " line " + lineNumber());
boolean enabledNow = enabled() && symbolIsDefined == isIfdef ;
pushEnableBit( enabledNow ) ; // condition
@@ -759,21 +759,23 @@ public class PCPP {
/** Handles #else directives */
private void handleElse() throws IOException {
popEnableBit(); // block
- boolean enabledStatusBefore = enabled(); // condition or true
- debugPrint(false, "#else, enabledBefore " + enabledStatusBefore + ", file \"" + filename() + " line " + lineNumber());
+ boolean enabledStatusCondition = enabled(); // condition
popEnableBit(); // condition
- pushEnableBit(!enabledStatusBefore); // don't care
- pushEnableBit(!enabledStatusBefore); // block
+ boolean enabledStatusWhole = enabled(); // whole block
+
+ debugPrint(false, "#else, enabledWhole " + enabledStatusWhole + ", file \"" + filename() + " line " + lineNumber());
+ pushEnableBit(enabledStatusWhole && !enabledStatusCondition); // don't care
+ pushEnableBit(enabledStatusWhole && !enabledStatusCondition); // block
}
private void handleEndif() {
popEnableBit(); // block
- boolean enabledStatusBefore = enabled();
popEnableBit(); // condition
+ boolean enabledStatusWhole = enabled();
// print the endif if we were enabled prior to popEnableBit() (sending
// false to debugPrint means "print regardless of current enabled() state).
- debugPrint(false, "#endif, enabledBefore " + enabledStatusBefore);
+ debugPrint(false, "#endif, enabledWhole " + enabledStatusWhole);
}
/**
@@ -781,25 +783,30 @@ public class PCPP {
* processing #elif.
*/
private void handleIf(boolean isIf) throws IOException {
+ boolean enabledStatusCondition = false;
+ boolean enabledStatusWhole;
+
if (!isIf) {
popEnableBit(); // block
+ enabledStatusCondition = enabled(); // condition
+ popEnableBit(); // condition
}
- boolean enabledStatusBefore = enabled(); // condition or true
+ enabledStatusWhole = enabled(); // whole block
+
boolean defineEvaluatedToTrue = handleIfRecursive(true);
- debugPrint(false, "#" + (isIf ? "if" : "elif") + ", enabledBefore " + enabledStatusBefore + ", eval " + defineEvaluatedToTrue + ", file \"" + filename() + " line " + lineNumber());
+ debugPrint(false, "#" + (isIf ? "if" : "elif") + ", enabledWhole " + enabledStatusWhole + ", eval " + defineEvaluatedToTrue + ", file \"" + filename() + " line " + lineNumber());
boolean enabledNow;
if(isIf) {
- enabledNow = enabledStatusBefore && defineEvaluatedToTrue ;
+ enabledNow = enabledStatusWhole && defineEvaluatedToTrue ;
pushEnableBit( enabledNow ) ; // condition
pushEnableBit( enabledNow ) ; // block
} else {
- popEnableBit(); // condition
- enabledNow = !enabledStatusBefore && defineEvaluatedToTrue ;
- pushEnableBit( enabledStatusBefore || enabledNow ) ; // condition: pass prev true condition
- pushEnableBit( enabledNow ) ; // block
+ enabledNow = enabledStatusWhole && !enabledStatusCondition && defineEvaluatedToTrue ;
+ pushEnableBit( enabledStatusCondition || enabledNow ) ; // condition: pass prev true condition
+ pushEnableBit( enabledNow ) ; // block
}
}
@@ -984,8 +991,7 @@ public class PCPP {
String fullname = findFile(filename);
//System.out.println("ACTIVE BLOCK, LOADING " + filename);
if (fullname == null) {
- LOG.log(WARNING, "unable to find #include file \"{0}\"", filename);
- return;
+ throw new RuntimeException("Can't find #include file \"" + filename + "\" at file " + filename() + ", line " + lineNumber());
}
// Process this file in-line
Reader reader = new BufferedReader(new FileReader(fullname));
diff --git a/test/junit/com/jogamp/gluegen/PCPPTest.java b/test/junit/com/jogamp/gluegen/PCPPTest.java
index 70b6a84..8e06646 100644
--- a/test/junit/com/jogamp/gluegen/PCPPTest.java
+++ b/test/junit/com/jogamp/gluegen/PCPPTest.java
@@ -68,7 +68,18 @@ public class PCPPTest {
"# 40 \"pcpptest.h\""+
"#54\"pcpptest.h\""+
" int TEST_D_GOOD;"+
- "#60\"pcpptest.h\"";
+ "#60\"pcpptest.h\""+
+ "#70\"pcpptest.h\""+
+ "#77\"pcpptest.h\""+
+ "#105\"pcpptest.h\""+
+ "#123\"pcpptest.h\""+
+ " int GOOD_F_1;"+
+ " int GOOD_F_2;"+
+ "#126\"pcpptest.h\""+
+ " int GOOD_G;"+
+ "#128\"pcpptest.h\""+
+ "#132\"pcpptest.h\""+
+ "#134\"pcpptest.h\"";
output.flush();
String result = output.toString();
diff --git a/test/junit/com/jogamp/gluegen/pcpptest.h b/test/junit/com/jogamp/gluegen/pcpptest.h
index e52cc5c..5a2d25a 100644
--- a/test/junit/com/jogamp/gluegen/pcpptest.h
+++ b/test/junit/com/jogamp/gluegen/pcpptest.h
@@ -57,3 +57,77 @@ int TEST_C;
int TEST_D_ERROR;
#endif
+#if (defined(__NO__) && defined(__NOPE__))
+ #define TEST_E_VAL ((long) 0x7FFFFFFFFFFFFFFFLL)
+#else
+ #define TEST_E_VAL ((long) 0x7FFFFFFFFFFFFFFFLL)
+#endif
+
+/***
+ ** STD API file ..
+ */
+
+#ifndef __test_h_
+#define __test_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined( __NANA__ )
+ #if defined( __MINGW64__ )
+ #include <cant_find_file_a.h>
+ #elif defined( __NONO__ )
+ #include <cant_find_file_b.h>
+ #else
+ #include <cant_find_file_c.h>
+ #endif
+ #if defined( __GNUC__ )
+ #include <cant_find_file_d.h>
+ #else
+ #include <cant_find_file_e.h>
+ #endif
+#else
+ #if defined( __MINGW64__ )
+ #include <cant_find_file_a.h>
+ #elif defined( __NONO__)
+ #include <cant_find_file_b.h>
+ #else
+ #define TEST_F_VAL1 GOOD_F_1
+ #endif
+ #if defined( __GNUC__ )
+ #include <cant_find_file_d.h>
+ #else
+ #define TEST_F_VAL2 GOOD_F_2
+ #endif
+#endif
+
+#if defined( __YES__ )
+ #if defined( __NONO__)
+ #include <cant_find_file_a.h>
+ #elif defined( __YES__)
+ #define TEST_G_VAL GOOD_G
+ #else
+ #include <cant_find_file_b.h>
+ #endif
+#else
+ #if defined( __MINGW64__ )
+ #include <cant_find_file_a.h>
+ #elif defined( __NONO__)
+ #include <cant_find_file_b.h>
+ #else
+ #include <cant_find_file_c.h>
+ #endif
+#endif
+
+int TEST_F_VAL1;
+int TEST_F_VAL2;
+
+int TEST_G_VAL;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __test_h_ */
+