@Override public void invoke(long userData, int level, long message) { LOGGER.fine("LibOVR [" + userData + "] [" + level + "] " + memASCII(message)); } };
/** * Returns the ASCII string value at the specified byte range. */ public String stringValueASCII(int offset, int limit) { buffer.position(offset); buffer.limit(limit); try { return MemoryUtil.memASCII(buffer); } finally { buffer.clear(); } }
/** * Ensures space for the specified string encoded in ASCII, encodes the * string at the allocated offset and returns that offset. */ public int stringParamASCII(CharSequence value, boolean nullTerminated) { if (value == null) { return -1; } int offset = bufferParam(value.length() + (nullTerminated ? 1 : 0)); MemoryUtil.memASCII(value, nullTerminated, buffer, offset); return offset; }
/** * ASCII encodes the specified strings with a null-terminator and ensures * space for a buffer filled with the memory addresses of the encoded * strings. * * <p> * The encoded buffers must be later freed with * {@link #pointerArrayFree(int, int)}.</p> * * @return the offset to the memory address buffer */ public int pointerArrayParamASCII(CharSequence... strings) { int buffersAddress = bufferParam(strings.length << POINTER_SHIFT); for (int i = 0; i < strings.length; i++) { ByteBuffer buffer = MemoryUtil.memASCII(strings[i]); pointerParam(buffersAddress, i, memAddress(buffer)); } return buffersAddress; }
/** * ASCII encodes the specified strings and ensures space for two additional * buffers filled with the lengths and memory addresses of the encoded * strings, respectively. The lengths are pointer-sized integers and the * memory address buffer starts immediately after the lengths buffer. * * <p> * The encoded buffers must be later freed with * {@link #pointerArrayFree(int, int)}.</p> * * @return the offset to the lengths buffer */ public int pointerArrayParamASCIIp(CharSequence... strings) { int buffersAddress = bufferParam(strings.length << POINTER_SHIFT); int lengthsAddress = bufferParam(strings.length << POINTER_SHIFT); for (int i = 0; i < strings.length; i++) { ByteBuffer buffer = MemoryUtil.memASCII(strings[i]); pointerParam(buffersAddress, i, memAddress(buffer)); pointerParam(lengthsAddress, i, buffer.remaining()); } return buffersAddress; }
/** * ASCII encodes the specified strings and ensures space for two additional * buffers filled with the lengths and memory addresses of the encoded * strings, respectively. The lengths are 4-bytes integers and the memory * address buffer starts immediately after the lengths buffer. * * <p> * The encoded buffers must be later freed with * {@link #pointerArrayFree(int, int)}.</p> * * @return the offset to the lengths buffer */ public int pointerArrayParamASCIIi(CharSequence... strings) { int buffersAddress = bufferParam(strings.length << POINTER_SHIFT); int lengthsAddress = bufferParam(strings.length << 2); for (int i = 0; i < strings.length; i++) { ByteBuffer buffer = MemoryUtil.memASCII(strings[i]); pointerParam(buffersAddress, i, memAddress(buffer)); intParam(lengthsAddress, i, buffer.remaining()); } return buffersAddress; }
private String Log(long device) { Utils.pointerBuffers[0].rewind(); int ret = CL10.clGetProgramBuildInfo(program, device, CL10.CL_PROGRAM_BUILD_LOG, (ByteBuffer) null, Utils.pointerBuffers[0]); Utils.checkError(ret, "clGetProgramBuildInfo"); int count = (int) Utils.pointerBuffers[0].get(0); final ByteBuffer buffer = BufferUtils.createByteBuffer(count); ret = CL10.clGetProgramBuildInfo(program, device, CL10.CL_PROGRAM_BUILD_LOG, buffer, null); Utils.checkError(ret, "clGetProgramBuildInfo"); return MemoryUtil.memASCII(buffer); }
/** * Converts the specified {@link MallocMessageCallback} arguments to a String. * * <p>This method may only be used inside a MallocMessageCallback invocation.</p> * * @param s the MallocMessageCallback {@code s} argument * * @return the message as a String */ public static String getMessage(long s) { return memASCII(s); }
/** * Returns a ByteBuffer containing the specified text ASCII encoded and null-terminated. * * @param text the text to encode * * @return the encoded text. The returned buffer must be deallocated manually with {@link #memFree}. */ public static ByteBuffer memASCII(CharSequence text) { return memASCII(text, true); }
/** Like {@link #memASCII(long, int) memASCII}, but returns {@code null} if {@code address} is {@link #NULL}. */ @Nullable public static String memASCIISafe(long address, int length) { return address == NULL ? null : memASCII(address, length); }
/** Like {@link #memASCII(CharSequence) memASCII}, but returns {@code null} if {@code text} is {@code null}. */ @Nullable public static ByteBuffer memASCIISafe(@Nullable CharSequence text) { return text == null ? null : memASCII(text, true); }
/** Like {@link #memASCII(long) memASCII}, but returns {@code null} if {@code address} is {@link #NULL}. */ @Nullable public static String memASCIISafe(long address) { return address == NULL ? null : memASCII(address, memLengthNT1(address, Integer.MAX_VALUE)); }
/** * Decodes the bytes with index {@code [position(), position()+remaining()}) in {@code buffer}, as an ASCII string. * * <p>The current {@code position} and {@code limit} of the specified {@code buffer} are not affected by this operation.</p> * * @param buffer the {@link ByteBuffer} to decode * * @return the decoded {@link String} */ public static String memASCII(ByteBuffer buffer) { return memASCII(memAddress(buffer), buffer.remaining()); }
/** * Reads the pointer at this buffer's current position, and then increments the position. The pointer is evaluated as a null-terminated ASCII string, which * is decoded and returned as a {@link String} instance. * * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit */ public String getStringASCII() { return memASCII(get()); }
/** Like {@link #memASCII(ByteBuffer) memASCII}, but returns {@code null} if {@code buffer} is {@code null}. */ @Nullable public static String memASCIISafe(@Nullable ByteBuffer buffer) { return buffer == null ? null : memASCII(memAddress(buffer), buffer.remaining()); }
@Override public long getFunctionAddress(ByteBuffer functionName) { long address = invokePP(alGetProcAddress, memAddress(functionName)); if (address == NULL && Checks.DEBUG_FUNCTIONS) { apiLog("Failed to locate address for AL function " + memASCII(functionName)); } return address; } };
@Override public long getFunctionAddress(ByteBuffer functionName) { long address = getExtensionAddress(memAddress(functionName)); if (address == NULL) { address = library.getFunctionAddress(functionName); if (address == NULL && DEBUG_FUNCTIONS) { apiLog("Failed to locate address for GL function " + memASCII(functionName)); } } return address; }
private String Log(long device) { Utils.pointerBuffers[0].rewind(); int ret = CL10.clGetProgramBuildInfo(program, device, CL10.CL_PROGRAM_BUILD_LOG, (ByteBuffer) null, Utils.pointerBuffers[0]); Utils.checkError(ret, "clGetProgramBuildInfo"); int count = (int) Utils.pointerBuffers[0].get(0); final ByteBuffer buffer = BufferUtils.createByteBuffer(count); ret = CL10.clGetProgramBuildInfo(program, device, CL10.CL_PROGRAM_BUILD_LOG, buffer, null); Utils.checkError(ret, "clGetProgramBuildInfo"); return MemoryUtil.memASCII(buffer); }
@NativeType("void") public static String glGetDriverControlStringQCOM(@NativeType("GLuint") int driverControl, @NativeType("GLsizei") int bufSize) { MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { IntBuffer length = stack.ints(0); ByteBuffer driverControlString = stack.malloc(bufSize); nglGetDriverControlStringQCOM(driverControl, bufSize, memAddress(length), memAddress(driverControlString)); return memASCII(driverControlString, length.get(0)); } finally { stack.setPointer(stackPointer); } }
/** Get the text that was entered into the text input. */ @NativeType("uint32_t") public static String VROverlay_GetKeyboardText(@NativeType("uint32_t") int cchText) { MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { ByteBuffer pchText = stack.malloc(cchText); int __result = nVROverlay_GetKeyboardText(memAddress(pchText), cchText); return memASCII(pchText, __result - 1); } finally { stack.setPointer(stackPointer); } }