Top Description Fields Constructors Methods
com.jogamp.gluegen

public Class MethodBinding

extends Object
Class Inheritance
Imports
com.jogamp.gluegen.cgram.types.FunctionSymbol, .Type, java.util.ArrayList, .List

Represents the binding of a C function to a Java method. Also used to represent calls through function pointers contained in structs.

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private final Type
private final JavaType
private final String
private List<JavaType>
private JavaType
private String
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private final FunctionSymbol
private int

Constructor Summary

AccessConstructor and Description
public
MethodBinding(final MethodBinding bindingToCopy)

Constructs a new MethodBinding that is an exact clone of the argument, including the java return type and java argument types.

public
MethodBinding(final FunctionSymbol sym, final String delegationImplName, final JavaType javaReturnType, final List<JavaType> javaArgumentTypes, final JavaType containingType, final Type containingCType)

Constructor for calling a C function or a function pointer contained in a struct.

Method Summary

Modifier and TypeMethod and Description
public void
public boolean
argumentsUseNIO()

Returns true if any of the outgoing arguments in the method's signature require conversion or checking due to the use of New I/O.

public void
clearThisPointer()

Clears any record of a this pointer for this MethodBinding.

protected void
computeSignatureProperties()

Computes summary information about the method's C and Java signatures.

public boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
protected String
erasedTypeDescriptor(final JavaType type, final boolean eraseBufferAndArrayTypes, final boolean skipBuffers)

public void
findThisPointer()

Find the leftmost argument matching the type of the containing type (for function pointer MethodBindings) and record that as a "this" pointer, meaning that it does not need to be explicitly passed at the Java level.

public String
getArgumentName(final int i)

Returns either the argument name specified by the underlying FunctionSymbol or a fabricated argument name based on the position.

public Type
getCArgumentType(final int i)

public Type
getContainingCType()

Retrieves the containing C type of this MethodBinding if it is for a function pointer contained in a struct.

public JavaType
getContainingType()

Retrieves the containing type of this MethodBinding if it is for a function pointer contained in a struct.

public Type
public FunctionSymbol
getCSymbol()

Returns the FunctionSymbol.

public String
getDelegationImplName()

The implementation delegation name, or null for no delegation.

public String
getDescriptor(final boolean forImplementingMethodCall, final boolean eraseBufferAndArrayTypes)

Returns a String containing the descriptor (signature in internal format) of this MethodBinding as it will be emitted.

public String
getImplName()

Returns the FunctionSymbol's name for the implementation, which is the current aliased API name per default, or the delegation name.

public String
getInterfaceName()

Returns the FunctionSymbol's current aliased API name for the interface.

public JavaType
getJavaArgumentType(final int i)

public JavaType
public String
getName()

Returns the FunctionSymbol's current aliased API name.

public String
getNativeName()

Returns the FunctionSymbol's name for the native function which is the original C API name per default, but may be overridden via setNativeName(String).

public int
public boolean
hasContainingType()

Indicates whether this MethodBinding is for a function pointer contained in a struct, or to access array- or pointer-data from a struct.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public boolean
isArgumentThisPointer(final int i)

Indicates whether the ith argument to this MethodBinding is actually a "this" pointer.

public boolean
needsNIOWrappingOrUnwrapping()

Returns true if the function needs NIO-related wrapping/unwrapping or conversion of various arguments.

public MethodBinding
replaceJavaArgumentType(final int argumentNumber, final JavaType newArgType)

Creates a new MethodBinding replacing the specified Java argument type with a new argument type.

public void
public void
public boolean
signatureCanUseIndirectNIO()

Returns true if it is possible for any of the outgoing arguments to be indirect NIO buffers.

public boolean
signatureRequiresStaticInitialization()

Returns true if the wrapper implementation requires static native code to be initialized, see JavaConfiguration#forceStaticInitCode(String).

public boolean
signatureUsesArraysOfCompoundTypeWrappers()

Returns true if the return type or any of the outgoing arguments in the method's signature use arrays of "compound type wrappers", or NIO-based wrappers for C data structures.

public boolean
signatureUsesCArrays()

Returns true if the return type or any of the outgoing arguments in the method's signature represent C arrays.

public boolean
signatureUsesCompoundTypeWrappers()

Returns true if the return type or any of the outgoing arguments in the method's signature use "compound type wrappers", or NIO-based wrappers for C data structures.

public boolean
signatureUsesCPrimitivePointers()

Returns true if the return type or any of the outgoing arguments in the method's signature represent C primitive pointers.

public boolean
signatureUsesCVoidPointers()

Returns true if the return type or any of the outgoing arguments in the method's signature represent C void* pointers.

public boolean
signatureUsesJavaPrimitiveArrays()

Returns true if the return type or any of the outgoing arguments in the method's signature represent Java primitive arrays.

public boolean
signatureUsesNIO()

Returns true if the return type or any of the outgoing arguments in the method's signature require conversion or checking due to the use of New I/O.

public String
toString()

Overrides java.lang.Object.toString.

Returns the signature of this binding.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

argumentsUseNIOback to summary
private boolean argumentsUseNIO
computedSignaturePropertiesback to summary
private boolean computedSignatureProperties
containingCTypeback to summary
private final Type containingCType
containingTypeback to summary
private final JavaType containingType
delegationImplNameback to summary
private final String delegationImplName
javaArgumentTypesback to summary
private List<JavaType> javaArgumentTypes
javaReturnTypeback to summary
private JavaType javaReturnType
nativeNameback to summary
private String nativeName
signatureCanUseIndirectNIOback to summary
private boolean signatureCanUseIndirectNIO
signatureRequiresStaticInitializationback to summary
private boolean signatureRequiresStaticInitialization
signatureUsesArraysOfCompoundTypeWrappersback to summary
private boolean signatureUsesArraysOfCompoundTypeWrappers
signatureUsesCArraysback to summary
private boolean signatureUsesCArrays
signatureUsesCompoundTypeWrappersback to summary
private boolean signatureUsesCompoundTypeWrappers
signatureUsesCPrimitivePointersback to summary
private boolean signatureUsesCPrimitivePointers
signatureUsesCVoidPointersback to summary
private boolean signatureUsesCVoidPointers
signatureUsesJavaPrimitiveArraysback to summary
private boolean signatureUsesJavaPrimitiveArrays
signatureUsesNIOback to summary
private boolean signatureUsesNIO
symback to summary
private final FunctionSymbol sym
thisPointerIndexback to summary
private int thisPointerIndex

Constructor Detail

MethodBindingback to summary
public MethodBinding(final MethodBinding bindingToCopy)

Constructs a new MethodBinding that is an exact clone of the argument, including the java return type and java argument types. It's safe to modify this binding after construction.

MethodBindingback to summary
public MethodBinding(final FunctionSymbol sym, final String delegationImplName, final JavaType javaReturnType, final List<JavaType> javaArgumentTypes, final JavaType containingType, final Type containingCType)

Constructor for calling a C function or a function pointer contained in a struct.

In case of the latter, a struct function pointer, the arguments containingType and containingCType must not be null!

Method Detail

addJavaArgumentTypeback to summary
public void addJavaArgumentType(final JavaType type)
argumentsUseNIOback to summary
public boolean argumentsUseNIO()

Returns true if any of the outgoing arguments in the method's signature require conversion or checking due to the use of New I/O.

clearThisPointerback to summary
public void clearThisPointer()

Clears any record of a this pointer for this MethodBinding.

computeSignaturePropertiesback to summary
protected void computeSignatureProperties()

Computes summary information about the method's C and Java signatures.

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
erasedTypeDescriptorback to summary
protected String erasedTypeDescriptor(final JavaType type, final boolean eraseBufferAndArrayTypes, final boolean skipBuffers)
findThisPointerback to summary
public void findThisPointer()

Find the leftmost argument matching the type of the containing type (for function pointer MethodBindings) and record that as a "this" pointer, meaning that it does not need to be explicitly passed at the Java level.

getArgumentNameback to summary
public String getArgumentName(final int i)

Returns either the argument name specified by the underlying FunctionSymbol or a fabricated argument name based on the position. Note that it is currently not guaranteed that there are no namespace clashes with these fabricated argument names.

getCArgumentTypeback to summary
public Type getCArgumentType(final int i)
getContainingCTypeback to summary
public Type getContainingCType()

Retrieves the containing C type of this MethodBinding if it is for a function pointer contained in a struct.

getContainingTypeback to summary
public JavaType getContainingType()

Retrieves the containing type of this MethodBinding if it is for a function pointer contained in a struct.

getCReturnTypeback to summary
public Type getCReturnType()
getCSymbolback to summary
public FunctionSymbol getCSymbol()

Returns the FunctionSymbol.

getDelegationImplNameback to summary
public String getDelegationImplName()

The implementation delegation name, or null for no delegation.

See Also
getImplName()
getDescriptorback to summary
public String getDescriptor(final boolean forImplementingMethodCall, final boolean eraseBufferAndArrayTypes)

Returns a String containing the descriptor (signature in internal format) of this MethodBinding as it will be emitted. This is used to disambiguate between overloadings when manually specifying prologue and epilogue code, for example.

getImplNameback to summary
public String getImplName()

Returns the FunctionSymbol's name for the implementation, which is the current aliased API name per default, or the delegation name.

See Also
getDelegationImplName()
getInterfaceNameback to summary
public String getInterfaceName()

Returns the FunctionSymbol's current aliased API name for the interface.

getJavaArgumentTypeback to summary
public JavaType getJavaArgumentType(final int i)
getJavaReturnTypeback to summary
public JavaType getJavaReturnType()
getNameback to summary
public String getName()

Returns the FunctionSymbol's current aliased API name.

getNativeNameback to summary
public String getNativeName()

Returns the FunctionSymbol's name for the native function which is the original C API name per default, but may be overridden via setNativeName(String).

getNumArgumentsback to summary
public int getNumArguments()
hasContainingTypeback to summary
public boolean hasContainingType()

Indicates whether this MethodBinding is for a function pointer contained in a struct, or to access array- or pointer-data from a struct.

The native calling convention, i.e. via a 'this' function pointer or by a static native function must be decided in the JavaEmitter handling structs and passed to the CMethodBindingEmitter#setIsCStructFunctionPointer(boolean).

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isArgumentThisPointerback to summary
public boolean isArgumentThisPointer(final int i)

Indicates whether the ith argument to this MethodBinding is actually a "this" pointer.

needsNIOWrappingOrUnwrappingback to summary
public boolean needsNIOWrappingOrUnwrapping()

Returns true if the function needs NIO-related wrapping/unwrapping or conversion of various arguments. Currently this returns the logical OR of signatureUsesNIO(), signatureUsesCompoundTypeWrappers() and signatureUsesArraysOfCompoundTypeWrappers().

replaceJavaArgumentTypeback to summary
public MethodBinding replaceJavaArgumentType(final int argumentNumber, final JavaType newArgType)

Creates a new MethodBinding replacing the specified Java argument type with a new argument type. If argumentNumber is less than 0 then replaces the return type.

setJavaReturnTypeback to summary
public void setJavaReturnType(final JavaType type)
setNativeNameback to summary
public void setNativeName(final String s)
signatureCanUseIndirectNIOback to summary
public boolean signatureCanUseIndirectNIO()

Returns true if it is possible for any of the outgoing arguments to be indirect NIO buffers.

signatureRequiresStaticInitializationback to summary
public boolean signatureRequiresStaticInitialization()

Returns true if the wrapper implementation requires static native code to be initialized, see JavaConfiguration#forceStaticInitCode(String).

Currently triggered by:

  • Return type is a "compound type" and not a pointer

signatureUsesArraysOfCompoundTypeWrappersback to summary
public boolean signatureUsesArraysOfCompoundTypeWrappers()

Returns true if the return type or any of the outgoing arguments in the method's signature use arrays of "compound type wrappers", or NIO-based wrappers for C data structures.

signatureUsesCArraysback to summary
public boolean signatureUsesCArrays()

Returns true if the return type or any of the outgoing arguments in the method's signature represent C arrays.

signatureUsesCompoundTypeWrappersback to summary
public boolean signatureUsesCompoundTypeWrappers()

Returns true if the return type or any of the outgoing arguments in the method's signature use "compound type wrappers", or NIO-based wrappers for C data structures.

signatureUsesCPrimitivePointersback to summary
public boolean signatureUsesCPrimitivePointers()

Returns true if the return type or any of the outgoing arguments in the method's signature represent C primitive pointers.

signatureUsesCVoidPointersback to summary
public boolean signatureUsesCVoidPointers()

Returns true if the return type or any of the outgoing arguments in the method's signature represent C void* pointers.

signatureUsesJavaPrimitiveArraysback to summary
public boolean signatureUsesJavaPrimitiveArrays()

Returns true if the return type or any of the outgoing arguments in the method's signature represent Java primitive arrays.

signatureUsesNIOback to summary
public boolean signatureUsesNIO()

Returns true if the return type or any of the outgoing arguments in the method's signature require conversion or checking due to the use of New I/O.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the signature of this binding.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override