Cleanup
This commit is contained in:
parent
c9531997e9
commit
2ddd363cad
|
@ -41,17 +41,15 @@ package org.lwjgl.generator;
|
|||
* @version $Revision$
|
||||
*/
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.nio.*;
|
||||
|
||||
public class ALTypeMap implements TypeMap {
|
||||
private final static Map<Class, PrimitiveType.Kind> native_types_to_primitive;
|
||||
private static final Map<Class, PrimitiveType.Kind> native_types_to_primitive;
|
||||
|
||||
static {
|
||||
native_types_to_primitive = new HashMap<Class, PrimitiveType.Kind>();
|
||||
|
@ -173,7 +171,7 @@ public class ALTypeMap implements TypeMap {
|
|||
public String getTypedefPrefix() {
|
||||
return "ALAPIENTRY";
|
||||
}
|
||||
|
||||
|
||||
public void printNativeIncludes(PrintWriter writer) {
|
||||
writer.println("#include \"checkALerror.h\"");
|
||||
writer.println("#include \"extal.h\"");
|
||||
|
@ -182,7 +180,7 @@ public class ALTypeMap implements TypeMap {
|
|||
public Class getStringElementType() {
|
||||
return ALubyte.class;
|
||||
}
|
||||
|
||||
|
||||
public Class[] getValidAnnotationTypes(Class type) {
|
||||
Class[] valid_types;
|
||||
if (Buffer.class.isAssignableFrom(type))
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -34,7 +34,7 @@ package org.lwjgl.generator;
|
|||
/**
|
||||
* $Id$
|
||||
*
|
||||
* @AutoSize specifies that a parameter should be pre-computed
|
||||
* AutoSize specifies that a parameter should be pre-computed
|
||||
* according to the remaining() of a Buffer parameter.
|
||||
*
|
||||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
|
|
|
@ -32,14 +32,11 @@
|
|||
|
||||
package org.lwjgl.generator;
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.nio.*;
|
||||
|
||||
public class FieldsGenerator {
|
||||
private static void validateField(FieldDeclaration field) {
|
||||
|
@ -61,7 +58,7 @@ public class FieldsGenerator {
|
|||
private static void generateField(PrintWriter writer, FieldDeclaration field) {
|
||||
Integer field_value = (Integer)field.getConstantValue();
|
||||
validateField(field);
|
||||
String field_value_string = Integer.toHexString(field_value.intValue());
|
||||
String field_value_string = Integer.toHexString(field_value);
|
||||
Utils.printDocComment(writer, field);
|
||||
// Print field declaration
|
||||
writer.println("\tpublic static final " + field.getType().toString() + " " + field.getSimpleName() + " = 0x" + field_value_string + ";");
|
||||
|
|
|
@ -41,17 +41,15 @@ package org.lwjgl.generator;
|
|||
* @version $Revision$
|
||||
*/
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.nio.*;
|
||||
|
||||
public class GLTypeMap implements TypeMap {
|
||||
private final static Map<Class, PrimitiveType.Kind> native_types_to_primitive;
|
||||
private static final Map<Class, PrimitiveType.Kind> native_types_to_primitive;
|
||||
|
||||
static {
|
||||
native_types_to_primitive = new HashMap<Class, PrimitiveType.Kind>();
|
||||
|
@ -209,7 +207,7 @@ public class GLTypeMap implements TypeMap {
|
|||
public String getTypedefPrefix() {
|
||||
return "APIENTRY";
|
||||
}
|
||||
|
||||
|
||||
public void printNativeIncludes(PrintWriter writer) {
|
||||
writer.println("#include \"extgl.h\"");
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -40,7 +40,6 @@ package org.lwjgl.generator;
|
|||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
|
||||
@NativeType
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
|
|
|
@ -34,19 +34,12 @@ package org.lwjgl.generator;
|
|||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Arrays;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static com.sun.mirror.util.DeclarationVisitors.*;
|
||||
|
||||
|
@ -61,7 +54,7 @@ import static com.sun.mirror.util.DeclarationVisitors.*;
|
|||
*/
|
||||
public class GeneratorProcessorFactory implements AnnotationProcessorFactory, RoundCompleteListener {
|
||||
private static boolean first_round = true;
|
||||
|
||||
|
||||
// Process any set of annotations
|
||||
private static final Collection<String> supportedAnnotations =
|
||||
unmodifiableCollection(Arrays.asList("*"));
|
||||
|
@ -108,7 +101,7 @@ public class GeneratorProcessorFactory implements AnnotationProcessorFactory, Ro
|
|||
if (k.startsWith("-Atypemap")) {
|
||||
typemap_classname = k.substring(delimiter + 1);
|
||||
}
|
||||
} else if (k.equals("-Ageneratechecks")) {
|
||||
} else if ( "-Ageneratechecks".equals(k)) {
|
||||
generate_error_checks = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ import java.io.IOException;
|
|||
import java.io.File;
|
||||
|
||||
import java.nio.*;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
@ -55,7 +54,7 @@ import java.lang.annotation.Annotation;
|
|||
* @version $Revision$
|
||||
*/
|
||||
public class GeneratorVisitor extends SimpleDeclarationVisitor {
|
||||
private final static String STUB_INITIALIZER_NAME = "initNativeStubs";
|
||||
private static final String STUB_INITIALIZER_NAME = "initNativeStubs";
|
||||
|
||||
private final AnnotationProcessorEnvironment env;
|
||||
private final TypeMap type_map;
|
||||
|
@ -66,12 +65,12 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor {
|
|||
this.type_map = type_map;
|
||||
this.generate_error_checks = generate_error_checks;
|
||||
}
|
||||
|
||||
|
||||
private void validateMethods(InterfaceDeclaration d) {
|
||||
for (MethodDeclaration method : d.getMethods())
|
||||
validateMethod(method);
|
||||
}
|
||||
|
||||
|
||||
private void validateMethod(MethodDeclaration method) {
|
||||
if (method.isVarArgs())
|
||||
throw new RuntimeException("Method " + method.getSimpleName() + " is variadic");
|
||||
|
@ -102,7 +101,7 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor {
|
|||
for (int i = 0; i < valid_types.length; i++)
|
||||
if (valid_types[i].equals(annotation_type))
|
||||
return;
|
||||
throw new RuntimeException(type + " is annotated with invalid native type " + annotation_type +
|
||||
throw new RuntimeException(type + " is annotated with invalid native type " + annotation_type +
|
||||
" in method " + method);
|
||||
}
|
||||
|
||||
|
@ -129,7 +128,7 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor {
|
|||
boolean found_auto_size_param = false;
|
||||
for (ParameterDeclaration inner_param : method.getParameters()) {
|
||||
AutoSize auto_size_annotation = inner_param.getAnnotation(AutoSize.class);
|
||||
if (auto_size_annotation != null &&
|
||||
if (auto_size_annotation != null &&
|
||||
auto_size_annotation.value().equals(param.getSimpleName())) {
|
||||
found_auto_size_param = true;
|
||||
break;
|
||||
|
@ -150,7 +149,7 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
private void generateMethodsNativePointers(PrintWriter writer, Collection<? extends MethodDeclaration> methods) {
|
||||
private static void generateMethodsNativePointers(PrintWriter writer, Collection<? extends MethodDeclaration> methods) {
|
||||
for (MethodDeclaration method : methods)
|
||||
generateMethodNativePointers(writer, method);
|
||||
}
|
||||
|
|
|
@ -32,20 +32,9 @@
|
|||
|
||||
package org.lwjgl.generator;
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
|
@ -69,23 +58,23 @@ public class JNITypeTranslator implements TypeVisitor {
|
|||
public void visitArrayType(ArrayType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitClassType(ClassType t) {
|
||||
signature.append("jobject");
|
||||
}
|
||||
|
||||
|
||||
public void visitDeclaredType(DeclaredType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitEnumType(EnumType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitInterfaceType(InterfaceType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitPrimitiveType(PrimitiveType t) {
|
||||
String type;
|
||||
switch (t.getKind()) {
|
||||
|
@ -112,23 +101,23 @@ public class JNITypeTranslator implements TypeVisitor {
|
|||
}
|
||||
signature.append(type);
|
||||
}
|
||||
|
||||
|
||||
public void visitReferenceType(ReferenceType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitTypeMirror(TypeMirror t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitTypeVariable(TypeVariable t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitVoidType(VoidType t) {
|
||||
signature.append(t.toString());
|
||||
}
|
||||
|
||||
|
||||
public void visitWildcardType(WildcardType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ package org.lwjgl.generator;
|
|||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
@ -170,6 +169,7 @@ public class JavaMethodsGenerator {
|
|||
StripPostfix strip_annotation = method.getAnnotation(StripPostfix.class);
|
||||
String method_name = method.getSimpleName();
|
||||
if (strip_annotation != null) {
|
||||
// TODO: This is not used, is it necessary? (keep Utils.findParameter only?)
|
||||
ParameterDeclaration postfix_parameter = Utils.findParameter(method, strip_annotation.value());
|
||||
if (mode == Mode.NORMAL)
|
||||
method_name = getPostfixStrippedName(type_map, interface_decl, method);
|
||||
|
@ -233,7 +233,7 @@ public class JavaMethodsGenerator {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static boolean hasAnyParameterAutoTypeAnnotation(MethodDeclaration method, ParameterDeclaration target_param) {
|
||||
for (ParameterDeclaration param : method.getParameters()) {
|
||||
AutoType auto_type_annotation = param.getAnnotation(AutoType.class);
|
||||
|
@ -354,7 +354,6 @@ public class JavaMethodsGenerator {
|
|||
}
|
||||
|
||||
private static void printMethodCallArguments(PrintWriter writer, MethodDeclaration method, Map<ParameterDeclaration, TypeInfo> typeinfos_instance, Mode mode) {
|
||||
Collection<ParameterDeclaration> params = method.getParameters();
|
||||
boolean first_parameter = true;
|
||||
for (ParameterDeclaration param : method.getParameters())
|
||||
if (param.getAnnotation(Result.class) == null) {
|
||||
|
@ -369,7 +368,7 @@ public class JavaMethodsGenerator {
|
|||
private static void printParameterChecks(PrintWriter writer, MethodDeclaration method, Mode mode) {
|
||||
for (ParameterDeclaration param : method.getParameters()) {
|
||||
Class java_type = Utils.getJavaType(param.getType());
|
||||
if (Utils.isAddressableType(java_type) &&
|
||||
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) {
|
||||
|
@ -399,7 +398,7 @@ public class JavaMethodsGenerator {
|
|||
writer.print("\t");
|
||||
}
|
||||
writer.print("\t\tBufferChecks.check");
|
||||
if (check_value != null && !check_value.equals("")) {
|
||||
if (check_value != null && !"".equals(check_value) ) {
|
||||
writer.print("Buffer(" + name + ", " + check_value);
|
||||
} else {
|
||||
writer.print("Direct");
|
||||
|
|
|
@ -32,23 +32,9 @@
|
|||
|
||||
package org.lwjgl.generator;
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
|
||||
import java.nio.*;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
|
@ -64,7 +50,7 @@ public class JavaTypeTranslator implements TypeVisitor {
|
|||
public Class getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
public void visitAnnotationType(AnnotationType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
@ -72,7 +58,7 @@ public class JavaTypeTranslator implements TypeVisitor {
|
|||
public void visitArrayType(ArrayType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitPrimitiveType(PrimitiveType t) {
|
||||
switch (t.getKind()) {
|
||||
case INT:
|
||||
|
@ -101,35 +87,35 @@ public class JavaTypeTranslator implements TypeVisitor {
|
|||
public void visitDeclaredType(DeclaredType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitEnumType(EnumType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitClassType(ClassType t) {
|
||||
type = NativeTypeTranslator.getClassFromType(t);
|
||||
}
|
||||
|
||||
|
||||
public void visitInterfaceType(InterfaceType t) {
|
||||
type = NativeTypeTranslator.getClassFromType(t);
|
||||
}
|
||||
|
||||
|
||||
public void visitReferenceType(ReferenceType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitTypeMirror(TypeMirror t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitTypeVariable(TypeVariable t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitVoidType(VoidType t) {
|
||||
type = void.class;
|
||||
}
|
||||
|
||||
|
||||
public void visitWildcardType(WildcardType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
|
|
@ -32,14 +32,6 @@
|
|||
|
||||
package org.lwjgl.generator;
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public enum Mode {
|
||||
BUFFEROBJECT,
|
||||
AUTOS,
|
||||
|
|
|
@ -44,15 +44,14 @@ package org.lwjgl.generator;
|
|||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.nio.*;
|
||||
|
||||
public class NativeMethodStubsGenerator {
|
||||
private final static String BUFFER_ADDRESS_POSTFIX = "_address";
|
||||
public final static String BUFFER_POSITION_POSTFIX = "_position";
|
||||
private static final String BUFFER_ADDRESS_POSTFIX = "_address";
|
||||
public static final String BUFFER_POSITION_POSTFIX = "_position";
|
||||
|
||||
public static void generateNativeMethodStubs(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, InterfaceDeclaration d, boolean generate_error_checks) {
|
||||
for (MethodDeclaration method : d.getMethods()) {
|
||||
|
@ -61,7 +60,7 @@ public class NativeMethodStubsGenerator {
|
|||
generateMethodStub(env, type_map, writer, Utils.getQualifiedClassName(d), method, Mode.BUFFEROBJECT, generate_error_checks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void generateParameters(PrintWriter writer, Collection<ParameterDeclaration> params, Mode mode) {
|
||||
for (ParameterDeclaration param : params)
|
||||
if (param.getAnnotation(Result.class) == null)
|
||||
|
|
|
@ -41,7 +41,6 @@ package org.lwjgl.generator;
|
|||
* @version $Revision$
|
||||
*/
|
||||
|
||||
import com.sun.mirror.type.PrimitiveType;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
|
|
|
@ -35,25 +35,19 @@ package org.lwjgl.generator;
|
|||
/**
|
||||
* $Id$
|
||||
*
|
||||
* A TypeVisitor that translates types (and optional native type
|
||||
* A TypeVisitor that translates types (and optional native type
|
||||
* annotations) to the native type string.
|
||||
*
|
||||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
|
||||
import java.nio.*;
|
||||
|
||||
|
@ -73,7 +67,7 @@ public class NativeTypeTranslator implements TypeVisitor {
|
|||
private boolean is_indirect;
|
||||
private final Declaration declaration;
|
||||
private final TypeMap type_map;
|
||||
|
||||
|
||||
public NativeTypeTranslator(TypeMap type_map, Declaration declaration) {
|
||||
this.declaration = declaration;
|
||||
this.type_map = type_map;
|
||||
|
@ -100,7 +94,7 @@ public class NativeTypeTranslator implements TypeVisitor {
|
|||
public void visitArrayType(ArrayType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public static PrimitiveType.Kind getPrimitiveKindFromBufferClass(Class c) {
|
||||
if (IntBuffer.class.equals(c))
|
||||
return PrimitiveType.Kind.INT;
|
||||
|
@ -145,7 +139,7 @@ public class NativeTypeTranslator implements TypeVisitor {
|
|||
throw new RuntimeException(t + " is not allowed");
|
||||
is_indirect = true;
|
||||
}
|
||||
|
||||
|
||||
public void visitPrimitiveType(PrimitiveType t) {
|
||||
getNativeTypeFromAnnotatedPrimitiveType(t.getKind());
|
||||
}
|
||||
|
@ -153,21 +147,21 @@ public class NativeTypeTranslator implements TypeVisitor {
|
|||
public void visitDeclaredType(DeclaredType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitEnumType(EnumType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitInterfaceType(InterfaceType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
// Check if the annotation is itself annotated with a certain annotation type
|
||||
public static <T extends Annotation> T getAnnotation(AnnotationMirror annotation, Class<T> type) {
|
||||
return annotation.getAnnotationType().getDeclaration().getAnnotation(type);
|
||||
}
|
||||
|
||||
private Class translateAnnotation(AnnotationMirror annotation) {
|
||||
private static Class translateAnnotation(AnnotationMirror annotation) {
|
||||
NativeType native_type = getAnnotation(annotation, NativeType.class);
|
||||
if (native_type != null) {
|
||||
return getClassFromType(annotation.getAnnotationType());
|
||||
|
@ -193,17 +187,17 @@ public class NativeTypeTranslator implements TypeVisitor {
|
|||
public void visitTypeMirror(TypeMirror t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitTypeVariable(TypeVariable t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitVoidType(VoidType t) {
|
||||
native_types = translateAnnotations();
|
||||
if (native_types.size() == 0)
|
||||
native_types.add(void.class);
|
||||
}
|
||||
|
||||
|
||||
public void visitWildcardType(WildcardType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
|
|
@ -42,27 +42,17 @@ package org.lwjgl.generator;
|
|||
* @version $Revision$
|
||||
*/
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
|
||||
import java.nio.*;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
public class PostfixTranslator implements TypeVisitor {
|
||||
private final StringBuilder signature = new StringBuilder();
|
||||
private final Declaration declaration;
|
||||
private final TypeMap type_map;
|
||||
|
||||
|
||||
public PostfixTranslator(TypeMap type_map, Declaration declaration) {
|
||||
this.declaration = declaration;
|
||||
this.type_map = type_map;
|
||||
|
@ -79,7 +69,7 @@ public class PostfixTranslator implements TypeVisitor {
|
|||
public void visitArrayType(ArrayType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
private static PrimitiveType.Kind getPrimitiveKindFromBufferClass(Class c) {
|
||||
if (IntBuffer.class.equals(c))
|
||||
return PrimitiveType.Kind.INT;
|
||||
|
@ -100,19 +90,19 @@ public class PostfixTranslator implements TypeVisitor {
|
|||
PrimitiveType.Kind kind = getPrimitiveKindFromBufferClass(c);
|
||||
visitPrimitiveTypeKind(kind);
|
||||
}
|
||||
|
||||
|
||||
public void visitDeclaredType(DeclaredType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitEnumType(EnumType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitInterfaceType(InterfaceType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
private boolean translateAnnotation(AnnotationMirror annotation) {
|
||||
NativeType native_type = NativeTypeTranslator.getAnnotation(annotation, NativeType.class);
|
||||
if (native_type != null) {
|
||||
|
@ -165,22 +155,22 @@ public class PostfixTranslator implements TypeVisitor {
|
|||
}
|
||||
signature.append(type);
|
||||
}
|
||||
|
||||
|
||||
public void visitReferenceType(ReferenceType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitTypeMirror(TypeMirror t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitTypeVariable(TypeVariable t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitVoidType(VoidType t) {
|
||||
}
|
||||
|
||||
|
||||
public void visitWildcardType(WildcardType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
|
|
@ -41,14 +41,11 @@ package org.lwjgl.generator;
|
|||
* @version $Revision$
|
||||
*/
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.nio.*;
|
||||
|
||||
public class RegisterStubsGenerator {
|
||||
public static void generateMethodsNativeStubBind(PrintWriter writer, InterfaceDeclaration d, boolean generate_error_checks) {
|
||||
|
@ -79,7 +76,7 @@ public class RegisterStubsGenerator {
|
|||
type.accept(v);
|
||||
return v.getSignature();
|
||||
}
|
||||
|
||||
|
||||
private static String getMethodSignature(MethodDeclaration method, Mode mode) {
|
||||
Collection<ParameterDeclaration> params = method.getParameters();
|
||||
String signature = "(";
|
||||
|
|
|
@ -41,8 +41,6 @@ package org.lwjgl.generator;
|
|||
* @version $Revision$
|
||||
*/
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
|
@ -52,7 +50,7 @@ class SignatureTranslator implements TypeVisitor {
|
|||
private final boolean add_position_signature;
|
||||
private final StringBuilder signature = new StringBuilder();
|
||||
|
||||
public SignatureTranslator(boolean add_position_signature) {
|
||||
SignatureTranslator(boolean add_position_signature) {
|
||||
this.add_position_signature = add_position_signature;
|
||||
}
|
||||
|
||||
|
@ -71,7 +69,7 @@ class SignatureTranslator implements TypeVisitor {
|
|||
public void visitArrayType(ArrayType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitClassType(ClassType t) {
|
||||
String type_name = getNativeNameFromClassName(t.getDeclaration().getQualifiedName());
|
||||
signature.append("L");
|
||||
|
@ -81,21 +79,20 @@ class SignatureTranslator implements TypeVisitor {
|
|||
signature.append("I");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void visitDeclaredType(DeclaredType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitEnumType(EnumType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitInterfaceType(InterfaceType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitPrimitiveType(PrimitiveType t) {
|
||||
String type;
|
||||
switch (t.getKind()) {
|
||||
case BOOLEAN:
|
||||
signature.append("Z");
|
||||
|
@ -122,23 +119,23 @@ class SignatureTranslator implements TypeVisitor {
|
|||
throw new RuntimeException("Unsupported type " + t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void visitReferenceType(ReferenceType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitTypeMirror(TypeMirror t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitTypeVariable(TypeVariable t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
|
||||
public void visitVoidType(VoidType t) {
|
||||
signature.append("V");
|
||||
}
|
||||
|
||||
|
||||
public void visitWildcardType(WildcardType t) {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ import java.util.*;
|
|||
import java.nio.*;
|
||||
|
||||
public class TypeInfo {
|
||||
public final static String UNSIGNED_PARAMETER_NAME = "unsigned";
|
||||
public static final String UNSIGNED_PARAMETER_NAME = "unsigned";
|
||||
|
||||
private final Signedness signedness;
|
||||
private final Class type;
|
||||
|
@ -67,7 +67,7 @@ public class TypeInfo {
|
|||
public Signedness getSignedness() {
|
||||
return signedness;
|
||||
}
|
||||
|
||||
|
||||
public String getAutoType() {
|
||||
if (auto_type == null)
|
||||
throw new RuntimeException("No auto type assigned");
|
||||
|
|
|
@ -41,27 +41,23 @@ package org.lwjgl.generator;
|
|||
* @version $Revision$
|
||||
*/
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.nio.*;
|
||||
|
||||
public interface TypeMap {
|
||||
public String getErrorCheckMethodName();
|
||||
public String getRegisterNativesFunctionName();
|
||||
public PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type);
|
||||
public String getTypedefPrefix();
|
||||
public void printNativeIncludes(PrintWriter writer);
|
||||
public Class getStringElementType();
|
||||
public Class[] getValidAnnotationTypes(Class type);
|
||||
public Class getVoidType();
|
||||
public String translateAnnotation(Class annotation_type);
|
||||
public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind);
|
||||
public String getAutoTypeFromAnnotation(AnnotationMirror annotation);
|
||||
public Class getInverseType(Class type);
|
||||
public Signedness getSignednessFromType(Class type);
|
||||
String getErrorCheckMethodName();
|
||||
String getRegisterNativesFunctionName();
|
||||
PrimitiveType.Kind getPrimitiveTypeFromNativeType(Class native_type);
|
||||
String getTypedefPrefix();
|
||||
void printNativeIncludes(PrintWriter writer);
|
||||
Class getStringElementType();
|
||||
Class[] getValidAnnotationTypes(Class type);
|
||||
Class getVoidType();
|
||||
String translateAnnotation(Class annotation_type);
|
||||
Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind);
|
||||
String getAutoTypeFromAnnotation(AnnotationMirror annotation);
|
||||
Class getInverseType(Class type);
|
||||
Signedness getSignednessFromType(Class type);
|
||||
}
|
||||
|
|
|
@ -41,16 +41,14 @@ package org.lwjgl.generator;
|
|||
* @version $Revision$
|
||||
*/
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class TypedefsGenerator {
|
||||
public final static String TYPEDEF_POSTFIX = "PROC";
|
||||
public static final String TYPEDEF_POSTFIX = "PROC";
|
||||
|
||||
private static void generateNativeTypedefs(TypeMap type_map, PrintWriter writer, MethodDeclaration method) {
|
||||
TypeMirror return_type = method.getReturnType();
|
||||
|
|
|
@ -45,18 +45,15 @@ import java.nio.Buffer;
|
|||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.mirror.apt.*;
|
||||
import com.sun.mirror.declaration.*;
|
||||
import com.sun.mirror.type.*;
|
||||
import com.sun.mirror.util.*;
|
||||
|
||||
public class Utils {
|
||||
public final static String BUFFER_OBJECT_METHOD_POSTFIX = "BO";
|
||||
public final static String BUFFER_OBJECT_PARAMETER_POSTFIX = "_buffer_offset";
|
||||
public final static String RESULT_SIZE_NAME = "result_size";
|
||||
public final static String RESULT_VAR_NAME = "__result";
|
||||
public final static String CACHED_BUFFER_NAME = "old_buffer";
|
||||
private final static String OVERLOADED_METHOD_PREFIX = "n";
|
||||
public static final String BUFFER_OBJECT_METHOD_POSTFIX = "BO";
|
||||
public static final String BUFFER_OBJECT_PARAMETER_POSTFIX = "_buffer_offset";
|
||||
public static final String RESULT_SIZE_NAME = "result_size";
|
||||
public static final String RESULT_VAR_NAME = "__result";
|
||||
public static final String CACHED_BUFFER_NAME = "old_buffer";
|
||||
private static final String OVERLOADED_METHOD_PREFIX = "n";
|
||||
|
||||
private static class AnnotationMirrorComparator implements Comparator<AnnotationMirror> {
|
||||
public int compare(AnnotationMirror a1, AnnotationMirror a2) {
|
||||
|
@ -80,11 +77,11 @@ public class Utils {
|
|||
public static boolean isAddressableType(TypeMirror type) {
|
||||
return isAddressableType(getJavaType(type));
|
||||
}
|
||||
|
||||
|
||||
public static boolean isAddressableType(Class type) {
|
||||
return Buffer.class.isAssignableFrom(type) || String.class.equals(type);
|
||||
}
|
||||
|
||||
|
||||
public static Class getJavaType(TypeMirror type_mirror) {
|
||||
JavaTypeTranslator translator = new JavaTypeTranslator();
|
||||
type_mirror.accept(translator);
|
||||
|
@ -105,7 +102,7 @@ public class Utils {
|
|||
throw new RuntimeException(param + " not defined as java.nio.Buffer but has multiple types");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static ParameterDeclaration findParameter(MethodDeclaration method, String name) {
|
||||
for (ParameterDeclaration param : method.getParameters())
|
||||
if (param.getSimpleName().equals(name))
|
||||
|
@ -176,7 +173,7 @@ public class Utils {
|
|||
result_type = method.getReturnType();
|
||||
return result_type;
|
||||
}
|
||||
|
||||
|
||||
public static void printExtraCallArguments(PrintWriter writer, MethodDeclaration method) {
|
||||
writer.print(", " + RESULT_SIZE_NAME);
|
||||
if (method.getAnnotation(CachedResult.class) != null) {
|
||||
|
@ -186,7 +183,7 @@ public class Utils {
|
|||
|
||||
private static String getClassName(InterfaceDeclaration interface_decl, String opengl_name) {
|
||||
Extension extension_annotation = interface_decl.getAnnotation(Extension.class);
|
||||
if (extension_annotation != null && !extension_annotation.className().equals("")) {
|
||||
if (extension_annotation != null && !"".equals(extension_annotation.className())) {
|
||||
return extension_annotation.className();
|
||||
}
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
|
Loading…
Reference in New Issue