From a87a66cca58095d24b02eda5a35bdba1177edb28 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 15 Feb 2012 13:38:50 +0100 Subject: Add more debug/analisys information. Throw exception when attempting to override a rename instruction w/ diff new value --- .../com/jogamp/gluegen/ConstantDefinition.java | 2 +- src/java/com/jogamp/gluegen/JavaConfiguration.java | 38 +++++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/java/com/jogamp/gluegen/ConstantDefinition.java b/src/java/com/jogamp/gluegen/ConstantDefinition.java index 4216b52..4971eda 100644 --- a/src/java/com/jogamp/gluegen/ConstantDefinition.java +++ b/src/java/com/jogamp/gluegen/ConstantDefinition.java @@ -89,7 +89,7 @@ public class ConstantDefinition { } } - public void addAliasedName(String name) { + public void addAliasedName(String name) { aliasedNames.add(name); } public Collection getAliasedNames() { diff --git a/src/java/com/jogamp/gluegen/JavaConfiguration.java b/src/java/com/jogamp/gluegen/JavaConfiguration.java index 09364b3..87d8978 100644 --- a/src/java/com/jogamp/gluegen/JavaConfiguration.java +++ b/src/java/com/jogamp/gluegen/JavaConfiguration.java @@ -166,6 +166,7 @@ public class JavaConfiguration { private Map parentClass = new HashMap(); private Map javaTypeRenames = new HashMap(); private Map javaSymbolRenames = new HashMap(); + private Map> javaRenamedSymbols = new HashMap>(); private Map> javaPrologues = new HashMap>(); private Map> javaEpilogues = new HashMap>(); @@ -667,6 +668,14 @@ public class JavaConfiguration { for (String key : javaSymbolRenames.keySet()) { System.err.println("\t"+key+" -> "+javaSymbolRenames.get(key)); } + + System.err.println("Symbol Aliasing (through renaming): "); + for(String newName : javaSymbolRenames.values()) { + Set origNames = javaRenamedSymbols.get(newName); + if(null!=origNames) { + System.err.println("\t"+newName+" <- "+origNames); + } + } } /** Returns true if this #define, function, struct, or field within @@ -802,19 +811,38 @@ public class JavaConfiguration { constant. If a function, it still calls the originally-named C function under the hood. Returns null if this symbol has not been explicitly renamed. */ - public String getJavaSymbolRename(String symbolName) { + public String getJavaSymbolRename(String origName) { if(DEBUG_RENAMES) { dumpRenamesOnce(); } - return javaSymbolRenames.get(symbolName); + return javaSymbolRenames.get(origName); } + /** Returns a set of replaced names to the given aliasedName. */ + public Set getRenamedJavaSymbols(String aliasedName) { + return javaRenamedSymbols.get(aliasedName); + } + /** Programmatically adds a rename directive for the given symbol. */ public void addJavaSymbolRename(String origName, String newName) { if(DEBUG_RENAMES) { - System.err.println("\tRename "+origName+" -> "+newName); + System.err.print("\tRename "+origName+" -> "+newName); + } + String prevValue = javaSymbolRenames.put(origName, newName); + if(null != prevValue && !prevValue.equals(newName)) { + throw new RuntimeException("Rename-Override Attampt: "+origName+" -> "+newName+ + ", but "+origName+" -> "+prevValue+" already exist. Run in 'debug' mode to analyze!"); + } + if(DEBUG_RENAMES) { + System.err.println(); + } + + Set origNames = javaRenamedSymbols.get(newName); + if(null == origNames) { + origNames = new HashSet(); + javaRenamedSymbols.put(newName, origNames); } - javaSymbolRenames.put(origName, newName); + origNames.add(origName); } /** Returns true if the emission style is AllStatic. */ @@ -1451,7 +1479,7 @@ public class JavaConfiguration { try { String fromName = tok.nextToken(); String toName = tok.nextToken(); - javaSymbolRenames.put(fromName, toName); + addJavaSymbolRename(fromName, toName); } catch (NoSuchElementException e) { throw new RuntimeException("Error parsing \"RenameJavaSymbol\" command at line " + lineNo + " in file \"" + filename + "\": missing expected parameter", e); -- cgit v1.2.3