use of org.bytedeco.javacpp.annotation.Namespace in project bigbluebutton by bigbluebutton.
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 (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 && !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;
}
use of org.bytedeco.javacpp.annotation.Namespace in project bigbluebutton by bigbluebutton.
the class Generator method cppFunctionTypeName.
String[] cppFunctionTypeName(Method functionMethod) {
String prefix, suffix;
Class<?> type = functionMethod.getDeclaringClass();
Convention convention = type.getAnnotation(Convention.class);
String callingConvention = convention == null ? "" : convention.value() + " ";
// for virtual functions, the namespace is managed by the enclosing class
Namespace namespace = FunctionPointer.class.isAssignableFrom(type) ? type.getAnnotation(Namespace.class) : null;
String spaceName = namespace == null ? "" : namespace.value();
if (spaceName.length() > 0 && !spaceName.endsWith("::")) {
spaceName += "::";
}
Class returnType = functionMethod.getReturnType();
Class[] parameterTypes = functionMethod.getParameterTypes();
Annotation[] annotations = functionMethod.getAnnotations();
Annotation[][] parameterAnnotations = functionMethod.getParameterAnnotations();
String[] returnTypeName = cppAnnotationTypeName(returnType, annotations);
AdapterInformation returnAdapterInfo = adapterInformation(false, valueTypeName(returnTypeName), annotations);
if (returnAdapterInfo != null && returnAdapterInfo.cast.length() > 0) {
prefix = returnAdapterInfo.cast;
} else {
prefix = returnTypeName[0] + returnTypeName[1];
}
prefix += " (" + callingConvention + spaceName + "*";
suffix = ")(";
if (FunctionPointer.class.isAssignableFrom(type) && namespace != null && (parameterTypes.length == 0 || !Pointer.class.isAssignableFrom(parameterTypes[0]))) {
logger.warn("First parameter of caller method call() or apply() for member function pointer " + type.getCanonicalName() + " is not a Pointer. Compilation will most likely fail.");
}
for (int j = namespace == null ? 0 : 1; j < parameterTypes.length; j++) {
String[] paramTypeName = cppAnnotationTypeName(parameterTypes[j], parameterAnnotations[j]);
AdapterInformation paramAdapterInfo = adapterInformation(false, valueTypeName(paramTypeName), parameterAnnotations[j]);
if (paramAdapterInfo != null && paramAdapterInfo.cast.length() > 0) {
suffix += paramAdapterInfo.cast + " arg" + j;
} else {
suffix += paramTypeName[0] + " arg" + j + paramTypeName[1];
}
if (j < parameterTypes.length - 1) {
suffix += ", ";
}
}
suffix += ")";
if (type.isAnnotationPresent(Const.class)) {
suffix += " const";
}
return new String[] { prefix, suffix };
}
use of org.bytedeco.javacpp.annotation.Namespace in project bigbluebutton by bigbluebutton.
the class Generator method cppScopeName.
static String cppScopeName(MethodInformation methodInfo) {
String scopeName = cppScopeName(methodInfo.cls);
if (methodInfo.method.isAnnotationPresent(Virtual.class)) {
String subType = "JavaCPP_" + mangle(scopeName);
scopeName = subType;
}
Namespace namespace = methodInfo.method.getAnnotation(Namespace.class);
String spaceName = namespace == null ? "" : namespace.value();
if ((namespace != null && namespace.value().length() == 0) || spaceName.startsWith("::")) {
// user wants to reset namespace here
scopeName = "";
}
if (scopeName.length() > 0 && !scopeName.endsWith("::")) {
scopeName += "::";
}
scopeName += spaceName;
if (spaceName.length() > 0 && !spaceName.endsWith("::")) {
scopeName += "::";
}
return scopeName + methodInfo.memberName[0];
}
Aggregations