com.kenai.jffi
Class HeapInvocationBuffer

java.lang.Object
  extended by com.kenai.jffi.HeapInvocationBuffer
All Implemented Interfaces:
InvocationBuffer

public final class HeapInvocationBuffer
extends java.lang.Object
implements InvocationBuffer

An implementation of InvocationBuffer that packs its parameters onto a java heap allocated buffer.


Constructor Summary
HeapInvocationBuffer(Function function)
          Creates a new instance of HeapInvocationBuffer.
 
Method Summary
 void putAddress(long value)
          Adds a native address parameter.
 void putArray(byte[] array, int offset, int length, int flags)
          Adds a java byte array as a pointer parameter.
 void putArray(double[] array, int offset, int length, int flags)
          Adds a java double array as a pointer parameter.
 void putArray(float[] array, int offset, int length, int flags)
          Adds a java float array as a pointer parameter.
 void putArray(int[] array, int offset, int length, int flags)
          Adds a java int array as a pointer parameter.
 void putArray(long[] array, int offset, int length, int flags)
          Adds a java long array as a pointer parameter.
 void putArray(short[] array, int offset, int length, int flags)
          Adds a java short array as a pointer parameter.
 void putByte(int value)
          Adds an 8 bit integer parameter.
 void putDirectBuffer(java.nio.Buffer value, int offset, int length)
          Adds a java direct buffer as a pointer parameter.
 void putDouble(double value)
          Adds a 64 bit floating point parameter.
 void putFloat(float value)
          Adds a 32 bit floating point parameter.
 void putInt(int value)
          Adds a 32 bit integer parameter.
 void putJNIEnvironment()
           
 void putLong(long value)
          Adds a 64 bit integer parameter.
 void putShort(int value)
          Adds a 16 bit integer parameter.
 void putStruct(byte[] struct, int offset)
          Adds a struct or union as a parameter.
 void putStruct(long struct)
          Adds a struct or union as a parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeapInvocationBuffer

public HeapInvocationBuffer(Function function)
Creates a new instance of HeapInvocationBuffer.

Parameters:
function - The function that this buffer is going to be used with.
Method Detail

putByte

public final void putByte(int value)
Description copied from interface: InvocationBuffer
Adds an 8 bit integer parameter.

Specified by:
putByte in interface InvocationBuffer
Parameters:
value - An 8 bit integer value to use as the parameter.

putShort

public final void putShort(int value)
Description copied from interface: InvocationBuffer
Adds a 16 bit integer parameter.

Specified by:
putShort in interface InvocationBuffer
Parameters:
value - A 16 bit integer value to use as the parameter.

putInt

public final void putInt(int value)
Description copied from interface: InvocationBuffer
Adds a 32 bit integer parameter.

Specified by:
putInt in interface InvocationBuffer
Parameters:
value - A 32 bit integer value to use as the parameter.

putLong

public final void putLong(long value)
Description copied from interface: InvocationBuffer
Adds a 64 bit integer parameter.

Specified by:
putLong in interface InvocationBuffer
Parameters:
value - A 64 bit integer value to use as the parameter.

putFloat

public final void putFloat(float value)
Description copied from interface: InvocationBuffer
Adds a 32 bit floating point parameter.

Specified by:
putFloat in interface InvocationBuffer
Parameters:
value - A 32 bit floating point value to use as the parameter.

putDouble

public final void putDouble(double value)
Description copied from interface: InvocationBuffer
Adds a 64 bit floating point parameter.

Specified by:
putDouble in interface InvocationBuffer
Parameters:
value - A 64 bit floating point value to use as the parameter.

putAddress

public final void putAddress(long value)
Description copied from interface: InvocationBuffer
Adds a native address parameter.

Specified by:
putAddress in interface InvocationBuffer
Parameters:
value - A native address value to use as the parameter.

putArray

public final void putArray(byte[] array,
                           int offset,
                           int length,
                           int flags)
Description copied from interface: InvocationBuffer
Adds a java byte array as a pointer parameter.

Specified by:
putArray in interface InvocationBuffer
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 interface: InvocationBuffer
Adds a java short array as a pointer parameter.

Specified by:
putArray in interface InvocationBuffer
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 interface: InvocationBuffer
Adds a java int array as a pointer parameter.

Specified by:
putArray in interface InvocationBuffer
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 interface: InvocationBuffer
Adds a java long array as a pointer parameter.

Specified by:
putArray in interface InvocationBuffer
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 interface: InvocationBuffer
Adds a java float array as a pointer parameter.

Specified by:
putArray in interface InvocationBuffer
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 interface: InvocationBuffer
Adds a java double array as a pointer parameter.

Specified by:
putArray in interface InvocationBuffer
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 interface: InvocationBuffer
Adds a java direct buffer as a pointer parameter.

Specified by:
putDirectBuffer in interface InvocationBuffer
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 interface: InvocationBuffer
Adds a struct or union as a parameter. This passes the struct or union by value, not by reference.

Specified by:
putStruct in interface InvocationBuffer
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 interface: InvocationBuffer
Adds a struct or union as a parameter. This passes the struct or union by value, not by reference.

Specified by:
putStruct in interface InvocationBuffer
Parameters:
struct - The native address to use as the struct contents.

putJNIEnvironment

public final void putJNIEnvironment()