outputln("if (sizeof(_arg0) > STRUCT_SIZE_LIMIT) {");
generate_objc_msgSend_stret(method, params, name);
paramStart = 1;
} else if (name.equalsIgnoreCase("call")) {
output("(");
JNIParameter param = params.get(0);
String cast = param.getCast();
if (cast.length() != 0 && !cast.equals("()")) {
output(cast);
if( param.isPointer() ) {
output("(intptr_t)");
}
} else {
output("(");
output(returnType.getTypeSignature2(!returnType.equals(returnType64)));
output(" (*)())");
}
output("arg0)");
paramStart = 1;
} else if (name.startsWith("VtblCall") || name.startsWith("_VtblCall")) {
output("((");
output(returnType.getTypeSignature2(!returnType.equals(returnType64)));
output(" (STDMETHODCALLTYPE *)(");
for (int i = 1; i < params.size(); i++) {
if (i != 1)
output(", ");
JNIParameter param = params.get(i);
JNIType paramType = param.getType32(), paramType64 = param.getType64();
output(paramType.getTypeSignature4(!paramType.equals(paramType64), false));
}
output("))(*(");
JNIType paramType = params.get(1).getType32(), paramType64 = params.get(1).getType64();
output(paramType.getTypeSignature4(!paramType.equals(paramType64), false));
output(" **)arg1)[arg0])");
paramStart = 1;
} else if (method.getFlag(MethodFlag.CPP_METHOD) || method.getFlag(MethodFlag.SETTER) || method.getFlag(MethodFlag.GETTER) || method.getFlag(MethodFlag.ADDER)) {
String[] parts = getNativeNameParts(method);
String className = parts[0];
String methodName = parts[1];
if (method.getFlag(MethodFlag.CS_OBJECT)) {
output("TO_HANDLE(");
}
output("(");
if( params.isEmpty() ) {
throw new Error(String.format("C++ bound method '%s' missing the 'this' parameter", method.getDeclaringClass().getSimpleName()+"."+method.getName()));
}
JNIParameter param = params.get(0);
if (param.getFlag(ArgFlag.BY_VALUE))
output("*");
String cast = param.getCast();
if (cast.length() != 0 && !cast.equals("()")) {
output(cast);
if( param.isPointer() ) {
output("(intptr_t)");
}
} else {
output("("+className+" *)(intptr_t)");
}
if (param.getFlag(ArgFlag.CS_OBJECT)) {
output("TO_OBJECT(");
}
output("arg0");
if (param.getFlag(ArgFlag.CS_OBJECT)) {
output(")");
}
output(")->");
output(methodName);
paramStart = 1;
} else if (method.getFlag(MethodFlag.CS_NEW)) {
output("TO_HANDLE(gcnew ");
String accessor = method.getAccessor();
if (accessor.length() != 0) {
output(accessor);
} else {
JNIClass dc = method.getDeclaringClass();
if( dc.getFlag(ClassFlag.CPP) || dc.getFlag(ClassFlag.STRUCT) ) {
output(dc.getNativeName());
} else {
int index = -1;
if ((index = name.indexOf('_')) != -1) {
output(name.substring(index + 1));
} else {
output(name);
}
}
}
} else if (method.getFlag(MethodFlag.CPP_NEW)) {
if (method.getFlag(MethodFlag.CS_OBJECT)) {
output("TO_HANDLE(");
}
output("new ");
String accessor = method.getAccessor();
if (accessor.length() != 0) {
output(accessor);
} else {
JNIClass dc = method.getDeclaringClass();
if( dc.getFlag(ClassFlag.CPP) ) {
output(method.getDeclaringClass().getNativeName());
} else {
int index = -1;
if ((index = name.indexOf('_')) != -1) {
output(name.substring(index+1));
} else {
output(name);
}
}
}
} else if (method.getFlag(MethodFlag.CPP_DELETE)) {
String[] parts = getNativeNameParts(method);
String className = parts[0];
output("delete ");
JNIParameter param = params.get(0);
String cast = param.getCast();
if (cast.length() != 0 && !cast.equals("()")) {
output(cast);
if( param.isPointer() ) {
output("(intptr_t)");
}
} else {
output("("+className+" *)(intptr_t)");
}
outputln("arg0;");
return;
} else {
if (method.getFlag(MethodFlag.CS_OBJECT)) {
output("TO_HANDLE(");
}
if (method.getFlag(MethodFlag.CAST)) {
output("((");
String returnCast = returnType.getTypeSignature2(!returnType.equals(returnType64));
if (name.equals("objc_msgSend_bool") && returnCast.equals("jboolean")) {
returnCast = "BOOL";
}
output(returnCast);
output(" (*)(");
for (int i = 0; i < params.size(); i++) {
if (i != 0)
output(", ");
JNIParameter param = params.get(i);
String cast = param.getCast();
if (cast.length() != 0 && !cast.equals("()") ) {
if (cast.startsWith("("))
cast = cast.substring(1);
if (cast.endsWith(")"))
cast = cast.substring(0, cast.length() - 1);
output(cast);
} else {
JNIType paramType = param.getType32(), paramType64 = param.getType64();
if (!(paramType.isPrimitive() || paramType.isArray())) {
if (param.getTypeClass().getFlag(ClassFlag.STRUCT) && !param.getTypeClass().getFlag(ClassFlag.TYPEDEF)) {
output("struct ");
}
}
output(paramType.getTypeSignature4(!paramType.equals(paramType64), param.getFlag(ArgFlag.BY_VALUE)));
}
}
output("))");
}
String accessor = method.getAccessor();