Package com.kenai.jffi
Class Function
- java.lang.Object
-
- com.kenai.jffi.Function
-
public final class Function extends java.lang.Object
Native function invocation context This class holds all the information that JFFI needs to correctly call a native function.
-
-
Field Summary
Fields Modifier and Type Field Description private CallContext
callContext
(package private) long
contextAddress
(package private) long
functionAddress
The address of the function
-
Constructor Summary
Constructors Constructor Description Function(long address, CallContext callContext)
Creates a new instance ofFunction
with default calling convention.Function(long address, Type returnType, int fixedParamCount, Type[] paramTypes, CallingConvention convention, boolean saveErrno)
Creates a new instance ofFunction
.Function(long address, Type returnType, Type... paramTypes)
Creates a new instance ofFunction
with default calling convention.Function(long address, Type returnType, Type[] paramTypes, CallingConvention convention)
Creates a new instance ofFunction
.Function(long address, Type returnType, Type[] paramTypes, CallingConvention convention, boolean saveErrno)
Creates a new instance ofFunction
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
dispose()
Deprecated.CallContext
getCallContext()
(package private) long
getContextAddress()
Gets the address of the function context.long
getFunctionAddress()
Gets the address of the function.int
getParameterCount()
Gets the number of parameters the native function accepts.Type
getParameterType(int index)
Gets the type of a parameter.int
getRawParameterSize()
Gets the number of bytes required to pack all the parameters this function accepts, into a region of memory.Type
getReturnType()
Gets the native return type of this function.
-
-
-
Field Detail
-
callContext
private final CallContext callContext
-
functionAddress
final long functionAddress
The address of the function
-
contextAddress
final long contextAddress
-
-
Constructor Detail
-
Function
public Function(long address, Type returnType, Type... paramTypes)
Creates a new instance ofFunction
with default calling convention.- Parameters:
address
- The native address of the function to invoke.returnType
- The return type of the native function.paramTypes
- The parameter types the function accepts.
-
Function
public Function(long address, CallContext callContext)
Creates a new instance ofFunction
with default calling convention.- Parameters:
address
- The native address of the function to invoke.
-
Function
public Function(long address, Type returnType, Type[] paramTypes, CallingConvention convention)
Creates a new instance ofFunction
.Function
instances created with this constructor will save the C errno contents after each call.- Parameters:
address
- The native address of the function to invoke.returnType
- The return type of the native function.paramTypes
- The parameter types the function accepts.convention
- The calling convention of the function.
-
Function
public Function(long address, Type returnType, Type[] paramTypes, CallingConvention convention, boolean saveErrno)
Creates a new instance ofFunction
.- Parameters:
address
- The native address of the function to invoke.returnType
- The return type of the native function.paramTypes
- The parameter types the function accepts.convention
- The calling convention of the function.saveErrno
- Whether the errno should be saved or not
-
Function
public Function(long address, Type returnType, int fixedParamCount, Type[] paramTypes, CallingConvention convention, boolean saveErrno)
Creates a new instance ofFunction
.- Parameters:
address
- The native address of the function to invoke.returnType
- The return type of the native function.fixedParamCount
- The number of fixed params for a variadic call.paramTypes
- The parameter types the function accepts.convention
- The calling convention of the function.saveErrno
- Whether the errno should be saved or not
-
-
Method Detail
-
getParameterCount
public final int getParameterCount()
Gets the number of parameters the native function accepts.- Returns:
- The number of parameters the native function accepts.
-
getRawParameterSize
public final int getRawParameterSize()
Gets the number of bytes required to pack all the parameters this function accepts, into a region of memory.- Returns:
- The number of bytes required to store all paraameters of this function.
-
getCallContext
public final CallContext getCallContext()
-
getContextAddress
final long getContextAddress()
Gets the address of the function context.- Returns:
- The address of the native function context struct.
-
getFunctionAddress
public final long getFunctionAddress()
Gets the address of the function.- Returns:
- The address of the native function.
-
getReturnType
public final Type getReturnType()
Gets the native return type of this function.- Returns:
- The native return type of this function.
-
getParameterType
public final Type getParameterType(int index)
Gets the type of a parameter.- Parameters:
index
- The index of the parameter in the function signature- Returns:
- The
Type
of the parameter.
-
dispose
@Deprecated public final void dispose()
Deprecated.
-
-