Top Description Inners Fields Constructors Methods
org.lwjgl.system

public final Class APIUtil

extends Object
Class Inheritance
Imports
org.lwjgl.*, org.lwjgl.system.libffi.*, org.lwjgl.system.linux.*, org.lwjgl.system.macosx.*, org.lwjgl.system.windows.*, javax.annotation.*, java.io.*, java.lang.reflect.*, java.nio.*, java.nio.file.*, java.util.*, java.util.function.*, java.util.regex.*, java.util.stream.*

Utility class useful to API bindings. [INTERNAL USE ONLY]

Method names in this class are prefixed with api to avoid ambiguities when used with static imports.

See Also
Configuration#DEBUG_STREAM

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
APIUtil.APIVersion

A data class for API versioning information.

public static interface

Field Summary

Modifier and TypeField and Description
private static final Pattern
public static final PrintStream
DEBUG_STREAM

The PrintStream used by LWJGL to print debug information and non-fatal errors.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static long

Returns:

the pointer array address on the stack
apiArray
(MemoryStack
the stack to use
stack
,
long...
the pointer addresses to store
addresses
)

Stores the specified array of pointer addresses on the specified MemoryStack.

public static long

Returns:

the pointer array address on the stack
apiArray
(MemoryStack
the stack to use
stack
,
ByteBuffer...
the buffers to store
buffers
)

Stores the addresses of the specified array of buffers on the specified MemoryStack.

public static long

Returns:

the pointer array address on the stack
apiArray
(MemoryStack
the stack to use
stack
,
APIUtil.Encoder
the encoder to use
encoder
,
CharSequence...
the strings to encode
strings
)

Encodes the specified strings with the specified Encoder and stores an array of pointers to the encoded data on the specified MemoryStack.

public static void
apiArrayFree(long
the pointer array to free
pointers
,
int
the pointer array length
length
)

Frees the specified array of pointers.

public static long

Returns:

the pointer array address on the stack
apiArrayi
(MemoryStack
the stack to use
stack
,
APIUtil.Encoder
the encoder to use
encoder
,
CharSequence...
the strings to encode
strings
)

Encodes the specified strings with the specified Encoder and stores an array of pointers to the encoded data on the specified MemoryStack.

public static long

Returns:

the pointer array address on the stack
apiArrayp
(MemoryStack
the stack to use
stack
,
ByteBuffer...
the buffers to store
buffers
)

Stores the addresses of the specified array of buffers on the specified MemoryStack.

public static long

Returns:

the pointer array address on the stack
apiArrayp
(MemoryStack
the stack to use
stack
,
APIUtil.Encoder
the encoder to use
encoder
,
CharSequence...
the strings to encode
strings
)

Encodes the specified strings with the specified Encoder and stores an array of pointers to the encoded data on the specified MemoryStack.

public static long
apiCheckAllocation(int elements, long bytes, long maxBytes)

public static Map<Integer, String>

Returns:

the token map
apiClassTokens
(BiPredicate<Field, Integer>
the filter to use (optional)
filter
,
Map<Integer, String>
the target map (optional)
target
,
Class<?>...
the classes to get tokens from
tokenClasses
)

Returns a map of public static final integer fields in the specified classes, to their String representations.

public static void
apiClosureRet(long ret, boolean __result)

public static void
apiClosureRet(long ret, byte __result)

public static void
apiClosureRet(long ret, short __result)

public static void
apiClosureRet(long ret, int __result)

public static void
apiClosureRet(long ret, float __result)

public static void
apiClosureRet(long ret, double __result)

public static void
apiClosureRetL(long ret, long __result)

public static void
apiClosureRetP(long ret, long __result)

public static FFIType
apiCreateArray(FFIType type, int length)

public static FFICIF
apiCreateCIF(int abi, FFIType rtype, FFIType... atypes)

Allocates and prepares a libffi CIF.

public static FFICIF
apiCreateCIFVar(int abi, int nfixedargs, FFIType rtype, FFIType... atypes)

Allocates and prepares a libffi var CIF.

public static SharedLibrary
public static FFIType
public static FFIType
apiCreateUnion(FFIType... members)

public static void
public static String
public static long
apiGetBytes(int elements, int elementShift)

public static long
public static long
public static ByteBuffer
apiGetMappedBuffer(ByteBuffer buffer, long mappedAddress, int capacity)

public static void
apiLog(CharSequence
the message to print
msg
)

Prints the specified message to the DEBUG_STREAM if Checks#DEBUG is true.

public static void
apiLogMissing(String api, ByteBuffer functionName)

public static void
apiLogMore(CharSequence
the message to print, in continuation of a previous message
msg
)

Same as apiLog, but replaces the LWJGL prefix with a tab character.

public static APIUtil.APIVersion
apiParseVersion(Configuration<?>
the option to query
option
)

Returns the APIVersion value of the specified option.

public static APIUtil.APIVersion

Returns:

the parsed APIVersion
apiParseVersion
(String
the version string
version
)

Parses a version string.

public static int
public static String
apiUnknownToken(int token)

public static String
apiUnknownToken(String description, int token)

private static PrintStream
private static void
private static FFIType
prep(FFIType type)

private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

API_VERSION_PATTERNback to summary
private static final Pattern API_VERSION_PATTERN
DEBUG_STREAMback to summary
public static final PrintStream DEBUG_STREAM

The PrintStream used by LWJGL to print debug information and non-fatal errors. Defaults to System#err which can be changed with Configuration#DEBUG_STREAM.

Constructor Detail

APIUtilback to summary
private APIUtil()

Method Detail

apiArrayback to summary
public static long apiArray(MemoryStack stack, long... addresses)

Stores the specified array of pointer addresses on the specified MemoryStack.

Parameters
stack:MemoryStack

the stack to use

addresses:long[]

the pointer addresses to store

Returns:long

the pointer array address on the stack

apiArrayback to summary
public static long apiArray(MemoryStack stack, ByteBuffer... buffers)

Stores the addresses of the specified array of buffers on the specified MemoryStack.

Parameters
stack:MemoryStack

the stack to use

buffers:ByteBuffer[]

the buffers to store

Returns:long

the pointer array address on the stack

apiArrayback to summary
public static long apiArray(MemoryStack stack, APIUtil.Encoder encoder, CharSequence... strings)

Encodes the specified strings with the specified Encoder and stores an array of pointers to the encoded data on the specified MemoryStack. The encoded strings include null-termination.

Parameters
stack:MemoryStack

the stack to use

encoder:APIUtil.Encoder

the encoder to use

strings:CharSequence[]

the strings to encode

Returns:long

the pointer array address on the stack

apiArrayFreeback to summary
public static void apiArrayFree(long pointers, int length)

Frees the specified array of pointers.

Parameters
pointers:long

the pointer array to free

length:int

the pointer array length

apiArrayiback to summary
public static long apiArrayi(MemoryStack stack, APIUtil.Encoder encoder, CharSequence... strings)

Encodes the specified strings with the specified Encoder and stores an array of pointers to the encoded data on the specified MemoryStack. A second array that contains the string lengths is stored immediately after the pointer array. Length values are 4-byte integers.

The encoded buffers must be freed with apiArrayFree.

Parameters
stack:MemoryStack

the stack to use

encoder:APIUtil.Encoder

the encoder to use

strings:CharSequence[]

the strings to encode

Returns:long

the pointer array address on the stack

apiArraypback to summary
public static long apiArrayp(MemoryStack stack, ByteBuffer... buffers)

Stores the addresses of the specified array of buffers on the specified MemoryStack. A second array that contains the buffer remaining bytes is stored immediately after the pointer array. Length values are pointer-sized integers.

Parameters
stack:MemoryStack

the stack to use

buffers:ByteBuffer[]

the buffers to store

Returns:long

the pointer array address on the stack

apiArraypback to summary
public static long apiArrayp(MemoryStack stack, APIUtil.Encoder encoder, CharSequence... strings)

Encodes the specified strings with the specified Encoder and stores an array of pointers to the encoded data on the specified MemoryStack. A second array that contains the string lengths is stored immediately after the pointer array. Length values are pointer-sized integers.

The encoded buffers must be freed with apiArrayFree.

Parameters
stack:MemoryStack

the stack to use

encoder:APIUtil.Encoder

the encoder to use

strings:CharSequence[]

the strings to encode

Returns:long

the pointer array address on the stack

apiCheckAllocationback to summary
public static long apiCheckAllocation(int elements, long bytes, long maxBytes)
apiClassTokensback to summary
public static Map<Integer, String> apiClassTokens(BiPredicate<Field, Integer> filter, Map<Integer, String> target, Class<?>... tokenClasses)

Returns a map of public static final integer fields in the specified classes, to their String representations. An optional filter can be specified to only include specific fields. The target map may be null, in which case a new map is allocated and returned.

This method is useful when debugging to quickly identify values returned from an API.

Parameters
filter:BiPredicate<Field, Integer>

the filter to use (optional)

target:Map<Integer, String>

the target map (optional)

tokenClasses:Class<?>[]

the classes to get tokens from

Returns:Map<Integer, String>

the token map

apiClosureRetback to summary
public static void apiClosureRet(long ret, boolean __result)
apiClosureRetback to summary
public static void apiClosureRet(long ret, byte __result)
apiClosureRetback to summary
public static void apiClosureRet(long ret, short __result)
apiClosureRetback to summary
public static void apiClosureRet(long ret, int __result)
apiClosureRetback to summary
public static void apiClosureRet(long ret, float __result)
apiClosureRetback to summary
public static void apiClosureRet(long ret, double __result)
apiClosureRetLback to summary
public static void apiClosureRetL(long ret, long __result)
apiClosureRetPback to summary
public static void apiClosureRetP(long ret, long __result)
apiCreateArrayback to summary
public static FFIType apiCreateArray(FFIType type, int length)
apiCreateCIFback to summary
public static FFICIF apiCreateCIF(int abi, FFIType rtype, FFIType... atypes)

Allocates and prepares a libffi CIF.

apiCreateCIFVarback to summary
public static FFICIF apiCreateCIFVar(int abi, int nfixedargs, FFIType rtype, FFIType... atypes)

Allocates and prepares a libffi var CIF.

apiCreateLibraryback to summary
public static SharedLibrary apiCreateLibrary(String name)
apiCreateStructback to summary
public static FFIType apiCreateStruct(FFIType... members)
apiCreateUnionback to summary
public static FFIType apiCreateUnion(FFIType... members)
apiFilterExtensionsback to summary
public static void apiFilterExtensions(Set<String> extensions, Configuration<Object> option)
apiFindLibraryback to summary
public static String apiFindLibrary(String start, String name)
apiGetBytesback to summary
public static long apiGetBytes(int elements, int elementShift)
apiGetFunctionAddressback to summary
public static long apiGetFunctionAddress(FunctionProvider provider, String functionName)
apiGetFunctionAddressOptionalback to summary
public static long apiGetFunctionAddressOptional(SharedLibrary library, String functionName)
apiGetMappedBufferback to summary
public static ByteBuffer apiGetMappedBuffer(ByteBuffer buffer, long mappedAddress, int capacity)
Annotations
@Nullable
apiLogback to summary
public static void apiLog(CharSequence msg)

Prints the specified message to the DEBUG_STREAM if Checks#DEBUG is true.

Parameters
msg:CharSequence

the message to print

apiLogMissingback to summary
public static void apiLogMissing(String api, ByteBuffer functionName)
apiLogMoreback to summary
public static void apiLogMore(CharSequence msg)

Same as apiLog, but replaces the LWJGL prefix with a tab character.

Parameters
msg:CharSequence

the message to print, in continuation of a previous message

apiParseVersionback to summary
public static APIUtil.APIVersion apiParseVersion(Configuration<?> option)

Returns the APIVersion value of the specified option.

Parameters
option:Configuration<?>

the option to query

Annotations
@Nullable
apiParseVersionback to summary
public static APIUtil.APIVersion apiParseVersion(String version)

Parses a version string.

The version string must have the format PREFIX MAJOR.MINOR.REVISION IMPL, where PREFIX is a prefix without digits (string, optional), MAJOR is the major version (integer), MINOR is the minor version (integer), REVISION is the revision version (string, optional) and IMPL is implementation-specific information (string, optional).

Parameters
version:String

the version string

Returns:APIUtil.APIVersion

the parsed APIVersion

apiStdcallback to summary
public static int apiStdcall()
apiUnknownTokenback to summary
public static String apiUnknownToken(int token)
apiUnknownTokenback to summary
public static String apiUnknownToken(String description, int token)
getDebugStreamback to summary
private static PrintStream getDebugStream()
Annotations
@SuppressWarnings:unchecked, UseOfSystemOutOrSystemErr
optionalFunctionMissingback to summary
private static void optionalFunctionMissing(SharedLibrary library, String functionName)
prepback to summary
private static FFIType prep(FFIType type)
requiredFunctionMissingback to summary
private static void requiredFunctionMissing(String functionName)
org.lwjgl.system back to summary

public Class APIUtil.APIVersion

extends Object
implements Comparable<APIUtil.APIVersion>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable

A data class for API versioning information.

Field Summary

Modifier and TypeField and Description
public final String
implementation

Returns the API implementation-specific versioning information.

public final int
major

Returns the API major version.

public final int
minor

Returns the API minor version.

public final String
revision

Returns the API revision.

Constructor Summary

AccessConstructor and Description
public
APIVersion(int major, int minor)

public
APIVersion(int major, int minor, String revision, String implementation)

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(APIUtil.APIVersion
the object to be compared.
other
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

implementationback to summary
public final String implementation

Returns the API implementation-specific versioning information. May be null.

Annotations
@Nullable
majorback to summary
public final int major

Returns the API major version.

minorback to summary
public final int minor

Returns the API minor version.

revisionback to summary
public final String revision

Returns the API revision. May be null.

Annotations
@Nullable

Constructor Detail

APIVersionback to summary
public APIVersion(int major, int minor)
APIVersionback to summary
public APIVersion(int major, int minor, String revision, String implementation)

Method Detail

compareToback to summary
public int compareTo(APIUtil.APIVersion other)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
other:APIUtil.APIVersion

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
org.lwjgl.system back to summary

public Interface APIUtil.Encoder


Method Summary

Modifier and TypeMethod and Description
public ByteBuffer
encode(CharSequence text, boolean nullTerminated)

Method Detail

encodeback to summary
public ByteBuffer encode(CharSequence text, boolean nullTerminated)