Class APIUtil

java.lang.Object
org.lwjgl.system.APIUtil

public final class APIUtil extends Object
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:
  • Field Details

  • Method Details

    • apiLog

      public static void apiLog(CharSequence msg)
      Prints the specified message to the DEBUG_STREAM if Checks.DEBUG is true.
      Parameters:
      msg - the message to print
    • apiLogMore

      public static void apiLogMore(CharSequence msg)
      Same as apiLog(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

      public static void apiLogMissing(String api, ByteBuffer functionName)
    • apiFindLibrary

      public static String apiFindLibrary(String start, String name)
    • apiCreateLibrary

      public static SharedLibrary apiCreateLibrary(String name)
    • apiGetFunctionAddress

      public static long apiGetFunctionAddress(FunctionProvider provider, String functionName)
    • apiGetFunctionAddressOptional

      public static long apiGetFunctionAddressOptional(SharedLibrary library, String functionName)
    • 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

      @Nullable public static APIUtil.APIVersion apiParseVersion(Configuration<?> option)
      Returns the APIUtil.APIVersion value of the specified option.
      Parameters:
      option - the option to query
    • apiParseVersion

      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 - the version string
      Returns:
      the parsed APIUtil.APIVersion
    • apiFilterExtensions

      public static void apiFilterExtensions(Set<String> extensions, Configuration<Object> option)
    • apiUnknownToken

      public static String apiUnknownToken(int token)
    • apiUnknownToken

      public static String apiUnknownToken(String description, int token)
    • 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

      public static long apiArray(MemoryStack stack, long... addresses)
      Stores the specified array of pointer addresses on the specified MemoryStack.
      Parameters:
      stack - the stack to use
      addresses - the pointer addresses to store
      Returns:
      the pointer array address on the stack
    • apiArray

      public static long apiArray(MemoryStack stack, ByteBuffer... buffers)
      Stores the addresses of the specified array of buffers on the specified MemoryStack.
      Parameters:
      stack - the stack to use
      buffers - the buffers to store
      Returns:
      the pointer array address on the stack
    • apiArrayp

      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 - the stack to use
      buffers - the buffers to store
      Returns:
      the pointer array address on the stack
    • apiArray

      public static long apiArray(MemoryStack stack, APIUtil.Encoder encoder, CharSequence... strings)
      Encodes the specified strings with the specified APIUtil.Encoder and stores an array of pointers to the encoded data on the specified MemoryStack. The encoded strings include null-termination.
      Parameters:
      stack - the stack to use
      encoder - the encoder to use
      strings - the strings to encode
      Returns:
      the pointer array address on the stack
    • apiArrayi

      public static long apiArrayi(MemoryStack stack, APIUtil.Encoder encoder, CharSequence... strings)
      Encodes the specified strings with the specified APIUtil.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(long, int).

      Parameters:
      stack - the stack to use
      encoder - the encoder to use
      strings - the strings to encode
      Returns:
      the pointer array address on the stack
    • apiArrayp

      public static long apiArrayp(MemoryStack stack, APIUtil.Encoder encoder, CharSequence... strings)
      Encodes the specified strings with the specified APIUtil.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(long, int).

      Parameters:
      stack - the stack to use
      encoder - the encoder to use
      strings - 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 free
      length - the pointer array length
    • apiCreateStruct

      public static FFIType apiCreateStruct(FFIType... members)
    • apiCreateUnion

      public static FFIType apiCreateUnion(FFIType... members)
    • apiCreateArray

      public static FFIType apiCreateArray(FFIType type, int length)
    • apiCreateCIF

      public static FFICIF apiCreateCIF(int abi, FFIType rtype, FFIType... atypes)
      Allocates and prepares a libffi CIF.
    • apiCreateCIFVar

      public static FFICIF apiCreateCIFVar(int abi, int nfixedargs, FFIType rtype, FFIType... atypes)
      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)