else:
arr_name = "ret"
arr_len = ret_arr_len
+ if arr_name == "arg":
+ arr_name = "ret"
if ty_info.c_ty == "int8_tArray":
(set_pfx, set_sfx) = self.consts.set_native_arr_contents(arr_name + "_arr", arr_len, ty_info)
ret_conv = ("int8_tArray " + arr_name + "_arr = " + self.consts.create_native_arr_call(arr_len, ty_info) + ";\n" + set_pfx, "")
else:
assert not arr_len.isdigit() # fixed length arrays not implemented
assert ty_info.java_ty[len(ty_info.java_ty) - 2:] == "[]"
- conv_name = "arr_conv_" + str(len(ty_info.java_hu_ty))
+ if arr_name == "":
+ arr_name = "ret"
+ conv_name = arr_name + "_conv_" + str(len(ty_info.java_hu_ty))
idxc = chr(ord('a') + (len(ty_info.java_hu_ty) % 26))
ty_info.subty.var_name = conv_name
#XXX: We'd really prefer to only ever set to False, avoiding lots of clone, but need smarter free logic
# ChannelMonitors inside of vecs.
ty_info.subty.requires_clone = False
subty = self.map_type_with_info(ty_info.subty, False, None, is_free, holds_ref)
- if arr_name == "":
- arr_name = "arg"
arg_conv = ty_info.rust_obj + " " + arr_name + "_constr;\n"
arg_conv = arg_conv + arr_name + "_constr." + arr_len + " = " + self.consts.get_native_arr_len_call[0] + arr_name + self.consts.get_native_arr_len_call[1] + ";\n"
arg_conv = arg_conv + "if (" + arr_name + "_constr." + arr_len + " > 0)\n"
if ty_info.is_ptr:
arg_conv_cleanup = "FREE(" + arr_name + "_constr." + ty_info.arr_access + ");"
- if arr_name == "arg":
- arr_name = "ret"
ret_conv = (ty_info.rust_obj + " " + arr_name + "_var = ", "")
if subty.ret_conv is None:
ret_conv = ("DUMMY", "DUMMY")
size_t alloc_count = 0;
size_t alloc_size = 0;
for (allocation* a = allocation_ll; a != NULL; a = a->next) {
- fprintf(stderr, "%s %p remains:\\n", a->struct_name, a->ptr);
+ fprintf(stderr, "%s %p (%lu bytes) remains:\\n", a->struct_name, a->ptr, a->alloc_len);
backtrace_symbols_fd(a->bt, a->bt_len, STDERR_FILENO);
fprintf(stderr, "\\n\\n");
alloc_count++;
out_c = out_c + "\tjobject obj = (*env)->NewLocalRef(env, j_calls->o);\n\tCHECK(obj != NULL);\n"
if fn_line.ret_ty_info.c_ty.endswith("Array"):
- out_c = out_c + "\t" + fn_line.ret_ty_info.c_ty + " arg = (*env)->CallObjectMethod(env, obj, j_calls->" + fn_line.fn_name + "_meth"
+ out_c = out_c + "\t" + fn_line.ret_ty_info.c_ty + " ret = (*env)->CallObjectMethod(env, obj, j_calls->" + fn_line.fn_name + "_meth"
elif not fn_line.ret_ty_info.passed_as_ptr:
out_c = out_c + "\treturn (*env)->Call" + fn_line.ret_ty_info.java_ty.title() + "Method(env, obj, j_calls->" + fn_line.fn_name + "_meth"
else:
out_c = out_c + arg_info.ret_conv[1].replace('\n', '\n\t') + "\n"
if fn_line.ret_ty_info.c_ty.endswith("Array"):
- out_c = out_c + "\t" + fn_line.ret_ty_info.c_ty + " arg = js_invoke_function_" + str(len(fn_line.args_ty)) + "(j_calls->" + fn_line.fn_name + "_meth"
+ out_c = out_c + "\t" + fn_line.ret_ty_info.c_ty + " ret = js_invoke_function_" + str(len(fn_line.args_ty)) + "(j_calls->" + fn_line.fn_name + "_meth"
elif fn_line.ret_ty_info.java_ty == "void":
out_c = out_c + "\tjs_invoke_function_" + str(len(fn_line.args_ty)) + "(j_calls->" + fn_line.fn_name + "_meth"
elif not fn_line.ret_ty_info.passed_as_ptr: