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 and Description static classAPIUtil.APIVersionA data class for API versioning information.static interfaceAPIUtil.Encoder
-
Field Summary
Fields Modifier and Type Field and 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 and Description 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 longapiArray(MemoryStack stack, java.nio.ByteBuffer... buffers)Stores the addresses of the specified array of buffers on the specifiedMemoryStack.static longapiArray(MemoryStack stack, long... addresses)Stores the specified array of pointer addresses 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, 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 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 booleanapiCompareCapabilities(java.lang.Iterable<java.lang.reflect.Field> flags, java.lang.Iterable<java.lang.reflect.Field> funcs, java.lang.Object a, java.lang.Object b)static longapiCreateCallback(CallbackI function, java.lang.String signature)Creates a native function that delegates to the specifiedCallbackIinstance when called.static longapiCreateCallback(CallbackI function, java.lang.String signature, boolean systemCallConvention)Creates a native function that delegates to the specifiedCallbackinstance when called.static SharedLibraryapiCreateLibrary(java.lang.String name)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 voidapiLog(java.lang.CharSequence msg)Prints the specified message to theAPIUtil.DEBUG_STREAMifChecks.DEBUGis true.static java.lang.Class<?>apiOptionalClass(java.lang.String className)static APIUtil.APIVersionapiParseVersion(Configuration<?> option)Returns theAPIUtil.APIVersionvalue of the specified option.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 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(java.lang.CharSequence msg)
Prints the specified message to theAPIUtil.DEBUG_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
-
apiCreateLibrary
public static SharedLibrary apiCreateLibrary(java.lang.String name)
-
apiGetFunctionAddress
public static long apiGetFunctionAddress(FunctionProvider provider, java.lang.String functionName)
-
apiCreateCallback
public static long apiCreateCallback(CallbackI function, java.lang.String signature)
Creates a native function that delegates to the specifiedCallbackIinstance when called.The native function uses the default calling convention.
- Parameters:
function- the targetCallbackIinstancesignature- thedyncallfunction signature- Returns:
- the dynamically generated native function
-
apiCreateCallback
public static long apiCreateCallback(CallbackI function, java.lang.String signature, boolean systemCallConvention)
Creates a native function that delegates to the specifiedCallbackinstance when called.- Parameters:
function- the targetCallbackIinstancesignature- thedyncallfunction signaturesystemCallConvention- if true, the system calling convention will be used (i.e. stdcall on Windows x86)- Returns:
- the dynamically generated native function
-
apiParseVersion
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, 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(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. 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
-
apiOptionalClass
public static java.lang.Class<?> apiOptionalClass(java.lang.String className)
-
apiCompareCapabilities
public static boolean apiCompareCapabilities(java.lang.Iterable<java.lang.reflect.Field> flags, java.lang.Iterable<java.lang.reflect.Field> funcs, java.lang.Object a, java.lang.Object b)
-
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
APIUtil.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
APIUtil.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
-
-