Search in sources :

Example 6 with ByPtrPtr

use of org.bytedeco.javacpp.annotation.ByPtrPtr in project bigbluebutton by bigbluebutton.

the class Generator method cppCastTypeName.

String[] cppCastTypeName(Class<?> type, Annotation... annotations) {
    String[] typeName = null;
    boolean warning = false, adapter = false;
    for (Annotation a : annotations) {
        if (a instanceof Cast) {
            warning = typeName != null;
            String prefix = ((Cast) a).value()[0], suffix = "";
            int parenthesis = prefix.indexOf(')');
            if (parenthesis > 0) {
                suffix = prefix.substring(parenthesis).trim();
                prefix = prefix.substring(0, parenthesis).trim();
            }
            typeName = prefix.length() > 0 ? new String[] { prefix, suffix } : null;
        } else if (a instanceof Const) {
            if (warning = typeName != null) {
                // prioritize @Cast
                continue;
            }
            typeName = cppTypeName(type);
            boolean[] b = ((Const) a).value();
            if (b.length > 1 && b[1]) {
                typeName[0] = valueTypeName(typeName) + " const *";
            }
            if (b.length > 0 && b[0]) {
                typeName[0] = "const " + typeName[0];
            }
            Annotation by = by(annotations);
            if (by instanceof ByPtrPtr) {
                typeName[0] += "*";
            } else if (by instanceof ByPtrRef) {
                typeName[0] += "&";
            }
        } else if (a instanceof Adapter || a.annotationType().isAnnotationPresent(Adapter.class)) {
            adapter = true;
        }
    }
    if (warning && !adapter) {
        logger.warn("Without \"Adapter\", \"Cast\" and \"Const\" annotations are mutually exclusive.");
    }
    if (typeName == null) {
        typeName = cppTypeName(type);
    }
    return typeName;
}
Also used : Cast(org.bytedeco.javacpp.annotation.Cast) ByPtrRef(org.bytedeco.javacpp.annotation.ByPtrRef) Const(org.bytedeco.javacpp.annotation.Const) Adapter(org.bytedeco.javacpp.annotation.Adapter) ByPtrPtr(org.bytedeco.javacpp.annotation.ByPtrPtr) Annotation(java.lang.annotation.Annotation)

Aggregations

Annotation (java.lang.annotation.Annotation)6 ByPtrPtr (org.bytedeco.javacpp.annotation.ByPtrPtr)6 ByPtrRef (org.bytedeco.javacpp.annotation.ByPtrRef)4 ByVal (org.bytedeco.javacpp.annotation.ByVal)4 BoolPointer (org.bytedeco.javacpp.BoolPointer)3 BytePointer (org.bytedeco.javacpp.BytePointer)3 CLongPointer (org.bytedeco.javacpp.CLongPointer)3 CharPointer (org.bytedeco.javacpp.CharPointer)3 DoublePointer (org.bytedeco.javacpp.DoublePointer)3 FloatPointer (org.bytedeco.javacpp.FloatPointer)3 FunctionPointer (org.bytedeco.javacpp.FunctionPointer)3 IntPointer (org.bytedeco.javacpp.IntPointer)3 LongPointer (org.bytedeco.javacpp.LongPointer)3 Pointer (org.bytedeco.javacpp.Pointer)3 PointerPointer (org.bytedeco.javacpp.PointerPointer)3 ShortPointer (org.bytedeco.javacpp.ShortPointer)3 SizeTPointer (org.bytedeco.javacpp.SizeTPointer)3 ByRef (org.bytedeco.javacpp.annotation.ByRef)3 Buffer (java.nio.Buffer)2 ByteBuffer (java.nio.ByteBuffer)2