- ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 3", to_hu_conv_name = None, from_hu_conv = None) # its a pointer, no conv needed
- elif ty_info.is_ptr:
- return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
- arg_conv = None, arg_conv_name = ty_info.var_name, arg_conv_cleanup = None,
- ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 4", to_hu_conv_name = None, from_hu_conv = None)
- else:
- return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
- arg_conv = None, arg_conv_name = ty_info.var_name, arg_conv_cleanup = None,
- ret_conv = None, ret_conv_name = None, to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None)
- elif not print_void:
- # We don't have a parameter name, and want one, just call it arg
- if ty_info.rust_obj is not None:
- assert(not is_free or ty_info.rust_obj not in opaque_structs)
- return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
- arg_conv = ty_info.rust_obj + " arg_conv = *(" + ty_info.rust_obj + "*)arg;\nFREE((void*)arg);",
- arg_conv_name = "arg_conv", arg_conv_cleanup = None,
- ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 7", to_hu_conv_name = None, from_hu_conv = None)
- else:
- assert(not is_free)
- return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
- arg_conv = None, arg_conv_name = "arg", arg_conv_cleanup = None,
- ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 8", to_hu_conv_name = None, from_hu_conv = None)
- else:
- # We don't have a parameter name, and don't want one (cause we're returning)
- if ty_info.rust_obj is not None:
- if not ty_info.is_ptr:
- if ty_info.rust_obj in unitary_enums:
- return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
- arg_conv = ty_info.rust_obj + " ret_conv = " + ty_info.rust_obj + "_from_java(_env, ret);",
- arg_conv_name = "ret_conv", arg_conv_cleanup = None,
- ret_conv = ("jclass ret = " + ty_info.rust_obj + "_to_java(_env, ", ");"), ret_conv_name = "ret",
- to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None)
- if ty_info.rust_obj in opaque_structs:
- # If we're returning a newly-allocated struct, we don't want Rust to ever
- # free, instead relying on the Java GC to lose the ref. We undo this in
- # any _free function.
- # To avoid any issues, we first assert that the incoming object is non-ref.
- return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
- ret_conv = (ty_info.rust_obj + " ret = ", ";"),
- ret_conv_name = "((long)ret.inner) | (ret.is_owned ? 1 : 0)",
- arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None,
- to_hu_conv = ty_info.java_hu_ty + " ret_hu_conv = new " + ty_info.java_hu_ty + "(null, ret);",
- to_hu_conv_name = "ret_hu_conv", from_hu_conv = None)
- elif ty_info.rust_obj in trait_structs:
- return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
- ret_conv = (ty_info.rust_obj + "* ret = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n*ret = ", ";"),
- ret_conv_name = "(long)ret",
- arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None,
- to_hu_conv = ty_info.java_hu_ty + " ret_hu_conv = new " + ty_info.java_hu_ty + "(null, ret);\nret_hu_conv.ptrs_to.add(this);",
- to_hu_conv_name = "ret_hu_conv", from_hu_conv = None)
- else:
- return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
- ret_conv = (ty_info.rust_obj + "* ret = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n*ret = ", ";"),
- ret_conv_name = "(long)ret",
- arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None,
- to_hu_conv = ty_info.java_hu_ty + " ret_hu_conv = new " + ty_info.java_hu_ty + "(null, ret);\nret_hu_conv.ptrs_to.add(this);",
- to_hu_conv_name = "ret_hu_conv", from_hu_conv = None)