Package org.lwjgl.system
Class APIUtil
java.lang.Object
org.lwjgl.system.APIUtil
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:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A data class for API versioning information.static interface
-
Field Summary
Modifier and TypeFieldDescriptionstatic final PrintStream
ThePrintStream
used by LWJGL to print debug information and non-fatal errors. -
Method Summary
Modifier and TypeMethodDescriptionstatic long
apiArray
(MemoryStack stack, long... addresses) Stores the specified array of pointer addresses on the specifiedMemoryStack
.static long
apiArray
(MemoryStack stack, ByteBuffer... buffers) Stores the addresses of the specified array of buffers on the specifiedMemoryStack
.static long
apiArray
(MemoryStack stack, APIUtil.Encoder encoder, CharSequence... strings) Encodes the specified strings with the specifiedAPIUtil.Encoder
and stores an array of pointers to the encoded data on the specifiedMemoryStack
.static void
apiArrayFree
(long pointers, int length) Frees the specified array of pointers.static long
apiArrayi
(MemoryStack stack, APIUtil.Encoder encoder, CharSequence... strings) Encodes the specified strings with the specifiedAPIUtil.Encoder
and stores an array of pointers to the encoded data on the specifiedMemoryStack
.static long
apiArrayp
(MemoryStack stack, ByteBuffer... buffers) Stores the addresses of the specified array of buffers on the specifiedMemoryStack
.static long
apiArrayp
(MemoryStack stack, APIUtil.Encoder encoder, CharSequence... strings) Encodes the specified strings with the specifiedAPIUtil.Encoder
and stores an array of pointers to the encoded data on the specifiedMemoryStack
.static long
apiCheckAllocation
(int elements, long bytes, long maxBytes) 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.static void
apiClosureRet
(long ret, boolean __result) static void
apiClosureRet
(long ret, byte __result) static void
apiClosureRet
(long ret, double __result) static void
apiClosureRet
(long ret, float __result) static void
apiClosureRet
(long ret, int __result) static void
apiClosureRet
(long ret, short __result) static void
apiClosureRetL
(long ret, long __result) static void
apiClosureRetP
(long ret, long __result) static FFIType
apiCreateArray
(FFIType type, int length) static FFICIF
apiCreateCIF
(int abi, FFIType rtype, FFIType... atypes) Allocates and prepares a libffi CIF.static FFICIF
apiCreateCIFVar
(int abi, int nfixedargs, FFIType rtype, FFIType... atypes) Allocates and prepares a libffi var CIF.static SharedLibrary
apiCreateLibrary
(String name) static FFIType
apiCreateStruct
(FFIType... members) static FFIType
apiCreateUnion
(FFIType... members) static void
apiFilterExtensions
(Set<String> extensions, Configuration<Object> option) static String
apiFindLibrary
(String start, String name) static long
apiGetBytes
(int elements, int elementShift) static long
apiGetFunctionAddress
(FunctionProvider provider, String functionName) static long
apiGetFunctionAddressOptional
(SharedLibrary library, String functionName) static ByteBuffer
apiGetMappedBuffer
(ByteBuffer buffer, long mappedAddress, int capacity) static void
apiLog
(CharSequence msg) Prints the specified message to theDEBUG_STREAM
ifChecks.DEBUG
is true.static void
apiLogMissing
(String api, ByteBuffer functionName) static void
apiLogMore
(CharSequence msg) Same asapiLog(java.lang.CharSequence)
, but replaces the LWJGL prefix with a tab character.static APIUtil.APIVersion
apiParseVersion
(String version) Parses a version string.static APIUtil.APIVersion
apiParseVersion
(Configuration<?> option) Returns theAPIUtil.APIVersion
value of the specified option.static int
static String
apiUnknownToken
(int token) static String
apiUnknownToken
(String description, int token)
-
Field Details
-
DEBUG_STREAM
ThePrintStream
used by LWJGL to print debug information and non-fatal errors. Defaults toSystem.err
which can be changed withConfiguration.DEBUG_STREAM
.
-
-
Method Details
-
apiLog
Prints the specified message to theDEBUG_STREAM
ifChecks.DEBUG
is true.- Parameters:
msg
- the message to print
-
apiLogMore
Same asapiLog(java.lang.CharSequence)
, but replaces the LWJGL prefix with a tab character.- Parameters:
msg
- the message to print, in continuation of a previous message
-
apiLogMissing
-
apiFindLibrary
-
apiCreateLibrary
-
apiGetFunctionAddress
-
apiGetMappedBuffer
@Nullable public static ByteBuffer apiGetMappedBuffer(@Nullable ByteBuffer buffer, long mappedAddress, int capacity) -
apiGetBytes
public static long apiGetBytes(int elements, int elementShift) -
apiCheckAllocation
public static long apiCheckAllocation(int elements, long bytes, long maxBytes) -
apiParseVersion
Returns theAPIUtil.APIVersion
value of the specified option.- Parameters:
option
- the option to query
-
apiParseVersion
Parses a version string.The version string must have the format
PREFIX MAJOR.MINOR.REVISION IMPL
, wherePREFIX
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) andIMPL
is implementation-specific information (string, optional).- Parameters:
version
- the version string- Returns:
- the parsed
APIUtil.APIVersion
-
apiFilterExtensions
-
apiUnknownToken
-
apiUnknownToken
-
apiClassTokens
public static Map<Integer,String> apiClassTokens(@Nullable BiPredicate<Field, Integer> filter, @Nullable 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
- the filter to use (optional)target
- the target map (optional)tokenClasses
- the classes to get tokens from- Returns:
- the token map
-
apiArray
Stores the specified array of pointer addresses on the specifiedMemoryStack
.- Parameters:
stack
- the stack to useaddresses
- the pointer addresses to store- Returns:
- the pointer array address on the stack
-
apiArray
Stores the addresses of the specified array of buffers on the specifiedMemoryStack
.- Parameters:
stack
- the stack to usebuffers
- the buffers to store- Returns:
- the pointer array address on the stack
-
apiArrayp
Stores the addresses of the specified array of buffers on the specifiedMemoryStack
. A second array that contains the buffer remaining bytes is stored immediately after the pointer array. Length values are pointer-sized integers.- Parameters:
stack
- the stack to usebuffers
- the buffers to store- Returns:
- the pointer array address on the stack
-
apiArray
Encodes the specified strings with the specifiedAPIUtil.Encoder
and stores an array of pointers to the encoded data on the specifiedMemoryStack
. The encoded strings include null-termination.- Parameters:
stack
- the stack to useencoder
- the encoder to usestrings
- the strings to encode- Returns:
- the pointer array address on the stack
-
apiArrayi
Encodes the specified strings with the specifiedAPIUtil.Encoder
and stores an array of pointers to the encoded data on the specifiedMemoryStack
. 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(long, int)
.- Parameters:
stack
- the stack to useencoder
- the encoder to usestrings
- the strings to encode- Returns:
- the pointer array address on the stack
-
apiArrayp
Encodes the specified strings with the specifiedAPIUtil.Encoder
and stores an array of pointers to the encoded data on the specifiedMemoryStack
. 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(long, int)
.- Parameters:
stack
- the stack to useencoder
- the encoder to usestrings
- the strings to encode- Returns:
- the pointer array address on the stack
-
apiArrayFree
public static void apiArrayFree(long pointers, int length) Frees the specified array of pointers.- Parameters:
pointers
- the pointer array to freelength
- the pointer array length
-
apiCreateStruct
-
apiCreateUnion
-
apiCreateArray
-
apiCreateCIF
Allocates and prepares a libffi CIF. -
apiCreateCIFVar
Allocates and prepares a libffi var CIF. -
apiStdcall
public static int apiStdcall() -
apiClosureRet
public static void apiClosureRet(long ret, boolean __result) -
apiClosureRet
public static void apiClosureRet(long ret, byte __result) -
apiClosureRet
public static void apiClosureRet(long ret, short __result) -
apiClosureRet
public static void apiClosureRet(long ret, int __result) -
apiClosureRetL
public static void apiClosureRetL(long ret, long __result) -
apiClosureRetP
public static void apiClosureRetP(long ret, long __result) -
apiClosureRet
public static void apiClosureRet(long ret, float __result) -
apiClosureRet
public static void apiClosureRet(long ret, double __result)
-