Class FFM

java.lang.Object
org.lwjgl.system.ffm.FFM

  • Field Details

    • int8_t

      public static final ValueLayout.OfByte int8_t
      A layout that can be used to map the C int8_t type.
    • int16_t

      public static final ValueLayout.OfShort int16_t
      A layout that can be used to map the C int16_t type.
    • int32_t

      public static final ValueLayout.OfInt int32_t
      A layout that can be used to map the C int32_t type.
    • int64_t

      public static final ValueLayout.OfLong int64_t
      A layout that can be used to map the C int64_t type.
    • uint8_t

      public static final ValueLayout.OfByte uint8_t
      A layout that can be used to map the C uint8_t type.
    • uint16_t

      public static final ValueLayout.OfShort uint16_t
      A layout that can be used to map the C uint16_t type.
    • uint32_t

      public static final ValueLayout.OfInt uint32_t
      A layout that can be used to map the C uint32_t type.
    • uint64_t

      public static final ValueLayout.OfLong uint64_t
      A layout that can be used to map the C uint64_t type.
    • size_t

      public static final AddressLayout size_t
      A layout that can be used to map the C size_t type.
    • ptrdiff_t

      public static final AddressLayout ptrdiff_t
      A layout that can be used to map the C ssize_t type.
    • intptr_t

      public static final AddressLayout intptr_t
      A layout that can be used to map the C intptr_t type.
    • uintptr_t

      public static final AddressLayout uintptr_t
      A layout that can be used to map the C uintptr_t type.
    • cchar

      public static final ValueLayout.OfByte cchar
      A layout that can be used to map the C char type.
    • cshort

      public static final ValueLayout.OfShort cshort
      A layout that can be used to map the C short type.
    • cint

      public static final ValueLayout.OfInt cint
      A layout that can be used to map the C int type.
    • clong

      public static final ValueLayout clong
      A layout that can be used to map the C long type.
    • long_long

      public static final ValueLayout.OfLong long_long
      A layout that can be used to map the C long long type.
    • unsigned_char

      public static final ValueLayout.OfByte unsigned_char
      A layout that can be used to map the C unsigned char type.
    • unsigned_short

      public static final ValueLayout.OfShort unsigned_short
      A layout that can be used to map the C unsigned short type.
    • unsigned_int

      public static final ValueLayout.OfInt unsigned_int
      A layout that can be used to map the C unsigned int type.
    • unsigned_clong

      public static final ValueLayout unsigned_clong
      A layout that can be used to map the C unsigned long type.
    • unsigned_long_long

      public static final ValueLayout.OfLong unsigned_long_long
      A layout that can be used to map the C unsigned long long type.
    • float32

      public static final ValueLayout.OfFloat float32
      A layout that can be used to map the C float type.
    • float64

      public static final ValueLayout.OfDouble float64
      A layout that can be used to map the C double type.
  • Method Details

    • bootstrapDowncall

      public static MethodHandle bootstrapDowncall(MethodHandles.Lookup lookup, String name, Class<?> bootstrapClass, int methodIndex) throws IllegalAccessException
      The Condy boostrap method for downcalls, called the first time the LDC bytecode is executed. [INTERNAL API]
      Throws:
      IllegalAccessException
    • typedef

      public static ValueLayout.OfByte typedef(String name, ValueLayout.OfByte layout)
      Creates an alias of the specified layout with a new name.
      Parameters:
      name - the new name
      layout - the layout to alias
      Returns:
      the new layout
    • typedef

      public static ValueLayout.OfShort typedef(String name, ValueLayout.OfShort layout)
      Creates an alias of the specified layout with a new name.
      Parameters:
      name - the new name
      layout - the layout to alias
      Returns:
      the new layout
    • typedef

      public static ValueLayout.OfInt typedef(String name, ValueLayout.OfInt layout)
      Creates an alias of the specified layout with a new name.
      Parameters:
      name - the new name
      layout - the layout to alias
      Returns:
      the new layout
    • typedef

      public static ValueLayout.OfLong typedef(String name, ValueLayout.OfLong layout)
      Creates an alias of the specified layout with a new name.
      Parameters:
      name - the new name
      layout - the layout to alias
      Returns:
      the new layout
    • typedef

      public static ValueLayout.OfFloat typedef(String name, ValueLayout.OfFloat layout)
      Creates an alias of the specified layout with a new name.
      Parameters:
      name - the new name
      layout - the layout to alias
      Returns:
      the new layout
    • typedef

      public static ValueLayout.OfDouble typedef(String name, ValueLayout.OfDouble layout)
      Creates an alias of the specified layout with a new name.
      Parameters:
      name - the new name
      layout - the layout to alias
      Returns:
      the new layout
    • typedef

      public static ValueLayout typedef(String name, ValueLayout layout)
      Creates an alias of the specified layout with a new name.
      Parameters:
      name - the new name
      layout - the layout to alias
      Returns:
      the new layout
    • typedef

      public static AddressLayout typedef(String name, AddressLayout layout)
      Creates an alias of the specified layout with a new name.
      Parameters:
      name - the new name
      layout - the layout to alias
      Returns:
      the new layout
    • typedef

      public static SequenceLayout typedef(String name, SequenceLayout layout)
      Creates an alias of the specified layout with a new name.
      Parameters:
      name - the new name
      layout - the layout to alias
      Returns:
      the new layout
    • typedef

      public static StructLayout typedef(String name, StructLayout layout)
      Creates an alias of the specified layout with a new name.
      Parameters:
      name - the new name
      layout - the layout to alias
      Returns:
      the new layout
    • typedef

      public static UnionLayout typedef(String name, UnionLayout layout)
      Creates an alias of the specified layout with a new name.
      Parameters:
      name - the new name
      layout - the layout to alias
      Returns:
      the new layout
    • array

      public static SequenceLayout array(MemoryLayout layout, long elementCount)
      Creates a SequenceLayout with the specified named layout and element count.
      Parameters:
      layout - the element layout, which must be named
      elementCount - the number of elements
      Returns:
      the sequence layout
    • opaque

      public static AddressLayout opaque(String name)
      Creates an opaque pointer layout with the specified name.
      Parameters:
      name - the opaque pointer name
      Returns:
      the opaque pointer layout
    • p

      public static AddressLayout p(GroupBinder<?,?> binder)
      Creates a pointer layout that targets the specified binder's layout.
      Parameters:
      binder - the binder that provides the target layout
      Returns:
      the pointer layout
    • p

      public static AddressLayout p(MemoryLayout layout)
      Creates a pointer layout that targets the specified layout.
      Parameters:
      layout - the target layout
      Returns:
      the pointer layout
    • ffmStruct

      public static <T> FFM.StructBinderBuilder<T> ffmStruct(Class<T> structInterface)
      Creates a StructBinder builder for the specified struct interface, with the default state.
      Parameters:
      structInterface - the struct interface
      Returns:
      the struct binder builder
    • ffmUnion

      public static <T> FFM.UnionBinderBuilder<T> ffmUnion(Class<T> unionInterface)
      Creates a UnionBinder builder for the specified union interface, with the default state.
      Parameters:
      unionInterface - the union interface
      Returns:
      the union binder builder
    • ffmUpcall

      public static <T> UpcallBinder<T> ffmUpcall(Class<T> upcallInterface)
      Generates a class that implements the UpcallBinder interface for the specified upcall interface, then returns a new instance of that class.
      Parameters:
      upcallInterface - the upcall interface
      Returns:
      the UpcallBinder implementation
    • ffmUpcall

      public static <T> UpcallBinder<T> ffmUpcall(Class<T> upcallInterface, @Nullable FFICIF cif)
      Generates a class that implements the UpcallBinder interface for the specified upcall interface and associated libffi call interface, then returns a new instance of that class.

      This method is used for integration with LWJGL 3 callbacks. It should not be used for custom bindings.

      Parameters:
      upcallInterface - the upcall interface
      cif - the libffi call interface
      Returns:
      the UpcallBinder implementation
    • ffmScopedArena

      public static ScopedValue<Arena> ffmScopedArena()
      Returns the scoped arena.

      This method is used for integration with LWJGL 3 callbacks. It should not be used for custom bindings.

    • ffmScopedRun

      public static void ffmScopedRun(Arena arena, Runnable runnable)
      Runs the specified runnable within the scope of the specified arena. If the bindings generator needs to allocate memory before this method returns, it will use this arena.

      This method is used for integration with LWJGL 3 callbacks. It should not be used for custom bindings.

      Parameters:
      arena - the arena
      runnable - the runnable
    • ffmScopedCall

      public static <R, X extends Throwable> R ffmScopedCall(Arena arena, ScopedValue.CallableOp<? extends R, X> op) throws X
      Runs the specified operation within the scope of the specified arena. If the bindings generator needs to allocate memory before this method returns, it will use this arena.

      This method is used for integration with LWJGL 3 callbacks. It should not be used for custom bindings.

      Parameters:
      arena - the arena
      op - the operation
      Returns:
      the result of the operation
      Throws:
      X
    • ffmGenerate

      public static <T> T ffmGenerate(Class<T> bindingInterface)
      Generates a class that implements the specified binding interface, using the FFMConfig registered for this interface.
      Parameters:
      bindingInterface - the binding interface
      Returns:
      the generated binding implementation
      Throws:
      IllegalStateException - if no FFMConfig is registered for the specified interface
    • ffmGenerate

      public static <T> T ffmGenerate(Class<T> bindingInterface, FFMConfig config)
      Generates a class that implements the specified binding interface, using the specified FFMConfig.
      Parameters:
      bindingInterface - the binding interface
      config - the binding configuration
      Returns:
      the generated binding implementation
    • ffmConfigBuilder

      public static FFM.FFMConfigBuilder ffmConfigBuilder(MethodHandles.Lookup lookup)
      Creates a builder for FFMConfig instances, with the default state.
    • ffmConfig

      public static void ffmConfig(Package _package, @Nullable FFMConfig config)
      Registers a binding configuration for the specified package.

      The specified configuration will be used when generating any interface that belongs to this package, for which a more specific configuration does not exist.

      Parameters:
      _package - the package
      config - the binding configuration, or null to unregister the specified package
      See Also:
    • ffmConfig

      public static void ffmConfig(Class<?> _class, @Nullable FFMConfig config)
      Registers a binding configuration for the specified class.

      The specified configuration will be used when generating any interface that is this class or is enclosed by it, for which a more specific configuration does not exist.

      Parameters:
      _class - the class
      config - the binding configuration, or null to unregister the specified class
      See Also: