From bbea09816015ecf3596acdcc033553127fcc0ef3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 11 Mar 2015 15:10:15 +0100 Subject: Bug 1144 - Add 'DelegateImplementation': Requires own MethodBinding for delegates impl. / Adding ReturnsOpaque - DelegateImplementation requires own MethodBinding for delegates impl. The delegation name must be included within the FunctionSymbol's aliases _only_ for implementations, where delegation applies. This allows all subsequent type/cfg checks to hit on AliasedSymbol! Hence we need to create individual MethodBinding instances for interfaces and public/private implementations. - Adding ReturnsOpaque Configuration: ReturnsOpaque This feature is necessary to achieve 'Opaque' functionality for function's return type - instead of types in general. - Fix AliasedSymbolImpl copy-ctor, i.e. this.name = o.name ! --- src/java/com/jogamp/gluegen/JavaConfiguration.java | 52 +++++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'src/java/com/jogamp/gluegen/JavaConfiguration.java') diff --git a/src/java/com/jogamp/gluegen/JavaConfiguration.java b/src/java/com/jogamp/gluegen/JavaConfiguration.java index 21ba8d9..019ca2d 100644 --- a/src/java/com/jogamp/gluegen/JavaConfiguration.java +++ b/src/java/com/jogamp/gluegen/JavaConfiguration.java @@ -138,6 +138,7 @@ public class JavaConfiguration { private final Map accessControl = new HashMap(); private final Map typeInfoMap = new HashMap(); private final Set returnsString = new HashSet(); + private final Map returnsOpaqueJType = new HashMap(); private final Map returnedArrayLengths = new HashMap(); /** @@ -519,7 +520,6 @@ public class JavaConfiguration { oneInSet(returnsString, symbol.getAliasedNames()); } - /** * Returns a MessageFormat string of the Java expression calculating * the number of elements in the returned array from the specified function @@ -886,7 +886,7 @@ public class JavaConfiguration { if( null == res ) { return null; } - LOG.log(INFO, "DelegatedImplementation: {0}", functionName); + LOG.log(INFO, "DelegatedImplementation: {0} -> {1}", functionName, res); return res; } @@ -924,6 +924,41 @@ public class JavaConfiguration { return res; } + /** + * Variant of {@link #getOpaqueReturnType(AliasedSymbol)}, + * where this method only considers the {@link AliasedSymbol#getName() current-name} + * of the given symbol, not the {@link #getJavaSymbolRename(String) renamed-symbol}. + */ + public JavaType getOpaqueReturnType(final String functionName) { + final JavaType res = returnsOpaqueJType.get(functionName); + if( null == res ) { + return null; + } + LOG.log(INFO, "ReturnsOpaque: {0} -> {1}", functionName, res); + return res; + } + + /** + * Returns the opaque {@link JavaType} for the given function {@link AliasedSymbol} + * or {@code null} if not opaque. + *

+ * {@code ReturnsOpaque } + *

+ */ + public JavaType getOpaqueReturnType(final AliasedSymbol symbol) { + final String name = symbol.getName(); + final Set aliases = symbol.getAliasedNames(); + JavaType res = returnsOpaqueJType.get(name); + if( null == res ) { + res = oneInMap(returnsOpaqueJType, aliases); + if( null == res ) { + return null; + } + } + LOG.log(INFO, getASTLocusTag(symbol), "ReturnsOpaque: {0} -> {1}", symbol, res); + return res; + } + /** * Variant of {@link #shouldIgnoreInInterface(AliasedSymbol)}, * where this method only considers the {@link AliasedSymbol#getName() current-name} @@ -1222,6 +1257,8 @@ public class JavaConfiguration { readOpaque(tok, filename, lineNo); } else if (cmd.equalsIgnoreCase("ReturnsString")) { readReturnsString(tok, filename, lineNo); + } else if (cmd.equalsIgnoreCase("ReturnsOpaque")) { + readReturnsOpaque(tok, filename, lineNo); } else if (cmd.equalsIgnoreCase("ReturnedArrayLength")) { readReturnedArrayLength(tok, filename, lineNo); // Warning: make sure delimiters are reset at the top of this loop @@ -1418,6 +1455,17 @@ public class JavaConfiguration { } } + protected void readReturnsOpaque(final StringTokenizer tok, final String filename, final int lineNo) { + try { + final JavaType javaType = JavaType.createForOpaqueClass(stringToPrimitiveType(tok.nextToken())); + final String funcName = tok.nextToken(); + returnsOpaqueJType.put(funcName, javaType); + } catch (final Exception e) { + throw new RuntimeException("Error parsing \"ReturnsOpaque\" command at line " + lineNo + + " in file \"" + filename + "\"", e); + } + } + protected void readReturnsString(final StringTokenizer tok, final String filename, final int lineNo) { try { final String name = tok.nextToken(); -- cgit v1.2.3