Class NativeLayout
java.lang.Object
club.doki7.ffm.NativeLayout
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final @NotNull ValueLayout
Memory layout of current JVM platform Clong
type.static final int
static final @NotNull ValueLayout
Memory layout of current JVM platform Csize_t
type.static final int
static final int
static final long
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
readCLong
(@NotNull MemorySegment segment, long offset) static long
readCSizeT
(@NotNull MemorySegment segment, long offset) static @NotNull StructLayout
structLayout
(@NotNull MemoryLayout... elements) UnlikeMemoryLayout.structLayout
, this function will automatically compute and add padding to the layout to ensure that each element is properly aligned.static @NotNull UnionLayout
unionLayout
(@NotNull MemoryLayout... elements) Currently forwards toMemoryLayout.unionLayout(java.lang.foreign.MemoryLayout...)
.static void
writeCLong
(@NotNull MemorySegment segment, long offset, long value) static void
writeCSizeT
(@NotNull MemorySegment segment, long offset, long value)
-
Field Details
-
C_SIZE_T
Memory layout of current JVM platform C
size_t
type.Currently, this field is set to
ValueLayout.ADDRESS
, whose JavaDoc claims that it has the same size and alignment with a Csize_t
type. -
POINTER_SIZE
public static final int POINTER_SIZE -
C_LONG
Memory layout of current JVM platform C
long
type.Currently, all 32bit platforms will use
ValueLayout.JAVA_INT
. For 64bit platforms, Windows will useValueLayout.JAVA_INT
, while other platforms will useValueLayout.JAVA_LONG
.The detection algorithm came from LWJGL3.
- See Also:
-
C_LONG_SIZE
public static final int C_LONG_SIZE -
UINT32_MAX
- See Also:
-
UINT64_MAX
- See Also:
-
-
Method Details
-
readCLong
-
writeCLong
-
readCSizeT
-
writeCSizeT
public static void writeCSizeT(@NotNull @NotNull MemorySegment segment, long offset, @Unsigned long value) -
structLayout
@NotNull public static @NotNull StructLayout structLayout(@NotNull @NotNull MemoryLayout... elements) UnlikeMemoryLayout.structLayout
, this function will automatically compute and add padding to the layout to ensure that each element is properly aligned. The resulting layout should be the same with a C struct layout.- Parameters:
elements
- the elements of the struct- Returns:
- the struct layout
-
unionLayout
Currently forwards toMemoryLayout.unionLayout(java.lang.foreign.MemoryLayout...)
.
-