From: <sp...@us...> - 2010-03-12 21:55:21
|
Revision: 3281 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3281&view=rev Author: spasi Date: 2010-03-12 21:55:13 +0000 (Fri, 12 Mar 2010) Log Message: ----------- Added support for Strings! (WIP, needs more testing) Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/generator/Alternate.java trunk/LWJGL/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/GLTypeMap.java trunk/LWJGL/src/java/org/lwjgl/util/generator/GeneratorVisitor.java trunk/LWJGL/src/java/org/lwjgl/util/generator/JNITypeTranslator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/StringList.java trunk/LWJGL/src/java/org/lwjgl/util/generator/TypedefsGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/Utils.java trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_gpu_shader4.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_separate_shader_objects.java trunk/LWJGL/src/templates/org/lwjgl/opengl/EXT_transform_feedback.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL20.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL30.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL31.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL33.java trunk/LWJGL/src/templates/org/lwjgl/opengl/NV_transform_feedback.java Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opengl/StringUtils.java trunk/LWJGL/src/java/org/lwjgl/util/generator/GLstring.java trunk/LWJGL/src/java/org/lwjgl/util/generator/GLstringOffset.java Added: trunk/LWJGL/src/java/org/lwjgl/opengl/StringUtils.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/StringUtils.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/StringUtils.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.opengl; + +import org.lwjgl.BufferUtils; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +/** @author spasi */ +final class StringUtils { + + private static final int INITIAL_BUFFER_SIZE = 256; + private static final int INITIAL_LENGTHS_SIZE = 4; + + private static final ThreadLocal arrayTL = new ThreadLocal() { + protected Object initialValue() { + return new char[INITIAL_BUFFER_SIZE]; + } + }; + + private static final ThreadLocal bufferTL = new ThreadLocal() { + protected Object initialValue() { + return BufferUtils.createByteBuffer(INITIAL_BUFFER_SIZE); + } + }; + + private static final ThreadLocal lengthsTL = new ThreadLocal() { + protected Object initialValue() { + return BufferUtils.createIntBuffer(INITIAL_LENGTHS_SIZE); + } + }; + + private StringUtils() { + } + + private static char[] getArray(final int size) { + char[] array = (char[])arrayTL.get(); + + if ( array.length < size ) { + int sizeNew = array.length << 1; + while ( sizeNew < size ) + sizeNew <<= 1; + + array = new char[size]; + arrayTL.set(array); + } + + return array; + } + + static ByteBuffer getBuffer(final int size) { + ByteBuffer buffer = (ByteBuffer)bufferTL.get(); + + if ( buffer.capacity() < size ) { + int sizeNew = buffer.capacity() << 1; + while ( sizeNew < size ) + sizeNew <<= 1; + + buffer = BufferUtils.createByteBuffer(size); + bufferTL.set(buffer); + } + + buffer.clear(); + return buffer; + } + + private static ByteBuffer getBufferOffset(final int size) { + ByteBuffer buffer = (ByteBuffer)bufferTL.get(); + + if ( buffer.capacity() < size ) { + int sizeNew = buffer.capacity() << 1; + while ( sizeNew < size ) + sizeNew <<= 1; + + final ByteBuffer bufferNew = BufferUtils.createByteBuffer(size); + bufferNew.put(buffer); + bufferTL.set(buffer = bufferNew); + } else { + buffer.position(buffer.limit()); + buffer.limit(buffer.capacity()); + } + + return buffer; + } + + static IntBuffer getLengths(final int size) { + IntBuffer lengths = (IntBuffer)lengthsTL.get(); + + if ( lengths.capacity() < size ) { + int sizeNew = lengths.capacity(); + while ( sizeNew < size ) + sizeNew <<= 1; + + lengths = BufferUtils.createIntBuffer(size); + lengthsTL.set(lengths); + } + + lengths.clear(); + return lengths; + } + + /* + * Reads a byte string from the specified buffer. + * + * @param buffer + * + * @return the buffer as a String. + */ + + static String getString(final ByteBuffer buffer) { + final int length = buffer.remaining(); + final char[] charArray = getArray(length); + + for ( int i = buffer.position(); i < buffer.limit(); i++ ) + charArray[i - buffer.position()] = (char)buffer.get(i); + + return new String(charArray, 0, length); + } + + /** + * Returns a buffer containing the specified string as bytes. + * + * @param string + * + * @return the String as a ByteBuffer + */ + static ByteBuffer getBuffer(final CharSequence string) { + final ByteBuffer buffer = getBuffer(string.length()); + + for ( int i = 0; i < string.length(); i++ ) + buffer.put((byte)string.charAt(i)); + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified string as bytes, starting at the specified offset. + * + * @param string + * + * @return the String as a ByteBuffer + */ + static ByteBuffer getBufferOffset(final CharSequence string, final int offset) { + final ByteBuffer buffer = getBufferOffset(offset + string.length()); + + for ( int i = 0; i < string.length(); i++ ) + buffer.put((byte)string.charAt(i)); + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified string as bytes, including null-termination. + * + * @param string + * + * @return the String as a ByteBuffer + */ + static ByteBuffer getBufferNT(final CharSequence string) { + final ByteBuffer buffer = getBuffer(string.length() + 1); + + for ( int i = 0; i < string.length(); i++ ) + buffer.put((byte)string.charAt(i)); + + buffer.put((byte)0); + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified strings as bytes. + * + * @param strings + * + * @return the Strings as a ByteBuffer + */ + static ByteBuffer getBuffer(final CharSequence[] strings) { + int length = 0; + for ( int i = 0; i < strings.length; i++ ) + length += strings[i].length(); + + final ByteBuffer buffer = getBuffer(length); + + for ( int i = 0; i < strings.length; i++ ) { + final CharSequence string = strings[i]; + for ( int j = 0; j < string.length(); j++ ) + buffer.put((byte)string.charAt(i)); + } + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the specified strings as bytes, including null-termination. + * + * @param strings + * + * @return the Strings as a ByteBuffer + */ + static ByteBuffer getBufferNT(final CharSequence[] strings) { + int length = 0; + for ( int i = 0; i < strings.length; i++ ) + length += strings[i].length() + 1; + + final ByteBuffer buffer = getBuffer(length); + + for ( int i = 0; i < strings.length; i++ ) { + final CharSequence string = strings[i]; + for ( int j = 0; j < string.length(); j++ ) + buffer.put((byte)string.charAt(i)); + buffer.put((byte)0); + } + + buffer.flip(); + return buffer; + } + + /** + * Returns a buffer containing the lengths of the specified strings. + * + * @param strings + * + * @return the String lengths in an IntBuffer + */ + static IntBuffer getLengths(final CharSequence[] strings) { + IntBuffer buffer = getLengths(strings.length); + + for ( int i = 0; i < strings.length; i++ ) + buffer.put(strings[i].length()); + + buffer.flip(); + return buffer; + } + +} \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/Alternate.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/Alternate.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/Alternate.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -42,6 +42,10 @@ */ @Target({ ElementType.METHOD }) public @interface Alternate { + /** This must match an existing GL method name. */ String value(); + + /** If true, an alternate Java->native call will be created. Useful when the alternate implementation uses different types. */ + boolean nativeAlt() default false; } \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/ContextCapabilitiesGenerator.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -210,8 +210,18 @@ writer.println(") {"); writer.println("\t\treturn "); + + boolean first = true; while ( methods.hasNext() ) { MethodDeclaration method = methods.next(); + if ( method.getAnnotation(Alternate.class) != null ) + continue; + + if ( !first ) + writer.println(" &&"); + else + first = false; + optional = method.getAnnotation(Optional.class) != null; deprecated = method.getAnnotation(DeprecatedGL.class) != null; dependent = method.getAnnotation(Dependent.class); @@ -261,8 +271,6 @@ writer.print(')'); if ( optional ) writer.print(" || true)"); - if ( methods.hasNext() ) - writer.println(" &&"); } writer.println(";"); writer.println("\t}"); @@ -271,7 +279,8 @@ public static void generateSymbolAddresses(PrintWriter writer, InterfaceDeclaration d) { for ( MethodDeclaration method : d.getMethods() ) { - writer.println("\tlong " + Utils.getFunctionAddressName(d, method) + ";"); + if ( method.getAnnotation(Alternate.class) == null ) + writer.println("\tlong " + Utils.getFunctionAddressName(d, method) + ";"); } } Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/GLTypeMap.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/GLTypeMap.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/GLTypeMap.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -220,7 +220,7 @@ else if ( type.equals(boolean.class) ) return new Class[] { GLboolean.class }; else if ( type.equals(void.class) ) - return new Class[] { GLvoid.class }; + return new Class[] { GLvoid.class, GLstring.class }; else return new Class[] { }; } @@ -243,6 +243,8 @@ valid_types = new Class[] { GLubyte.class }; else if ( PointerWrapper.class.isAssignableFrom(type) ) valid_types = new Class[] { GLpointer.class }; + else if (void.class.equals(type) ) + valid_types = new Class[] { GLstring.class }; else valid_types = new Class[] { }; return valid_types; Added: trunk/LWJGL/src/java/org/lwjgl/util/generator/GLstring.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/GLstring.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/GLstring.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.util.generator; + +/** + * Methods annotated with @GLstring will return a String instead of void. + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@NativeType +@Target({ ElementType.METHOD }) +public @interface GLstring { + /** The ByteBuffer argument that will be used to retrieve the String bytes. */ + String string(); + /** The argument that specifies the maximum number of bytes that may be read. */ + String maxLength(); +} \ No newline at end of file Added: trunk/LWJGL/src/java/org/lwjgl/util/generator/GLstringOffset.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/GLstringOffset.java (rev 0) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/GLstringOffset.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl.util.generator; + +/** + * This annotation must be used when there are more than one CharSequence arguments in a method. + * TODO: Add support for CharSequence[] if/when we need it. + * + * @author spasi + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ ElementType.PARAMETER }) +public @interface GLstringOffset { + /** An expression that will specify the offset from which this String will be written to the ByteBuffer. */ + String value(); +} \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/GeneratorVisitor.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/GeneratorVisitor.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/GeneratorVisitor.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -125,7 +125,8 @@ private void validateParameters(MethodDeclaration method) { for (ParameterDeclaration param : method.getParameters()) { validateTypes(method, param.getAnnotationMirrors(), param.getType()); - if (Utils.getNIOBufferType(param.getType()) != null) { + Class<?> param_type = Utils.getJavaType(param.getType()); + if (Utils.getNIOBufferType(param.getType()) != null && param_type != CharSequence.class && param_type != CharSequence[].class) { Check parameter_check_annotation = param.getAnnotation(Check.class); NullTerminated null_terminated_annotation = param.getAnnotation(NullTerminated.class); if (parameter_check_annotation == null && null_terminated_annotation == null) { @@ -138,7 +139,11 @@ break; } } - if (!found_auto_size_param && param.getAnnotation(Result.class) == null && param.getAnnotation(Constant.class) == null) + if (!found_auto_size_param + && param.getAnnotation(Result.class) == null + && param.getAnnotation(Constant.class) == null + && !Utils.isReturnString(method, param) + ) throw new RuntimeException(param + " has no Check, Result nor Constant annotation and no other parameters has" + " an @AutoSize annotation on it in method " + method); } @@ -158,8 +163,10 @@ } private static void generateMethodsNativePointers(PrintWriter writer, Collection<? extends MethodDeclaration> methods) { - for (MethodDeclaration method : methods) - generateMethodNativePointers(writer, method); + for (MethodDeclaration method : methods) { + if ( method.getAnnotation(Alternate.class) == null ) + generateMethodNativePointers(writer, method); + } } private static void generateMethodNativePointers(PrintWriter writer, MethodDeclaration method) { Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/JNITypeTranslator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/JNITypeTranslator.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/JNITypeTranslator.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -56,7 +56,10 @@ } public void visitArrayType(ArrayType t) { - throw new RuntimeException(t + " is not allowed"); + if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) + signature.append("jobject"); + else + throw new RuntimeException(t + " is not allowed"); } public void visitClassType(ClassType t) { Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -71,7 +71,8 @@ if ( method.getAnnotation(CachedResult.class) != null && !method.getAnnotation(CachedResult.class).isRange() ) { printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.CACHEDRESULT, generate_error_checks, context_specific); } - if ( method.getAnnotation(Alternate.class) == null ) { + Alternate alt_annotation = method.getAnnotation(Alternate.class); + if ( alt_annotation == null || alt_annotation.nativeAlt() ) { printJavaNativeStub(writer, method, Mode.NORMAL, generate_error_checks, context_specific); if (Utils.hasMethodBufferObjectParameter(method)) { printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.BUFFEROBJECT, generate_error_checks, context_specific); @@ -119,8 +120,12 @@ writer.print("boolean " + TypeInfo.UNSIGNED_PARAMETER_NAME); } } - } else if (param.getAnnotation(Result.class) == null && (native_stub || param.getAnnotation(Constant.class) == null) && - (getAutoTypeParameter(method, param) == null || mode != Mode.AUTOS)) { + } else if ( + param.getAnnotation(Result.class) == null + && (native_stub || (param.getAnnotation(Constant.class) == null && !Utils.isReturnString(method, param))) + && (getAutoTypeParameter(method, param) == null || mode != Mode.AUTOS) + ) + { TypeInfo type_info = typeinfos_instance.get(param); first_parameter = generateParameterJava(writer, param, type_info, native_stub, first_parameter, mode); } @@ -161,10 +166,15 @@ } else { if ( native_stub && param.getAnnotation(GLpointer.class) != null ) writer.print("long"); - else - writer.print(type_info.getType().getSimpleName()); + else { + Class type = type_info.getType(); + if ( native_stub && (type == CharSequence.class || type == CharSequence[].class) ) + writer.print("ByteBuffer"); + else + writer.print(type_info.getType().getSimpleName()); + } writer.print(" " + param.getSimpleName()); - if (buffer_type != null && native_stub) + if ( native_stub && buffer_type != null ) writer.print(", int " + param.getSimpleName() + NativeMethodStubsGenerator.BUFFER_POSITION_POSTFIX); } return false; @@ -208,7 +218,7 @@ if (context_specific) { writer.println("\t\tContextCapabilities caps = GLContext.getCapabilities();"); writer.print("\t\tlong " + Utils.FUNCTION_POINTER_VAR_NAME + " = caps."); - writer.println(Utils.getFunctionAddressName(interface_decl, method) + ";"); + writer.println(Utils.getFunctionAddressName(interface_decl, method, true) + ";"); writer.print("\t\tBufferChecks.checkFunctionAddress("); writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");"); } @@ -227,6 +237,13 @@ if ( method.getAnnotation(GLpointer.class) != null ) writer.print("new " + method.getReturnType() + "("); } + GLstring string_annotation = method.getAnnotation(GLstring.class); + if ( string_annotation != null ) { + has_result = true; + writer.println("IntBuffer " + string_annotation.string() + "_length = StringUtils.getLengths(1);"); + writer.println("\t\tByteBuffer " + string_annotation.string() + " = StringUtils.getBuffer(" + string_annotation.maxLength() + ");"); + writer.print("\t\t"); + } writer.print(Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific)); if (mode == Mode.BUFFEROBJECT) writer.print(Utils.BUFFER_OBJECT_METHOD_POSTFIX); @@ -244,8 +261,14 @@ writer.println("\t\t" + type_map.getErrorCheckMethodName() + ";"); // DISABLED: indirect buffer support //printNondirectParameterCopies(writer, method, mode); - if (has_result) - writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";"); + if (has_result) { + if ( string_annotation == null ) + writer.println("\t\treturn " + Utils.RESULT_VAR_NAME + ";"); + else { + writer.println("\t\t" + string_annotation.string() + ".limit(" + string_annotation.string() + "_length.get(0));"); + writer.println("\t\treturn StringUtils.getString(" + string_annotation.string() + ");"); + } + } writer.println("\t}"); } @@ -383,8 +406,24 @@ boolean hide_buffer = mode == Mode.AUTOS && getAutoTypeParameter(method, param) != null; if (hide_buffer) writer.print("null"); - else - writer.print(param.getSimpleName()); + else { + Class type = typeinfos_instance.get(param).getType(); + if ( type == CharSequence.class || type == CharSequence[].class ) { + GLstringOffset offset_annotation = param.getAnnotation(GLstringOffset.class); + + writer.print("StringUtils.getBuffer"); + if ( offset_annotation != null ) + writer.print("Offset"); + if ( param.getAnnotation(NullTerminated.class) != null ) + writer.print("NT"); + writer.print("(" + param.getSimpleName()); + if ( offset_annotation != null ) + writer.print(", " + offset_annotation.value()); + writer.print(")"); + hide_buffer = true; + } else + writer.print(param.getSimpleName()); + } Class buffer_type = Utils.getNIOBufferType(param.getType()); if (buffer_type != null) { writer.print(", "); @@ -404,7 +443,9 @@ writer.print(" << " + shifting); if (check_annotation != null && check_annotation.canBeNull()) writer.print(" : 0"); - } else + } else if ( param.getAnnotation(GLstringOffset.class) != null ) + writer.print(param.getAnnotation(GLstringOffset.class).value()); + else writer.print("0"); } else if ( param.getAnnotation(GLpointer.class) != null ) { writer.print(".getPointer()"); @@ -489,7 +530,8 @@ if (Utils.isAddressableType(java_type) && (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) && (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) && - param.getAnnotation(Result.class) == null) { + param.getAnnotation(Result.class) == null && + !Utils.isReturnString(method, param) ) { String check_value = null; boolean can_be_null = false; Check check_annotation = param.getAnnotation(Check.class); @@ -547,6 +589,8 @@ private static void printResultType(PrintWriter writer, MethodDeclaration method, boolean native_stub) { if ( native_stub && method.getAnnotation(GLpointer.class) != null ) writer.print("long"); + else if ( !native_stub && method.getAnnotation(GLstring.class) != null ) + writer.print("String"); else writer.print(Utils.getMethodReturnType(method).toString()); } Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaTypeTranslator.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -56,7 +56,10 @@ } public void visitArrayType(ArrayType t) { - throw new RuntimeException(t + " is not allowed"); + if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) + type = CharSequence[].class; + else + throw new RuntimeException(t + " is not allowed"); } public void visitPrimitiveType(PrimitiveType t) { Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -56,6 +56,9 @@ public static void generateNativeMethodStubs(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration d, boolean generate_error_checks, boolean context_specific) { for (MethodDeclaration method : d.getMethods()) { + Alternate alt_annotation = method.getAnnotation(Alternate.class); + if ( alt_annotation != null && !alt_annotation.nativeAlt() ) + continue; generateMethodStub(env, type_map, writer, Utils.getQualifiedClassName(d), method, Mode.NORMAL, generate_error_checks, context_specific); if (Utils.hasMethodBufferObjectParameter(method)) generateMethodStub(env, type_map, writer, Utils.getQualifiedClassName(d), method, Mode.BUFFEROBJECT, generate_error_checks, context_specific); @@ -117,9 +120,10 @@ } writer.println(") {"); generateBufferParameterAddresses(type_map, writer, method, mode); + Alternate alt_annotation = method.getAnnotation(Alternate.class); if (context_specific) { String typedef_name = Utils.getTypedefName(method); - writer.print("\t" + typedef_name + " " + method.getSimpleName()); + writer.print("\t" + typedef_name + " " + (alt_annotation == null ? method.getSimpleName() : alt_annotation.value())); writer.print(" = (" + typedef_name + ")((intptr_t)"); writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");"); } @@ -141,7 +145,7 @@ } else writer.print(" = "); } - writer.print(method.getSimpleName() + "("); + writer.print((alt_annotation == null ? method.getSimpleName() : alt_annotation.value()) + "("); generateCallParameters(writer, type_map, method.getParameters()); writer.print(")"); writer.println(";"); @@ -222,13 +226,13 @@ } private static void generateBufferParameterAddresses(TypeMap type_map, PrintWriter writer, MethodDeclaration method, Mode mode) { + boolean loopDeclared = false; for (ParameterDeclaration param : method.getParameters()) - if (Utils.isAddressableType(param.getType()) && - param.getAnnotation(Result.class) == null) - generateBufferParameterAddress(type_map, writer, method, param, mode); + if (Utils.isAddressableType(param.getType()) && param.getAnnotation(Result.class) == null) + loopDeclared = generateBufferParameterAddress(type_map, writer, method, param, mode, loopDeclared); } - private static void generateBufferParameterAddress(TypeMap type_map, PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Mode mode) { + private static boolean generateBufferParameterAddress(TypeMap type_map, PrintWriter writer, MethodDeclaration method, ParameterDeclaration param, Mode mode, boolean loopDeclared) { NativeTypeTranslator translator = new NativeTypeTranslator(type_map, param); param.getType().accept(translator); writer.print("\t" + translator.getSignature() + param.getSimpleName()); @@ -240,7 +244,7 @@ writer.print("offsetToPointer(" + param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX + "))"); } else { Class java_type = Utils.getJavaType(param.getType()); - if (Buffer.class.isAssignableFrom(java_type)) { + if (Buffer.class.isAssignableFrom(java_type) || java_type.equals(CharSequence.class) || java_type.equals(CharSequence[].class)) { boolean explicitly_byte_sized = java_type.equals(Buffer.class) || translator.getAnnotationType().equals(type_map.getVoidType()); if (explicitly_byte_sized) @@ -262,30 +266,47 @@ writer.println(";"); if ( param.getAnnotation(StringList.class) != null ) { - if ( param.getAnnotation(GLchar.class) == null || - param.getAnnotation(NullTerminated.class) == null || - param.getAnnotation(NullTerminated.class).value().length() == 0 + if ( Utils.getJavaType(param.getType()) != CharSequence[].class && ( + param.getAnnotation(GLchar.class) == null || + param.getAnnotation(NullTerminated.class) == null || + param.getAnnotation(NullTerminated.class).value().length() == 0 + ) ) throw new RuntimeException("StringList annotation can only be applied on null-terminated GLchar buffers."); - // Declare string array and loop counters - writer.print("\tGLchar **" + param.getSimpleName() + STRING_LIST_POSTFIX + "; "); - writer.println("\tunsigned int " + param.getSimpleName() + "_i = 0;"); - writer.println("\tGLchar *" + param.getSimpleName() + "_next = (GLchar *)" + param.getSimpleName() + BUFFER_ADDRESS_POSTFIX + ";"); + if ( "_str".equals(param.getSimpleName()) ) + throw new RuntimeException("The name '_str' is not valid for arguments annotated with StringList"); + + // Declare loop counters and allocate string array + if ( !loopDeclared ) { + writer.println("\tunsigned int _str_i;"); + writer.println("\tGLchar *_str_address;"); + loopDeclared = true; + } + writer.println("\tGLchar **" + param.getSimpleName() + STRING_LIST_POSTFIX + " = (GLchar **) malloc(" + param.getAnnotation(StringList.class).value() + "*sizeof(GLchar*));"); } + return loopDeclared; } private static void generateStringListInits(PrintWriter writer, Collection<ParameterDeclaration> params) { for ( ParameterDeclaration param : params ) { StringList stringList_annotation = param.getAnnotation(StringList.class); if ( stringList_annotation != null ) { - // Allocate the string array - writer.println("\t" + param.getSimpleName() + STRING_LIST_POSTFIX + " = (GLchar **) malloc(" + stringList_annotation.value() + "*sizeof(GLchar*));"); + String lengths = stringList_annotation.lengths(); + + // Init vars + writer.println("\t_str_i = 0;"); + writer.println("\t_str_address = (GLchar *)" + param.getSimpleName() + BUFFER_ADDRESS_POSTFIX + ";"); // Fill string array with the string pointers - writer.println("\tdo {"); - writer.println("\t\t" + param.getSimpleName() + STRING_LIST_POSTFIX + "[" + param.getSimpleName() + "_i++] = " + param.getSimpleName() + "_next;"); - writer.println("\t\t" + param.getSimpleName() + "_next += strlen(" + param.getSimpleName() + "_next) + 1;"); - writer.println("\t} while ( " + param.getSimpleName() + "_i < " + stringList_annotation.value() + " );"); + writer.println("\twhile ( _str_i < " + stringList_annotation.value() + " ) {"); + if ( lengths.length() == 0 ) { + writer.println("\t\t" + param.getSimpleName() + STRING_LIST_POSTFIX + "[_str_i++] = _str_address;"); + writer.println("\t\t_str_address += strlen(_str_address_next) + 1;"); + } else { + writer.println("\t\t" + param.getSimpleName() + STRING_LIST_POSTFIX + "[_str_i] = _str_address;"); + writer.println("\t\t_str_address += " + lengths + BUFFER_ADDRESS_POSTFIX + "[_str_i++];"); + } + writer.println("\t}"); } } } Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeTypeTranslator.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -104,7 +104,12 @@ } public void visitArrayType(ArrayType t) { - throw new RuntimeException(t + " is not allowed"); + if ( "java.lang.CharSequence".equals(t.getComponentType().toString()) ) { + is_indirect = true; + native_types = new ArrayList<Class>(); + native_types.add(GLchar.class); + } else + throw new RuntimeException(t + " is not allowed"); } public static PrimitiveType.Kind getPrimitiveKindFromBufferClass(Class c) { Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/StringList.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/StringList.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/StringList.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -41,5 +41,8 @@ @Target({ElementType.PARAMETER, ElementType.METHOD}) public @interface StringList { + /** Number of values in the string list (name of native-side parameter) */ String value(); + /** List of string lengths (name of native-side parameter) */ + String lengths() default ""; } \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/TypedefsGenerator.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/TypedefsGenerator.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/TypedefsGenerator.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -82,8 +82,10 @@ } public static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, Collection<? extends MethodDeclaration> methods) { - for (MethodDeclaration method : methods) - generateNativeTypedefs(type_map, writer, method); + for (MethodDeclaration method : methods) { + if ( method.getAnnotation(Alternate.class) == null ) + generateNativeTypedefs(type_map, writer, method); + } } } Modified: trunk/LWJGL/src/java/org/lwjgl/util/generator/Utils.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/generator/Utils.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/java/org/lwjgl/util/generator/Utils.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -43,9 +43,16 @@ import com.sun.mirror.type.*; import java.nio.Buffer; import java.io.*; +import java.nio.ByteBuffer; import java.util.*; +import javax.lang.model.util.SimpleTypeVisitor6; + import com.sun.mirror.declaration.*; +import com.sun.mirror.type.PrimitiveType.Kind; +import com.sun.mirror.util.SimpleTypeVisitor; +import com.sun.mirror.util.TypeVisitor; +import com.sun.mirror.util.Types; public class Utils { public static final String TYPEDEF_POSTFIX = "PROC"; @@ -63,13 +70,22 @@ private static final String OVERLOADED_METHOD_PREFIX = "n"; public static String getTypedefName(MethodDeclaration method) { - return method.getSimpleName() + TYPEDEF_POSTFIX; + Alternate alt_annotation = method.getAnnotation(Alternate.class); + return (alt_annotation == null ? method.getSimpleName() : alt_annotation.value()) + TYPEDEF_POSTFIX; } public static String getFunctionAddressName(InterfaceDeclaration interface_decl, MethodDeclaration method) { - return interface_decl.getSimpleName() + "_" + method.getSimpleName() + FUNCTION_POINTER_POSTFIX; + return getFunctionAddressName(interface_decl, method, false); } + public static String getFunctionAddressName(InterfaceDeclaration interface_decl, MethodDeclaration method, boolean forceAlt) { + Alternate alt_annotation = method.getAnnotation(Alternate.class); + if ( alt_annotation == null || (alt_annotation.nativeAlt() && !forceAlt) ) + return interface_decl.getSimpleName() + "_" + method.getSimpleName() + FUNCTION_POINTER_POSTFIX; + else + return interface_decl.getSimpleName() + "_" + alt_annotation.value() + FUNCTION_POINTER_POSTFIX; + } + public static boolean isFinal(InterfaceDeclaration d) { Extension extension_annotation = d.getAnnotation(Extension.class); return extension_annotation == null || extension_annotation.isFinal(); @@ -103,7 +119,7 @@ } public static boolean isAddressableType(Class type) { - return Buffer.class.isAssignableFrom(type) || String.class.equals(type); + return Buffer.class.isAssignableFrom(type) || String.class.equals(type) || CharSequence.class.equals(type) || CharSequence[].class.equals(type); } public static Class getJavaType(TypeMirror type_mirror) { @@ -248,6 +264,8 @@ Class<?> param_type = getJavaType(t); if (Buffer.class.isAssignableFrom(param_type)) return param_type; + else if ( param_type == CharSequence.class || param_type == CharSequence[].class ) + return ByteBuffer.class; else return null; } @@ -255,10 +273,15 @@ public static String getSimpleNativeMethodName(MethodDeclaration method, boolean generate_error_checks, boolean context_specific) { String method_name; Alternate alt_annotation = method.getAnnotation(Alternate.class); - method_name = alt_annotation == null ? method.getSimpleName() : alt_annotation.value(); + method_name = alt_annotation == null || alt_annotation.nativeAlt() ? method.getSimpleName() : alt_annotation.value(); if (isMethodIndirect(generate_error_checks, context_specific, method)) method_name = OVERLOADED_METHOD_PREFIX + method_name; return method_name; } + static boolean isReturnString(MethodDeclaration method, ParameterDeclaration param) { + GLstring string_annotation = method.getAnnotation(GLstring.class); + return string_annotation != null && string_annotation.string().equals(param.getSimpleName()); + } + } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/AMD_performance_monitor.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -68,14 +68,25 @@ void glGetPerfMonitorGroupStringAMD(@GLuint int group, @AutoSize("groupString") @GLsizei int bufSize, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, - @GLchar ByteBuffer groupString); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer groupString); - void glGetPerfMonitorCounterStringAMD(@GLuint int group, @GLuint int counter, - @AutoSize("counterString") @GLsizei int bufSize, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, - @GLchar ByteBuffer counterString); + @Alternate("glGetPerfMonitorGroupStringAMD") + @GLstring(string = "groupString", maxLength = "bufSize") + void glGetPerfMonitorGroupStringAMD2(@GLuint int group, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("groupString_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer groupString); + void glGetPerfMonitorCounterStringAMD(@GLuint int group, @GLuint int counter, @AutoSize("counterString") @GLsizei int bufSize, + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer counterString); + + @Alternate("glGetPerfMonitorCounterStringAMD") + @GLstring(string = "counterString", maxLength = "bufSize") + void glGetPerfMonitorCounterStringAMD2(@GLuint int group, @GLuint int counter, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("counterString_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer counterString); + void glGetPerfMonitorCounterInfoAMD(@GLuint int group, @GLuint int counter, @GLenum int pname, @Check(value = "16") @GLvoid ByteBuffer data); void glGenPerfMonitorsAMD(@AutoSize("monitors") @GLsizei int n, @OutParameter @GLuint IntBuffer monitors); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_blend_func_extended.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -31,10 +31,7 @@ */ package org.lwjgl.opengl; -import org.lwjgl.util.generator.Const; -import org.lwjgl.util.generator.GLchar; -import org.lwjgl.util.generator.GLuint; -import org.lwjgl.util.generator.NullTerminated; +import org.lwjgl.util.generator.*; import java.nio.ByteBuffer; @@ -58,6 +55,12 @@ void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glBindFragDataLocationIndexed") + void glBindFragDataLocationIndexed(@GLuint int program, @GLuint int colorNumber, @GLuint int index, @NullTerminated CharSequence name); + int glGetFragDataIndex(@GLuint int program, @NullTerminated @Const @GLchar ByteBuffer name); + @Alternate("glGetFragDataIndex") + int glGetFragDataIndex(@GLuint int program, @NullTerminated CharSequence name); + } \ No newline at end of file Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shader_objects.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -105,15 +105,17 @@ * This method uses just a single string, that should NOT be null-terminated. */ void glShaderSourceARB(@GLhandleARB int shader, @Constant("1") @GLsizei int count, - @Indirect - @Check - @Const - @GLcharARB ByteBuffer string, - @AutoSize("string") - @Indirect - @Const - @GLint int length); + @Indirect @Const @GLcharARB @Check ByteBuffer string, + @AutoSize("string") @Indirect @Const @GLint int length); + @Alternate("glShaderSourceARB") + void glShaderSourceARB2(@GLhandleARB int shader, @Constant("1") @GLsizei int count, CharSequence string, @Constant("string.length()") @Indirect @Const int length); + + @Alternate(value = "glShaderSourceARB", nativeAlt = true) + void glShaderSourceARB3(@GLhandleARB int shader, @Constant("strings.length") @GLsizei int count, + @Const @StringList(value = "count", lengths = "length") CharSequence[] strings, + @Constant("StringUtils.getLengths(strings), 0") @Const IntBuffer length); + void glCompileShaderARB(@GLhandleARB int shaderObj); @GLhandleARB @@ -183,18 +185,18 @@ void glGetObjectParameterivARB(@GLhandleARB int obj, @GLenum int pname, @OutParameter @Check IntBuffer params); void glGetInfoLogARB(@GLhandleARB int obj, @AutoSize("infoLog") @GLsizei int maxLength, - @OutParameter - @Check(value = "1", canBeNull = true) - @GLsizei IntBuffer length, - @OutParameter - @GLcharARB ByteBuffer infoLog); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLcharARB ByteBuffer infoLog); + @Alternate("glGetInfoLogARB") + @GLstring(string = "infoLog", maxLength = "maxLength") + void glGetInfoLogARB2(@GLhandleARB int obj, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("infoLog_length, 0") IntBuffer length, + @OutParameter @GLcharARB ByteBuffer infoLog); + void glGetAttachedObjectsARB(@GLhandleARB int containerObj, @AutoSize("obj") @GLsizei int maxCount, - @OutParameter - @Check(value = "1", canBeNull = true) - @GLsizei IntBuffer count, - @OutParameter - @GLhandleARB IntBuffer obj); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer count, + @OutParameter @GLhandleARB IntBuffer obj); /** * Returns the location of the uniform with the specified name. The ByteBuffer should contain the uniform name as a <b>null-terminated</b> string. @@ -204,16 +206,23 @@ */ int glGetUniformLocationARB(@GLhandleARB int programObj, @NullTerminated @Const @GLcharARB ByteBuffer name); + @Alternate("glGetUniformLocationARB") + int glGetUniformLocationARB(@GLhandleARB int programObj, @NullTerminated CharSequence name); + void glGetActiveUniformARB(@GLhandleARB int programObj, @GLuint int index, @AutoSize("name") @GLsizei int maxLength, - @OutParameter - @Check(value = "1", canBeNull = true) - @GLsizei IntBuffer length, - @Check("1") IntBuffer size, - @Check("1") - @GLenum IntBuffer type, - @OutParameter - @GLcharARB ByteBuffer name); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLcharARB ByteBuffer name); + @Alternate("glGetActiveUniformARB") + @GLstring(string = "name", maxLength = "maxLength") + void glGetActiveUniformARB2(@GLhandleARB int programObj, @GLuint int index, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("name_length, 0") IntBuffer length, + @OutParameter @Check("1") IntBuffer size, + @OutParameter @GLenum @Check("1") IntBuffer type, + @OutParameter @GLcharARB ByteBuffer name); + @StripPostfix("params") void glGetUniformfvARB(@GLhandleARB int programObj, int location, @OutParameter @Check FloatBuffer params); @@ -221,9 +230,13 @@ void glGetUniformivARB(@GLhandleARB int programObj, int location, @OutParameter @Check IntBuffer params); void glGetShaderSourceARB(@GLhandleARB int obj, @AutoSize("source") @GLsizei int maxLength, - @OutParameter - @Check(value = "1", canBeNull = true) - @GLsizei IntBuffer length, - @OutParameter - @GLcharARB ByteBuffer source); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLcharARB ByteBuffer source); + + @Alternate("glGetShaderSourceARB") + @GLstring(string = "source", maxLength = "maxLength") + void glGetShaderSourceARB2(@GLhandleARB int obj, @GLsizei int maxLength, + @OutParameter @GLsizei @Constant("source_length, 0") IntBuffer length, + @OutParameter @GLcharARB ByteBuffer source); + } Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_shading_language_include.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -45,29 +45,50 @@ int GL_NAMED_STRING_LENGTH_ARB = 0x8DE9; int GL_NAMED_STRING_TYPE_ARB = 0x8DEA; - void glNamedStringARB(@GLenum int type, @AutoSize("name") int namelen, @Const ByteBuffer name, @AutoSize("string") int stringlen, @Const ByteBuffer string); + void glNamedStringARB(@GLenum int type, + @AutoSize("name") int namelen, @Const @GLchar ByteBuffer name, + @AutoSize("string") int stringlen, @Const @GLchar ByteBuffer string); - void glDeleteNamedStringARB(@AutoSize("name") int namelen, @Const ByteBuffer name); + @Alternate("glNamedStringARB") + void glNamedStringARB(@GLenum int type, + @Constant("name.length()") int namelen, CharSequence name, + @Constant("string.length()") int stringlen, @GLstringOffset("name.length()") CharSequence string); + void glDeleteNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name); + + @Alternate("glDeleteNamedStringARB") + void glDeleteNamedStringARB(@Constant("name.length()") int namelen, CharSequence name); + void glCompileShaderIncludeARB(@GLuint int shader, @GLsizei int count, @Const @NullTerminated("count") @StringList("count") @GLchar ByteBuffer path, @Constant("null, 0") @Const IntBuffer length); - /* TODO: Implement @Check - @Alternate("glCompileShaderIncludeARB") - void glCompileShaderIncludeARB2(@GLuint int shader, @AutoSize("length") @GLsizei int count, - @Const @Check("...") @StringList("count") @GLchar ByteBuffer path, - @Const IntBuffer length); - */ + @Alternate(value = "glCompileShaderIncludeARB", nativeAlt = true) + void glCompileShaderIncludeARB2(@GLuint int shader, @Constant("path.length") @GLsizei int count, + @Const @StringList(value = "count", lengths = "length") CharSequence[] path, + @Constant("StringUtils.getLengths(path), 0") @Const IntBuffer length); - boolean glIsNamedStringARB(@AutoSize("name") int namelen, @Const ByteBuffer name); + boolean glIsNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name); - void glGetNamedStringARB(@AutoSize("name") int namelen, @Const ByteBuffer name, + @Alternate("glIsNamedStringARB") + boolean glIsNamedStringARB(@Constant("name.length()") int namelen, CharSequence name); + + void glGetNamedStringARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name, @AutoSize("string") @GLsizei int bufSize, @OutParameter @Check(value = "1", canBeNull = true) IntBuffer stringlen, @OutParameter ByteBuffer string); + @Alternate("glGetNamedStringARB") + void glGetNamedStringARB(@Constant("name.length()") int namelen, CharSequence name, + @AutoSize("string") @GLsizei int bufSize, + @OutParameter @Check(value = "1", canBeNull = true) IntBuffer stringlen, + @OutParameter ByteBuffer string); + @StripPostfix("params") - void glGetNamedStringivARB(@AutoSize("name") int namelen, @Const ByteBuffer name, @GLenum int pname, @Check("1") @OutParameter IntBuffer params); + void glGetNamedStringivARB(@AutoSize("name") int namelen, @Const @GLchar ByteBuffer name, @GLenum int pname, @Check("1") @OutParameter IntBuffer params); + @StripPostfix("params") + @Alternate("glGetNamedStringivARB") + void glGetNamedStringivARB2(@Constant("name.length()") int namelen, CharSequence name, @GLenum int pname, @Check("1") @OutParameter IntBuffer params); + } \ No newline at end of file Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_uniform_buffer_object.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -102,27 +102,47 @@ @Const @NullTerminated("uniformIndices.remaining()") @GLchar @StringList("uniformCount") ByteBuffer uniformNames, @OutParameter @GLuint IntBuffer uniformIndices); + @Alternate(value = "glGetUniformIndices") + void glGetUniformIndices(@GLuint int program, @Constant("uniformNames.length") @GLsizei int uniformCount, + @Const @NullTerminated @StringList("uniformCount") CharSequence[] uniformNames, + @OutParameter @Check("uniformNames.length") @GLuint IntBuffer uniformIndices); + @StripPostfix("params") void glGetActiveUniformsiv(@GLuint int program, @AutoSize("uniformIndices") @GLsizei int uniformCount, @Const @GLuint IntBuffer uniformIndices, - @GLenum int pname, - @Check(value = "1") @GLint IntBuffer params); // TODO: We need to AutoSize "params" using "uniformCount" + @GLenum int pname, @Check("uniformIndices.remaining()") @GLint IntBuffer params); void glGetActiveUniformName(@GLuint int program, @GLuint int uniformIndex, @AutoSize("uniformName") @GLsizei int bufSize, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, - @GLchar ByteBuffer uniformName); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformName); + @Alternate("glGetActiveUniformName") + @GLstring(string = "uniformName", maxLength = "bufSize") + void glGetActiveUniformName2(@GLuint int program, @GLuint int uniformIndex, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("uniformName_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformName); + @GLuint int glGetUniformBlockIndex(@GLuint int program, @Const @NullTerminated @GLchar ByteBuffer uniformBlockName); + @Alternate("glGetUniformBlockIndex") + @GLuint + int glGetUniformBlockIndex(@GLuint int program, @NullTerminated CharSequence uniformBlockName); + @StripPostfix("params") void glGetActiveUniformBlockiv(@GLuint int program, @GLuint int uniformBlockIndex, @GLenum int pname, @OutParameter @Check(value = "16") @GLint IntBuffer params); void glGetActiveUniformBlockName(@GLuint int program, @GLuint int uniformBlockIndex, @AutoSize("uniformBlockName") @GLsizei int bufSize, - @OutParameter @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, - @GLchar ByteBuffer uniformBlockName); + @OutParameter @GLsizei @Check(value = "1", canBeNull = true) IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformBlockName); + @Alternate("glGetActiveUniformBlockName") + @GLstring(string = "uniformBlockName", maxLength = "bufSize") + void glGetActiveUniformBlockName2(@GLuint int program, @GLuint int uniformBlockIndex, @GLsizei int bufSize, + @OutParameter @GLsizei @Constant("uniformBlockName_length, 0") IntBuffer length, + @OutParameter @GLchar ByteBuffer uniformBlockName); + void glBindBufferRange(@GLenum int target, @GLuint int index, @GLuint int buffer, @GLintptr long offset, @GLsizeiptr long size); void glBindBufferBase(@GLenum int target, @GLuint int index, @GLuint int buffer); Modified: trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java =================================================================== --- trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java 2010-03-12 20:15:38 UTC (rev 3280) +++ trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_vertex_shader.java 2010-03-12 21:55:13 UTC (rev 3281) @@ -141,22 +141,28 @@ void glBindAttribLocationARB(@GLhandleARB int programObj, @GLuint int index, @NullTerminated @Const @GLcharARB ByteBuffer name); - void glGetActiveAttribARB(@GLhandleARB int programObj, @GLuint int index, - ... [truncated message content] |