aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/MethodBinding.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/jogamp/gluegen/MethodBinding.java')
-rw-r--r--src/java/com/jogamp/gluegen/MethodBinding.java98
1 files changed, 57 insertions, 41 deletions
diff --git a/src/java/com/jogamp/gluegen/MethodBinding.java b/src/java/com/jogamp/gluegen/MethodBinding.java
index 93c55d5..95a10c6 100644
--- a/src/java/com/jogamp/gluegen/MethodBinding.java
+++ b/src/java/com/jogamp/gluegen/MethodBinding.java
@@ -43,8 +43,6 @@ import com.jogamp.gluegen.cgram.types.FunctionSymbol;
import com.jogamp.gluegen.cgram.types.Type;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
/** Represents the binding of a C function to a Java method. Also used
@@ -54,8 +52,10 @@ import java.util.List;
public class MethodBinding {
private final FunctionSymbol sym;
- private String renamedMethodName;
- private final HashSet<String> aliasedNames;
+ private final String delegationImplName;
+ private final JavaType containingType;
+ private final Type containingCType;
+ private String nativeName;
private JavaType javaReturnType;
private List<JavaType> javaArgumentTypes;
private boolean computedSignatureProperties;
@@ -69,8 +69,6 @@ public class MethodBinding {
private boolean signatureUsesCArrays;
private boolean signatureUsesJavaPrimitiveArrays;
private boolean signatureRequiresStaticInitialization;
- private JavaType containingType;
- private Type containingCType;
private int thisPointerIndex = -1;
/**
@@ -79,12 +77,12 @@ public class MethodBinding {
* types. It's safe to modify this binding after construction.
*/
public MethodBinding(final MethodBinding bindingToCopy) {
- this.sym = bindingToCopy.sym;
-
- this.renamedMethodName = bindingToCopy.renamedMethodName;
- this.aliasedNames = new HashSet<String>(bindingToCopy.aliasedNames);
+ this.sym = bindingToCopy.sym;
+ this.delegationImplName = bindingToCopy.delegationImplName;
this.containingType = bindingToCopy.containingType;
this.containingCType = bindingToCopy.containingCType;
+
+ this.nativeName = bindingToCopy.nativeName;
this.javaReturnType = bindingToCopy.javaReturnType;
this.javaArgumentTypes = ( null != bindingToCopy.javaArgumentTypes ) ? new ArrayList<JavaType>(bindingToCopy.javaArgumentTypes) : null;
this.computedSignatureProperties = bindingToCopy.computedSignatureProperties;
@@ -101,19 +99,27 @@ public class MethodBinding {
this.thisPointerIndex = bindingToCopy.thisPointerIndex;
}
- /** Constructor for calling a C function. */
- public MethodBinding(final FunctionSymbol sym) {
- this.sym = sym;
- this.aliasedNames = new HashSet<String>();
- }
-
- /** Constructor for calling a function pointer contained in a
- struct. */
- public MethodBinding(final FunctionSymbol sym, final JavaType containingType, final Type containingCType) {
+ /**
+ * Constructor for calling a C function or a function pointer contained in a struct.
+ * <p>
+ * In case of the latter, a struct function pointer,
+ * the arguments {@code containingType} and {@code containingCType} must not be {@code null}!
+ * </p>
+ */
+ public MethodBinding(final FunctionSymbol sym,
+ final String delegationImplName,
+ final JavaType javaReturnType,
+ final List<JavaType> javaArgumentTypes,
+ final JavaType containingType,
+ final Type containingCType) {
this.sym = sym;
+ this.delegationImplName = delegationImplName;
this.containingType = containingType;
this.containingCType = containingCType;
- this.aliasedNames = new HashSet<String>();
+
+ this.nativeName = null;
+ this.javaReturnType = javaReturnType;
+ this.javaArgumentTypes = javaArgumentTypes;
}
public void setJavaReturnType(final JavaType type) {
@@ -149,6 +155,7 @@ public class MethodBinding {
return sym.getArgumentType(i);
}
+ /** Returns the {@link FunctionSymbol}. */
public FunctionSymbol getCSymbol() {
return sym;
}
@@ -166,33 +173,42 @@ public class MethodBinding {
return "arg" + i;
}
- public String getOrigName() {
- return sym.getName();
- }
-
+ /** Returns the {@link FunctionSymbol}'s current {@link FunctionSymbol#getName() aliased} API name. */
public String getName() {
- // Defaults to same as C symbol unless renamed
- if (renamedMethodName != null) {
- return renamedMethodName;
- }
return sym.getName();
}
-
- /** Supports renaming C function in Java binding. */
- public void renameMethodName(final String name) {
- if (null != name) {
- renamedMethodName = name;
- aliasedNames.add(sym.getName());
- }
- }
-
- public void addAliasedName(final String name) {
- aliasedNames.add(name);
+ /**
+ * The
+ * {@link JavaConfiguration#getDelegatedImplementation(com.jogamp.gluegen.cgram.types.AliasedSymbol) implementation delegation}
+ * name, or {@code null} for no delegation.
+ * @see #getImplName()
+ */
+ public String getDelegationImplName() {
+ return delegationImplName;
}
- public Collection<String> getAliasedNames() {
- return aliasedNames;
+ /** Returns the {@link FunctionSymbol}'s current {@link FunctionSymbol#getName() aliased} API name for the interface. */
+ public String getInterfaceName() {
+ return sym.getName();
}
+ /**
+ * Returns the {@link FunctionSymbol}'s name for the implementation,
+ * which is the current {@link FunctionSymbol#getName() aliased} API name per default,
+ * or the {@link #getDelegationImplName() delegation} name.
+ * @see #getDelegationImplName()
+ */
+ public String getImplName() {
+ return null != delegationImplName ? delegationImplName : sym.getName();
+ }
+ /**
+ * Returns the {@link FunctionSymbol}'s name for the native function
+ * which is the {@link FunctionSymbol#getOrigName() original} C API name per default,
+ * but may be overridden via {@link #setNativeName(String)}.
+ */
+ public String getNativeName() {
+ return null != nativeName ? nativeName : sym.getOrigName();
+ }
+ public void setNativeName(final String s) { nativeName = s; }
/** Creates a new MethodBinding replacing the specified Java
argument type with a new argument type. If argumentNumber is