Class ObjectBuffer

java.lang.Object
com.kenai.jffi.ObjectBuffer

final class ObjectBuffer extends Object
Holds objects the native code must handle - such as primitive arrays
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (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 address
    static final int
    The jobject handle
    (package private) static final int
     
    private int
    The index of the next object storage slot
    private Object[]
    The objects stored in this buffer
    static final int
    After calling the function, reload the array contents from native memory
    static 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
    Constructor
    Description
     
    ObjectBuffer(int objectCount)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private final void
    Ensures that sufficient space is available to insert at least one more object
    (package private) final int[]
    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 this ObjectBuffer.
    (package private) final Object[]
    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
    putJNI(int index, Object obj, int type)
    Put the address of the current JNIEnv into this parameter position
    (package private) void
    putObject(Object array, int offset, int length, int flags)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ObjectBuffer

      ObjectBuffer()
    • ObjectBuffer

      ObjectBuffer(int objectCount)
  • Method Details

    • objectCount

      final int objectCount()
      Gets the number of objects stored in this ObjectBuffer.
      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 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, 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, 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(Object array, int offset, int length, int flags)