Search in sources :

Example 1 with GLvoid

use of org.lwjgl.util.generator.opengl.GLvoid in project lwjgl by LWJGL.

the class TypeInfo method getTypeInfos.

private static Collection<TypeInfo> getTypeInfos(TypeMap type_map, VariableElement param) {
    List<? extends AnnotationMirror> annotations = Utils.getSortedAnnotations(param.getAnnotationMirrors());
    GLvoid void_annotation = param.getAnnotation(GLvoid.class);
    Map<Class, TypeInfo> types = new HashMap<Class, TypeInfo>();
    Collection<TypeInfo> multityped_result = new ArrayList<TypeInfo>();
    boolean add_default_type = true;
    for (AnnotationMirror annotation : annotations) {
        NativeType native_type_annotation = NativeTypeTranslator.getAnnotation(annotation, NativeType.class);
        if (native_type_annotation != null) {
            Class<? extends Annotation> annotation_type = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType());
            Signedness signedness = type_map.getSignednessFromType(annotation_type);
            Class inverse_type = type_map.getInverseType(annotation_type);
            String auto_type = type_map.getAutoTypeFromAnnotation(annotation);
            if (inverse_type != null) {
                if (types.containsKey(inverse_type)) {
                    TypeInfo inverse_type_info = types.get(inverse_type);
                    String inverse_auto_type = inverse_type_info.getAutoType();
                    auto_type = signedness == Signedness.UNSIGNED ? auto_type + " : " + inverse_auto_type : inverse_auto_type + " : " + auto_type;
                    auto_type = UNSIGNED_PARAMETER_NAME + " ? " + auto_type;
                    signedness = Signedness.BOTH;
                    types.remove(inverse_type);
                    multityped_result.remove(inverse_type_info);
                }
            }
            Class type;
            TypeKind kind;
            kind = void_annotation == null ? type_map.getPrimitiveTypeFromNativeType(annotation_type) : void_annotation.value();
            if (Utils.getNIOBufferType(param.asType()) != null) {
                type = getBufferTypeFromPrimitiveKind(kind, annotation);
            } else {
                type = getTypeFromPrimitiveKind(kind);
            }
            TypeInfo type_info = new TypeInfo(type, signedness, auto_type);
            types.put(annotation_type, type_info);
            multityped_result.add(type_info);
            add_default_type = false;
        }
    }
    if (add_default_type) {
        TypeInfo default_type_info = getDefaultTypeInfo(param.asType());
        Collection<TypeInfo> result = new ArrayList<TypeInfo>();
        result.add(default_type_info);
        return result;
    } else {
        return multityped_result;
    }
}
Also used : TypeKind(javax.lang.model.type.TypeKind) AnnotationMirror(javax.lang.model.element.AnnotationMirror) GLvoid(org.lwjgl.util.generator.opengl.GLvoid)

Aggregations

AnnotationMirror (javax.lang.model.element.AnnotationMirror)1 TypeKind (javax.lang.model.type.TypeKind)1 GLvoid (org.lwjgl.util.generator.opengl.GLvoid)1