summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/JavaConfiguration.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-03-11 15:10:15 +0100
committerSven Gothel <[email protected]>2015-03-11 15:10:15 +0100
commitbbea09816015ecf3596acdcc033553127fcc0ef3 (patch)
treeab38152b5b74ee7d99e955658c7778de4181438b /src/java/com/jogamp/gluegen/JavaConfiguration.java
parent25f248669f603c2bbd6ad97f31e0c72ce780f507 (diff)
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 <Primitive Java Type> <Function Name> 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 !
Diffstat (limited to 'src/java/com/jogamp/gluegen/JavaConfiguration.java')
-rw-r--r--src/java/com/jogamp/gluegen/JavaConfiguration.java52
1 files changed, 50 insertions, 2 deletions
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<String, MethodAccess> accessControl = new HashMap<String, MethodAccess>();
private final Map<String, TypeInfo> typeInfoMap = new HashMap<String, TypeInfo>();
private final Set<String> returnsString = new HashSet<String>();
+ private final Map<String, JavaType> returnsOpaqueJType = new HashMap<String, JavaType>();
private final Map<String, String> returnedArrayLengths = new HashMap<String, String>();
/**
@@ -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;
}
@@ -925,6 +925,41 @@ public class JavaConfiguration {
}
/**
+ * 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.
+ * <p>
+ * {@code ReturnsOpaque <Primitive Java Type> <Function Name>}
+ * </p>
+ */
+ public JavaType getOpaqueReturnType(final AliasedSymbol symbol) {
+ final String name = symbol.getName();
+ final Set<String> 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}
* of the given symbol, not the {@link #getJavaSymbolRename(String) renamed-symbol}.
@@ -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();