Package com.kenai.jffi
Class ObjectBuffer
java.lang.Object
com.kenai.jffi.ObjectBuffer
Holds objects the native code must handle - such as primitive arrays
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
static final int
For OUT arrays, clear the temporary native memory area(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
static final int
Copy the array contents to native memory before calling the function(package private) static final int
(package private) static final int
private int[]
The flags/offset/length descriptor array.private int
The index of the next descriptor storage slot(package private) static final int
(package private) static final int
static final int
The JNIEnv addressstatic final int
The jobject handle(package private) static final int
private int
The index of the next object storage slotprivate Object[]
The objects stored in this bufferstatic final int
After calling the function, reload the array contents from native memorystatic final int
Pin the array memory and pass the JVM memory pointer directly to the function(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
static final int
Append a NUL byte to the array contents after copying to native memory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate final void
Ensures that sufficient space is available to insert at least one more object(package private) final int[]
info()
Gets the object descriptor array.(package private) static final int
makeBufferFlags
(int index) Encodes the native object flags for an NIO Buffer.private static final int
makeJNIFlags
(int index, int type) (package private) static final int
makeObjectFlags
(int ioflags, int type, int index) Encodes the native object flags for an array.(package private) final int
Gets the number of objects stored in thisObjectBuffer
.(package private) final Object[]
objects()
Gets the array of stored objects.void
putArray
(int index, boolean[] array, int offset, int length, int flags) Adds a java boolean array as a pointer parameter.void
putArray
(int index, byte[] array, int offset, int length, int flags) Adds a java byte array as a pointer parameter.void
putArray
(int index, char[] array, int offset, int length, int flags) Adds a java char array as a pointer parameter.void
putArray
(int index, double[] array, int offset, int length, int flags) Adds a java double array as a pointer parameter.void
putArray
(int index, float[] array, int offset, int length, int flags) Adds a java float array as a pointer parameter.void
putArray
(int index, int[] array, int offset, int length, int flags) Adds a java int array as a pointer parameter.void
putArray
(int index, long[] array, int offset, int length, int flags) Adds a java long array as a pointer parameter.void
putArray
(int index, short[] array, int offset, int length, int flags) Adds a java short array as a pointer parameter.void
putDirectBuffer
(int index, Buffer obj, int offset, int length) Adds a java direct buffer as a pointer parameter.void
Put the address of the current JNIEnv into this parameter position(package private) void
-
Field Details
-
IN
Copy the array contents to native memory before calling the function- See Also:
-
OUT
After calling the function, reload the array contents from native memory- See Also:
-
ZERO_TERMINATE
Append a NUL byte to the array contents after copying to native memory- See Also:
-
PINNED
Pin the array memory and pass the JVM memory pointer directly to the function- See Also:
-
CLEAR
For OUT arrays, clear the temporary native memory area- See Also:
-
INDEX_SHIFT
- See Also:
-
INDEX_MASK
- See Also:
-
TYPE_SHIFT
- See Also:
-
TYPE_MASK
- See Also:
-
PRIM_MASK
- See Also:
-
FLAGS_SHIFT
- See Also:
-
FLAGS_MASK
- See Also:
-
ARRAY
- See Also:
-
BUFFER
- See Also:
-
JNI
- See Also:
-
BYTE
- See Also:
-
SHORT
- See Also:
-
INT
- See Also:
-
LONG
- See Also:
-
FLOAT
- See Also:
-
DOUBLE
- See Also:
-
BOOLEAN
- See Also:
-
CHAR
- See Also:
-
JNIENV
The JNIEnv address- See Also:
-
JNIOBJECT
The jobject handle- See Also:
-
objects
The objects stored in this buffer -
info
private int[] infoThe flags/offset/length descriptor array. Along with each object, a 3-tuple is stored in the descriptor array. The first element of the tuple stores a mask of the type, parameter index and array flags The second element stores the offset within the array the data starts. The third element stores the length of data. -
infoIndex
private int infoIndexThe index of the next descriptor storage slot -
objectIndex
private int objectIndexThe index of the next object storage slot
-
-
Constructor Details
-
ObjectBuffer
ObjectBuffer() -
ObjectBuffer
ObjectBuffer(int objectCount)
-
-
Method Details
-
objectCount
final int objectCount()Gets the number of objects stored in thisObjectBuffer
.- Returns:
- the number of objects already stored.
-
info
final int[] info()Gets the object descriptor array.- Returns:
- An array of integers describing the objects stored.
-
objects
Gets the array of stored objects.- Returns:
- An array of objects stored in this buffer.
-
ensureSpace
private final void ensureSpace()Ensures that sufficient space is available to insert at least one more object -
makeObjectFlags
static final int makeObjectFlags(int ioflags, int type, int index) Encodes the native object flags for an array.- Parameters:
ioflags
- The array flags (IN, OUT) for the object.type
- The type of the object.index
- The parameter index the object should be passed as.- Returns:
- A bitmask of flags.
-
makeBufferFlags
static final int makeBufferFlags(int index) Encodes the native object flags for an NIO Buffer.- Parameters:
index
- The parameter index of the buffer.- Returns:
- A bitmask of flags.
-
makeJNIFlags
private static final int makeJNIFlags(int index, int type) -
putArray
public void putArray(int index, byte[] array, int offset, int length, int flags) Adds a java byte array as a pointer parameter.- 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, NULTERMINATE)
-
putArray
public void putArray(int index, short[] array, int offset, int length, int flags) Adds a java short array as a pointer parameter.- 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 void putArray(int index, int[] array, int offset, int length, int flags) Adds a java int array as a pointer parameter.- 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 void putArray(int index, long[] array, int offset, int length, int flags) Adds a java long array as a pointer parameter.- 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 void putArray(int index, float[] array, int offset, int length, int flags) Adds a java float array as a pointer parameter.- 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 void putArray(int index, double[] array, int offset, int length, int flags) Adds a java double array as a pointer parameter.- 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 void putArray(int index, boolean[] array, int offset, int length, int flags) Adds a java boolean array as a pointer parameter.- 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 void putArray(int index, char[] array, int offset, int length, int flags) Adds a java char array as a pointer parameter.- 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
Adds a java direct buffer as a pointer parameter.- Parameters:
buffer
- 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.
-
putJNI
Put the address of the current JNIEnv into this parameter position- Parameters:
index
- The index of the parameter.
-
putObject
-