Class FFIType

  • All Implemented Interfaces:
    java.lang.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  FFIType.Buffer
      An array of FFIType structs.
      • Nested classes/interfaces inherited from interface org.lwjgl.system.Pointer

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

        org.lwjgl.system.Struct.StructValidation
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ALIGNMENT
      The struct member offsets.
      static int ALIGNOF
      The struct alignment in bytes.
      static int ELEMENTS
      SIZE
      The struct member offsets.
      static int SIZEOF
      The struct size in bytes.
      static int TYPE
      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​(java.nio.ByteBuffer container)
      Creates a FFIType instance at the current position of the specified ByteBuffer container.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      short alignment()
      set by libffi; you should initialize it to zero.
      FFIType alignment​(short value)
      Sets the specified value to the alignment() field.
      static FFIType calloc()
      Returns a new FFIType instance allocated with memCalloc.
      static FFIType.Buffer calloc​(int capacity)
      Returns a new FFIType.Buffer instance allocated with memCalloc.
      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.
      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 create()
      Returns a new FFIType instance allocated with BufferUtils.
      static FFIType.Buffer 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.
      static FFIType.Buffer 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.
      static FFIType.Buffer createSafe​(long address, int capacity)
      Like create, but returns null if address is NULL.
      org.lwjgl.PointerBuffer elements​(int capacity)  
      FFIType elements​(org.lwjgl.PointerBuffer value)
      Sets the address of the specified PointerBuffer to the elements(int) field.
      static FFIType malloc()
      Returns a new FFIType instance allocated with memAlloc.
      static FFIType.Buffer malloc​(int capacity)
      Returns a new FFIType.Buffer instance allocated with memAlloc.
      static FFIType.Buffer 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.
      FFIType set​(long size, short alignment, short type, org.lwjgl.PointerBuffer elements)
      Initializes this struct with the specified values.
      FFIType set​(FFIType src)
      Copies the specified struct data to this struct.
      long size()
      set by libffi; you should initialize it to zero.
      FFIType size​(long value)
      Sets the specified value to the size() field.
      int sizeof()  
      short type()
      for a structure, this should be set to TYPE_STRUCT.
      FFIType type​(short value)
      Sets the specified value to the type() field.
      • Methods inherited from interface org.lwjgl.system.NativeResource

        close, free
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from class org.lwjgl.system.Pointer.Default

        address, equals, hashCode, toString
      • Methods inherited from class org.lwjgl.system.Struct

        clear, free, isNull, validate
    • Field Detail

      • SIZEOF

        The struct size in bytes.
      • ALIGNOF

        The struct alignment in bytes.
      • SIZE, ALIGNMENT, TYPE, ELEMENTS

        The struct member offsets.
    • Constructor Detail

      • FFIType

        public FFIType​(java.nio.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 Detail

      • sizeof

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

        public long size()
        
        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:
        stack - the stack from which to allocate
        capacity - the buffer capacity
      • 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:
        stack - the stack from which to allocate
        capacity - the buffer capacity
      • 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.