diff options
author | Sven Gothel <[email protected]> | 2010-11-04 20:32:58 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-11-04 20:32:58 +0100 |
commit | c4f4ec8b7be3c73b0d416ea82030b3fb8aa99efa (patch) | |
tree | fe863b668d4e33728b2e74c332a44e11699afd9f /src/java/com/sun/gluegen/GlueGen.java | |
parent | 12168e5bced1eaaaf4fc340cd67cdcbc8112d6d7 (diff) |
Fix PCPP 'elif' case; Adding PCPP #error/#warning; Adding debug mode.
Fix PCPP 'elif' case
----------------------
Use the evaluated expression after the 'elif' statement as well.
This was always true for 'if'.
Otherwise the file obviously won't get parsed correctly,
ie it was always assuming 'true'.
Adding PCPP #error/#warning
----------------------------
LOG all occurence of #error and #warning CPP directives
Adding debug mode.
----------------------
Add '--debug' commandline flag and 'debug' property for ant task,
which enables debug mode of PCPP.
Diffstat (limited to 'src/java/com/sun/gluegen/GlueGen.java')
-rw-r--r-- | src/java/com/sun/gluegen/GlueGen.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/java/com/sun/gluegen/GlueGen.java b/src/java/com/sun/gluegen/GlueGen.java index aac5319..866f602 100644 --- a/src/java/com/sun/gluegen/GlueGen.java +++ b/src/java/com/sun/gluegen/GlueGen.java @@ -84,13 +84,13 @@ public class GlueGen implements GlueEmitterControls { @SuppressWarnings("unchecked") - public void run(final Reader reader, final String filename, Class<?> emitterClass, List<String> includePaths, List<String> cfgFiles, String outputRootDir) { + public void run(final Reader reader, final String filename, Class<?> emitterClass, List<String> includePaths, List<String> cfgFiles, String outputRootDir, boolean debug) { try { final PipedInputStream ppIn = new PipedInputStream(); final PipedOutputStream ppOut = new PipedOutputStream(ppIn); - preprocessor = new PCPP(includePaths); + preprocessor = new PCPP(includePaths, debug); preprocessor.setOut(ppOut); new Thread("PCPP") { @@ -136,9 +136,12 @@ public class GlueGen implements GlueEmitterControls { // walk that tree headerParser.translationUnit(parser.getAST()); + /** // For debugging: Dump type dictionary and struct dictionary to System.err - //td.dumpDictionary(err, "All Types"); - //sd.dumpDictionary(err, "All Structs"); + if(debug) { + td.dumpDictionary(err, "All Types"); + sd.dumpDictionary(err, "All Structs"); + } */ // At this point we have all of the pieces we need in order to // generate glue code: the #defines to constants, the set of @@ -306,6 +309,7 @@ public class GlueGen implements GlueEmitterControls { String emitterFQN = null; String outputRootDir = null; List<String> cfgFiles = new ArrayList<String>(); + boolean debug = false; List<String> includePaths = new ArrayList<String>(); for (int i = 0; i < args.length; i++) { @@ -320,6 +324,8 @@ public class GlueGen implements GlueEmitterControls { emitterFQN = arg.substring(2); } else if (arg.startsWith("-C")) { cfgFiles.add(arg.substring(2)); + } else if (arg.equals("--debug")) { + debug=true; } else { usage(); } @@ -344,7 +350,7 @@ public class GlueGen implements GlueEmitterControls { try { Class<?> emitterClass = emitterFQN == null ? null : Class.forName(emitterFQN); - new GlueGen().run(reader, filename, emitterClass, includePaths, cfgFiles, outputRootDir); + new GlueGen().run(reader, filename, emitterClass, includePaths, cfgFiles, outputRootDir, debug); } catch (ClassNotFoundException ex) { throw new RuntimeException("specified emitter class was not in the classpath", ex); } @@ -367,6 +373,7 @@ public class GlueGen implements GlueEmitterControls { out.println("declarations) to standard output. Emitter-specific configuration"); out.println("file or files can be specified with -C option; e.g,"); out.println("-Cjava-emitter.cfg."); + out.println(" --debug enables debug mode"); exit(1); } } |