Package com.kenai.jffi
Class DirectClosureBuffer
- java.lang.Object
-
- com.kenai.jffi.DirectClosureBuffer
-
- All Implemented Interfaces:
Closure.Buffer
final class DirectClosureBuffer extends java.lang.Object implements Closure.Buffer
Implementation of theClosure.Buffer
interface to read/write parameter and return value data in native memory
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DirectClosureBuffer.NativeWordIO
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 class
DirectClosureBuffer.NativeWordIO32
private static class
DirectClosureBuffer.NativeWordIO64
-
Field Summary
Fields Modifier and Type Field Description private CallContext
callContext
private static MemoryIO
IO
private static long
PARAM_SIZE
private long
parameters
private long
retval
private static DirectClosureBuffer.NativeWordIO
WordIO
-
Constructor Summary
Constructors Constructor Description DirectClosureBuffer(CallContext callContext, long retval, long parameters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getAddress(int index)
Gets the value of a native pointer parameter.byte
getByte(int index)
Gets the value of an 8 bit integer parameter.double
getDouble(int index)
Gets the value of a 64 bit floating point parameter.float
getFloat(int index)
Gets the value of a 32 bit floating point parameter.int
getInt(int index)
Gets the value of a 32 bit integer parameter.long
getLong(int index)
Gets the value of a 64 bit integer parameter.short
getShort(int index)
Gets the value of a 16 bit integer parameter.long
getStruct(int index)
Gets the address of a struct parameter that is passed by value.void
setAddressReturn(long address)
Sets the closure return value to a native pointer value.void
setByteReturn(byte value)
Sets the closure return value to an 8 bit integer value.void
setDoubleReturn(double value)
Sets the closure return value to a 64 bit floating point value.void
setFloatReturn(float value)
Sets the closure return value to a 32 bit floating point value.void
setIntReturn(int value)
Sets the closure return value to a 32 bit integer value.void
setLongReturn(long value)
Sets the closure return value to a 64 bit integer value.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 Detail
-
IO
private static final MemoryIO IO
-
WordIO
private static final DirectClosureBuffer.NativeWordIO WordIO
-
PARAM_SIZE
private static final long PARAM_SIZE
-
retval
private final long retval
-
parameters
private final long parameters
-
callContext
private final CallContext callContext
-
-
Constructor Detail
-
DirectClosureBuffer
public DirectClosureBuffer(CallContext callContext, long retval, long parameters)
-
-
Method Detail
-
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
-
-