]> git.bitcoin.ninja Git - ldk-java/commitdiff
Fix calling Java/TS methods that return strings
authorMatt Corallo <git@bluematt.me>
Thu, 23 Sep 2021 22:41:47 +0000 (22:41 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 24 Sep 2021 21:28:51 +0000 (21:28 +0000)
java_strings.py
typescript_strings.py

index 1f4ddaff009dfcf940632e9046082d18f5a7c8d6..b6b1f13fdaae7c1d9abe8f9afe68f9a09855a458 100644 (file)
@@ -849,6 +849,9 @@ import javax.annotation.Nullable;
                     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 fn_line.ret_ty_info.c_ty == "void":
                     out_c += "\t(*env)->Call" + fn_line.ret_ty_info.java_ty.title() + "Method(env, obj, j_calls->" + fn_line.fn_name + "_meth"
+                elif fn_line.ret_ty_info.java_ty == "String":
+                    # Manually write out String methods as they're just an Object
+                    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 += "\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:
index 9f0676a5e711e35552edd1c2761b7ae17e1cced7..f3a7f29adcd6fa5879a23e532aacbece19e65dbd 100644 (file)
@@ -720,6 +720,8 @@ const decodeString = (stringPointer, free = true) => {
                     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 fn_line.ret_ty_info.java_ty == "String":
+                    out_c = out_c + "\tuint32_t ret = js_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:
                     out_c = out_c + "\treturn js_invoke_function_" + str(len(fn_line.args_ty)) + "(j_calls->" + fn_line.fn_name + "_meth"
                 else: