Package jnr.ffi

Class Struct

  • Direct Known Subclasses:
    Union

    public abstract class Struct
    extends java.lang.Object
    Representation of C structures in java. Note: This class is not threadsafe.
    • Constructor Detail

      • Struct

        protected Struct​(Runtime runtime)
        Creates a new Struct.
        Parameters:
        runtime - The current runtime.
      • Struct

        protected Struct​(Runtime runtime,
                         Struct enclosing)
      • Struct

        protected Struct​(Runtime runtime,
                         boolean isUnion)
        Creates a new Struct.
        Parameters:
        runtime - the current jnr-ffi runtime
        isUnion - if this Struct is a Union
    • Method Detail

      • getRuntime

        public final Runtime getRuntime()
      • useMemory

        public final void useMemory​(Pointer address)
        Uses the specified memory address as the backing store for this structure.
        Parameters:
        address - the native memory area.
      • getMemory

        public static Pointer getMemory​(Struct struct,
                                        int flags)
      • size

        public static int size​(Struct struct)
      • alignment

        public static int alignment​(Struct struct)
      • isDirect

        public static boolean isDirect​(Struct struct)
      • arrayOf

        public static <T extends Struct> T[] arrayOf​(Runtime runtime,
                                                     java.lang.Class<T> type,
                                                     int length)
      • toString

        public java.lang.String toString()
        Returns a human readable String representation of the structure.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String representation of this structure.
      • arrayBegin

        protected final void arrayBegin()
        Starts an array construction session
      • arrayEnd

        protected final void arrayEnd()
        Ends an array construction session
      • array

        protected <T extends Struct.Member> T[] array​(T[] array)
        Creates an array of Member instances.
        Type Parameters:
        T - The type of the Member subclass to create.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected <T extends java.lang.Enum<T>> Struct.Enum8<T>[] array​(Struct.Enum8<T>[] array,
                                                                        java.lang.Class<T> enumClass)
        Creates an array of Enum8 instances.
        Type Parameters:
        T - The type of the java.lang.Enum
        Parameters:
        array - the array to store the instances in
        enumClass - class of java.lang.Enum, these Enum8 instances will represent
        Returns:
        the array that was passed in
      • array

        protected <T extends java.lang.Enum<T>> Struct.Enum16<T>[] array​(Struct.Enum16<T>[] array,
                                                                         java.lang.Class<T> enumClass)
        Creates an array of Enum16 instances.
        Type Parameters:
        T - The type of the java.lang.Enum
        Parameters:
        array - the array to store the instances in
        enumClass - class of java.lang.Enum, these Enum16 instances will represent
        Returns:
        the array that was passed in
      • array

        protected <T extends java.lang.Enum<T>> Struct.Enum32<T>[] array​(Struct.Enum32<T>[] array,
                                                                         java.lang.Class<T> enumClass)
        Creates an array of Enum32 instances.
        Type Parameters:
        T - The type of the java.lang.Enum
        Parameters:
        array - the array to store the instances in
        enumClass - class of java.lang.Enum, these Enum32 instances will represent
        Returns:
        the array that was passed in
      • array

        protected <T extends java.lang.Enum<T>> Struct.Enum64<T>[] array​(Struct.Enum64<T>[] array,
                                                                         java.lang.Class<T> enumClass)
        Creates an array of Enum64 instances.
        Type Parameters:
        T - The type of the java.lang.Enum
        Parameters:
        array - the array to store the instances in
        enumClass - class of java.lang.Enum, these Enum64 instances will represent
        Returns:
        the array that was passed in
      • array

        protected <T extends java.lang.Enum<T>> Struct.Enum<T>[] array​(Struct.Enum<T>[] array,
                                                                       java.lang.Class<T> enumClass)
        Creates an array of Enum instances.
        Type Parameters:
        T - The type of the java.lang.Enum
        Parameters:
        array - the array to store the instances in
        enumClass - class of java.lang.Enum, these Enum instances will represent
        Returns:
        the array that was passed in
      • array

        protected <T extends Struct> T[] array​(T[] array)
        Creates an array of Struct instances.
        Type Parameters:
        T - the type of Struct
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.Signed8[] array​(Struct.Signed8[] array)
        Creates an array of Signed8 instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.Unsigned8[] array​(Struct.Unsigned8[] array)
        Creates an array of Unsigned8 instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.Signed16[] array​(Struct.Signed16[] array)
        Creates an array of Signed16 instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.Unsigned16[] array​(Struct.Unsigned16[] array)
        Creates an array of Unsigned16 instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.Signed32[] array​(Struct.Signed32[] array)
        Creates an array of Signed32 instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.Unsigned32[] array​(Struct.Unsigned32[] array)
        Creates an array of Unsigned32 instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.Signed64[] array​(Struct.Signed64[] array)
        Creates an array of Signed64 instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.Unsigned64[] array​(Struct.Unsigned64[] array)
        Creates an array of Unsigned64 instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.SignedLong[] array​(Struct.SignedLong[] array)
        Creates an array of SignedLong instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.UnsignedLong[] array​(Struct.UnsignedLong[] array)
        Creates an array of UnsignedLong instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.Float[] array​(Struct.Float[] array)
        Creates an array of Float instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.Double[] array​(Struct.Double[] array)
        Creates an array of Double instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.Address[] array​(Struct.Address[] array)
        Creates an array of Address instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected final Struct.Pointer[] array​(Struct.Pointer[] array)
        Creates an array of Pointer instances.
        Parameters:
        array - the array to store the instances in
        Returns:
        the array that was passed in
      • array

        protected Struct.UTF8String[] array​(Struct.UTF8String[] array,
                                            int stringLength)
        Creates an array of UTF8String instances.
        Parameters:
        array - the array to store the instances in
        stringLength - length of each string in array
        Returns:
        the array that was passed in
      • inner

        protected final <T extends Struct> T inner​(T struct)
      • function

        protected final <T> Struct.Function<T> function​(java.lang.Class<T> closureClass)