Top Description Fields Constructors Methods
com.kenai.jffi

pack-priv final Class ObjectBuffer

extends Object
Class Inheritance
Imports
java.lang.annotation.Native

Holds objects the native code must handle - such as primitive arrays

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
public static final int
CLEAR

For OUT arrays, clear the temporary native memory area

pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
public static final int
IN

Copy the array contents to native memory before calling the function

pack-priv static final int
pack-priv static final int
private int[]
info

The flags/offset/length descriptor array.

private int
infoIndex

The index of the next descriptor storage slot

pack-priv static final int
pack-priv static final int
public static final int
JNIENV

The JNIEnv address

public static final int
JNIOBJECT

The jobject handle

pack-priv static final int
private int
objectIndex

The index of the next object storage slot

private Object[]
objects

The objects stored in this buffer

public static final int
OUT

After calling the function, reload the array contents from native memory

public static final int
PINNED

Pin the array memory and pass the JVM memory pointer directly to the function

pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
public static final int
ZERO_TERMINATE

Append a NUL byte to the array contents after copying to native memory

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
ObjectBuffer(int objectCount)

Method Summary

Modifier and TypeMethod and Description
private final void
ensureSpace()

Ensures that sufficient space is available to insert at least one more object

pack-priv final int[]

Returns:

An array of integers describing the objects stored.
info
()

Gets the object descriptor array.

pack-priv static final int

Returns:

A bitmask of flags.
makeBufferFlags
(int
The parameter index of the buffer.
index
)

Encodes the native object flags for an NIO Buffer.

private static final int
makeJNIFlags(int index, int type)

pack-priv static final int

Returns:

A bitmask of flags.
makeObjectFlags
(int
The array flags (IN, OUT) for the object.
ioflags
,
int
The type of the object.
type
,
int
The parameter index the object should be passed as.
index
)

Encodes the native object flags for an array.

pack-priv final int

Returns:

the number of objects already stored.
objectCount
()

Gets the number of objects stored in this ObjectBuffer.

pack-priv final Object[]

Returns:

An array of objects stored in this buffer.
objects
()

Gets the array of stored objects.

public void
putArray(int index, byte[]
The java array to use as the pointer parameter.
array
,
int
The offset from the start of the array.
offset
,
int
The length of the array to use.
length
,
int
The flags to use (IN, OUT, NULTERMINATE)
flags
)

Adds a java byte array as a pointer parameter.

public void
putArray(int index, short[]
The java array to use as the pointer parameter.
array
,
int
The offset from the start of the array.
offset
,
int
The length of the array to use.
length
,
int
The flags to use (IN, OUT)
flags
)

Adds a java short array as a pointer parameter.

public void
putArray(int index, int[]
The java array to use as the pointer parameter.
array
,
int
The offset from the start of the array.
offset
,
int
The length of the array to use.
length
,
int
The flags to use (IN, OUT)
flags
)

Adds a java int array as a pointer parameter.

public void
putArray(int index, long[]
The java array to use as the pointer parameter.
array
,
int
The offset from the start of the array.
offset
,
int
The length of the array to use.
length
,
int
The flags to use (IN, OUT)
flags
)

Adds a java long array as a pointer parameter.

public void
putArray(int index, float[]
The java array to use as the pointer parameter.
array
,
int
The offset from the start of the array.
offset
,
int
The length of the array to use.
length
,
int
The flags to use (IN, OUT)
flags
)

Adds a java float array as a pointer parameter.

public void
putArray(int index, double[]
The java array to use as the pointer parameter.
array
,
int
The offset from the start of the array.
offset
,
int
The length of the array to use.
length
,
int
The flags to use (IN, OUT)
flags
)

Adds a java double array as a pointer parameter.

public void
putArray(int index, boolean[]
The java array to use as the pointer parameter.
array
,
int
The offset from the start of the array.
offset
,
int
The length of the array to use.
length
,
int
The flags to use (IN, OUT)
flags
)

Adds a java boolean array as a pointer parameter.

public void
putArray(int index, char[]
The java array to use as the pointer parameter.
array
,
int
The offset from the start of the array.
offset
,
int
The length of the array to use.
length
,
int
The flags to use (IN, OUT)
flags
)

Adds a java char array as a pointer parameter.

public void
putDirectBuffer(int
The buffer to use as a pointer argument.
index
,
Buffer obj, int
An offset to add to the buffer native address.
offset
,
int
The length of the buffer to use.
length
)

Adds a java direct buffer as a pointer parameter.

public void
putJNI(int
The index of the parameter.
index
,
Object obj, int type)

Put the address of the current JNIEnv into this parameter position

pack-priv void
putObject(Object array, int offset, int length, int flags)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ARRAYback to summary
pack-priv static final int ARRAY
Annotations
@Native
BOOLEANback to summary
pack-priv static final int BOOLEAN
Annotations
@Native
BUFFERback to summary
pack-priv static final int BUFFER
Annotations
@Native
BYTEback to summary
pack-priv static final int BYTE
Annotations
@Native
CHARback to summary
pack-priv static final int CHAR
Annotations
@Native
CLEARback to summary
public static final int CLEAR

For OUT arrays, clear the temporary native memory area

Annotations
@Native
DOUBLEback to summary
pack-priv static final int DOUBLE
Annotations
@Native
FLAGS_MASKback to summary
pack-priv static final int FLAGS_MASK
Annotations
@Native
FLAGS_SHIFTback to summary
pack-priv static final int FLAGS_SHIFT
Annotations
@Native
FLOATback to summary
pack-priv static final int FLOAT
Annotations
@Native
INback to summary
public static final int IN

Copy the array contents to native memory before calling the function

Annotations
@Native
INDEX_MASKback to summary
pack-priv static final int INDEX_MASK
Annotations
@Native
INDEX_SHIFTback to summary
pack-priv static final int INDEX_SHIFT
Annotations
@Native
infoback to summary
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.

infoIndexback to summary
private int infoIndex

The index of the next descriptor storage slot

INTback to summary
pack-priv static final int INT
Annotations
@Native
JNIback to summary
pack-priv static final int JNI
Annotations
@Native
JNIENVback to summary
public static final int JNIENV

The JNIEnv address

Annotations
@Native
JNIOBJECTback to summary
public static final int JNIOBJECT

The jobject handle

Annotations
@Native
LONGback to summary
pack-priv static final int LONG
Annotations
@Native
objectIndexback to summary
private int objectIndex

The index of the next object storage slot

objectsback to summary
private Object[] objects

The objects stored in this buffer

OUTback to summary
public static final int OUT

After calling the function, reload the array contents from native memory

Annotations
@Native
PINNEDback to summary
public static final int PINNED

Pin the array memory and pass the JVM memory pointer directly to the function

Annotations
@Native
PRIM_MASKback to summary
pack-priv static final int PRIM_MASK
Annotations
@Native
SHORTback to summary
pack-priv static final int SHORT
Annotations
@Native
TYPE_MASKback to summary
pack-priv static final int TYPE_MASK
Annotations
@Native
TYPE_SHIFTback to summary
pack-priv static final int TYPE_SHIFT
Annotations
@Native
ZERO_TERMINATEback to summary
public static final int ZERO_TERMINATE

Append a NUL byte to the array contents after copying to native memory

Annotations
@Native

Constructor Detail

ObjectBufferback to summary
pack-priv ObjectBuffer()
ObjectBufferback to summary
pack-priv ObjectBuffer(int objectCount)

Method Detail

ensureSpaceback to summary
private final void ensureSpace()

Ensures that sufficient space is available to insert at least one more object

infoback to summary
pack-priv final int[] info()

Gets the object descriptor array.

Returns:int[]

An array of integers describing the objects stored.

makeBufferFlagsback to summary
pack-priv static final int makeBufferFlags(int index)

Encodes the native object flags for an NIO Buffer.

Parameters
index:int

The parameter index of the buffer.

Returns:int

A bitmask of flags.

makeJNIFlagsback to summary
private static final int makeJNIFlags(int index, int type)
makeObjectFlagsback to summary
pack-priv static final int makeObjectFlags(int ioflags, int type, int index)

Encodes the native object flags for an array.

Parameters
ioflags:int

The array flags (IN, OUT) for the object.

type:int

The type of the object.

index:int

The parameter index the object should be passed as.

Returns:int

A bitmask of flags.

objectCountback to summary
pack-priv final int objectCount()

Gets the number of objects stored in this ObjectBuffer.

Returns:int

the number of objects already stored.

objectsback to summary
pack-priv final Object[] objects()

Gets the array of stored objects.

Returns:Object[]

An array of objects stored in this buffer.

putArrayback to summary
public void putArray(int index, byte[] array, int offset, int length, int flags)

Adds a java byte array as a pointer parameter.

Parameters
array:byte[]

The java array to use as the pointer parameter.

offset:int

The offset from the start of the array.

length:int

The length of the array to use.

flags:int

The flags to use (IN, OUT, NULTERMINATE)

putArrayback to summary
public void putArray(int index, short[] array, int offset, int length, int flags)

Adds a java short array as a pointer parameter.

Parameters
array:short[]

The java array to use as the pointer parameter.

offset:int

The offset from the start of the array.

length:int

The length of the array to use.

flags:int

The flags to use (IN, OUT)

putArrayback to summary
public void putArray(int index, int[] array, int offset, int length, int flags)

Adds a java int array as a pointer parameter.

Parameters
array:int[]

The java array to use as the pointer parameter.

offset:int

The offset from the start of the array.

length:int

The length of the array to use.

flags:int

The flags to use (IN, OUT)

putArrayback to summary
public void putArray(int index, long[] array, int offset, int length, int flags)

Adds a java long array as a pointer parameter.

Parameters
array:long[]

The java array to use as the pointer parameter.

offset:int

The offset from the start of the array.

length:int

The length of the array to use.

flags:int

The flags to use (IN, OUT)

putArrayback to summary
public void putArray(int index, float[] array, int offset, int length, int flags)

Adds a java float array as a pointer parameter.

Parameters
array:float[]

The java array to use as the pointer parameter.

offset:int

The offset from the start of the array.

length:int

The length of the array to use.

flags:int

The flags to use (IN, OUT)

putArrayback to summary
public void putArray(int index, double[] array, int offset, int length, int flags)

Adds a java double array as a pointer parameter.

Parameters
array:double[]

The java array to use as the pointer parameter.

offset:int

The offset from the start of the array.

length:int

The length of the array to use.

flags:int

The flags to use (IN, OUT)

putArrayback to summary
public void putArray(int index, boolean[] array, int offset, int length, int flags)

Adds a java boolean array as a pointer parameter.

Parameters
array:boolean[]

The java array to use as the pointer parameter.

offset:int

The offset from the start of the array.

length:int

The length of the array to use.

flags:int

The flags to use (IN, OUT)

putArrayback to summary
public void putArray(int index, char[] array, int offset, int length, int flags)

Adds a java char array as a pointer parameter.

Parameters
array:char[]

The java array to use as the pointer parameter.

offset:int

The offset from the start of the array.

length:int

The length of the array to use.

flags:int

The flags to use (IN, OUT)

putDirectBufferback to summary
public void putDirectBuffer(int index, Buffer obj, int offset, int length)

Adds a java direct buffer as a pointer parameter.

Parameters
index:int

The buffer to use as a pointer argument.

offset:int

An offset to add to the buffer native address.

length:int

The length of the buffer to use.

putJNIback to summary
public void putJNI(int index, Object obj, int type)

Put the address of the current JNIEnv into this parameter position

Parameters
index:int

The index of the parameter.

putObjectback to summary
pack-priv void putObject(Object array, int offset, int length, int flags)