Class DirectClosureBuffer

java.lang.Object
com.kenai.jffi.DirectClosureBuffer
All Implemented Interfaces:
Closure.Buffer

final class DirectClosureBuffer extends Object implements Closure.Buffer
Implementation of the Closure.Buffer interface to read/write parameter and return value data in native memory
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    Reads annd writes data types that are smaller than the size of a native long, as a native long for compatibility with FFI.
    private static final class 
     
    private static final class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final CallContext
     
    private static final MemoryIO
     
    private static final long
     
    private final long
     
    private final long
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DirectClosureBuffer(CallContext callContext, long retval, long parameters)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final long
    getAddress(int index)
    Gets the value of a native pointer parameter.
    final byte
    getByte(int index)
    Gets the value of an 8 bit integer parameter.
    final double
    getDouble(int index)
    Gets the value of a 64 bit floating point parameter.
    final float
    getFloat(int index)
    Gets the value of a 32 bit floating point parameter.
    final int
    getInt(int index)
    Gets the value of a 32 bit integer parameter.
    final long
    getLong(int index)
    Gets the value of a 64 bit integer parameter.
    final short
    getShort(int index)
    Gets the value of a 16 bit integer parameter.
    final long
    getStruct(int index)
    Gets the address of a struct parameter that is passed by value.
    final void
    setAddressReturn(long address)
    Sets the closure return value to a native pointer value.
    final void
    setByteReturn(byte value)
    Sets the closure return value to an 8 bit integer value.
    final void
    setDoubleReturn(double value)
    Sets the closure return value to a 64 bit floating point value.
    final void
    setFloatReturn(float value)
    Sets the closure return value to a 32 bit floating point value.
    final void
    setIntReturn(int value)
    Sets the closure return value to a 32 bit integer value.
    final void
    setLongReturn(long value)
    Sets the closure return value to a 64 bit integer value.
    final void
    setShortReturn(short value)
    Sets the closure return value to a 16 bit integer value.
    void
    setStructReturn(byte[] data, int offset)
    Sets the closure return value to the contents of a struct
    void
    setStructReturn(long value)
    Sets the closure return value to the contents of a struct

    Methods inherited from class java.lang.Object

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

    • IO

      private static final MemoryIO IO
    • WordIO

      private static final DirectClosureBuffer.NativeWordIO WordIO
    • PARAM_SIZE

      private static final long PARAM_SIZE
    • retval

      private final long retval
    • parameters

      private final long parameters
    • callContext

      private final CallContext callContext
  • Constructor Details

    • DirectClosureBuffer

      public DirectClosureBuffer(CallContext callContext, long retval, long parameters)
  • Method Details

    • getByte

      public final byte getByte(int index)
      Description copied from interface: Closure.Buffer
      Gets the value of an 8 bit integer parameter.
      Specified by:
      getByte in interface Closure.Buffer
      Parameters:
      index - The parameter index
      Returns:
      An 8 bit integer value.
    • getShort

      public final short getShort(int index)
      Description copied from interface: Closure.Buffer
      Gets the value of a 16 bit integer parameter.
      Specified by:
      getShort in interface Closure.Buffer
      Parameters:
      index - The parameter index
      Returns:
      A 16 bit integer value.
    • getInt

      public final int getInt(int index)
      Description copied from interface: Closure.Buffer
      Gets the value of a 32 bit integer parameter.
      Specified by:
      getInt in interface Closure.Buffer
      Parameters:
      index - The parameter index
      Returns:
      A 32 bit integer value.
    • getLong

      public final long getLong(int index)
      Description copied from interface: Closure.Buffer
      Gets the value of a 64 bit integer parameter.
      Specified by:
      getLong in interface Closure.Buffer
      Parameters:
      index - The parameter index
      Returns:
      A 64 bit integer value.
    • getFloat

      public final float getFloat(int index)
      Description copied from interface: Closure.Buffer
      Gets the value of a 32 bit floating point parameter.
      Specified by:
      getFloat in interface Closure.Buffer
      Parameters:
      index - The parameter index
      Returns:
      A 32 bit floating point value.
    • getDouble

      public final double getDouble(int index)
      Description copied from interface: Closure.Buffer
      Gets the value of a 64 bit floating point parameter.
      Specified by:
      getDouble in interface Closure.Buffer
      Parameters:
      index - The parameter index
      Returns:
      A 64 bit floating point value.
    • getAddress

      public final long getAddress(int index)
      Description copied from interface: Closure.Buffer
      Gets the value of a native pointer parameter.
      Specified by:
      getAddress in interface Closure.Buffer
      Parameters:
      index - The parameter index
      Returns:
      A native memory address.
    • getStruct

      public final long getStruct(int index)
      Description copied from interface: Closure.Buffer
      Gets the address of a struct parameter that is passed by value.
      Specified by:
      getStruct in interface Closure.Buffer
      Parameters:
      index - The parameter index
      Returns:
      A native memory address.
    • setByteReturn

      public final void setByteReturn(byte value)
      Description copied from interface: Closure.Buffer
      Sets the closure return value to an 8 bit integer value.
      Specified by:
      setByteReturn in interface Closure.Buffer
      Parameters:
      value - The 8 bit integer value to return from the closure.
    • setShortReturn

      public final void setShortReturn(short value)
      Description copied from interface: Closure.Buffer
      Sets the closure return value to a 16 bit integer value.
      Specified by:
      setShortReturn in interface Closure.Buffer
      Parameters:
      value - The 16 bit integer value to return from the closure.
    • setIntReturn

      public final void setIntReturn(int value)
      Description copied from interface: Closure.Buffer
      Sets the closure return value to a 32 bit integer value.
      Specified by:
      setIntReturn in interface Closure.Buffer
      Parameters:
      value - The 32 bit integer value to return from the closure.
    • setLongReturn

      public final void setLongReturn(long value)
      Description copied from interface: Closure.Buffer
      Sets the closure return value to a 64 bit integer value.
      Specified by:
      setLongReturn in interface Closure.Buffer
      Parameters:
      value - The 64 bit integer value to return from the closure.
    • setFloatReturn

      public final void setFloatReturn(float value)
      Description copied from interface: Closure.Buffer
      Sets the closure return value to a 32 bit floating point value.
      Specified by:
      setFloatReturn in interface Closure.Buffer
      Parameters:
      value - The 32 bit floating point value to return from the closure.
    • setDoubleReturn

      public final void setDoubleReturn(double value)
      Description copied from interface: Closure.Buffer
      Sets the closure return value to a 64 bit floating point value.
      Specified by:
      setDoubleReturn in interface Closure.Buffer
      Parameters:
      value - The 64 bit floating point value to return from the closure.
    • setAddressReturn

      public final void setAddressReturn(long address)
      Description copied from interface: Closure.Buffer
      Sets the closure return value to a native pointer value.
      Specified by:
      setAddressReturn in interface Closure.Buffer
      Parameters:
      address - The native pointer value to return from the closure.
    • setStructReturn

      public void setStructReturn(long value)
      Description copied from interface: Closure.Buffer
      Sets the closure return value to the contents of a struct
      Specified by:
      setStructReturn in interface Closure.Buffer
      Parameters:
      value - The address of a native struct to return as a struct value from the closure.
    • setStructReturn

      public void setStructReturn(byte[] data, int offset)
      Description copied from interface: Closure.Buffer
      Sets the closure return value to the contents of a struct
      Specified by:
      setStructReturn in interface Closure.Buffer
      Parameters:
      data - Struct data packed into a byte array to return as a struct value from the closure.
      offset - the offset within the byte array to start copying data