Package com.kenai.jffi
Class DirectClosureBuffer
java.lang.Object
com.kenai.jffi.DirectClosureBuffer
- All Implemented Interfaces:
Closure.Buffer
Implementation of the
Closure.Buffer
interface to read/write
parameter and return value data in native memory-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Reads annd writes data types that are smaller than the size of a native long, as a native long for compatibility with FFI.private static final class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CallContext
private static final MemoryIO
private static final long
private final long
private final long
private static final DirectClosureBuffer.NativeWordIO
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal long
getAddress
(int index) Gets the value of a native pointer parameter.final byte
getByte
(int index) Gets the value of an 8 bit integer parameter.final double
getDouble
(int index) Gets the value of a 64 bit floating point parameter.final float
getFloat
(int index) Gets the value of a 32 bit floating point parameter.final int
getInt
(int index) Gets the value of a 32 bit integer parameter.final long
getLong
(int index) Gets the value of a 64 bit integer parameter.final short
getShort
(int index) Gets the value of a 16 bit integer parameter.final long
getStruct
(int index) Gets the address of a struct parameter that is passed by value.final void
setAddressReturn
(long address) Sets the closure return value to a native pointer value.final void
setByteReturn
(byte value) Sets the closure return value to an 8 bit integer value.final void
setDoubleReturn
(double value) Sets the closure return value to a 64 bit floating point value.final void
setFloatReturn
(float value) Sets the closure return value to a 32 bit floating point value.final void
setIntReturn
(int value) Sets the closure return value to a 32 bit integer value.final void
setLongReturn
(long value) Sets the closure return value to a 64 bit integer value.final void
setShortReturn
(short value) Sets the closure return value to a 16 bit integer value.void
setStructReturn
(byte[] data, int offset) Sets the closure return value to the contents of a structvoid
setStructReturn
(long value) Sets the closure return value to the contents of a struct
-
Field Details
-
IO
-
WordIO
-
PARAM_SIZE
private static final long PARAM_SIZE -
retval
private final long retval -
parameters
private final long parameters -
callContext
-
-
Constructor Details
-
DirectClosureBuffer
-
-
Method Details
-
getByte
public final byte getByte(int index) Description copied from interface:Closure.Buffer
Gets the value of an 8 bit integer parameter.- Specified by:
getByte
in interfaceClosure.Buffer
- Parameters:
index
- The parameter index- Returns:
- An 8 bit integer value.
-
getShort
public final short getShort(int index) Description copied from interface:Closure.Buffer
Gets the value of a 16 bit integer parameter.- Specified by:
getShort
in interfaceClosure.Buffer
- Parameters:
index
- The parameter index- Returns:
- A 16 bit integer value.
-
getInt
public final int getInt(int index) Description copied from interface:Closure.Buffer
Gets the value of a 32 bit integer parameter.- Specified by:
getInt
in interfaceClosure.Buffer
- Parameters:
index
- The parameter index- Returns:
- A 32 bit integer value.
-
getLong
public final long getLong(int index) Description copied from interface:Closure.Buffer
Gets the value of a 64 bit integer parameter.- Specified by:
getLong
in interfaceClosure.Buffer
- Parameters:
index
- The parameter index- Returns:
- A 64 bit integer value.
-
getFloat
public final float getFloat(int index) Description copied from interface:Closure.Buffer
Gets the value of a 32 bit floating point parameter.- Specified by:
getFloat
in interfaceClosure.Buffer
- Parameters:
index
- The parameter index- Returns:
- A 32 bit floating point value.
-
getDouble
public final double getDouble(int index) Description copied from interface:Closure.Buffer
Gets the value of a 64 bit floating point parameter.- Specified by:
getDouble
in interfaceClosure.Buffer
- Parameters:
index
- The parameter index- Returns:
- A 64 bit floating point value.
-
getAddress
public final long getAddress(int index) Description copied from interface:Closure.Buffer
Gets the value of a native pointer parameter.- Specified by:
getAddress
in interfaceClosure.Buffer
- Parameters:
index
- The parameter index- Returns:
- A native memory address.
-
getStruct
public final long getStruct(int index) Description copied from interface:Closure.Buffer
Gets the address of a struct parameter that is passed by value.- Specified by:
getStruct
in interfaceClosure.Buffer
- Parameters:
index
- The parameter index- Returns:
- A native memory address.
-
setByteReturn
public final void setByteReturn(byte value) Description copied from interface:Closure.Buffer
Sets the closure return value to an 8 bit integer value.- Specified by:
setByteReturn
in interfaceClosure.Buffer
- Parameters:
value
- The 8 bit integer value to return from the closure.
-
setShortReturn
public final void setShortReturn(short value) Description copied from interface:Closure.Buffer
Sets the closure return value to a 16 bit integer value.- Specified by:
setShortReturn
in interfaceClosure.Buffer
- Parameters:
value
- The 16 bit integer value to return from the closure.
-
setIntReturn
public final void setIntReturn(int value) Description copied from interface:Closure.Buffer
Sets the closure return value to a 32 bit integer value.- Specified by:
setIntReturn
in interfaceClosure.Buffer
- Parameters:
value
- The 32 bit integer value to return from the closure.
-
setLongReturn
public final void setLongReturn(long value) Description copied from interface:Closure.Buffer
Sets the closure return value to a 64 bit integer value.- Specified by:
setLongReturn
in interfaceClosure.Buffer
- Parameters:
value
- The 64 bit integer value to return from the closure.
-
setFloatReturn
public final void setFloatReturn(float value) Description copied from interface:Closure.Buffer
Sets the closure return value to a 32 bit floating point value.- Specified by:
setFloatReturn
in interfaceClosure.Buffer
- Parameters:
value
- The 32 bit floating point value to return from the closure.
-
setDoubleReturn
public final void setDoubleReturn(double value) Description copied from interface:Closure.Buffer
Sets the closure return value to a 64 bit floating point value.- Specified by:
setDoubleReturn
in interfaceClosure.Buffer
- Parameters:
value
- The 64 bit floating point value to return from the closure.
-
setAddressReturn
public final void setAddressReturn(long address) Description copied from interface:Closure.Buffer
Sets the closure return value to a native pointer value.- Specified by:
setAddressReturn
in interfaceClosure.Buffer
- Parameters:
address
- The native pointer value to return from the closure.
-
setStructReturn
public void setStructReturn(long value) Description copied from interface:Closure.Buffer
Sets the closure return value to the contents of a struct- Specified by:
setStructReturn
in interfaceClosure.Buffer
- Parameters:
value
- The address of a native struct to return as a struct value from the closure.
-
setStructReturn
public void setStructReturn(byte[] data, int offset) Description copied from interface:Closure.Buffer
Sets the closure return value to the contents of a struct- Specified by:
setStructReturn
in interfaceClosure.Buffer
- Parameters:
data
- Struct data packed into a byte array to return as a struct value from the closure.offset
- the offset within the byte array to start copying data
-