Top Description Fields Constructors Methods
com.kenai.jffi

public final Class Function

extends Object
Class Inheritance

Native function invocation context This class holds all the information that JFFI needs to correctly call a native function.

Field Summary

Modifier and TypeField and Description
private final CallContext
pack-priv final long
pack-priv final long
functionAddress

The address of the function

Constructor Summary

AccessConstructor and Description
public
Function(long
The native address of the function to invoke.
address
,
Type
The return type of the native function.
returnType
,
Type...
The parameter types the function accepts.
paramTypes
)

Creates a new instance of Function with default calling convention.

public
Function(long
The native address of the function to invoke.
address
,
CallContext callContext)

Creates a new instance of Function with default calling convention.

public
Function(long
The native address of the function to invoke.
address
,
Type
The return type of the native function.
returnType
,
Type[]
The parameter types the function accepts.
paramTypes
,
CallingConvention
The calling convention of the function.
convention
)

Creates a new instance of Function.

public
Function(long
The native address of the function to invoke.
address
,
Type
The return type of the native function.
returnType
,
Type[]
The parameter types the function accepts.
paramTypes
,
CallingConvention
The calling convention of the function.
convention
,
boolean
Whether the errno should be saved or not
saveErrno
)

Creates a new instance of Function.

public
Function(long
The native address of the function to invoke.
address
,
Type
The return type of the native function.
returnType
,
int
The number of fixed params for a variadic call.
fixedParamCount
,
Type[]
The parameter types the function accepts.
paramTypes
,
CallingConvention
The calling convention of the function.
convention
,
boolean
Whether the errno should be saved or not
saveErrno
)

Creates a new instance of Function.

Method Summary

Modifier and TypeMethod and Description
public final void
dispose()

Deprecated
public final CallContext
pack-priv final long

Returns:

The address of the native function context struct.
getContextAddress
()

Gets the address of the function context.

public final long

Returns:

The address of the native function.
getFunctionAddress
()

Gets the address of the function.

public final int

Returns:

The number of parameters the native function accepts.
getParameterCount
()

Gets the number of parameters the native function accepts.

public final Type

Returns:

The Type of the parameter.
getParameterType
(int
The index of the parameter in the function signature
index
)

Gets the type of a parameter.

public final int

Returns:

The number of bytes required to store all paraameters of this function.
getRawParameterSize
()

Gets the number of bytes required to pack all the parameters this function accepts, into a region of memory.

public final Type

Returns:

The native return type of this function.
getReturnType
()

Gets the native return type of this function.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callContextback to summary
private final CallContext callContext
contextAddressback to summary
pack-priv final long contextAddress
functionAddressback to summary
pack-priv final long functionAddress

The address of the function

Constructor Detail

Functionback to summary
public Function(long address, Type returnType, Type... paramTypes)

Creates a new instance of Function with default calling convention.

Parameters
address:long

The native address of the function to invoke.

returnType:Type

The return type of the native function.

paramTypes:Type[]

The parameter types the function accepts.

Functionback to summary
public Function(long address, CallContext callContext)

Creates a new instance of Function with default calling convention.

Parameters
address:long

The native address of the function to invoke.

Functionback to summary
public Function(long address, Type returnType, Type[] paramTypes, CallingConvention convention)

Creates a new instance of Function. Function instances created with this constructor will save the C errno contents after each call.

Parameters
address:long

The native address of the function to invoke.

returnType:Type

The return type of the native function.

paramTypes:Type[]

The parameter types the function accepts.

convention:CallingConvention

The calling convention of the function.

Functionback to summary
public Function(long address, Type returnType, Type[] paramTypes, CallingConvention convention, boolean saveErrno)

Creates a new instance of Function.

Parameters
address:long

The native address of the function to invoke.

returnType:Type

The return type of the native function.

paramTypes:Type[]

The parameter types the function accepts.

convention:CallingConvention

The calling convention of the function.

saveErrno:boolean

Whether the errno should be saved or not

Functionback to summary
public Function(long address, Type returnType, int fixedParamCount, Type[] paramTypes, CallingConvention convention, boolean saveErrno)

Creates a new instance of Function.

Parameters
address:long

The native address of the function to invoke.

returnType:Type

The return type of the native function.

fixedParamCount:int

The number of fixed params for a variadic call.

paramTypes:Type[]

The parameter types the function accepts.

convention:CallingConvention

The calling convention of the function.

saveErrno:boolean

Whether the errno should be saved or not

Method Detail

disposeback to summary
public final void dispose()

Deprecated

Annotations
@Deprecated
getCallContextback to summary
public final CallContext getCallContext()
getContextAddressback to summary
pack-priv final long getContextAddress()

Gets the address of the function context.

Returns:long

The address of the native function context struct.

getFunctionAddressback to summary
public final long getFunctionAddress()

Gets the address of the function.

Returns:long

The address of the native function.

getParameterCountback to summary
public final int getParameterCount()

Gets the number of parameters the native function accepts.

Returns:int

The number of parameters the native function accepts.

getParameterTypeback to summary
public final Type getParameterType(int index)

Gets the type of a parameter.

Parameters
index:int

The index of the parameter in the function signature

Returns:Type

The Type of the parameter.

getRawParameterSizeback to summary
public final int getRawParameterSize()

Gets the number of bytes required to pack all the parameters this function accepts, into a region of memory.

Returns:int

The number of bytes required to store all paraameters of this function.

getReturnTypeback to summary
public final Type getReturnType()

Gets the native return type of this function.

Returns:Type

The native return type of this function.