Class NativeLayout
java.lang.Object
club.doki7.ffm.NativeLayout
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final @NotNull ValueLayoutMemory layout of current JVM platform Clongtype.static final intstatic final @NotNull ValueLayoutMemory layout of current JVM platform Csize_ttype.static final intstatic final intstatic final longstatic final intstatic final @NotNull ValueLayoutMemory layout of current JVM platform Cwchar_ttype. -
Method Summary
Modifier and TypeMethodDescriptionstatic longreadCLong(@NotNull MemorySegment segment, long offset) static longreadCSizeT(@NotNull MemorySegment segment, long offset) static intreadWCharT(@NotNull MemorySegment segment, long offset) static @NotNull StructLayoutstructLayout(@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 UnionLayoutunionLayout(@NotNull MemoryLayout... elements) Currently forwards toMemoryLayout.unionLayout(java.lang.foreign.MemoryLayout...).static voidwriteCLong(@NotNull MemorySegment segment, long offset, long value) static voidwriteCSizeT(@NotNull MemorySegment segment, long offset, long value) static voidwriteWCharT(@NotNull MemorySegment segment, long offset, int value)
-
Field Details
-
C_SIZE_T
Memory layout of current JVM platform C
size_ttype.Currently, this field is set to
ValueLayout.ADDRESS, whose JavaDoc claims that it has the same size and alignment with a Csize_ttype. -
POINTER_SIZE
public static final int POINTER_SIZE -
C_LONG
Memory layout of current JVM platform C
longtype.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 -
WCHAR_T
Memory layout of current JVM platform C
wchar_ttype.Currently, on Windows it is
ValueLayout.JAVA_SHORT(2 bytes), while on other platforms it isValueLayout.JAVA_INT(4 bytes). -
WCHAR_SIZE
public static final int WCHAR_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) -
readWCharT
-
writeWCharT
-
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...).
-