Package com.kenai.jffi
Class HeapInvocationBuffer
- java.lang.Object
-
- com.kenai.jffi.InvocationBuffer
-
- com.kenai.jffi.HeapInvocationBuffer
-
public final class HeapInvocationBuffer extends InvocationBuffer
An implementation ofInvocationBufferthat packs its parameters onto a java heap allocated buffer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classHeapInvocationBuffer.ArrayIOprivate static classHeapInvocationBuffer.BE32ArrayIOBig endian, 32 bit array encoderprivate static classHeapInvocationBuffer.BE64ArrayIOBig endian, 64 bit array encoderprivate static classHeapInvocationBuffer.BigEndianArrayIOBase class for all big-endian architecture array encoders.private static classHeapInvocationBuffer.DefaultEncoder(package private) static classHeapInvocationBuffer.EncoderEncodes java data types into native parameter framesprivate static classHeapInvocationBuffer.InvalidArrayIOprivate static classHeapInvocationBuffer.LE32ArrayIOLittle endian, 32 bit implementation ofArrayIOprivate static classHeapInvocationBuffer.LE64ArrayIOLittle endian, 64 bit implementation ofArrayIOprivate static classHeapInvocationBuffer.LittleEndianArrayIOBase class for all little-endian architecture array encoders.
-
Field Summary
Fields Modifier and Type Field Description private byte[]bufferprivate CallContextcallContextprivate ObjectBufferobjectBufferprivate static intPARAM_SIZEprivate intparamIndexprivate intparamOffset
-
Constructor Summary
Constructors Constructor Description HeapInvocationBuffer(CallContext callContext)Creates a new instance ofHeapInvocationBuffer.HeapInvocationBuffer(CallContext context, int objectCount)Creates a new instance ofHeapInvocationBuffer.HeapInvocationBuffer(Function function)Creates a new instance ofHeapInvocationBuffer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) byte[]array()Gets the backing array of thisInvocationBufferprivate ObjectBuffergetObjectBuffer()(package private) ObjectBufferobjectBuffer()Gets the object buffer used to store java heap array parametersvoidputAddress(long value)Adds a native address parameter.voidputArray(byte[] array, int offset, int length, int flags)Adds a java byte array as a pointer parameter.voidputArray(double[] array, int offset, int length, int flags)Adds a java double array as a pointer parameter.voidputArray(float[] array, int offset, int length, int flags)Adds a java float array as a pointer parameter.voidputArray(int[] array, int offset, int length, int flags)Adds a java int array as a pointer parameter.voidputArray(long[] array, int offset, int length, int flags)Adds a java long array as a pointer parameter.voidputArray(short[] array, int offset, int length, int flags)Adds a java short array as a pointer parameter.voidputByte(int value)Adds an 8 bit integer parameter.voidputDirectBuffer(java.nio.Buffer value, int offset, int length)Adds a java direct buffer as a pointer parameter.voidputDouble(double value)Adds a 64 bit floating point parameter.voidputFloat(float value)Adds a 32 bit floating point parameter.voidputInt(int value)Adds a 32 bit integer parameter.voidputJNIEnvironment()voidputJNIObject(java.lang.Object obj)voidputLong(long value)Adds a 64 bit integer parameter.voidputLongDouble(double value)voidputLongDouble(java.math.BigDecimal value)voidputObject(java.lang.Object o, ObjectParameterStrategy strategy, int flags)voidputObject(java.lang.Object o, ObjectParameterStrategy strategy, ObjectParameterInfo info)voidputShort(int value)Adds a 16 bit integer parameter.voidputStruct(byte[] struct, int offset)Adds a struct or union as a parameter.voidputStruct(long struct)Adds a struct or union as a parameter.
-
-
-
Field Detail
-
PARAM_SIZE
private static final int PARAM_SIZE
- See Also:
- Constant Field Values
-
callContext
private final CallContext callContext
-
buffer
private final byte[] buffer
-
objectBuffer
private ObjectBuffer objectBuffer
-
paramOffset
private int paramOffset
-
paramIndex
private int paramIndex
-
-
Constructor Detail
-
HeapInvocationBuffer
public HeapInvocationBuffer(Function function)
Creates a new instance ofHeapInvocationBuffer.- Parameters:
function- The function that this buffer is going to be used with.
-
HeapInvocationBuffer
public HeapInvocationBuffer(CallContext callContext)
Creates a new instance ofHeapInvocationBuffer.- Parameters:
callContext- TheCallContextdescribing how the function should be invoked
-
HeapInvocationBuffer
public HeapInvocationBuffer(CallContext context, int objectCount)
Creates a new instance ofHeapInvocationBuffer.- Parameters:
context- TheCallContextdescribing how the function should be invoked
-
-
Method Detail
-
array
byte[] array()
Gets the backing array of thisInvocationBuffer- Returns:
- The backing array for this buffer.
-
objectBuffer
ObjectBuffer objectBuffer()
Gets the object buffer used to store java heap array parameters- Returns:
- An
ObjectBuffer
-
putByte
public final void putByte(int value)
Description copied from class:InvocationBufferAdds an 8 bit integer parameter.- Specified by:
putBytein classInvocationBuffer- Parameters:
value- An 8 bit integer value to use as the parameter.
-
putShort
public final void putShort(int value)
Description copied from class:InvocationBufferAdds a 16 bit integer parameter.- Specified by:
putShortin classInvocationBuffer- Parameters:
value- A 16 bit integer value to use as the parameter.
-
putInt
public final void putInt(int value)
Description copied from class:InvocationBufferAdds a 32 bit integer parameter.- Specified by:
putIntin classInvocationBuffer- Parameters:
value- A 32 bit integer value to use as the parameter.
-
putLong
public final void putLong(long value)
Description copied from class:InvocationBufferAdds a 64 bit integer parameter.- Specified by:
putLongin classInvocationBuffer- Parameters:
value- A 64 bit integer value to use as the parameter.
-
putFloat
public final void putFloat(float value)
Description copied from class:InvocationBufferAdds a 32 bit floating point parameter.- Specified by:
putFloatin classInvocationBuffer- Parameters:
value- A 32 bit floating point value to use as the parameter.
-
putDouble
public final void putDouble(double value)
Description copied from class:InvocationBufferAdds a 64 bit floating point parameter.- Specified by:
putDoublein classInvocationBuffer- Parameters:
value- A 64 bit floating point value to use as the parameter.
-
putLongDouble
public final void putLongDouble(double value)
-
putLongDouble
public final void putLongDouble(java.math.BigDecimal value)
-
putAddress
public final void putAddress(long value)
Description copied from class:InvocationBufferAdds a native address parameter.- Specified by:
putAddressin classInvocationBuffer- Parameters:
value- A native address value to use as the parameter.
-
getObjectBuffer
private final ObjectBuffer getObjectBuffer()
-
putArray
public final void putArray(byte[] array, int offset, int length, int flags)Description copied from class:InvocationBufferAdds a java byte array as a pointer parameter.- Specified by:
putArrayin classInvocationBuffer- Parameters:
array- The java array to use as the pointer parameter.offset- The offset from the start of the array.length- The length of the array to use.flags- The flags to use (IN, OUT)
-
putArray
public final void putArray(short[] array, int offset, int length, int flags)Description copied from class:InvocationBufferAdds a java short array as a pointer parameter.- Specified by:
putArrayin classInvocationBuffer- Parameters:
array- The java array to use as the pointer parameter.offset- The offset from the start of the array.length- The length of the array to use.flags- The flags to use (IN, OUT)
-
putArray
public final void putArray(int[] array, int offset, int length, int flags)Description copied from class:InvocationBufferAdds a java int array as a pointer parameter.- Specified by:
putArrayin classInvocationBuffer- Parameters:
array- The java array to use as the pointer parameter.offset- The offset from the start of the array.length- The length of the array to use.flags- The flags to use (IN, OUT)
-
putArray
public final void putArray(long[] array, int offset, int length, int flags)Description copied from class:InvocationBufferAdds a java long array as a pointer parameter.- Specified by:
putArrayin classInvocationBuffer- Parameters:
array- The java array to use as the pointer parameter.offset- The offset from the start of the array.length- The length of the array to use.flags- The flags to use (IN, OUT)
-
putArray
public final void putArray(float[] array, int offset, int length, int flags)Description copied from class:InvocationBufferAdds a java float array as a pointer parameter.- Specified by:
putArrayin classInvocationBuffer- Parameters:
array- The java array to use as the pointer parameter.offset- The offset from the start of the array.length- The length of the array to use.flags- The flags to use (IN, OUT)
-
putArray
public final void putArray(double[] array, int offset, int length, int flags)Description copied from class:InvocationBufferAdds a java double array as a pointer parameter.- Specified by:
putArrayin classInvocationBuffer- Parameters:
array- The java array to use as the pointer parameter.offset- The offset from the start of the array.length- The length of the array to use.flags- The flags to use (IN, OUT)
-
putDirectBuffer
public final void putDirectBuffer(java.nio.Buffer value, int offset, int length)Description copied from class:InvocationBufferAdds a java direct buffer as a pointer parameter.- Specified by:
putDirectBufferin classInvocationBuffer- Parameters:
value- The buffer to use as a pointer argument.offset- An offset to add to the buffer native address.length- The length of the buffer to use.
-
putStruct
public final void putStruct(byte[] struct, int offset)Description copied from class:InvocationBufferAdds a struct or union as a parameter. This passes the struct or union by value, not by reference.- Specified by:
putStructin classInvocationBuffer- Parameters:
struct- A java byte array with the struct contents.offset- The offset from the start of the array.
-
putStruct
public final void putStruct(long struct)
Description copied from class:InvocationBufferAdds a struct or union as a parameter. This passes the struct or union by value, not by reference.- Specified by:
putStructin classInvocationBuffer- Parameters:
struct- The native address to use as the struct contents.
-
putObject
public final void putObject(java.lang.Object o, ObjectParameterStrategy strategy, ObjectParameterInfo info)
-
putObject
public final void putObject(java.lang.Object o, ObjectParameterStrategy strategy, int flags)
-
putJNIEnvironment
public final void putJNIEnvironment()
-
putJNIObject
public final void putJNIObject(java.lang.Object obj)
-
-