Search in sources :

Example 6 with Name

use of org.bytedeco.javacpp.annotation.Name in project javacpp by bytedeco.

the class Generator method cppScopeName.

static String cppScopeName(Class<?> type) {
    String scopeName = "";
    while (type != null) {
        Namespace namespace = type.getAnnotation(Namespace.class);
        String spaceName = namespace == null ? "" : namespace.value();
        if ((Enum.class.isAssignableFrom(type) || Pointer.class.isAssignableFrom(type)) && (!baseClasses.contains(type) || type.isAnnotationPresent(Name.class))) {
            Name name = type.getAnnotation(Name.class);
            String s;
            if (name == null) {
                s = type.getName();
                int i = s.lastIndexOf("$");
                if (i < 0) {
                    i = s.lastIndexOf(".");
                }
                s = s.substring(i + 1);
            } else {
                s = name.value()[0];
            }
            if (spaceName.length() > 0 && !spaceName.endsWith("::")) {
                spaceName += "::";
            }
            spaceName += s;
        }
        if (scopeName.length() > 0 && !scopeName.startsWith("class ") && !scopeName.startsWith("struct ") && !scopeName.startsWith("union ") && !spaceName.endsWith("::")) {
            spaceName += "::";
        }
        scopeName = spaceName + scopeName;
        if ((namespace != null && namespace.value().length() == 0) || spaceName.startsWith("::")) {
            // user wants to reset namespace here
            break;
        }
        type = type.getDeclaringClass();
    }
    return scopeName;
}
Also used : CLongPointer(org.bytedeco.javacpp.CLongPointer) CharPointer(org.bytedeco.javacpp.CharPointer) IntPointer(org.bytedeco.javacpp.IntPointer) BytePointer(org.bytedeco.javacpp.BytePointer) PointerPointer(org.bytedeco.javacpp.PointerPointer) FunctionPointer(org.bytedeco.javacpp.FunctionPointer) LongPointer(org.bytedeco.javacpp.LongPointer) ShortPointer(org.bytedeco.javacpp.ShortPointer) BoolPointer(org.bytedeco.javacpp.BoolPointer) DoublePointer(org.bytedeco.javacpp.DoublePointer) FloatPointer(org.bytedeco.javacpp.FloatPointer) Pointer(org.bytedeco.javacpp.Pointer) SizeTPointer(org.bytedeco.javacpp.SizeTPointer) Namespace(org.bytedeco.javacpp.annotation.Namespace) Name(org.bytedeco.javacpp.annotation.Name)

Aggregations

Name (org.bytedeco.javacpp.annotation.Name)6 Method (java.lang.reflect.Method)4 BoolPointer (org.bytedeco.javacpp.BoolPointer)4 BytePointer (org.bytedeco.javacpp.BytePointer)4 CLongPointer (org.bytedeco.javacpp.CLongPointer)4 CharPointer (org.bytedeco.javacpp.CharPointer)4 DoublePointer (org.bytedeco.javacpp.DoublePointer)4 FloatPointer (org.bytedeco.javacpp.FloatPointer)4 FunctionPointer (org.bytedeco.javacpp.FunctionPointer)4 IntPointer (org.bytedeco.javacpp.IntPointer)4 LongPointer (org.bytedeco.javacpp.LongPointer)4 Pointer (org.bytedeco.javacpp.Pointer)4 PointerPointer (org.bytedeco.javacpp.PointerPointer)4 ShortPointer (org.bytedeco.javacpp.ShortPointer)4 SizeTPointer (org.bytedeco.javacpp.SizeTPointer)4 Namespace (org.bytedeco.javacpp.annotation.Namespace)3 Annotation (java.lang.annotation.Annotation)2 LinkedHashSet (java.util.LinkedHashSet)2 Allocator (org.bytedeco.javacpp.annotation.Allocator)2 ArrayAllocator (org.bytedeco.javacpp.annotation.ArrayAllocator)2