Added support for PointerBuffer parameters to OpenGL.
This commit is contained in:
parent
c324b6c215
commit
1df5d25560
|
@ -168,12 +168,9 @@ public class NativeTypeTranslator implements TypeVisitor {
|
||||||
} else if ( Buffer.class.equals(c) ) {
|
} else if ( Buffer.class.equals(c) ) {
|
||||||
native_types = new ArrayList<Class>();
|
native_types = new ArrayList<Class>();
|
||||||
native_types.add(type_map.getVoidType());
|
native_types.add(type_map.getVoidType());
|
||||||
} else if ( Buffer.class.isAssignableFrom(c) ) {
|
} else if ( Buffer.class.isAssignableFrom(c) || PointerBuffer.class.isAssignableFrom(c) ) {
|
||||||
PrimitiveType.Kind kind = getPrimitiveKindFromBufferClass(c);
|
PrimitiveType.Kind kind = getPrimitiveKindFromBufferClass(c);
|
||||||
getNativeTypeFromAnnotatedPrimitiveType(kind);
|
getNativeTypeFromAnnotatedPrimitiveType(kind);
|
||||||
} else if ( PointerBuffer.class.isAssignableFrom(c) ) {
|
|
||||||
native_types = new ArrayList<Class>();
|
|
||||||
native_types.add(PointerBuffer.class);
|
|
||||||
} else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(c) ) {
|
} else if ( org.lwjgl.PointerWrapper.class.isAssignableFrom(c) ) {
|
||||||
native_types = new ArrayList<Class>();
|
native_types = new ArrayList<Class>();
|
||||||
native_types.add(PointerWrapper.class);
|
native_types.add(PointerWrapper.class);
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2002-2013 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;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/** Marker interface for pointer types. */
|
||||||
|
@Target(ElementType.ANNOTATION_TYPE)
|
||||||
|
public @interface PointerType {
|
||||||
|
|
||||||
|
}
|
|
@ -41,6 +41,7 @@ package org.lwjgl.util.generator;
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.lwjgl.PointerBuffer;
|
||||||
import org.lwjgl.util.generator.opengl.GLvoid;
|
import org.lwjgl.util.generator.opengl.GLvoid;
|
||||||
|
|
||||||
import com.sun.mirror.declaration.*;
|
import com.sun.mirror.declaration.*;
|
||||||
|
@ -107,7 +108,7 @@ public class TypeInfo {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Class getBufferTypeFromPrimitiveKind(PrimitiveType.Kind kind) {
|
private static Class getBufferTypeFromPrimitiveKind(PrimitiveType.Kind kind, AnnotationMirror annotation) {
|
||||||
Class type;
|
Class type;
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case INT:
|
case INT:
|
||||||
|
@ -123,7 +124,10 @@ public class TypeInfo {
|
||||||
type = ShortBuffer.class;
|
type = ShortBuffer.class;
|
||||||
break;
|
break;
|
||||||
case LONG:
|
case LONG:
|
||||||
type = LongBuffer.class;
|
if ( annotation.getAnnotationType().getDeclaration().getAnnotation(PointerType.class) != null )
|
||||||
|
type = PointerBuffer.class;
|
||||||
|
else
|
||||||
|
type = LongBuffer.class;
|
||||||
break;
|
break;
|
||||||
case BYTE: /* fall through */
|
case BYTE: /* fall through */
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
|
@ -178,7 +182,7 @@ public class TypeInfo {
|
||||||
GLvoid void_annotation = param.getAnnotation(GLvoid.class);
|
GLvoid void_annotation = param.getAnnotation(GLvoid.class);
|
||||||
kind = void_annotation == null ? type_map.getPrimitiveTypeFromNativeType(annotation_type) : void_annotation.value();
|
kind = void_annotation == null ? type_map.getPrimitiveTypeFromNativeType(annotation_type) : void_annotation.value();
|
||||||
if (Utils.getNIOBufferType(decl_type) != null)
|
if (Utils.getNIOBufferType(decl_type) != null)
|
||||||
type = getBufferTypeFromPrimitiveKind(kind);
|
type = getBufferTypeFromPrimitiveKind(kind, annotation);
|
||||||
else
|
else
|
||||||
type = getTypeFromPrimitiveKind(kind);
|
type = getTypeFromPrimitiveKind(kind);
|
||||||
TypeInfo type_info = new TypeInfo(type, signedness, auto_type);
|
TypeInfo type_info = new TypeInfo(type, signedness, auto_type);
|
||||||
|
|
|
@ -41,6 +41,7 @@ package org.lwjgl.util.generator.opengl;
|
||||||
* $Id: GLTypeMap.java 3392 2010-07-27 15:33:22Z spasi $
|
* $Id: GLTypeMap.java 3392 2010-07-27 15:33:22Z spasi $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.lwjgl.PointerBuffer;
|
||||||
import org.lwjgl.util.generator.NativeTypeTranslator;
|
import org.lwjgl.util.generator.NativeTypeTranslator;
|
||||||
import org.lwjgl.util.generator.PointerWrapper;
|
import org.lwjgl.util.generator.PointerWrapper;
|
||||||
import org.lwjgl.util.generator.Signedness;
|
import org.lwjgl.util.generator.Signedness;
|
||||||
|
@ -274,6 +275,8 @@ public class GLTypeMap implements TypeMap {
|
||||||
valid_types = new Class[] { PointerWrapper.class };
|
valid_types = new Class[] { PointerWrapper.class };
|
||||||
else if (void.class.equals(type) )
|
else if (void.class.equals(type) )
|
||||||
valid_types = new Class[] { GLreturn.class };
|
valid_types = new Class[] { GLreturn.class };
|
||||||
|
else if ( PointerBuffer.class.equals(type) )
|
||||||
|
valid_types = new Class[] { GLintptr.class, GLintptrARB.class, GLsizeiptr.class, GLsizeiptrARB.class };
|
||||||
else
|
else
|
||||||
valid_types = new Class[] { };
|
valid_types = new Class[] { };
|
||||||
return valid_types;
|
return valid_types;
|
||||||
|
|
|
@ -39,11 +39,13 @@ package org.lwjgl.util.generator.opengl;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.lwjgl.util.generator.NativeType;
|
import org.lwjgl.util.generator.NativeType;
|
||||||
|
import org.lwjgl.util.generator.PointerType;
|
||||||
|
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
|
|
||||||
@NativeType
|
@NativeType
|
||||||
|
@PointerType
|
||||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||||
public @interface GLintptr {
|
public @interface GLintptr {
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,13 @@ package org.lwjgl.util.generator.opengl;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.lwjgl.util.generator.NativeType;
|
import org.lwjgl.util.generator.NativeType;
|
||||||
|
import org.lwjgl.util.generator.PointerType;
|
||||||
|
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
|
|
||||||
@NativeType
|
@NativeType
|
||||||
|
@PointerType
|
||||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||||
public @interface GLintptrARB {
|
public @interface GLintptrARB {
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,13 @@ package org.lwjgl.util.generator.opengl;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.lwjgl.util.generator.NativeType;
|
import org.lwjgl.util.generator.NativeType;
|
||||||
|
import org.lwjgl.util.generator.PointerType;
|
||||||
|
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
|
|
||||||
@NativeType
|
@NativeType
|
||||||
|
@PointerType
|
||||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||||
public @interface GLsizeiptr {
|
public @interface GLsizeiptr {
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,13 @@ package org.lwjgl.util.generator.opengl;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.lwjgl.util.generator.NativeType;
|
import org.lwjgl.util.generator.NativeType;
|
||||||
|
import org.lwjgl.util.generator.PointerType;
|
||||||
|
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
|
|
||||||
@NativeType
|
@NativeType
|
||||||
|
@PointerType
|
||||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||||
public @interface GLsizeiptrARB {
|
public @interface GLsizeiptrARB {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue