net.java.games.gluegen

Class MethodBinding


public class MethodBinding
extends java.lang.Object

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

Constructor Summary

MethodBinding(MethodBinding bindingToCopy)
Constructs a new MethodBinding that is an exact clone of the argument, including the java return type and java argument types.
MethodBinding(net.java.games.gluegen.cgram.types.FunctionSymbol sym)
Constructor for calling a C function.
MethodBinding(net.java.games.gluegen.cgram.types.FunctionSymbol sym, JavaType containingType, net.java.games.gluegen.cgram.types.Type containingCType)
Constructor for calling a function pointer contained in a struct.

Method Summary

void
addJavaArgumentType(JavaType type)
void
clearThisPointer()
Clears any record of a this pointer for this MethodBinding.
Object
clone()
protected void
computeSignatureProperties()
Computes summary information about the method's C and Java signatures.
MethodBinding
createCPrimitivePointerVariant(int argumentNumber, JavaType newArgType)
Replaces the C primitive pointer argument at slot argumentNumber (0..getNumArguments() - 1) with the specified type.
MethodBinding
createNIOBufferVariant()
boolean
equals(Object obj)
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.
String
getArgumentName(int i)
Returns either the argument name specified by the underlying FunctionSymbol or a fabricated argument name based on the position.
net.java.games.gluegen.cgram.types.Type
getCArgumentType(int i)
net.java.games.gluegen.cgram.types.Type
getCReturnType()
net.java.games.gluegen.cgram.types.FunctionSymbol
getCSymbol()
net.java.games.gluegen.cgram.types.Type
getContainingCType()
Retrieves the containing C type of this MethodBinding if it is for a function pointer contained in a struct.
JavaType
getContainingType()
Retrieves the containing type of this MethodBinding if it is for a function pointer contained in a struct.
JavaType
getJavaArgumentType(int i)
JavaType
getJavaReturnType()
String
getName()
int
getNumArguments()
boolean
hasContainingType()
Indicates whether this MethodBinding is for a function pointer contained in a struct.
boolean
isArgumentThisPointer(int i)
Indicates whether the ith argument to this MethodBinding is actually a "this" pointer.
void
setJavaReturnType(JavaType type)
boolean
signatureUsesCArrays()
Returns true if any of the outgoing arguments in the method's signature represent fixed-length C arrays which require length checking during the call.
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.
boolean
signatureUsesPrimitiveArrays()
Returns true if any of the outgoing arguments in the method's signature represent primitive arrays which require a GetPrimitiveArrayCritical or similar operation during the call.
String
toString()
Returns the signature of this binding.

Constructor Details

MethodBinding

public MethodBinding(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.

MethodBinding

public MethodBinding(net.java.games.gluegen.cgram.types.FunctionSymbol sym)
Constructor for calling a C function.

MethodBinding

public MethodBinding(net.java.games.gluegen.cgram.types.FunctionSymbol sym,
                     JavaType containingType,
                     net.java.games.gluegen.cgram.types.Type containingCType)
Constructor for calling a function pointer contained in a struct.

Method Details

addJavaArgumentType

public void addJavaArgumentType(JavaType type)

clearThisPointer

public void clearThisPointer()
Clears any record of a this pointer for this MethodBinding.

clone

public final Object clone()

computeSignatureProperties

protected void computeSignatureProperties()
Computes summary information about the method's C and Java signatures.

createCPrimitivePointerVariant

public MethodBinding createCPrimitivePointerVariant(int argumentNumber,
                                                    JavaType newArgType)
Replaces the C primitive pointer argument at slot argumentNumber (0..getNumArguments() - 1) with the specified type. If argumentNumber is less than 0 then replaces the return type.

createNIOBufferVariant

public MethodBinding createNIOBufferVariant()

equals

public boolean equals(Object obj)

findThisPointer

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.

getArgumentName

public String getArgumentName(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.

getCArgumentType

public net.java.games.gluegen.cgram.types.Type getCArgumentType(int i)

getCReturnType

public net.java.games.gluegen.cgram.types.Type getCReturnType()

getCSymbol

public net.java.games.gluegen.cgram.types.FunctionSymbol getCSymbol()

getContainingCType

public net.java.games.gluegen.cgram.types.Type getContainingCType()
Retrieves the containing C type of this MethodBinding if it is for a function pointer contained in a struct.

getContainingType

public JavaType getContainingType()
Retrieves the containing type of this MethodBinding if it is for a function pointer contained in a struct.

getJavaArgumentType

public JavaType getJavaArgumentType(int i)

getJavaReturnType

public JavaType getJavaReturnType()

getName

public String getName()

getNumArguments

public int getNumArguments()

hasContainingType

public boolean hasContainingType()
Indicates whether this MethodBinding is for a function pointer contained in a struct.

isArgumentThisPointer

public boolean isArgumentThisPointer(int i)
Indicates whether the ith argument to this MethodBinding is actually a "this" pointer.

setJavaReturnType

public void setJavaReturnType(JavaType type)

signatureUsesCArrays

public boolean signatureUsesCArrays()
Returns true if any of the outgoing arguments in the method's signature represent fixed-length C arrays which require length checking during the call.

signatureUsesNIO

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.

signatureUsesPrimitiveArrays

public boolean signatureUsesPrimitiveArrays()
Returns true if any of the outgoing arguments in the method's signature represent primitive arrays which require a GetPrimitiveArrayCritical or similar operation during the call.

toString

public String toString()
Returns the signature of this binding.