diff options
author | Sven Gothel <[email protected]> | 2010-11-07 23:44:00 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-11-07 23:44:00 +0100 |
commit | e024d6cab3b07ac2033630aac54e94d6494d8c5e (patch) | |
tree | 3ba91dd2a15cdb5c690b8c4374048bb5cb5dc203 /src/java/com | |
parent | 40ed7595d282f79eb332965c1684bb368674ac36 (diff) |
Fix PCPP 'define' case; Keep PCPP output file if 'debug' ; GlueGen uses PCPP in same thread via File.
Fix PCPP 'define' case
------------------------
A recursive define like:
#define LALA ((int)1)
#define LILI LALA
was streamed out of PCPP, even though such 'macro defines' like
#define LILI ((int)1)
are disabled due to the parsers inability to digg those.
Added test on macro definition for replaced values.
GlueGen uses PCPP in same thread via File
------------------------------------------
To ease debugging we call PCPP from the same thread
and use normal temp files as i/o.
Keep PCPP output file if 'debug'
---------------------------------
Keep temp outfile if debug is enabled
Diffstat (limited to 'src/java/com')
-rw-r--r-- | src/java/com/jogamp/gluegen/GlueGen.java | 27 | ||||
-rw-r--r-- | src/java/com/jogamp/gluegen/pcpp/PCPP.java | 10 |
2 files changed, 22 insertions, 15 deletions
diff --git a/src/java/com/jogamp/gluegen/GlueGen.java b/src/java/com/jogamp/gluegen/GlueGen.java index 719d54c..f24d0b2 100644 --- a/src/java/com/jogamp/gluegen/GlueGen.java +++ b/src/java/com/jogamp/gluegen/GlueGen.java @@ -107,23 +107,24 @@ public class GlueGen implements GlueEmitterControls { final PipedInputStream ppIn = new PipedInputStream(); final PipedOutputStream ppOut = new PipedOutputStream(ppIn); + File out = File.createTempFile("PCPPTemp", ".pcpp"); + FileOutputStream outStream = new FileOutputStream(out); + + if(debug) { + System.err.println("PCPP output at (persistent): " + out.getAbsolutePath()); + } else { + out.deleteOnExit(); + } + preprocessor = new PCPP(includePaths, debug, copyPCPPOutput2Stderr); - preprocessor.setOut(ppOut); + preprocessor.setOut(outStream); - new Thread("PCPP") { + preprocessor.run(reader, filename); + outStream.flush(); - @Override - public void run() { - try { - preprocessor.run(reader, filename); - ppOut.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - }.start(); + FileInputStream inStream = new FileInputStream(out); + DataInputStream dis = new DataInputStream(inStream); - DataInputStream dis = new DataInputStream(ppIn); GnuCLexer lexer = new GnuCLexer(dis); lexer.setTokenObjectClass(CToken.class.getName()); lexer.initialize(); diff --git a/src/java/com/jogamp/gluegen/pcpp/PCPP.java b/src/java/com/jogamp/gluegen/pcpp/PCPP.java index 95a4b43..db45e3e 100644 --- a/src/java/com/jogamp/gluegen/pcpp/PCPP.java +++ b/src/java/com/jogamp/gluegen/pcpp/PCPP.java @@ -551,17 +551,23 @@ public class PCPP { debugPrint(true, "DEFINE " + name + " ["+oldDef+" ] -> "+value + " CONST"); //System.err.println("//---DEFINED: " + name + " to \"" + value + "\""); } else { - debugPrint(true, "DEFINE " + name + " -> "+value + " SYMB"); // Value is a symbolic constant like "#define FOO BAR". // Try to look up the symbol's value String newValue = resolveDefine(value, true); + debugPrint(true, "DEFINE " + name + " -> "+value + " -> <" + newValue + "> SYMB"); if (newValue != null) { // Set the value to the value of the symbol. // // TO DO: Is this correct? Why not output the symbol unchanged? // I think that it's a good thing to see that some symbols are // defined in terms of others. -chris - values.set(0, newValue); + macroDefinition = newValue.contains("("); + if(macroDefinition) { + // parser can't dig this currently + emitDefine = false; + } else { + values.set(0, newValue); + } } else { // Still perform textual replacement defineMap.put(name, value); |