Generator: Make sure that @GLvoid types result in proper address calculations at the native side, even though the parameter java type is not java.nio.Buffer
This commit is contained in:
parent
9709e6da2b
commit
93eabcf999
|
@ -215,7 +215,8 @@ public class NativeMethodStubsGenerator {
|
||||||
} else {
|
} else {
|
||||||
Class java_type = Utils.getJavaType(param.getType());
|
Class java_type = Utils.getJavaType(param.getType());
|
||||||
if (Buffer.class.isAssignableFrom(java_type)) {
|
if (Buffer.class.isAssignableFrom(java_type)) {
|
||||||
boolean explicitly_byte_sized = java_type.equals(Buffer.class);
|
boolean explicitly_byte_sized = java_type.equals(Buffer.class) ||
|
||||||
|
translator.getAnnotationType().equals(type_map.getVoidType());
|
||||||
if (explicitly_byte_sized)
|
if (explicitly_byte_sized)
|
||||||
writer.print("(((char *)");
|
writer.print("(((char *)");
|
||||||
if (method.getAnnotation(GenerateAutos.class) != null || (check_annotation != null && check_annotation.canBeNull())) {
|
if (method.getAnnotation(GenerateAutos.class) != null || (check_annotation != null && check_annotation.canBeNull())) {
|
||||||
|
|
|
@ -77,16 +77,20 @@ public class NativeTypeTranslator implements TypeVisitor {
|
||||||
StringBuilder signature = new StringBuilder();
|
StringBuilder signature = new StringBuilder();
|
||||||
if (declaration.getAnnotation(Const.class) != null)
|
if (declaration.getAnnotation(Const.class) != null)
|
||||||
signature.append("const ");
|
signature.append("const ");
|
||||||
if (native_types.size() != 1)
|
|
||||||
throw new RuntimeException("Expected only one native type for declaration " + declaration +
|
|
||||||
", but got " + native_types.size());
|
|
||||||
// Use the name of the native type annotation as the C type name
|
// Use the name of the native type annotation as the C type name
|
||||||
signature.append(native_types.iterator().next().getSimpleName());
|
signature.append(getAnnotationType().getSimpleName());
|
||||||
if (is_indirect)
|
if (is_indirect)
|
||||||
signature.append(" *");
|
signature.append(" *");
|
||||||
return signature.toString();
|
return signature.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Class getAnnotationType() {
|
||||||
|
if (native_types.size() != 1)
|
||||||
|
throw new RuntimeException("Expected only one native type for declaration " + declaration +
|
||||||
|
", but got " + native_types.size());
|
||||||
|
return native_types.iterator().next();
|
||||||
|
}
|
||||||
|
|
||||||
public void visitAnnotationType(AnnotationType t) {
|
public void visitAnnotationType(AnnotationType t) {
|
||||||
throw new RuntimeException(t + " is not allowed");
|
throw new RuntimeException(t + " is not allowed");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue