org.purejava.appindicator._AtkDocumentIface Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of libayatana-appindicator-java-full Show documentation
Show all versions of libayatana-appindicator-java-full Show documentation
Java bindings for libayatana-appindicator in 100% pure Java
// Generated by jextract
package org.purejava.appindicator;
import java.lang.invoke.*;
import java.lang.foreign.*;
import java.nio.ByteOrder;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
import static java.lang.foreign.ValueLayout.*;
import static java.lang.foreign.MemoryLayout.PathElement.*;
/**
* {@snippet lang=c :
* struct _AtkDocumentIface {
* GTypeInterface parent;
* const gchar *(*get_document_type)(AtkDocument *);
* gpointer (*get_document)(AtkDocument *);
* const gchar *(*get_document_locale)(AtkDocument *);
* AtkAttributeSet *(*get_document_attributes)(AtkDocument *);
* const gchar *(*get_document_attribute_value)(AtkDocument *, const gchar *);
* gboolean (*set_document_attribute)(AtkDocument *, const gchar *, const gchar *);
* gint (*get_current_page_number)(AtkDocument *);
* gint (*get_page_count)(AtkDocument *);
* }
* }
*/
public class _AtkDocumentIface {
_AtkDocumentIface() {
// Should not be called directly
}
private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
_GTypeInterface.layout().withName("parent"),
app_indicator_h.C_POINTER.withName("get_document_type"),
app_indicator_h.C_POINTER.withName("get_document"),
app_indicator_h.C_POINTER.withName("get_document_locale"),
app_indicator_h.C_POINTER.withName("get_document_attributes"),
app_indicator_h.C_POINTER.withName("get_document_attribute_value"),
app_indicator_h.C_POINTER.withName("set_document_attribute"),
app_indicator_h.C_POINTER.withName("get_current_page_number"),
app_indicator_h.C_POINTER.withName("get_page_count")
).withName("_AtkDocumentIface");
/**
* The layout of this struct
*/
public static final GroupLayout layout() {
return $LAYOUT;
}
private static final GroupLayout parent$LAYOUT = (GroupLayout)$LAYOUT.select(groupElement("parent"));
/**
* Layout for field:
* {@snippet lang=c :
* GTypeInterface parent
* }
*/
public static final GroupLayout parent$layout() {
return parent$LAYOUT;
}
private static final long parent$OFFSET = 0;
/**
* Offset for field:
* {@snippet lang=c :
* GTypeInterface parent
* }
*/
public static final long parent$offset() {
return parent$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* GTypeInterface parent
* }
*/
public static MemorySegment parent(MemorySegment struct) {
return struct.asSlice(parent$OFFSET, parent$LAYOUT.byteSize());
}
/**
* Setter for field:
* {@snippet lang=c :
* GTypeInterface parent
* }
*/
public static void parent(MemorySegment struct, MemorySegment fieldValue) {
MemorySegment.copy(fieldValue, 0L, struct, parent$OFFSET, parent$LAYOUT.byteSize());
}
/**
* {@snippet lang=c :
* const gchar *(*get_document_type)(AtkDocument *)
* }
*/
public class get_document_type {
/**
* The function pointer signature, expressed as a functional interface
*/
public interface Function {
MemorySegment apply(MemorySegment _x0);
}
private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
app_indicator_h.C_POINTER,
app_indicator_h.C_POINTER
);
/**
* The descriptor of this function pointer
*/
public static FunctionDescriptor descriptor() {
return $DESC;
}
private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(get_document_type.Function.class, "apply", $DESC);
/**
* Allocates a new upcall stub, whose implementation is defined by {@code fi}.
* The lifetime of the returned segment is managed by {@code arena}
*/
public static MemorySegment allocate(get_document_type.Function fi, Arena arena) {
return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
}
private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
/**
* Invoke the upcall stub {@code funcPtr}, with given parameters
*/
public static MemorySegment invoke(MemorySegment funcPtr,MemorySegment _x0) {
try {
return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
}
}
private static final AddressLayout get_document_type$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("get_document_type"));
/**
* Layout for field:
* {@snippet lang=c :
* const gchar *(*get_document_type)(AtkDocument *)
* }
*/
public static final AddressLayout get_document_type$layout() {
return get_document_type$LAYOUT;
}
private static final long get_document_type$OFFSET = 16;
/**
* Offset for field:
* {@snippet lang=c :
* const gchar *(*get_document_type)(AtkDocument *)
* }
*/
public static final long get_document_type$offset() {
return get_document_type$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* const gchar *(*get_document_type)(AtkDocument *)
* }
*/
public static MemorySegment get_document_type(MemorySegment struct) {
return struct.get(get_document_type$LAYOUT, get_document_type$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* const gchar *(*get_document_type)(AtkDocument *)
* }
*/
public static void get_document_type(MemorySegment struct, MemorySegment fieldValue) {
struct.set(get_document_type$LAYOUT, get_document_type$OFFSET, fieldValue);
}
/**
* {@snippet lang=c :
* gpointer (*get_document)(AtkDocument *)
* }
*/
public class get_document {
/**
* The function pointer signature, expressed as a functional interface
*/
public interface Function {
MemorySegment apply(MemorySegment _x0);
}
private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
app_indicator_h.C_POINTER,
app_indicator_h.C_POINTER
);
/**
* The descriptor of this function pointer
*/
public static FunctionDescriptor descriptor() {
return $DESC;
}
private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(get_document.Function.class, "apply", $DESC);
/**
* Allocates a new upcall stub, whose implementation is defined by {@code fi}.
* The lifetime of the returned segment is managed by {@code arena}
*/
public static MemorySegment allocate(get_document.Function fi, Arena arena) {
return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
}
private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
/**
* Invoke the upcall stub {@code funcPtr}, with given parameters
*/
public static MemorySegment invoke(MemorySegment funcPtr,MemorySegment _x0) {
try {
return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
}
}
private static final AddressLayout get_document$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("get_document"));
/**
* Layout for field:
* {@snippet lang=c :
* gpointer (*get_document)(AtkDocument *)
* }
*/
public static final AddressLayout get_document$layout() {
return get_document$LAYOUT;
}
private static final long get_document$OFFSET = 24;
/**
* Offset for field:
* {@snippet lang=c :
* gpointer (*get_document)(AtkDocument *)
* }
*/
public static final long get_document$offset() {
return get_document$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* gpointer (*get_document)(AtkDocument *)
* }
*/
public static MemorySegment get_document(MemorySegment struct) {
return struct.get(get_document$LAYOUT, get_document$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* gpointer (*get_document)(AtkDocument *)
* }
*/
public static void get_document(MemorySegment struct, MemorySegment fieldValue) {
struct.set(get_document$LAYOUT, get_document$OFFSET, fieldValue);
}
/**
* {@snippet lang=c :
* const gchar *(*get_document_locale)(AtkDocument *)
* }
*/
public class get_document_locale {
/**
* The function pointer signature, expressed as a functional interface
*/
public interface Function {
MemorySegment apply(MemorySegment _x0);
}
private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
app_indicator_h.C_POINTER,
app_indicator_h.C_POINTER
);
/**
* The descriptor of this function pointer
*/
public static FunctionDescriptor descriptor() {
return $DESC;
}
private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(get_document_locale.Function.class, "apply", $DESC);
/**
* Allocates a new upcall stub, whose implementation is defined by {@code fi}.
* The lifetime of the returned segment is managed by {@code arena}
*/
public static MemorySegment allocate(get_document_locale.Function fi, Arena arena) {
return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
}
private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
/**
* Invoke the upcall stub {@code funcPtr}, with given parameters
*/
public static MemorySegment invoke(MemorySegment funcPtr,MemorySegment _x0) {
try {
return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
}
}
private static final AddressLayout get_document_locale$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("get_document_locale"));
/**
* Layout for field:
* {@snippet lang=c :
* const gchar *(*get_document_locale)(AtkDocument *)
* }
*/
public static final AddressLayout get_document_locale$layout() {
return get_document_locale$LAYOUT;
}
private static final long get_document_locale$OFFSET = 32;
/**
* Offset for field:
* {@snippet lang=c :
* const gchar *(*get_document_locale)(AtkDocument *)
* }
*/
public static final long get_document_locale$offset() {
return get_document_locale$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* const gchar *(*get_document_locale)(AtkDocument *)
* }
*/
public static MemorySegment get_document_locale(MemorySegment struct) {
return struct.get(get_document_locale$LAYOUT, get_document_locale$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* const gchar *(*get_document_locale)(AtkDocument *)
* }
*/
public static void get_document_locale(MemorySegment struct, MemorySegment fieldValue) {
struct.set(get_document_locale$LAYOUT, get_document_locale$OFFSET, fieldValue);
}
/**
* {@snippet lang=c :
* AtkAttributeSet *(*get_document_attributes)(AtkDocument *)
* }
*/
public class get_document_attributes {
/**
* The function pointer signature, expressed as a functional interface
*/
public interface Function {
MemorySegment apply(MemorySegment _x0);
}
private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
app_indicator_h.C_POINTER,
app_indicator_h.C_POINTER
);
/**
* The descriptor of this function pointer
*/
public static FunctionDescriptor descriptor() {
return $DESC;
}
private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(get_document_attributes.Function.class, "apply", $DESC);
/**
* Allocates a new upcall stub, whose implementation is defined by {@code fi}.
* The lifetime of the returned segment is managed by {@code arena}
*/
public static MemorySegment allocate(get_document_attributes.Function fi, Arena arena) {
return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
}
private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
/**
* Invoke the upcall stub {@code funcPtr}, with given parameters
*/
public static MemorySegment invoke(MemorySegment funcPtr,MemorySegment _x0) {
try {
return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
}
}
private static final AddressLayout get_document_attributes$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("get_document_attributes"));
/**
* Layout for field:
* {@snippet lang=c :
* AtkAttributeSet *(*get_document_attributes)(AtkDocument *)
* }
*/
public static final AddressLayout get_document_attributes$layout() {
return get_document_attributes$LAYOUT;
}
private static final long get_document_attributes$OFFSET = 40;
/**
* Offset for field:
* {@snippet lang=c :
* AtkAttributeSet *(*get_document_attributes)(AtkDocument *)
* }
*/
public static final long get_document_attributes$offset() {
return get_document_attributes$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* AtkAttributeSet *(*get_document_attributes)(AtkDocument *)
* }
*/
public static MemorySegment get_document_attributes(MemorySegment struct) {
return struct.get(get_document_attributes$LAYOUT, get_document_attributes$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* AtkAttributeSet *(*get_document_attributes)(AtkDocument *)
* }
*/
public static void get_document_attributes(MemorySegment struct, MemorySegment fieldValue) {
struct.set(get_document_attributes$LAYOUT, get_document_attributes$OFFSET, fieldValue);
}
/**
* {@snippet lang=c :
* const gchar *(*get_document_attribute_value)(AtkDocument *, const gchar *)
* }
*/
public class get_document_attribute_value {
/**
* The function pointer signature, expressed as a functional interface
*/
public interface Function {
MemorySegment apply(MemorySegment _x0, MemorySegment _x1);
}
private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
app_indicator_h.C_POINTER,
app_indicator_h.C_POINTER,
app_indicator_h.C_POINTER
);
/**
* The descriptor of this function pointer
*/
public static FunctionDescriptor descriptor() {
return $DESC;
}
private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(get_document_attribute_value.Function.class, "apply", $DESC);
/**
* Allocates a new upcall stub, whose implementation is defined by {@code fi}.
* The lifetime of the returned segment is managed by {@code arena}
*/
public static MemorySegment allocate(get_document_attribute_value.Function fi, Arena arena) {
return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
}
private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
/**
* Invoke the upcall stub {@code funcPtr}, with given parameters
*/
public static MemorySegment invoke(MemorySegment funcPtr,MemorySegment _x0, MemorySegment _x1) {
try {
return (MemorySegment) DOWN$MH.invokeExact(funcPtr, _x0, _x1);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
}
}
private static final AddressLayout get_document_attribute_value$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("get_document_attribute_value"));
/**
* Layout for field:
* {@snippet lang=c :
* const gchar *(*get_document_attribute_value)(AtkDocument *, const gchar *)
* }
*/
public static final AddressLayout get_document_attribute_value$layout() {
return get_document_attribute_value$LAYOUT;
}
private static final long get_document_attribute_value$OFFSET = 48;
/**
* Offset for field:
* {@snippet lang=c :
* const gchar *(*get_document_attribute_value)(AtkDocument *, const gchar *)
* }
*/
public static final long get_document_attribute_value$offset() {
return get_document_attribute_value$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* const gchar *(*get_document_attribute_value)(AtkDocument *, const gchar *)
* }
*/
public static MemorySegment get_document_attribute_value(MemorySegment struct) {
return struct.get(get_document_attribute_value$LAYOUT, get_document_attribute_value$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* const gchar *(*get_document_attribute_value)(AtkDocument *, const gchar *)
* }
*/
public static void get_document_attribute_value(MemorySegment struct, MemorySegment fieldValue) {
struct.set(get_document_attribute_value$LAYOUT, get_document_attribute_value$OFFSET, fieldValue);
}
/**
* {@snippet lang=c :
* gboolean (*set_document_attribute)(AtkDocument *, const gchar *, const gchar *)
* }
*/
public class set_document_attribute {
/**
* The function pointer signature, expressed as a functional interface
*/
public interface Function {
int apply(MemorySegment _x0, MemorySegment _x1, MemorySegment _x2);
}
private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
app_indicator_h.C_INT,
app_indicator_h.C_POINTER,
app_indicator_h.C_POINTER,
app_indicator_h.C_POINTER
);
/**
* The descriptor of this function pointer
*/
public static FunctionDescriptor descriptor() {
return $DESC;
}
private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(set_document_attribute.Function.class, "apply", $DESC);
/**
* Allocates a new upcall stub, whose implementation is defined by {@code fi}.
* The lifetime of the returned segment is managed by {@code arena}
*/
public static MemorySegment allocate(set_document_attribute.Function fi, Arena arena) {
return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
}
private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
/**
* Invoke the upcall stub {@code funcPtr}, with given parameters
*/
public static int invoke(MemorySegment funcPtr,MemorySegment _x0, MemorySegment _x1, MemorySegment _x2) {
try {
return (int) DOWN$MH.invokeExact(funcPtr, _x0, _x1, _x2);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
}
}
private static final AddressLayout set_document_attribute$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("set_document_attribute"));
/**
* Layout for field:
* {@snippet lang=c :
* gboolean (*set_document_attribute)(AtkDocument *, const gchar *, const gchar *)
* }
*/
public static final AddressLayout set_document_attribute$layout() {
return set_document_attribute$LAYOUT;
}
private static final long set_document_attribute$OFFSET = 56;
/**
* Offset for field:
* {@snippet lang=c :
* gboolean (*set_document_attribute)(AtkDocument *, const gchar *, const gchar *)
* }
*/
public static final long set_document_attribute$offset() {
return set_document_attribute$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* gboolean (*set_document_attribute)(AtkDocument *, const gchar *, const gchar *)
* }
*/
public static MemorySegment set_document_attribute(MemorySegment struct) {
return struct.get(set_document_attribute$LAYOUT, set_document_attribute$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* gboolean (*set_document_attribute)(AtkDocument *, const gchar *, const gchar *)
* }
*/
public static void set_document_attribute(MemorySegment struct, MemorySegment fieldValue) {
struct.set(set_document_attribute$LAYOUT, set_document_attribute$OFFSET, fieldValue);
}
/**
* {@snippet lang=c :
* gint (*get_current_page_number)(AtkDocument *)
* }
*/
public class get_current_page_number {
/**
* The function pointer signature, expressed as a functional interface
*/
public interface Function {
int apply(MemorySegment _x0);
}
private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
app_indicator_h.C_INT,
app_indicator_h.C_POINTER
);
/**
* The descriptor of this function pointer
*/
public static FunctionDescriptor descriptor() {
return $DESC;
}
private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(get_current_page_number.Function.class, "apply", $DESC);
/**
* Allocates a new upcall stub, whose implementation is defined by {@code fi}.
* The lifetime of the returned segment is managed by {@code arena}
*/
public static MemorySegment allocate(get_current_page_number.Function fi, Arena arena) {
return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
}
private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
/**
* Invoke the upcall stub {@code funcPtr}, with given parameters
*/
public static int invoke(MemorySegment funcPtr,MemorySegment _x0) {
try {
return (int) DOWN$MH.invokeExact(funcPtr, _x0);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
}
}
private static final AddressLayout get_current_page_number$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("get_current_page_number"));
/**
* Layout for field:
* {@snippet lang=c :
* gint (*get_current_page_number)(AtkDocument *)
* }
*/
public static final AddressLayout get_current_page_number$layout() {
return get_current_page_number$LAYOUT;
}
private static final long get_current_page_number$OFFSET = 64;
/**
* Offset for field:
* {@snippet lang=c :
* gint (*get_current_page_number)(AtkDocument *)
* }
*/
public static final long get_current_page_number$offset() {
return get_current_page_number$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* gint (*get_current_page_number)(AtkDocument *)
* }
*/
public static MemorySegment get_current_page_number(MemorySegment struct) {
return struct.get(get_current_page_number$LAYOUT, get_current_page_number$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* gint (*get_current_page_number)(AtkDocument *)
* }
*/
public static void get_current_page_number(MemorySegment struct, MemorySegment fieldValue) {
struct.set(get_current_page_number$LAYOUT, get_current_page_number$OFFSET, fieldValue);
}
/**
* {@snippet lang=c :
* gint (*get_page_count)(AtkDocument *)
* }
*/
public class get_page_count {
/**
* The function pointer signature, expressed as a functional interface
*/
public interface Function {
int apply(MemorySegment _x0);
}
private static final FunctionDescriptor $DESC = FunctionDescriptor.of(
app_indicator_h.C_INT,
app_indicator_h.C_POINTER
);
/**
* The descriptor of this function pointer
*/
public static FunctionDescriptor descriptor() {
return $DESC;
}
private static final MethodHandle UP$MH = app_indicator_h.upcallHandle(get_page_count.Function.class, "apply", $DESC);
/**
* Allocates a new upcall stub, whose implementation is defined by {@code fi}.
* The lifetime of the returned segment is managed by {@code arena}
*/
public static MemorySegment allocate(get_page_count.Function fi, Arena arena) {
return Linker.nativeLinker().upcallStub(UP$MH.bindTo(fi), $DESC, arena);
}
private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC);
/**
* Invoke the upcall stub {@code funcPtr}, with given parameters
*/
public static int invoke(MemorySegment funcPtr,MemorySegment _x0) {
try {
return (int) DOWN$MH.invokeExact(funcPtr, _x0);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
}
}
private static final AddressLayout get_page_count$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("get_page_count"));
/**
* Layout for field:
* {@snippet lang=c :
* gint (*get_page_count)(AtkDocument *)
* }
*/
public static final AddressLayout get_page_count$layout() {
return get_page_count$LAYOUT;
}
private static final long get_page_count$OFFSET = 72;
/**
* Offset for field:
* {@snippet lang=c :
* gint (*get_page_count)(AtkDocument *)
* }
*/
public static final long get_page_count$offset() {
return get_page_count$OFFSET;
}
/**
* Getter for field:
* {@snippet lang=c :
* gint (*get_page_count)(AtkDocument *)
* }
*/
public static MemorySegment get_page_count(MemorySegment struct) {
return struct.get(get_page_count$LAYOUT, get_page_count$OFFSET);
}
/**
* Setter for field:
* {@snippet lang=c :
* gint (*get_page_count)(AtkDocument *)
* }
*/
public static void get_page_count(MemorySegment struct, MemorySegment fieldValue) {
struct.set(get_page_count$LAYOUT, get_page_count$OFFSET, fieldValue);
}
/**
* Obtains a slice of {@code arrayParam} which selects the array element at {@code index}.
* The returned segment has address {@code arrayParam.address() + index * layout().byteSize()}
*/
public static MemorySegment asSlice(MemorySegment array, long index) {
return array.asSlice(layout().byteSize() * index);
}
/**
* The size (in bytes) of this struct
*/
public static long sizeof() { return layout().byteSize(); }
/**
* Allocate a segment of size {@code layout().byteSize()} using {@code allocator}
*/
public static MemorySegment allocate(SegmentAllocator allocator) {
return allocator.allocate(layout());
}
/**
* Allocate an array of size {@code elementCount} using {@code allocator}.
* The returned segment has size {@code elementCount * layout().byteSize()}.
*/
public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) {
return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout()));
}
/**
* Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction) (if any).
* The returned segment has size {@code layout().byteSize()}
*/
public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer cleanup) {
return reinterpret(addr, 1, arena, cleanup);
}
/**
* Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction) (if any).
* The returned segment has size {@code elementCount * layout().byteSize()}
*/
public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer cleanup) {
return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup);
}
}