Interface GroupBinder<L extends GroupLayout, T>

All Known Subinterfaces:
StructBinder<T>, UnionBinder<T>

public sealed interface GroupBinder<L extends GroupLayout, T> permits StructBinder<T>, UnionBinder<T>
The base binder class for struct and union interfaces.

Group binder implementations can be created using the builders returned by ffmStruct and ffmUnion.

See Also:
  • Method Details

    • layout

      L layout()
      Returns the memory layout of the group type.
      Returns:
      the group layout
    • ofAddress

      T ofAddress(long address)
      Creates a group instance at the specified memory address.
      Parameters:
      address - the memory address
      Returns:
      the group instance
    • addressOf

      long addressOf(T value)
      Returns the memory address of the specified group instance.
      Parameters:
      value - the group instance
      Returns:
      the memory address
    • copy

      T copy(T src, T dst)
      Copies the contents of the source group to the destination group.
      Parameters:
      src - the source group instance
      dst - the destination group instance
      Returns:
      the destination group instance
    • clear

      T clear(T value)
      Clears the contents of the specified group instance.
      Parameters:
      value - the group instance
      Returns:
      the cleared group instance
    • get

      T get(MemorySegment segment)
      Returns a group instance mapped to the specified memory segment.
      Parameters:
      segment - the memory segment
      Returns:
      the group instance
    • get

      T get(MemorySegment segment, long offset)
      Returns a group instance mapped to the specified memory segment and offset.
      Parameters:
      segment - the memory segment
      offset - the memory offset
      Returns:
      the group instance
    • getAtIndex

      T getAtIndex(MemorySegment segment, long index)
      Returns a group instance mapped to the specified memory segment and index.
      Parameters:
      segment - the memory segment
      index - the element index
      Returns:
      the group instance
    • sizeof

      default long sizeof()
      Returns the size of the group type, in bytes.
      Returns:
      the size
    • alignof

      default long alignof()
      Returns the alignment of the group type, in bytes.
      Returns:
      the alignment
    • ofAddressSafe

      default @Nullable T ofAddressSafe(long address)
      Returns a group instance at the specified memory address, or null if the address is NULL.
      Parameters:
      address - the memory address
      Returns:
      the group instance, or null if the address is NULL
    • addressOfSafe

      default long addressOfSafe(@Nullable T value)
      Returns the memory address of the specified group instance, or NULL if the instance is null.
      Parameters:
      value - the group instance
      Returns:
      the memory address, or NULL if the instance is null
    • set

      GroupBinder<L,T> set(MemorySegment segment, T value)
      Sets the contents of the specified memory segment to the specified group value.
      Parameters:
      segment - the memory segment
      value - the group instance
      Returns:
      this binder
    • set

      GroupBinder<L,T> set(MemorySegment segment, long offset, T value)
      Sets the contents of the specified memory segment at the specified offset to the specified group value.
      Parameters:
      segment - the memory segment
      offset - the memory offset
      value - the group instance
      Returns:
      this binder
    • setAtIndex

      GroupBinder<L,T> setAtIndex(MemorySegment segment, long index, T value)
      Sets the contents of the specified memory segment at the specified index to the specified group value.
      Parameters:
      segment - the memory segment
      index - the element index
      value - the group instance
      Returns:
      this binder
    • array

      GroupArray<L,T> array(MemorySegment segment)
      Returns a group array mapped to the specified memory segment.
      Parameters:
      segment - the memory segment
      Returns:
      the group array
    • array

      GroupArray<L,T> array(MemorySegment segment, long index)
      Returns a group array mapped to the specified memory segment and starting at the specified index.
      Parameters:
      segment - the memory segment
      index - the starting index
      Returns:
      the group array
    • array

      GroupArray<L,T> array(MemorySegment segment, long index, long elementCount)
      Returns a group array mapped to the specified memory segment and starting at the specified index, with the specified element count.
      Parameters:
      segment - the memory segment
      index - the starting index
      elementCount - the number of elements
      Returns:
      the group array
    • asSegment

      default MemorySegment asSegment(T value)
      Returns a memory segment view of the specified group instance.
      Parameters:
      value - the group instance
      Returns:
      the memory segment
    • malloc

      default T malloc(SegmentStack stack)
      Allocates a memory segment, without zero-initialization, for a single group instance on the specified segment stack.
      Parameters:
      stack - the segment stack
      Returns:
      the group instancen
    • malloc

      GroupArray<L,T> malloc(SegmentStack stack, long elementCount)
      Allocates a memory segment, without zero-initialization, for the specified number of group instances on the specified segment stack.
      Parameters:
      stack - the segment stack
      elementCount - the number of elements
      Returns:
      the group array
    • allocate

      default T allocate(SegmentStack stack)
      Allocates a memory segment, without zero-initialization, for a single group instance using the specified segment allocator.
      Parameters:
      stack - the segment allocator
      Returns:
      the group instance
    • allocate

      default T allocate(SegmentAllocator allocator)
      Allocates a memory segment for a single group instance using the specified segment allocator.
      Parameters:
      allocator - the segment allocator
      Returns:
      the group instance
    • allocate

      GroupArray<L,T> allocate(SegmentStack stack, long elementCount)
      Allocates a memory segment, with zero-initialization, for the specified number of group instances on the specified segment stack.
      Parameters:
      stack - the segment stack
      elementCount - the number of elements
      Returns:
      the group array
    • allocate

      GroupArray<L,T> allocate(SegmentAllocator allocator, long elementCount)
      Allocates a memory segment for the specified number of group instances using the specified segment allocator.
      Parameters:
      allocator - the segment allocator
      elementCount - the number of elements
      Returns:
      the group array
    • mallocSegment

      default MemorySegment mallocSegment(SegmentStack stack)
      Allocates a memory segment, without zero-initialization, for a single group instance on the specified segment stack.
      Parameters:
      stack - the segment stack
      Returns:
      the memory segment
    • mallocSegment

      default MemorySegment mallocSegment(SegmentStack stack, long elementCount)
      Allocates a memory segment, without zero-initialization, for the specified number of group instances on the specified segment stack.
      Parameters:
      stack - the segment stack
      elementCount - the number of elements
      Returns:
      the memory segment
    • allocateSegment

      default MemorySegment allocateSegment(SegmentStack stack)
      Allocates a memory segment, with zero-initialization, for a single group instance on the specified segment stack.
      Parameters:
      stack - the segment stack
      Returns:
      the memory segment
    • allocateSegment

      default MemorySegment allocateSegment(SegmentAllocator allocator)
      Allocates a memory segment for a single group instance using the specified segment allocator.
      Parameters:
      allocator - the segment allocator
      Returns:
      the memory segment
    • allocateSegment

      default MemorySegment allocateSegment(SegmentStack stack, long elementCount)
      Allocates a memory segment, with zero-initialization, for the specified number of group instances on the specified segment stack.
      Parameters:
      stack - the segment stack
      elementCount - the number of elements
      Returns:
      the memory segment
    • allocateSegment

      default MemorySegment allocateSegment(SegmentAllocator allocator, long elementCount)
      Allocates a memory segment for the specified number of group instances using the specified segment allocator.
      Parameters:
      allocator - the segment allocator
      elementCount - the number of elements
      Returns:
      the memory segment
    • apply

      GroupBinder<L,T> apply(MemorySegment array, long offset, Consumer<T> consumer)
      Applies the specified consumer to the group instance mapped to the specified memory segment and offset.
      Parameters:
      array - the memory segment
      offset - the offset of the group instance
      consumer - the consumer to apply
      Returns:
      this binder
    • applyAtIndex

      GroupBinder<L,T> applyAtIndex(MemorySegment segment, long index, Consumer<T> consumer)
      Applies the specified consumer to the group instance mapped to the specified memory segment and index.
      Parameters:
      segment - the memory segment
      index - the index of the group instance
      consumer - the consumer to apply
      Returns:
      this binder
    • forEach

      default void forEach(MemorySegment segment, Consumer<? super T> action)
      Performs the given action for each group instance in the specified memory segment.
      Parameters:
      segment - the memory segment
      action - the action to perform
    • iterable

      default Iterable<T> iterable(MemorySegment segment)
      Returns an Iterable over the group instances in the specified memory segment.
      Parameters:
      segment - the memory segment
      Returns:
      an iterable over the group instances
    • iterator

      default Iterator<T> iterator(MemorySegment segment)
      Returns an Iterator over the group instances in the specified memory segment.
      Parameters:
      segment - the memory segment
      Returns:
      an iterator over the group instances
    • spliterator

      default Spliterator<T> spliterator(MemorySegment segment)
      Returns a Spliterator over the group instances in the specified memory segment.
      Parameters:
      segment - the memory segment
      Returns:
      a spliterator over the group instances
    • stream

      default Stream<T> stream(MemorySegment segment)
      Returns a sequential Stream over the group instances in the specified memory segment.
      Parameters:
      segment - the memory segment
      Returns:
      a sequential stream over the group instances
    • parallelStream

      default Stream<T> parallelStream(MemorySegment segment)
      Returns a parallel Stream over the group instances in the specified memory segment.
      Parameters:
      segment - the memory segment
      Returns:
      a parallel stream over the group instances
    • asSlice

      default MemorySegment asSlice(MemorySegment segment, long index)
      Returns a slice of the specified memory segment at the specified index.
      Parameters:
      segment - the memory segment
      index - the index of the group instance
      Returns:
      a slice of the memory segment
    • asSlice

      default MemorySegment asSlice(MemorySegment segment, long index, long elementCount)
      Returns a slice of the specified memory segment at the specified index and element count.
      Parameters:
      segment - the memory segment
      index - the index of the group instance
      elementCount - the number of elements in the group
      Returns:
      a slice of the memory segment
    • reinterpret

      default MemorySegment reinterpret(MemorySegment addr)
      Reinterprets the specified memory segment to the size of the group type.
      Parameters:
      addr - the memory segment to reinterpret
      Returns:
      a new memory segment with the reinterpreted size
    • reinterpret

      default MemorySegment reinterpret(MemorySegment addr, long elementCount)
      Reinterprets the specified memory segment to the size of the group type multiplied by the specified element count.
      Parameters:
      addr - the memory segment to reinterpret
      elementCount - the number of elements in the group
      Returns:
      a new memory segment with the reinterpreted size
    • reinterpret

      default MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer<MemorySegment> cleanup)
      Reinterprets the specified memory segment to the size of the group type, using the specified arena and cleanup action.
      Parameters:
      addr - the memory segment to reinterpret
      arena - the arena to use
      cleanup - the cleanup action
      Returns:
      a new memory segment with the reinterpreted size
    • reinterpret

      default MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer<MemorySegment> cleanup)
      Reinterprets the specified memory segment to the size of the group type multiplied by the specified element count, using the specified arena and cleanup
      Parameters:
      addr - the memory segment to reinterpret
      elementCount - the number of elements in the group
      arena - the arena to use
      cleanup - the cleanup action
      Returns:
      a new memory segment with the reinterpreted sizen
    • bootstrapRecord

      static Object bootstrapRecord(MethodHandles.Lookup lookup, String methodName, TypeDescriptor type, String names, String... getterNames) throws Throwable
      Bootstrap method to generate the Object.equals(Object), Object.hashCode(), and Object.toString() methods in group types, with the same semantics as the corresponding methods in Record types. [INTERNAL API]
      Throws:
      Throwable