Top Description Inners Fields Constructors Methods
org.lwjgl.system

public abstract Class Struct<SELF extends Struct<SELF>>

extends Default
Class Inheritance
Known Direct Subclasses
org.lwjgl.system.jni.JNINativeMethod, org.lwjgl.system.libffi.FFICIF, org.lwjgl.system.libffi.FFIClosure, org.lwjgl.system.libffi.FFIType, org.lwjgl.system.linux.XDestroyWindowEvent, org.lwjgl.system.linux.CMsghdr, org.lwjgl.system.linux.EpollData, org.lwjgl.system.linux.EpollEvent, org.lwjgl.system.linux.Flock, org.lwjgl.system.linux.FOwnerEx, org.lwjgl.system.linux.IOVec, org.lwjgl.system.linux.KernelTimespec, org.lwjgl.system.linux.Msghdr, org.lwjgl.system.linux.OpenHow, org.lwjgl.system.linux.Sockaddr, org.lwjgl.system.linux.Statx, org.lwjgl.system.linux.StatxTimestamp, org.lwjgl.system.linux.Visual, org.lwjgl.system.linux.XAnyEvent, org.lwjgl.system.linux.XButtonEvent, org.lwjgl.system.linux.XCirculateEvent, org.lwjgl.system.linux.XCirculateRequestEvent, org.lwjgl.system.linux.XClientMessageEvent, org.lwjgl.system.linux.XColormapEvent, org.lwjgl.system.linux.XConfigureEvent, org.lwjgl.system.linux.XConfigureRequestEvent, org.lwjgl.system.linux.XCreateWindowEvent, org.lwjgl.system.linux.XCrossingEvent, org.lwjgl.system.linux.XErrorEvent, org.lwjgl.system.linux.XEvent, org.lwjgl.system.linux.XExposeEvent, org.lwjgl.system.linux.XFocusChangeEvent, org.lwjgl.system.linux.XGenericEvent, org.lwjgl.system.linux.XGenericEventCookie, org.lwjgl.system.linux.XGraphicsExposeEvent, org.lwjgl.system.linux.XGravityEvent, org.lwjgl.system.linux.XKeyEvent, org.lwjgl.system.linux.XKeymapEvent, org.lwjgl.system.linux.XMapEvent, org.lwjgl.system.linux.XMappingEvent, org.lwjgl.system.linux.XMapRequestEvent, org.lwjgl.system.linux.XMotionEvent, org.lwjgl.system.linux.XNoExposeEvent, org.lwjgl.system.linux.XPropertyEvent, org.lwjgl.system.linux.XReparentEvent, org.lwjgl.system.linux.XResizeRequestEvent, org.lwjgl.system.linux.XSelectionClearEvent, org.lwjgl.system.linux.XSelectionEvent, org.lwjgl.system.linux.XSelectionRequestEvent, org.lwjgl.system.linux.XSetWindowAttributes, org.lwjgl.system.linux.XTimeCoord, org.lwjgl.system.linux.XUnmapEvent, org.lwjgl.system.linux.XVisibilityEvent, org.lwjgl.system.linux.XVisualInfo, org.lwjgl.system.linux.liburing.IOCQRingOffsets, org.lwjgl.system.linux.liburing.IOSQRingOffsets, org.lwjgl.system.linux.liburing.IOURing, org.lwjgl.system.linux.liburing.IOURingBuf, org.lwjgl.system.linux.liburing.IOURingBufReg, org.lwjgl.system.linux.liburing.IOURingBufRing, org.lwjgl.system.linux.liburing.IOURingCQ, org.lwjgl.system.linux.liburing.IOURingCQE, org.lwjgl.system.linux.liburing.IOURingFileIndexRange, org.lwjgl.system.linux.liburing.IOURingGeteventsArg, org.lwjgl.system.linux.liburing.IOURingParams, org.lwjgl.system.linux.liburing.IOURingProbe, org.lwjgl.system.linux.liburing.IOURingProbeOp, org.lwjgl.system.linux.liburing.IOURingRecvmsgOut, org.lwjgl.system.linux.liburing.IOURingRestriction, org.lwjgl.system.linux.liburing.IOURingRSRCRegister, org.lwjgl.system.linux.liburing.IOURingRSRCUpdate, org.lwjgl.system.linux.liburing.IOURingRSRCUpdate2, org.lwjgl.system.linux.liburing.IOURingSQ, org.lwjgl.system.linux.liburing.IOURingSQE, org.lwjgl.system.linux.liburing.IOURingSyncCancelReg, org.lwjgl.system.macosx.CGEventTapInformation, org.lwjgl.system.macosx.CGPoint, org.lwjgl.system.macosx.ObjCMethodDescription, org.lwjgl.system.macosx.ObjCPropertyAttribute, org.lwjgl.system.windows.CRYPTPROTECT_PROMPTSTRUCT, org.lwjgl.system.windows.DATA_BLOB, org.lwjgl.system.windows.DEVMODE, org.lwjgl.system.windows.DISPLAY_DEVICE, org.lwjgl.system.windows.HARDWAREINPUT, org.lwjgl.system.windows.INPUT, org.lwjgl.system.windows.KEYBDINPUT, org.lwjgl.system.windows.LARGE_INTEGER, org.lwjgl.system.windows.MONITORINFOEX, org.lwjgl.system.windows.MOUSEINPUT, org.lwjgl.system.windows.MSG, org.lwjgl.system.windows.PIXELFORMATDESCRIPTOR, org.lwjgl.system.windows.POINT, org.lwjgl.system.windows.POINTL, org.lwjgl.system.windows.RECT, org.lwjgl.system.windows.SECURITY_ATTRIBUTES, org.lwjgl.system.windows.TOUCHINPUT, org.lwjgl.system.windows.WINDOWPLACEMENT, org.lwjgl.system.windows.WNDCLASSEX
Imports
javax.annotation.*, java.nio.*, java.util.*

Base class of all struct implementations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
protected static class
public static interface
Struct.StructValidation

A functional interface that enables lambda expressions to be passed to the validate method.

Field Summary

Modifier and TypeField and Description
protected ByteBuffer
protected static final int
protected static final int
Inherited from org.lwjgl.system.Pointer.Default:
ADDRESSaddressBUFFER_CAPACITYBUFFER_CONTAINERBUFFER_LIMITBUFFER_MARKBUFFER_POSITIONUNSAFE

Constructor Summary

AccessConstructor and Description
protected
Struct(long
the struct memory address
address
,
ByteBuffer
an optional container buffer, to be referenced strongly by the struct instance.
container
)

Creates a struct instance at the specified address.

Method Summary

Modifier and TypeMethod and Description
protected static Struct.Member
__array(int size, int length)

protected static Struct.Member
__array(int size, int alignment, int length)

protected static Struct.Member
__array(int size, int alignment, boolean forceAlignment, int length)

protected static ByteBuffer
__checkContainer(ByteBuffer container, int sizeof)

protected static long
__checkMalloc(int elements, int elementSize)

protected static ByteBuffer
__create(int elements, int elementSize)

protected static <T extends Struct<T>> ByteBuffer
__getContainer(T struct)

protected static ByteBuffer
protected static Struct.Member
__member(int size)

protected static Struct.Member
__member(int size, int alignment)

protected static Struct.Member
__member(int size, int alignment, boolean forceAlignment)

protected static Struct.Member
__padding(int num, boolean condition)

protected static Struct.Member
__padding(int num, int size, boolean condition)

protected static Struct.Layout
__struct(Struct.Member... members)

protected static Struct.Layout
__struct(int packAlignment, int alignas, Struct.Member... members)

protected static Struct.Layout
__union(Struct.Member... members)

protected static Struct.Layout
__union(int packAlignment, int alignas, Struct.Member... members)

private static void
addNestedMembers(Struct.Member nested, List<Struct.Member> members, int offset)

private static int
align(int offset, int alignment)

private void
checkMemberOffset(int memberOffset)

public void
clear()

Zeroes-out the struct data.

protected abstract SELF
create(long
the struct memory address
address
,
ByteBuffer
an optional container buffer, to be referenced strongly by the struct instance.
container
)

Similar to the constructor, but returns the exact type of the Struct subclass.

public void
free()

Frees the struct allocation.

private static long
getBytes(int elements, int elementSize)

public boolean

Returns:

true if the member is NULL
isNull
(int
the byte offset of the member to query
memberOffset
)

Returns true if the pointer member that corresponds to the specified memberOffset is NULL.

public abstract int
sizeof()

Returns sizeof(struct).

public static void
validate(long
the struct array to validate
array
,
int
the number of structs in array
count
,
int
the size of each struct, in bytes
SIZEOF
,
Struct.StructValidation validation)

Validates each struct contained in the specified struct array.

Inherited from org.lwjgl.system.Pointer.Default:
addressequalshashCodetoString

Field Detail

containerback to summary
protected ByteBuffer container
Annotations
@SuppressWarnings:unused, FieldCanBeLocal
@Nullable
DEFAULT_ALIGN_ASback to summary
protected static final int DEFAULT_ALIGN_AS
DEFAULT_PACK_ALIGNMENTback to summary
protected static final int DEFAULT_PACK_ALIGNMENT

Constructor Detail

Structback to summary
protected Struct(long address, ByteBuffer container)

Creates a struct instance at the specified address.

Parameters
address:long

the struct memory address

container:ByteBuffer

an optional container buffer, to be referenced strongly by the struct instance.

Method Detail

__arrayback to summary
protected static Struct.Member __array(int size, int length)
__arrayback to summary
protected static Struct.Member __array(int size, int alignment, int length)
__arrayback to summary
protected static Struct.Member __array(int size, int alignment, boolean forceAlignment, int length)
__checkContainerback to summary
protected static ByteBuffer __checkContainer(ByteBuffer container, int sizeof)
__checkMallocback to summary
protected static long __checkMalloc(int elements, int elementSize)
__createback to summary
protected static ByteBuffer __create(int elements, int elementSize)
__getContainerback to summary
protected static <T extends Struct<T>> ByteBuffer __getContainer(T struct)
Annotations
@Nullable
__getContainerback to summary
protected static ByteBuffer __getContainer(StructBuffer<?, ?> struct)
Annotations
@Nullable
__memberback to summary
protected static Struct.Member __member(int size)
__memberback to summary
protected static Struct.Member __member(int size, int alignment)
__memberback to summary
protected static Struct.Member __member(int size, int alignment, boolean forceAlignment)
__paddingback to summary
protected static Struct.Member __padding(int num, boolean condition)
__paddingback to summary
protected static Struct.Member __padding(int num, int size, boolean condition)
__structback to summary
protected static Struct.Layout __struct(Struct.Member... members)
__structback to summary
protected static Struct.Layout __struct(int packAlignment, int alignas, Struct.Member... members)
__unionback to summary
protected static Struct.Layout __union(Struct.Member... members)
__unionback to summary
protected static Struct.Layout __union(int packAlignment, int alignas, Struct.Member... members)
addNestedMembersback to summary
private static void addNestedMembers(Struct.Member nested, List<Struct.Member> members, int offset)
alignback to summary
private static int align(int offset, int alignment)
checkMemberOffsetback to summary
private void checkMemberOffset(int memberOffset)
clearback to summary
public void clear()

Zeroes-out the struct data.

createback to summary
protected abstract SELF create(long address, ByteBuffer container)

Similar to the constructor, but returns the exact type of the Struct subclass.

Effectively, every Struct instance is a factory for more instances of the same type. This is used by StructBuffer.

Parameters
address:long

the struct memory address

container:ByteBuffer

an optional container buffer, to be referenced strongly by the struct instance.

freeback to summary
public void free()

Frees the struct allocation.

This method should not be used if the memory backing this struct is not owned by the struct.

getBytesback to summary
private static long getBytes(int elements, int elementSize)
isNullback to summary
public boolean isNull(int memberOffset)

Returns true if the pointer member that corresponds to the specified memberOffset is NULL.

This is useful to verify that not nullable members of an untrusted struct instance are indeed not NULL.

Parameters
memberOffset:int

the byte offset of the member to query

Returns:boolean

true if the member is NULL

sizeofback to summary
public abstract int sizeof()

Returns sizeof(struct).

validateback to summary
public static void validate(long array, int count, int SIZEOF, Struct.StructValidation validation)

Validates each struct contained in the specified struct array. [INTERNAL USE ONLY]

Parameters
array:long

the struct array to validate

count:int

the number of structs in array

SIZEOF:int

the size of each struct, in bytes

org.lwjgl.system back to summary

protected Class Struct.Layout

extends Member
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final Struct.Member[]
Inherited from org.lwjgl.system.Struct.Member:
alignmentforcedAlignmentoffsetsize

Constructor Summary

AccessConstructor and Description
pack-priv
Layout(int size, int alignment, boolean forceAlignment, Struct.Member[] members)

Method Summary

Modifier and TypeMethod and Description
public int
offsetof(int member)

Inherited from org.lwjgl.system.Struct.Member:
getAlignmentgetAlignmentgetSize

Field Detail

membersback to summary
pack-priv final Struct.Member[] members

Constructor Detail

Layoutback to summary
pack-priv Layout(int size, int alignment, boolean forceAlignment, Struct.Member[] members)

Method Detail

offsetofback to summary
public int offsetof(int member)
org.lwjgl.system back to summary

protected Class Struct.Member

extends Object
Class Inheritance
Known Direct Subclasses
org.lwjgl.system.Struct.Layout

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final boolean
pack-priv int
pack-priv final int

Constructor Summary

AccessConstructor and Description
pack-priv
Member(int size, int alignment, boolean forcedAlignment)

Method Summary

Modifier and TypeMethod and Description
public int
public int
getAlignment(int packAlignment)

public int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

alignmentback to summary
pack-priv final int alignment
forcedAlignmentback to summary
pack-priv final boolean forcedAlignment
offsetback to summary
pack-priv int offset
sizeback to summary
pack-priv final int size

Constructor Detail

Memberback to summary
pack-priv Member(int size, int alignment, boolean forcedAlignment)

Method Detail

getAlignmentback to summary
public int getAlignment()
getAlignmentback to summary
public int getAlignment(int packAlignment)
getSizeback to summary
public int getSize()
org.lwjgl.system back to summary

public Interface Struct.StructValidation

Annotations
@FunctionalInterface

A functional interface that enables lambda expressions to be passed to the validate method. [INTERNAL USE ONLY]

Method Summary

Modifier and TypeMethod and Description
public void
validate(long struct)

Method Detail

validateback to summary
public void validate(long struct)