Package org.lwjgl.system
Class APIUtil
- java.lang.Object
-
- org.lwjgl.system.APIUtil
-
public final class APIUtil extends java.lang.ObjectUtility class useful to API bindings. [INTERNAL USE ONLY]Method names in this class are prefixed with
apito avoid ambiguities when used with static imports.- See Also:
Configuration.DEBUG_STREAM
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAPIUtil.APIVersionA data class for API versioning information.static interfaceAPIUtil.Encoder
-
Field Summary
Fields Modifier and Type Field Description static java.io.PrintStreamDEBUG_STREAMThePrintStreamused by LWJGL to print debug information and non-fatal errors.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longapiArray(MemoryStack stack, long... addresses)Stores the specified array of pointer addresses on the specifiedMemoryStack.static longapiArray(MemoryStack stack, java.nio.ByteBuffer... buffers)Stores the addresses of the specified array of buffers on the specifiedMemoryStack.static longapiArray(MemoryStack stack, APIUtil.Encoder encoder, java.lang.CharSequence... strings)Encodes the specified strings with the specifiedAPIUtil.Encoderand stores an array of pointers to the encoded data on the specifiedMemoryStack.static voidapiArrayFree(long pointers, int length)Frees the specified array of pointers.static longapiArrayi(MemoryStack stack, APIUtil.Encoder encoder, java.lang.CharSequence... strings)Encodes the specified strings with the specifiedAPIUtil.Encoderand stores an array of pointers to the encoded data on the specifiedMemoryStack.static longapiArrayp(MemoryStack stack, java.nio.ByteBuffer... buffers)Stores the addresses of the specified array of buffers on the specifiedMemoryStack.static longapiArrayp(MemoryStack stack, APIUtil.Encoder encoder, java.lang.CharSequence... strings)Encodes the specified strings with the specifiedAPIUtil.Encoderand stores an array of pointers to the encoded data on the specifiedMemoryStack.static longapiCheckAllocation(int elements, long bytes, long maxBytes)static java.util.Map<java.lang.Integer,java.lang.String>apiClassTokens(java.util.function.BiPredicate<java.lang.reflect.Field,java.lang.Integer> filter, java.util.Map<java.lang.Integer,java.lang.String> target, java.lang.Class<?>... tokenClasses)Returns a map of public static final integer fields in the specified classes, to their String representations.static SharedLibraryapiCreateLibrary(java.lang.String name)static java.lang.StringapiFindLibrary(java.lang.String start, java.lang.String name)static longapiGetBytes(int elements, int elementShift)static longapiGetFunctionAddress(FunctionProvider provider, java.lang.String functionName)static java.util.Optional<java.lang.String>apiGetManifestValue(java.lang.String attributeName)Returns the value of the specified manifest attribute in the LWJGL JAR file.static java.nio.ByteBufferapiGetMappedBuffer(java.nio.ByteBuffer buffer, long mappedAddress, int capacity)static voidapiLog(java.lang.CharSequence msg)Prints the specified message to theDEBUG_STREAMifChecks.DEBUGis true.static APIUtil.APIVersionapiParseVersion(java.lang.String version)Parses a version string.static APIUtil.APIVersionapiParseVersion(java.lang.String version, java.lang.String prefix)Parses a version string.static APIUtil.APIVersionapiParseVersion(Configuration<?> option)Returns theAPIUtil.APIVersionvalue of the specified option.static java.lang.StringapiUnknownToken(int token)static java.lang.StringapiUnknownToken(java.lang.String description, int token)
-
-
-
Field Detail
-
DEBUG_STREAM
public static final java.io.PrintStream DEBUG_STREAM
ThePrintStreamused by LWJGL to print debug information and non-fatal errors. Defaults toSystem.errwhich can be changed withConfiguration.DEBUG_STREAM.
-
-
Method Detail
-
apiLog
public static void apiLog(@Nullable java.lang.CharSequence msg)Prints the specified message to theDEBUG_STREAMifChecks.DEBUGis true.- Parameters:
msg- the message to print
-
apiGetManifestValue
public static java.util.Optional<java.lang.String> apiGetManifestValue(java.lang.String attributeName)
Returns the value of the specified manifest attribute in the LWJGL JAR file.- Parameters:
attributeName- the attribute name- Returns:
- the attribute value or null if the attribute was not found or there is no LWJGL JAR file
-
apiFindLibrary
public static java.lang.String apiFindLibrary(java.lang.String start, java.lang.String name)
-
apiCreateLibrary
public static SharedLibrary apiCreateLibrary(java.lang.String name)
-
apiGetFunctionAddress
public static long apiGetFunctionAddress(FunctionProvider provider, java.lang.String functionName)
-
apiGetMappedBuffer
@Nullable public static java.nio.ByteBuffer apiGetMappedBuffer(@Nullable java.nio.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
@Nullable public static APIUtil.APIVersion apiParseVersion(Configuration<?> option)
Returns theAPIUtil.APIVersionvalue of the specified option.- Parameters:
option- the option to query
-
apiParseVersion
public static APIUtil.APIVersion apiParseVersion(java.lang.String version)
Parses a version string. The version string must have the formatMAJOR.MINOR.REVISION IMPL, whereMAJORis the major version (integer),MINORis the minor version (integer),REVISIONis the revision version (string, optional) andIMPLis implementation-specific information (string, optional).- Parameters:
version- the API version string- Returns:
- the parsed
APIUtil.APIVersion
-
apiParseVersion
public static APIUtil.APIVersion apiParseVersion(java.lang.String version, @Nullable java.lang.String prefix)
Parses a version string. The version string must have the formatPREFIX MAJOR.MINOR.REVISION IMPL, wherePREFIXis the specified prefix (string, optional),MAJORis the major version (integer),MINORis the minor version (integer),REVISIONis the revision version (string, optional) andIMPLis implementation-specific information (string, optional).- Parameters:
version- the version stringprefix- the version string prefix, may be null- Returns:
- the parsed
APIUtil.APIVersion
-
apiUnknownToken
public static java.lang.String apiUnknownToken(int token)
-
apiUnknownToken
public static java.lang.String apiUnknownToken(java.lang.String description, int token)
-
apiClassTokens
public static java.util.Map<java.lang.Integer,java.lang.String> apiClassTokens(@Nullable java.util.function.BiPredicate<java.lang.reflect.Field,java.lang.Integer> filter, @Nullable java.util.Map<java.lang.Integer,java.lang.String> target, java.lang.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
public static long apiArray(MemoryStack stack, long... addresses)
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
public static long apiArray(MemoryStack stack, java.nio.ByteBuffer... buffers)
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
public static long apiArrayp(MemoryStack stack, java.nio.ByteBuffer... buffers)
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
public static long apiArray(MemoryStack stack, APIUtil.Encoder encoder, java.lang.CharSequence... strings)
Encodes the specified strings with the specifiedAPIUtil.Encoderand 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
public static long apiArrayi(MemoryStack stack, APIUtil.Encoder encoder, java.lang.CharSequence... strings)
Encodes the specified strings with the specifiedAPIUtil.Encoderand 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
public static long apiArrayp(MemoryStack stack, APIUtil.Encoder encoder, java.lang.CharSequence... strings)
Encodes the specified strings with the specifiedAPIUtil.Encoderand 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
-
-