Class FFIType

java.lang.Object
org.lwjgl.system.Pointer.Default
org.lwjgl.system.Struct
org.lwjgl.system.libffi.FFIType
All Implemented Interfaces:
AutoCloseable, org.lwjgl.system.NativeResource, org.lwjgl.system.Pointer

public class FFIType extends org.lwjgl.system.Struct implements org.lwjgl.system.NativeResource
Contains information about a libffi type.

Layout


 struct ffi_type {
     size_t size();
     unsigned short alignment();
     unsigned short type();
     ffi_type * elements(int);
 }
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    An array of FFIType structs.

    Nested classes/interfaces inherited from class org.lwjgl.system.Struct

    org.lwjgl.system.Struct.StructValidation

    Nested classes/interfaces inherited from interface org.lwjgl.system.Pointer

    org.lwjgl.system.Pointer.Default
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The struct member offsets.
    static final int
    The struct alignment in bytes.
    static final int
    The struct member offsets.
    static final int
    The struct member offsets.
    static final int
    The struct size in bytes.
    static final int
    The struct member offsets.

    Fields inherited from interface org.lwjgl.system.Pointer

    BITS32, BITS64, CLONG_SHIFT, CLONG_SIZE, POINTER_SHIFT, POINTER_SIZE
  • Constructor Summary

    Constructors
    Constructor
    Description
    FFIType(ByteBuffer container)
    Creates a FFIType instance at the current position of the specified ByteBuffer container.
  • Method Summary

    Modifier and Type
    Method
    Description
    short
    set by libffi; you should initialize it to zero.
    alignment(short value)
    Sets the specified value to the alignment() field.
    static FFIType
    Returns a new FFIType instance allocated with memCalloc.
    calloc(int capacity)
    Returns a new FFIType.Buffer instance allocated with memCalloc.
    calloc(int capacity, org.lwjgl.system.MemoryStack stack)
    Returns a new FFIType.Buffer instance allocated on the specified MemoryStack and initializes all its bits to zero.
    static FFIType
    calloc(org.lwjgl.system.MemoryStack stack)
    Returns a new FFIType instance allocated on the specified MemoryStack and initializes all its bits to zero.
    static FFIType
    Returns a new FFIType instance allocated with BufferUtils.
    create(int capacity)
    Returns a new FFIType.Buffer instance allocated with BufferUtils.
    static FFIType
    create(long address)
    Returns a new FFIType instance for the specified memory address.
    create(long address, int capacity)
    Create a FFIType.Buffer instance at the specified memory.
    static FFIType
    createSafe(long address)
    Like create, but returns null if address is NULL.
    createSafe(long address, int capacity)
    Like create, but returns null if address is NULL.
    org.lwjgl.PointerBuffer
    elements(int capacity)
     
    elements(org.lwjgl.PointerBuffer value)
    Sets the address of the specified PointerBuffer to the elements(int) field.
    static FFIType
    Returns a new FFIType instance allocated with memAlloc.
    malloc(int capacity)
    Returns a new FFIType.Buffer instance allocated with memAlloc.
    malloc(int capacity, org.lwjgl.system.MemoryStack stack)
    Returns a new FFIType.Buffer instance allocated on the specified MemoryStack.
    static FFIType
    malloc(org.lwjgl.system.MemoryStack stack)
    Returns a new FFIType instance allocated on the specified MemoryStack.
    static short
    nalignment(long struct)
    Unsafe version of alignment().
    static void
    nalignment(long struct, short value)
    Unsafe version of alignment.
    static org.lwjgl.PointerBuffer
    nelements(long struct, int capacity)
    Unsafe version of elements.
    static void
    nelements(long struct, org.lwjgl.PointerBuffer value)
    Unsafe version of elements.
    static long
    nsize(long struct)
    Unsafe version of size().
    static void
    nsize(long struct, long value)
    Unsafe version of size.
    static short
    ntype(long struct)
    Unsafe version of type().
    static void
    ntype(long struct, short value)
    Unsafe version of type.
    set(long size, short alignment, short type, org.lwjgl.PointerBuffer elements)
    Initializes this struct with the specified values.
    set(FFIType src)
    Copies the specified struct data to this struct.
    long
    set by libffi; you should initialize it to zero.
    size(long value)
    Sets the specified value to the size() field.
    int
     
    short
    for a structure, this should be set to TYPE_STRUCT.
    type(short value)
    Sets the specified value to the type() field.

    Methods inherited from class org.lwjgl.system.Struct

    clear, free, isNull, validate

    Methods inherited from class org.lwjgl.system.Pointer.Default

    address, equals, hashCode, toString

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.lwjgl.system.NativeResource

    close, free
  • Field Details

    • SIZEOF

      public static final int SIZEOF
      The struct size in bytes.
    • ALIGNOF

      public static final int ALIGNOF
      The struct alignment in bytes.
    • SIZE

      public static final int SIZE
      The struct member offsets.
    • ALIGNMENT

      public static final int ALIGNMENT
      The struct member offsets.
    • TYPE

      public static final int TYPE
      The struct member offsets.
    • ELEMENTS

      public static final int ELEMENTS
      The struct member offsets.
  • Constructor Details

    • FFIType

      public FFIType(ByteBuffer container)
      Creates a FFIType instance at the current position of the specified ByteBuffer container. Changes to the buffer's content will be visible to the struct instance and vice versa.

      The created instance holds a strong reference to the container object.

  • Method Details

    • sizeof

      public int sizeof()
      Specified by:
      sizeof in class org.lwjgl.system.Struct
    • size

      public long size()
      set by libffi; you should initialize it to zero.
    • alignment

      public short alignment()
      set by libffi; you should initialize it to zero.
    • type

      public short type()
      for a structure, this should be set to TYPE_STRUCT.
    • elements

      @Nullable public org.lwjgl.PointerBuffer elements(int capacity)
      Parameters:
      capacity - the number of elements in the returned buffer
      Returns:
      a null-terminated array of pointers to ffi_type objects. There is one element per field of the struct.
    • size

      public FFIType size(long value)
      Sets the specified value to the size() field.
    • alignment

      public FFIType alignment(short value)
      Sets the specified value to the alignment() field.
    • type

      public FFIType type(short value)
      Sets the specified value to the type() field.
    • elements

      public FFIType elements(@Nullable org.lwjgl.PointerBuffer value)
      Sets the address of the specified PointerBuffer to the elements(int) field.
    • set

      public FFIType set(long size, short alignment, short type, @Nullable org.lwjgl.PointerBuffer elements)
      Initializes this struct with the specified values.
    • set

      public FFIType set(FFIType src)
      Copies the specified struct data to this struct.
      Parameters:
      src - the source struct
      Returns:
      this struct
    • malloc

      public static FFIType malloc()
      Returns a new FFIType instance allocated with memAlloc. The instance must be explicitly freed.
    • calloc

      public static FFIType calloc()
      Returns a new FFIType instance allocated with memCalloc. The instance must be explicitly freed.
    • create

      public static FFIType create()
      Returns a new FFIType instance allocated with BufferUtils.
    • create

      public static FFIType create(long address)
      Returns a new FFIType instance for the specified memory address.
    • createSafe

      @Nullable public static FFIType createSafe(long address)
      Like create, but returns null if address is NULL.
    • malloc

      public static FFIType.Buffer malloc(int capacity)
      Returns a new FFIType.Buffer instance allocated with memAlloc. The instance must be explicitly freed.
      Parameters:
      capacity - the buffer capacity
    • calloc

      public static FFIType.Buffer calloc(int capacity)
      Returns a new FFIType.Buffer instance allocated with memCalloc. The instance must be explicitly freed.
      Parameters:
      capacity - the buffer capacity
    • create

      public static FFIType.Buffer create(int capacity)
      Returns a new FFIType.Buffer instance allocated with BufferUtils.
      Parameters:
      capacity - the buffer capacity
    • create

      public static FFIType.Buffer create(long address, int capacity)
      Create a FFIType.Buffer instance at the specified memory.
      Parameters:
      address - the memory address
      capacity - the buffer capacity
    • createSafe

      @Nullable public static FFIType.Buffer createSafe(long address, int capacity)
      Like create, but returns null if address is NULL.
    • malloc

      public static FFIType malloc(org.lwjgl.system.MemoryStack stack)
      Returns a new FFIType instance allocated on the specified MemoryStack.
      Parameters:
      stack - the stack from which to allocate
    • calloc

      public static FFIType calloc(org.lwjgl.system.MemoryStack stack)
      Returns a new FFIType instance allocated on the specified MemoryStack and initializes all its bits to zero.
      Parameters:
      stack - the stack from which to allocate
    • malloc

      public static FFIType.Buffer malloc(int capacity, org.lwjgl.system.MemoryStack stack)
      Returns a new FFIType.Buffer instance allocated on the specified MemoryStack.
      Parameters:
      capacity - the buffer capacity
      stack - the stack from which to allocate
    • calloc

      public static FFIType.Buffer calloc(int capacity, org.lwjgl.system.MemoryStack stack)
      Returns a new FFIType.Buffer instance allocated on the specified MemoryStack and initializes all its bits to zero.
      Parameters:
      capacity - the buffer capacity
      stack - the stack from which to allocate
    • nsize

      public static long nsize(long struct)
      Unsafe version of size().
    • nalignment

      public static short nalignment(long struct)
      Unsafe version of alignment().
    • ntype

      public static short ntype(long struct)
      Unsafe version of type().
    • nelements

      @Nullable public static org.lwjgl.PointerBuffer nelements(long struct, int capacity)
      Unsafe version of elements.
    • nsize

      public static void nsize(long struct, long value)
      Unsafe version of size.
    • nalignment

      public static void nalignment(long struct, short value)
      Unsafe version of alignment.
    • ntype

      public static void ntype(long struct, short value)
      Unsafe version of type.
    • nelements

      public static void nelements(long struct, @Nullable org.lwjgl.PointerBuffer value)
      Unsafe version of elements.