Top Description Inners Methods
com.kenai.jffi

public Interface Closure


Represents a native closure. A Closure is implemented by java code to act as a C function pointer.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Closure.Buffer

An interface to the native callback parameter buffer.

public static interface
Closure.Handle

A Handle is allocated by the ClosureManager, as a strong reference to the native closure trampoline.

Method Summary

Modifier and TypeMethod and Description
public void

Method Detail

invokeback to summary
public void invoke(Closure.Buffer buffer)
com.kenai.jffi back to summary

public Interface Closure.Buffer

Known Direct Implementers
com.kenai.jffi.DirectClosureBuffer

An interface to the native callback parameter buffer.

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

A native memory address.
getAddress
(int
The parameter index
index
)

Gets the value of a native pointer parameter.

public byte

Returns:

An 8 bit integer value.
getByte
(int
The parameter index
index
)

Gets the value of an 8 bit integer parameter.

public double

Returns:

A 64 bit floating point value.
getDouble
(int
The parameter index
index
)

Gets the value of a 64 bit floating point parameter.

public float

Returns:

A 32 bit floating point value.
getFloat
(int
The parameter index
index
)

Gets the value of a 32 bit floating point parameter.

public int

Returns:

A 32 bit integer value.
getInt
(int
The parameter index
index
)

Gets the value of a 32 bit integer parameter.

public long

Returns:

A 64 bit integer value.
getLong
(int
The parameter index
index
)

Gets the value of a 64 bit integer parameter.

public short

Returns:

A 16 bit integer value.
getShort
(int
The parameter index
index
)

Gets the value of a 16 bit integer parameter.

public long

Returns:

A native memory address.
getStruct
(int
The parameter index
index
)

Gets the address of a struct parameter that is passed by value.

public void
setAddressReturn(long
The native pointer value to return from the closure.
address
)

Sets the closure return value to a native pointer value.

public void
setByteReturn(byte
The 8 bit integer value to return from the closure.
value
)

Sets the closure return value to an 8 bit integer value.

public void
setDoubleReturn(double
The 64 bit floating point value to return from the closure.
value
)

Sets the closure return value to a 64 bit floating point value.

public void
setFloatReturn(float
The 32 bit floating point value to return from the closure.
value
)

Sets the closure return value to a 32 bit floating point value.

public void
setIntReturn(int
The 32 bit integer value to return from the closure.
value
)

Sets the closure return value to a 32 bit integer value.

public void
setLongReturn(long
The 64 bit integer value to return from the closure.
value
)

Sets the closure return value to a 64 bit integer value.

public void
setShortReturn(short
The 16 bit integer value to return from the closure.
value
)

Sets the closure return value to a 16 bit integer value.

public void
setStructReturn(long
The address of a native struct to return as a struct value from the closure.
address
)

Sets the closure return value to the contents of a struct

public void
setStructReturn(byte[]
Struct data packed into a byte array to return as a struct value from the closure.
data
,
int
the offset within the byte array to start copying data
offset
)

Sets the closure return value to the contents of a struct

Method Detail

getAddressback to summary
public long getAddress(int index)

Gets the value of a native pointer parameter.

Parameters
index:int

The parameter index

Returns:long

A native memory address.

getByteback to summary
public byte getByte(int index)

Gets the value of an 8 bit integer parameter.

Parameters
index:int

The parameter index

Returns:byte

An 8 bit integer value.

getDoubleback to summary
public double getDouble(int index)

Gets the value of a 64 bit floating point parameter.

Parameters
index:int

The parameter index

Returns:double

A 64 bit floating point value.

getFloatback to summary
public float getFloat(int index)

Gets the value of a 32 bit floating point parameter.

Parameters
index:int

The parameter index

Returns:float

A 32 bit floating point value.

getIntback to summary
public int getInt(int index)

Gets the value of a 32 bit integer parameter.

Parameters
index:int

The parameter index

Returns:int

A 32 bit integer value.

getLongback to summary
public long getLong(int index)

Gets the value of a 64 bit integer parameter.

Parameters
index:int

The parameter index

Returns:long

A 64 bit integer value.

getShortback to summary
public short getShort(int index)

Gets the value of a 16 bit integer parameter.

Parameters
index:int

The parameter index

Returns:short

A 16 bit integer value.

getStructback to summary
public long getStruct(int index)

Gets the address of a struct parameter that is passed by value.

Parameters
index:int

The parameter index

Returns:long

A native memory address.

setAddressReturnback to summary
public void setAddressReturn(long address)

Sets the closure return value to a native pointer value.

Parameters
address:long

The native pointer value to return from the closure.

setByteReturnback to summary
public void setByteReturn(byte value)

Sets the closure return value to an 8 bit integer value.

Parameters
value:byte

The 8 bit integer value to return from the closure.

setDoubleReturnback to summary
public void setDoubleReturn(double value)

Sets the closure return value to a 64 bit floating point value.

Parameters
value:double

The 64 bit floating point value to return from the closure.

setFloatReturnback to summary
public void setFloatReturn(float value)

Sets the closure return value to a 32 bit floating point value.

Parameters
value:float

The 32 bit floating point value to return from the closure.

setIntReturnback to summary
public void setIntReturn(int value)

Sets the closure return value to a 32 bit integer value.

Parameters
value:int

The 32 bit integer value to return from the closure.

setLongReturnback to summary
public void setLongReturn(long value)

Sets the closure return value to a 64 bit integer value.

Parameters
value:long

The 64 bit integer value to return from the closure.

setShortReturnback to summary
public void setShortReturn(short value)

Sets the closure return value to a 16 bit integer value.

Parameters
value:short

The 16 bit integer value to return from the closure.

setStructReturnback to summary
public void setStructReturn(long address)

Sets the closure return value to the contents of a struct

Parameters
address:long

The address of a native struct to return as a struct value from the closure.

setStructReturnback to summary
public void setStructReturn(byte[] data, int offset)

Sets the closure return value to the contents of a struct

Parameters
data:byte[]

Struct data packed into a byte array to return as a struct value from the closure.

offset:int

the offset within the byte array to start copying data

com.kenai.jffi back to summary

public Interface Closure.Handle

Known Direct Implementers
com.kenai.jffi.ClosureMagazine.Handle, com.kenai.jffi.ClosurePool.Handle

A Handle is allocated by the ClosureManager, as a strong reference to the native closure trampoline.

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Releases the closure memory back to the operating system.

public void
free()

Deprecated
public long

Returns:

The native address of the closure code.
getAddress
()

Gets the native code address of the closure.

public void
setAutoRelease(boolean
If true, the closure memory is automatically managed, else the closure memory must be explicitly freed.
autorelease
)

Sets whether the closure memory should be released when the Handle is garbage collected or not.

Method Detail

disposeback to summary
public void dispose()

Releases the closure memory back to the operating system. Although the closure trampoline memory will normally be released when the Handle is garbage collected, this may not happen for some time, and is non-deterministic. This allows explicit control over memory reclamation.

freeback to summary
public void free()

Deprecated

Annotations
@Deprecated
getAddressback to summary
public long getAddress()

Gets the native code address of the closure. This can be passed into a native function that takes a function pointer.

Returns:long

The native address of the closure code.

setAutoReleaseback to summary
public void setAutoRelease(boolean autorelease)

Sets whether the closure memory should be released when the Handle is garbage collected or not.

Parameters
autorelease:boolean

If true, the closure memory is automatically managed, else the closure memory must be explicitly freed.