]> git.bitcoin.ninja Git - ldk-java/commitdiff
Correct Rust -> Java method call semantics to avoid double-conversion
authorMatt Corallo <git@bluematt.me>
Tue, 17 Aug 2021 22:18:46 +0000 (22:18 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 18 Aug 2021 01:01:34 +0000 (01:01 +0000)
java_strings.py
typescript_strings.py

index 3482dfb9b63b3e011957c581ce273325b31f69ee..2ddecab7539aed909fc8f544515f4ec3497e1a0a 100644 (file)
@@ -849,7 +849,7 @@ import javax.annotation.Nullable;
                 elif not fn_line.ret_ty_info.passed_as_ptr:
                     out_c += "\t" + fn_line.ret_ty_info.c_ty + " ret = (*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 + "\t" + fn_line.ret_ty_info.rust_obj + "* ret = (" + fn_line.ret_ty_info.rust_obj + "*)(*env)->CallLongMethod(env, obj, j_calls->" + fn_line.fn_name + "_meth"
+                    out_c = out_c + "\tuint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->" + fn_line.fn_name + "_meth"
 
                 for idx, arg_info in enumerate(fn_line.args_ty):
                     if arg_info.ret_conv is not None:
index d1eae4e066f4c133aa10ce6a5503beba923004ea..9f0676a5e711e35552edd1c2761b7ae17e1cced7 100644 (file)
@@ -723,7 +723,7 @@ const decodeString = (stringPointer, free = true) => {
                 elif not fn_line.ret_ty_info.passed_as_ptr:
                     out_c = out_c + "\treturn js_invoke_function_" + str(len(fn_line.args_ty)) + "(j_calls->" + fn_line.fn_name + "_meth"
                 else:
-                    out_c = out_c + "\t" + fn_line.ret_ty_info.rust_obj + "* ret = (" + fn_line.ret_ty_info.rust_obj + "*)js_invoke_function_" + str(len(fn_line.args_ty)) + "(j_calls->" + fn_line.fn_name + "_meth"
+                    out_c = out_c + "\tuint32_t ret = js_invoke_function_" + str(len(fn_line.args_ty)) + "(j_calls->" + fn_line.fn_name + "_meth"
 
                 for idx, arg_info in enumerate(fn_line.args_ty):
                     if arg_info.ret_conv is not None: