Package com.kenai.jffi
Class ObjectBuffer
- java.lang.Object
-
- com.kenai.jffi.ObjectBuffer
-
final class ObjectBuffer extends java.lang.ObjectHolds objects the native code must handle - such as primitive arrays
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static intARRAY(package private) static intBOOLEAN(package private) static intBUFFER(package private) static intBYTE(package private) static intCHARstatic intCLEARFor OUT arrays, clear the temporary native memory area(package private) static intDOUBLE(package private) static intFLAGS_MASK(package private) static intFLAGS_SHIFT(package private) static intFLOATstatic intINCopy the array contents to native memory before calling the function(package private) static intINDEX_MASK(package private) static intINDEX_SHIFTprivate int[]infoThe flags/offset/length descriptor array.private intinfoIndexThe index of the next descriptor storage slot(package private) static intINT(package private) static intJNIstatic intJNIENVThe JNIEnv addressstatic intJNIOBJECTThe jobject handle(package private) static intLONGprivate intobjectIndexThe index of the next object storage slotprivate java.lang.Object[]objectsThe objects stored in this bufferstatic intOUTAfter calling the function, reload the array contents from native memorystatic intPINNEDPin the array memory and pass the JVM memory pointer directly to the function(package private) static intPRIM_MASK(package private) static intSHORT(package private) static intTYPE_MASK(package private) static intTYPE_SHIFTstatic intZERO_TERMINATEAppend a NUL byte to the array contents after copying to native memory
-
Constructor Summary
Constructors Constructor Description ObjectBuffer()ObjectBuffer(int objectCount)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidensureSpace()Ensures that sufficient space is available to insert at least one more object(package private) int[]info()Gets the object descriptor array.(package private) static intmakeBufferFlags(int index)Encodes the native object flags for an NIO Buffer.private static intmakeJNIFlags(int index, int type)(package private) static intmakeObjectFlags(int ioflags, int type, int index)Encodes the native object flags for an array.(package private) intobjectCount()Gets the number of objects stored in thisObjectBuffer.(package private) java.lang.Object[]objects()Gets the array of stored objects.voidputArray(int index, boolean[] array, int offset, int length, int flags)Adds a java boolean array as a pointer parameter.voidputArray(int index, byte[] array, int offset, int length, int flags)Adds a java byte array as a pointer parameter.voidputArray(int index, char[] array, int offset, int length, int flags)Adds a java char array as a pointer parameter.voidputArray(int index, double[] array, int offset, int length, int flags)Adds a java double array as a pointer parameter.voidputArray(int index, float[] array, int offset, int length, int flags)Adds a java float array as a pointer parameter.voidputArray(int index, int[] array, int offset, int length, int flags)Adds a java int array as a pointer parameter.voidputArray(int index, long[] array, int offset, int length, int flags)Adds a java long array as a pointer parameter.voidputArray(int index, short[] array, int offset, int length, int flags)Adds a java short array as a pointer parameter.voidputDirectBuffer(int index, java.nio.Buffer obj, int offset, int length)Adds a java direct buffer as a pointer parameter.voidputJNI(int index, java.lang.Object obj, int type)Put the address of the current JNIEnv into this parameter position(package private) voidputObject(java.lang.Object array, int offset, int length, int flags)
-
-
-
Field Detail
-
IN
@Native public static final int IN
Copy the array contents to native memory before calling the function- See Also:
- Constant Field Values
-
OUT
@Native public static final int OUT
After calling the function, reload the array contents from native memory- See Also:
- Constant Field Values
-
ZERO_TERMINATE
@Native public static final int ZERO_TERMINATE
Append a NUL byte to the array contents after copying to native memory- See Also:
- Constant Field Values
-
PINNED
@Native public static final int PINNED
Pin the array memory and pass the JVM memory pointer directly to the function- See Also:
- Constant Field Values
-
CLEAR
@Native public static final int CLEAR
For OUT arrays, clear the temporary native memory area- See Also:
- Constant Field Values
-
INDEX_SHIFT
@Native static final int INDEX_SHIFT
- See Also:
- Constant Field Values
-
INDEX_MASK
@Native static final int INDEX_MASK
- See Also:
- Constant Field Values
-
TYPE_SHIFT
@Native static final int TYPE_SHIFT
- See Also:
- Constant Field Values
-
TYPE_MASK
@Native static final int TYPE_MASK
- See Also:
- Constant Field Values
-
PRIM_MASK
@Native static final int PRIM_MASK
- See Also:
- Constant Field Values
-
FLAGS_SHIFT
@Native static final int FLAGS_SHIFT
- See Also:
- Constant Field Values
-
FLAGS_MASK
@Native static final int FLAGS_MASK
- See Also:
- Constant Field Values
-
ARRAY
@Native static final int ARRAY
- See Also:
- Constant Field Values
-
BUFFER
@Native static final int BUFFER
- See Also:
- Constant Field Values
-
JNI
@Native static final int JNI
- See Also:
- Constant Field Values
-
BYTE
@Native static final int BYTE
- See Also:
- Constant Field Values
-
SHORT
@Native static final int SHORT
- See Also:
- Constant Field Values
-
INT
@Native static final int INT
- See Also:
- Constant Field Values
-
LONG
@Native static final int LONG
- See Also:
- Constant Field Values
-
FLOAT
@Native static final int FLOAT
- See Also:
- Constant Field Values
-
DOUBLE
@Native static final int DOUBLE
- See Also:
- Constant Field Values
-
BOOLEAN
@Native static final int BOOLEAN
- See Also:
- Constant Field Values
-
CHAR
@Native static final int CHAR
- See Also:
- Constant Field Values
-
JNIENV
@Native public static final int JNIENV
The JNIEnv address- See Also:
- Constant Field Values
-
JNIOBJECT
@Native public static final int JNIOBJECT
The jobject handle- See Also:
- Constant Field Values
-
objects
private java.lang.Object[] objects
The objects stored in this buffer
-
info
private int[] info
The 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 infoIndex
The index of the next descriptor storage slot
-
objectIndex
private int objectIndex
The index of the next object storage slot
-
-
Method Detail
-
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
final java.lang.Object[] 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
public void putDirectBuffer(int index, java.nio.Buffer obj, int offset, int length)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
public void putJNI(int index, java.lang.Object obj, int type)Put the address of the current JNIEnv into this parameter position- Parameters:
index- The index of the parameter.
-
putObject
void putObject(java.lang.Object array, int offset, int length, int flags)
-
-