From: Matt Corallo Date: Thu, 22 Oct 2020 23:57:18 +0000 (-0400) Subject: Compact giant type-conversion-strings if tree somewhat X-Git-Tag: v0.0.1~92 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=1f89c40f328ae915df97681668a4c185091f14b5;p=ldk-java Compact giant type-conversion-strings if tree somewhat --- diff --git a/genbindings.py b/genbindings.py index 79e41fd9..f23ea81f 100755 --- a/genbindings.py +++ b/genbindings.py @@ -511,152 +511,7 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg "jstring " + ty_info.var_name + "_conv = (*_env)->NewStringUTF(_env, " + ty_info.var_name + "_str." + ty_info.arr_access + ");\n" + "FREE(" + ty_info.var_name + "_buf);"), ret_conv_name = ty_info.var_name + "_conv", to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None) - elif ty_info.var_name != "": - # If we have a parameter name, print it (noting that it may indicate its a pointer) - if ty_info.rust_obj is not None: - assert(ty_info.passed_as_ptr) - opaque_arg_conv = ty_info.rust_obj + " " + ty_info.var_name + "_conv;\n" - opaque_arg_conv = opaque_arg_conv + ty_info.var_name + "_conv.inner = (void*)(" + ty_info.var_name + " & (~1));\n" - opaque_arg_conv = opaque_arg_conv + ty_info.var_name + "_conv.is_owned = (" + ty_info.var_name + " & 1) || (" + ty_info.var_name + " == 0);" - if not ty_info.is_ptr and not is_free and not ty_info.pass_by_ref: - if (ty_info.java_hu_ty + "_clone") in clone_fns: - # TODO: This is a bit too naive, even with the checks above, we really need to know if rust wants a ref or not, not just if its pass as a ptr. - opaque_arg_conv = opaque_arg_conv + "\nif (" + ty_info.var_name + "_conv.inner != NULL)\n" - opaque_arg_conv = opaque_arg_conv + "\t" + ty_info.var_name + "_conv = " + ty_info.java_hu_ty + "_clone(&" + ty_info.var_name + "_conv);" - elif ty_info.passed_as_ptr: - opaque_arg_conv = opaque_arg_conv + "\n// Warning: we may need a move here but can't clone!" - 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 + " " + ty_info.var_name + "_conv = " + ty_info.rust_obj + "_from_java(_env, " + ty_info.var_name + ");", - arg_conv_name = ty_info.var_name + "_conv", - arg_conv_cleanup = None, - ret_conv = ("jclass " + ty_info.var_name + "_conv = " + ty_info.rust_obj + "_to_java(_env, ", ");"), - ret_conv_name = ty_info.var_name + "_conv", to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None) - if ty_info.rust_obj in opaque_structs: - ret_conv_suf = ";\nCHECK((((long)" + ty_info.var_name + "_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.\n" - ret_conv_suf = ret_conv_suf + "CHECK((((long)&" + ty_info.var_name + "_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.\n" - if holds_ref: - ret_conv_suf = ret_conv_suf + "long " + ty_info.var_name + "_ref = (long)" + ty_info.var_name + "_var.inner & ~1;" - else: - ret_conv_suf = ret_conv_suf + "long " + ty_info.var_name + "_ref;\n" - ret_conv_suf = ret_conv_suf + "if (" + ty_info.var_name + "_var.is_owned) {\n" - ret_conv_suf = ret_conv_suf + "\t" + ty_info.var_name + "_ref = (long)" + ty_info.var_name + "_var.inner | 1;\n" - ret_conv_suf = ret_conv_suf + "} else {\n" - ret_conv_suf = ret_conv_suf + "\t" + ty_info.var_name + "_ref = (long)" + ty_info.var_name + "_var.inner & ~1;\n" - ret_conv_suf = ret_conv_suf + "}" - return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - arg_conv = opaque_arg_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, - ret_conv = (ty_info.rust_obj + " " + ty_info.var_name + "_var = ", ret_conv_suf), - ret_conv_name = ty_info.var_name + "_ref", - to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_hu_conv = new " + ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");", - to_hu_conv_name = ty_info.var_name + "_hu_conv", - from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr & ~1", "this.ptrs_to.add(" + ty_info.var_name + ")")) - base_conv = ty_info.rust_obj + " " + ty_info.var_name + "_conv = *(" + ty_info.rust_obj + "*)" + ty_info.var_name + ";"; - if ty_info.rust_obj in trait_structs: - if not is_free: - base_conv = base_conv + "\nif (" + ty_info.var_name + "_conv.free == " + ty_info.rust_obj + "_JCalls_free) {\n" - base_conv = base_conv + "\t// If this_arg is a JCalls struct, then we need to increment the refcnt in it.\n" - base_conv = base_conv + "\t" + ty_info.rust_obj + "_JCalls_clone(" + ty_info.var_name + "_conv.this_arg);\n}" - else: - base_conv = base_conv + "\n" + "FREE((void*)" + ty_info.var_name + ");" - return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, - ret_conv = ("CANT PASS TRAIT TO Java?", ""), ret_conv_name = "NO CONV POSSIBLE", - to_hu_conv = "DUMMY", to_hu_conv_name = None, - from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr", "this.ptrs_to.add(" + ty_info.var_name + ")")) - if ty_info.rust_obj != "LDKu8slice" and ty_info.rust_obj != "LDKTransaction": - # Don't bother free'ing slices passed in - Rust doesn't auto-free the - # underlying unlike Vecs, and it gives Java more freedom. - base_conv = base_conv + "\nFREE((void*)" + ty_info.var_name + ");"; - if ty_info.rust_obj in complex_enums: - ret_conv = ("long " + ty_info.var_name + "_ref = (long)&", ";") - if not ty_info.is_ptr and not holds_ref and (ty_info.java_hu_ty + "_clone") in clone_fns: - ret_conv = (ty_info.rust_obj + " *" + ty_info.var_name + "_copy = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n", "") - ret_conv = (ret_conv[0] + "*" + ty_info.var_name + "_copy = " + ty_info.java_hu_ty + "_clone(&", ");\n") - ret_conv = (ret_conv[0], ret_conv[1] + "long " + ty_info.var_name + "_ref = (long)" + ty_info.var_name + "_copy;") - return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, - ret_conv = ret_conv, ret_conv_name = ty_info.var_name + "_ref", - to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_hu_conv = " + ty_info.java_hu_ty + ".constr_from_ptr(" + ty_info.var_name + ");", - to_hu_conv_name = ty_info.var_name + "_hu_conv", from_hu_conv = (ty_info.var_name + ".ptr", "")) - if ty_info.rust_obj in tuple_types: - from_hu_conv = "bindings." + tuple_types[ty_info.rust_obj][1].replace("LDK", "") + "_new(" - to_hu_conv_pfx = "" - to_hu_conv_sfx = ty_info.java_hu_ty + " " + ty_info.var_name + "_conv = new " + ty_info.java_hu_ty + "(" - for idx, conv in enumerate(tuple_types[ty_info.rust_obj][0]): - if idx != 0: - to_hu_conv_sfx = to_hu_conv_sfx + ", " - from_hu_conv = from_hu_conv + ", " - conv.var_name = ty_info.var_name + "_" + chr(idx + ord("a")) - conv_map = map_type_with_info(conv, False, None, is_free, holds_ref) - to_hu_conv_pfx = to_hu_conv_pfx + conv.java_ty + " " + ty_info.var_name + "_" + chr(idx + ord("a")) + " = " + "bindings." + tuple_types[ty_info.rust_obj][1] + "_get_" + chr(idx + ord("a")) + "(" + ty_info.var_name + ");\n" - if conv_map.to_hu_conv is not None: - to_hu_conv_pfx = to_hu_conv_pfx + conv_map.to_hu_conv + ";\n" - to_hu_conv_sfx = to_hu_conv_sfx + conv_map.to_hu_conv_name - else: - to_hu_conv_sfx = to_hu_conv_sfx + ty_info.var_name + "_" + chr(idx + ord("a")) - if conv_map.from_hu_conv is not None: - from_hu_conv = from_hu_conv + conv_map.from_hu_conv[0].replace(ty_info.var_name + "_" + chr(idx + ord("a")), ty_info.var_name + "." + chr(idx + ord("a"))) - if conv_map.from_hu_conv[1] != "": - from_hu_conv = from_hu_conv + "/*XXX: Need to call " + conv_map.from_hu_conv[1] + "*/" - else: - from_hu_conv = from_hu_conv + ty_info.var_name + "." + chr(idx + ord("a")) - return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, - ret_conv = ("long " + ty_info.var_name + "_ref = (long)&", ";"), ret_conv_name = ty_info.var_name + "_ref", - to_hu_conv = to_hu_conv_pfx + to_hu_conv_sfx + ");", to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = (from_hu_conv + ")", "")) - - # The manually-defined types - TxOut and Transaction - assert ty_info.rust_obj == "LDKTransaction" or ty_info.rust_obj == "LDKTxOut" - if ty_info.rust_obj == "LDKTransaction": - return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, - ret_conv = ("LDKTransaction *" + ty_info.var_name + "_copy = MALLOC(sizeof(LDKTransaction), \"LDKTransaction\");\n*" + ty_info.var_name + "_copy = ", ";\nlong " + ty_info.var_name + "_ref = (long)" + ty_info.var_name + "_copy;"), - ret_conv_name = ty_info.var_name + "_ref", - to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_conv = new " +ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");", - to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = (ty_info.var_name + ".ptr", "")) - return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, - ret_conv = ("long " + ty_info.var_name + "_ref = (long)&", ";"), ret_conv_name = ty_info.var_name + "_ref", - to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_conv = new " +ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");", - to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = (ty_info.var_name + ".ptr", "")) - else: - assert(not is_free) - if ty_info.rust_obj in opaque_structs: - return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - arg_conv = opaque_arg_conv, arg_conv_name = "&" + ty_info.var_name + "_conv", arg_conv_cleanup = None, - ret_conv = None, ret_conv_name = None, - to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_hu_conv = new " + ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");", - to_hu_conv_name = ty_info.var_name + "_hu_conv", - from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr & ~1", "this.ptrs_to.add(" + ty_info.var_name + ")")) # its a pointer, no conv needed - elif ty_info.rust_obj in complex_enums: - return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - arg_conv = ty_info.rust_obj + "* " + ty_info.var_name + "_conv = (" + ty_info.rust_obj + "*)" + ty_info.var_name + ";", - arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, - ret_conv = None, ret_conv_name = None, - to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_hu_conv = " + ty_info.java_hu_ty + ".constr_from_ptr(" + ty_info.var_name + ");", - to_hu_conv_name = ty_info.var_name + "_hu_conv", - from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr & ~1", "this.ptrs_to.add(" + ty_info.var_name + ")")) # its a pointer, no conv needed - elif ty_info.rust_obj in trait_structs: - return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - arg_conv = ty_info.rust_obj + "* " + ty_info.var_name + "_conv = (" + ty_info.rust_obj + "*)" + ty_info.var_name + ";", - arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, - ret_conv = None, ret_conv_name = None, to_hu_conv = "TODO 2.5", to_hu_conv_name = None, - from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr", "this.ptrs_to.add(" + ty_info.var_name + ")")) # its a pointer, no conv needed - return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - arg_conv = ty_info.rust_obj + "* " + ty_info.var_name + "_conv = (" + ty_info.rust_obj + "*)" + ty_info.var_name + ";", - arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, - 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 = None, 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: + elif ty_info.var_name == "" and 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) @@ -669,71 +524,197 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg 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) + elif ty_info.rust_obj is None: + 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) 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 complex_enums or ty_info.rust_obj in result_types: - 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 = " + ty_info.java_hu_ty + ".constr_from_ptr(ret);\nret_hu_conv.ptrs_to.add(this);", - to_hu_conv_name = "ret_hu_conv", from_hu_conv = ("ret != null ? ret.ptr : 0", "")) - 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 = ("ret.ptr", "")) - elif ty_info.rust_obj in tuple_types: - 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 = ("bindings." + ty_info.rust_obj.replace("LDK", "") + "_new(ret.a, ret.b)", "")) + # If we have a parameter name, print it (noting that it may indicate its a pointer) + assert(ty_info.passed_as_ptr) + opaque_arg_conv = ty_info.rust_obj + " " + ty_info.var_name + "_conv;\n" + opaque_arg_conv = opaque_arg_conv + ty_info.var_name + "_conv.inner = (void*)(" + ty_info.var_name + " & (~1));\n" + opaque_arg_conv = opaque_arg_conv + ty_info.var_name + "_conv.is_owned = (" + ty_info.var_name + " & 1) || (" + ty_info.var_name + " == 0);" + if not ty_info.is_ptr and not is_free and not ty_info.pass_by_ref: + if (ty_info.java_hu_ty + "_clone") in clone_fns: + # TODO: This is a bit too naive, even with the checks above, we really need to know if rust wants a ref or not, not just if its pass as a ptr. + opaque_arg_conv = opaque_arg_conv + "\nif (" + ty_info.var_name + "_conv.inner != NULL)\n" + opaque_arg_conv = opaque_arg_conv + "\t" + ty_info.var_name + "_conv = " + ty_info.java_hu_ty + "_clone(&" + ty_info.var_name + "_conv);" + elif ty_info.passed_as_ptr: + opaque_arg_conv = opaque_arg_conv + "\n// Warning: we may need a move here but can't clone!" + if not ty_info.is_ptr and ty_info.var_name != "": + 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 + " " + ty_info.var_name + "_conv = " + ty_info.rust_obj + "_from_java(_env, " + ty_info.var_name + ");", + arg_conv_name = ty_info.var_name + "_conv", + arg_conv_cleanup = None, + ret_conv = ("jclass " + ty_info.var_name + "_conv = " + ty_info.rust_obj + "_to_java(_env, ", ");"), + ret_conv_name = ty_info.var_name + "_conv", to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None) + if ty_info.rust_obj in opaque_structs: + ret_conv_suf = ";\nCHECK((((long)" + ty_info.var_name + "_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.\n" + ret_conv_suf = ret_conv_suf + "CHECK((((long)&" + ty_info.var_name + "_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.\n" + if holds_ref: + ret_conv_suf = ret_conv_suf + "long " + ty_info.var_name + "_ref = (long)" + ty_info.var_name + "_var.inner & ~1;" 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) + ret_conv_suf = ret_conv_suf + "long " + ty_info.var_name + "_ref;\n" + ret_conv_suf = ret_conv_suf + "if (" + ty_info.var_name + "_var.is_owned) {\n" + ret_conv_suf = ret_conv_suf + "\t" + ty_info.var_name + "_ref = (long)" + ty_info.var_name + "_var.inner | 1;\n" + ret_conv_suf = ret_conv_suf + "} else {\n" + ret_conv_suf = ret_conv_suf + "\t" + ty_info.var_name + "_ref = (long)" + ty_info.var_name + "_var.inner & ~1;\n" + ret_conv_suf = ret_conv_suf + "}" + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = opaque_arg_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, + ret_conv = (ty_info.rust_obj + " " + ty_info.var_name + "_var = ", ret_conv_suf), + ret_conv_name = ty_info.var_name + "_ref", + to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_hu_conv = new " + ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");", + to_hu_conv_name = ty_info.var_name + "_hu_conv", + from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr & ~1", "this.ptrs_to.add(" + ty_info.var_name + ")")) + base_conv = ty_info.rust_obj + " " + ty_info.var_name + "_conv = *(" + ty_info.rust_obj + "*)" + ty_info.var_name + ";"; + if ty_info.rust_obj in trait_structs: + if not is_free: + base_conv = base_conv + "\nif (" + ty_info.var_name + "_conv.free == " + ty_info.rust_obj + "_JCalls_free) {\n" + base_conv = base_conv + "\t// If this_arg is a JCalls struct, then we need to increment the refcnt in it.\n" + base_conv = base_conv + "\t" + ty_info.rust_obj + "_JCalls_clone(" + ty_info.var_name + "_conv.this_arg);\n}" + else: + base_conv = base_conv + "\n" + "FREE((void*)" + ty_info.var_name + ");" + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, + ret_conv = ("CANT PASS TRAIT TO Java?", ""), ret_conv_name = "NO CONV POSSIBLE", + to_hu_conv = "DUMMY", to_hu_conv_name = None, + from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr", "this.ptrs_to.add(" + ty_info.var_name + ")")) + if ty_info.rust_obj != "LDKu8slice" and ty_info.rust_obj != "LDKTransaction": + # Don't bother free'ing slices passed in - Rust doesn't auto-free the + # underlying unlike Vecs, and it gives Java more freedom. + base_conv = base_conv + "\nFREE((void*)" + ty_info.var_name + ");"; + if ty_info.rust_obj in complex_enums: + ret_conv = ("long " + ty_info.var_name + "_ref = (long)&", ";") + if not ty_info.is_ptr and not holds_ref and (ty_info.java_hu_ty + "_clone") in clone_fns: + ret_conv = (ty_info.rust_obj + " *" + ty_info.var_name + "_copy = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n", "") + ret_conv = (ret_conv[0] + "*" + ty_info.var_name + "_copy = " + ty_info.java_hu_ty + "_clone(&", ");\n") + ret_conv = (ret_conv[0], ret_conv[1] + "long " + ty_info.var_name + "_ref = (long)" + ty_info.var_name + "_copy;") + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, + ret_conv = ret_conv, ret_conv_name = ty_info.var_name + "_ref", + to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_hu_conv = " + ty_info.java_hu_ty + ".constr_from_ptr(" + ty_info.var_name + ");", + to_hu_conv_name = ty_info.var_name + "_hu_conv", from_hu_conv = (ty_info.var_name + ".ptr", "")) + if ty_info.rust_obj in tuple_types: + from_hu_conv = "bindings." + tuple_types[ty_info.rust_obj][1].replace("LDK", "") + "_new(" + to_hu_conv_pfx = "" + to_hu_conv_sfx = ty_info.java_hu_ty + " " + ty_info.var_name + "_conv = new " + ty_info.java_hu_ty + "(" + for idx, conv in enumerate(tuple_types[ty_info.rust_obj][0]): + if idx != 0: + to_hu_conv_sfx = to_hu_conv_sfx + ", " + from_hu_conv = from_hu_conv + ", " + conv.var_name = ty_info.var_name + "_" + chr(idx + ord("a")) + conv_map = map_type_with_info(conv, False, None, is_free, holds_ref) + to_hu_conv_pfx = to_hu_conv_pfx + conv.java_ty + " " + ty_info.var_name + "_" + chr(idx + ord("a")) + " = " + "bindings." + tuple_types[ty_info.rust_obj][1] + "_get_" + chr(idx + ord("a")) + "(" + ty_info.var_name + ");\n" + if conv_map.to_hu_conv is not None: + to_hu_conv_pfx = to_hu_conv_pfx + conv_map.to_hu_conv + ";\n" + to_hu_conv_sfx = to_hu_conv_sfx + conv_map.to_hu_conv_name + else: + to_hu_conv_sfx = to_hu_conv_sfx + ty_info.var_name + "_" + chr(idx + ord("a")) + if conv_map.from_hu_conv is not None: + from_hu_conv = from_hu_conv + conv_map.from_hu_conv[0].replace(ty_info.var_name + "_" + chr(idx + ord("a")), ty_info.var_name + "." + chr(idx + ord("a"))) + if conv_map.from_hu_conv[1] != "": + from_hu_conv = from_hu_conv + "/*XXX: " + conv_map.from_hu_conv[1] + "*/" + else: + from_hu_conv = from_hu_conv + ty_info.var_name + "." + chr(idx + ord("a")) + + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, + ret_conv = ("long " + ty_info.var_name + "_ref = (long)&", ";"), ret_conv_name = ty_info.var_name + "_ref", + to_hu_conv = to_hu_conv_pfx + to_hu_conv_sfx + ");", to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = (from_hu_conv + ")", "")) + + # The manually-defined types - TxOut and Transaction + assert ty_info.rust_obj == "LDKTransaction" or ty_info.rust_obj == "LDKTxOut" + if ty_info.rust_obj == "LDKTransaction": + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, + ret_conv = ("LDKTransaction *" + ty_info.var_name + "_copy = MALLOC(sizeof(LDKTransaction), \"LDKTransaction\");\n*" + ty_info.var_name + "_copy = ", ";\nlong " + ty_info.var_name + "_ref = (long)" + ty_info.var_name + "_copy;"), + ret_conv_name = ty_info.var_name + "_ref", + to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_conv = new " +ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");", + to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = (ty_info.var_name + ".ptr", "")) + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = base_conv, arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, + ret_conv = ("long " + ty_info.var_name + "_ref = (long)&", ";"), ret_conv_name = ty_info.var_name + "_ref", + to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_conv = new " +ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");", + to_hu_conv_name = ty_info.var_name + "_conv", from_hu_conv = (ty_info.var_name + ".ptr", "")) + elif ty_info.is_ptr: + assert(not is_free) + if ty_info.rust_obj in opaque_structs: + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = opaque_arg_conv, arg_conv_name = "&" + ty_info.var_name + "_conv", arg_conv_cleanup = None, + ret_conv = ("long ret_" + ty_info.var_name + " = (long)", ";"), ret_conv_name = "ret_" + ty_info.var_name, + to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_hu_conv = new " + ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");", + to_hu_conv_name = ty_info.var_name + "_hu_conv", + from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr & ~1", "this.ptrs_to.add(" + ty_info.var_name + ")")) + elif ty_info.rust_obj in complex_enums: + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = ty_info.rust_obj + "* " + ty_info.var_name + "_conv = (" + ty_info.rust_obj + "*)" + ty_info.var_name + ";", + arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, + ret_conv = ("long ret_" + ty_info.var_name + " = (long)", ";"), ret_conv_name = "ret_" + ty_info.var_name, + to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_hu_conv = " + ty_info.java_hu_ty + ".constr_from_ptr(" + ty_info.var_name + ");", + to_hu_conv_name = ty_info.var_name + "_hu_conv", + from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr & ~1", "this.ptrs_to.add(" + ty_info.var_name + ")")) elif ty_info.rust_obj in trait_structs: return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, - ret_conv = ("long ret = (long)", ";"), ret_conv_name = "ret", - arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, + arg_conv = ty_info.rust_obj + "* " + ty_info.var_name + "_conv = (" + ty_info.rust_obj + "*)" + ty_info.var_name + ";", + arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, + ret_conv = ("long ret_" + ty_info.var_name + " = (long)", ";"), ret_conv_name = "ret_" + ty_info.var_name, 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 = ("long ret = (long)", ";"), ret_conv_name = "ret", - arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None, - to_hu_conv = "TODO c", to_hu_conv_name = None, from_hu_conv = None) + to_hu_conv_name = "ret_hu_conv", + from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr", "this.ptrs_to.add(" + ty_info.var_name + ")")) + return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name, + arg_conv = ty_info.rust_obj + "* " + ty_info.var_name + "_conv = (" + ty_info.rust_obj + "*)" + ty_info.var_name + ";", + arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None, + ret_conv = ("long ret_" + ty_info.var_name + " = (long)", ";"), ret_conv_name = "ret_" + ty_info.var_name, + to_hu_conv = "TODO 3", to_hu_conv_name = None, from_hu_conv = None) # its a pointer, no conv needed + # We don't have a parameter name, and don't want one (cause we're returning) + assert 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 complex_enums or ty_info.rust_obj in result_types: + 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 = " + ty_info.java_hu_ty + ".constr_from_ptr(ret);\nret_hu_conv.ptrs_to.add(this);", + to_hu_conv_name = "ret_hu_conv", from_hu_conv = ("ret != null ? ret.ptr : 0", "")) + 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 = ("ret.ptr", "")) + elif ty_info.rust_obj in tuple_types: + 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 = ("bindings." + ty_info.rust_obj.replace("LDK", "") + "_new(ret.a, ret.b)", "")) 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, - ret_conv = None, ret_conv_name = None, - to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = 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) def map_fn(line, re_match, ret_arr_len, c_call_string): out_java.write("\t// " + line) diff --git a/src/main/jni/bindings.c b/src/main/jni/bindings.c index 3747589a..44b0a07d 100644 --- a/src/main/jni/bindings.c +++ b/src/main/jni/bindings.c @@ -1769,6 +1769,7 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_j LDKTransaction *commitment_tx_copy = MALLOC(sizeof(LDKTransaction), "LDKTransaction"); *commitment_tx_copy = commitment_tx; long commitment_tx_ref = (long)commitment_tx_copy; + long ret_keys = (long)keys; LDKCVec_HTLCOutputInCommitmentZ htlcs_var = htlcs; jlongArray htlcs_arr = (*_env)->NewLongArray(_env, htlcs_var.datalen); jlong *htlcs_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, htlcs_arr, NULL); @@ -1788,7 +1789,7 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_j FREE(htlcs_var.data); jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_counterparty_commitment_meth, feerate_per_kw, commitment_tx_ref, keys, htlcs_arr); + LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_counterparty_commitment_meth, feerate_per_kw, commitment_tx_ref, ret_keys, htlcs_arr); LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = *ret; FREE(ret); return res; @@ -1797,9 +1798,10 @@ LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, con LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; JNIEnv *_env; DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); + long ret_holder_commitment_tx = (long)holder_commitment_tx; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_holder_commitment_meth, holder_commitment_tx); + LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_holder_commitment_meth, ret_holder_commitment_tx); LDKCResult_SignatureNoneZ res = *ret; FREE(ret); return res; @@ -1808,9 +1810,10 @@ LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(c LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; JNIEnv *_env; DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); + long ret_holder_commitment_tx = (long)holder_commitment_tx; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_holder_commitment_htlc_transactions_meth, holder_commitment_tx); + LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_holder_commitment_htlc_transactions_meth, ret_holder_commitment_tx); LDKCResult_CVec_SignatureZNoneZ res = *ret; FREE(ret); return res; @@ -1824,9 +1827,10 @@ LDKCResult_SignatureNoneZ sign_justice_transaction_jcall(const void* this_arg, L long justice_tx_ref = (long)justice_tx_copy; jbyteArray per_commitment_key_arr = (*_env)->NewByteArray(_env, 32); (*_env)->SetByteArrayRegion(_env, per_commitment_key_arr, 0, 32, *per_commitment_key); + long ret_htlc = (long)htlc; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_justice_transaction_meth, justice_tx_ref, input, amount, per_commitment_key_arr, htlc); + LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_justice_transaction_meth, justice_tx_ref, input, amount, per_commitment_key_arr, ret_htlc); LDKCResult_SignatureNoneZ res = *ret; FREE(ret); return res; @@ -1840,9 +1844,10 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_jcall(const void* t long htlc_tx_ref = (long)htlc_tx_copy; jbyteArray per_commitment_point_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form); + long ret_htlc = (long)htlc; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_ref, input, amount, per_commitment_point_arr, htlc); + LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_ref, input, amount, per_commitment_point_arr, ret_htlc); LDKCResult_SignatureNoneZ res = *ret; FREE(ret); return res; @@ -1865,9 +1870,10 @@ LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; JNIEnv *_env; DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_channel_announcement_meth, msg); + LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*_env)->CallLongMethod(_env, obj, j_calls->sign_channel_announcement_meth, ret_msg); LDKCResult_SignatureNoneZ res = *ret; FREE(ret); return res; @@ -1876,9 +1882,10 @@ void on_accept_jcall(void* this_arg, const LDKChannelPublicKeys *channel_points, LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; JNIEnv *_env; DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); + long ret_channel_points = (long)channel_points; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->on_accept_meth, channel_points, counterparty_selected_contest_delay, holder_selected_contest_delay); + return (*_env)->CallVoidMethod(_env, obj, j_calls->on_accept_meth, ret_channel_points, counterparty_selected_contest_delay, holder_selected_contest_delay); } static void LDKChannelKeys_JCalls_free(void* this_arg) { LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; @@ -2343,12 +2350,13 @@ void register_output_jcall(const void* this_arg, const LDKOutPoint *outpoint, LD LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; JNIEnv *_env; DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); + long ret_outpoint = (long)outpoint; LDKu8slice script_pubkey_var = script_pubkey; jbyteArray script_pubkey_arr = (*_env)->NewByteArray(_env, script_pubkey_var.datalen); (*_env)->SetByteArrayRegion(_env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data); jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->register_output_meth, outpoint, script_pubkey_arr); + return (*_env)->CallVoidMethod(_env, obj, j_calls->register_output_meth, ret_outpoint, script_pubkey_arr); } static void LDKFilter_JCalls_free(void* this_arg) { LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; @@ -2920,9 +2928,10 @@ void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, } else { their_features_ref = (long)their_features_var.inner & ~1; } + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, ret_msg); } void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -2939,9 +2948,10 @@ void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_i } else { their_features_ref = (long)their_features_var.inner & ~1; } + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, ret_msg); } void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -2949,9 +2959,10 @@ void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, ret_msg); } void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -2959,9 +2970,10 @@ void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_i DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, ret_msg); } void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -2969,9 +2981,10 @@ void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_i DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, ret_msg); } void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -2979,9 +2992,10 @@ void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, con DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, ret_msg); } void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -2989,9 +3003,10 @@ void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_i DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, ret_msg); } void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -2999,9 +3014,10 @@ void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_ DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, ret_msg); } void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -3009,9 +3025,10 @@ void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_n DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, ret_msg); } void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -3019,9 +3036,10 @@ void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, ret_msg); } void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -3029,9 +3047,10 @@ void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, ret_msg); } void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -3039,9 +3058,10 @@ void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_nod DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, ret_msg); } void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -3049,9 +3069,10 @@ void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_i DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, ret_msg); } void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -3059,9 +3080,10 @@ void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, c DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, ret_msg); } void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -3069,9 +3091,10 @@ void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey the DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, ret_msg); } void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -3089,9 +3112,10 @@ void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, cons DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->peer_connected_meth, their_node_id_arr, ret_msg); } void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -3099,9 +3123,10 @@ void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_n DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, ret_msg); } void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage *msg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -3109,9 +3134,10 @@ void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); jbyteArray their_node_id_arr = (*_env)->NewByteArray(_env, 33); (*_env)->SetByteArrayRegion(_env, their_node_id_arr, 0, 33, their_node_id.compressed_form); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_error_meth, their_node_id_arr, msg); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_error_meth, their_node_id_arr, ret_msg); } static void LDKChannelMessageHandler_JCalls_free(void* this_arg) { LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; @@ -3690,9 +3716,10 @@ LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_a LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; JNIEnv *_env; DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_node_announcement_meth, msg); + LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_node_announcement_meth, ret_msg); LDKCResult_boolLightningErrorZ res = *ret; FREE(ret); return res; @@ -3701,9 +3728,10 @@ LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* thi LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; JNIEnv *_env; DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_channel_announcement_meth, msg); + LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_channel_announcement_meth, ret_msg); LDKCResult_boolLightningErrorZ res = *ret; FREE(ret); return res; @@ -3712,9 +3740,10 @@ LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; JNIEnv *_env; DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); + long ret_msg = (long)msg; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_channel_update_meth, msg); + LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*_env)->CallLongMethod(_env, obj, j_calls->handle_channel_update_meth, ret_msg); LDKCResult_boolLightningErrorZ res = *ret; FREE(ret); return res; @@ -3723,9 +3752,10 @@ void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFa LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; JNIEnv *_env; DO_ASSERT((*j_calls->vm)->GetEnv(j_calls->vm, (void**)&_env, JNI_VERSION_1_8) == JNI_OK); + long ret_update = (long)update; jobject obj = (*_env)->NewLocalRef(_env, j_calls->o); CHECK(obj != NULL); - return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_htlc_fail_channel_update_meth, update); + return (*_env)->CallVoidMethod(_env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update); } LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) { LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; @@ -3889,7 +3919,7 @@ JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1g jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen); jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL); for (size_t l = 0; l < ret_var.datalen; l++) { - /*XXX False */long arr_conv_63_ref = (long)&ret_var.data[l]; + long arr_conv_63_ref = (long)&ret_var.data[l]; ret_arr_ptr[l] = arr_conv_63_ref; } (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0); @@ -6107,7 +6137,7 @@ JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1block_1c jlongArray ret_arr = (*_env)->NewLongArray(_env, ret_var.datalen); jlong *ret_arr_ptr = (*_env)->GetPrimitiveArrayCritical(_env, ret_arr, NULL); for (size_t b = 0; b < ret_var.datalen; b++) { - /*XXX False */long arr_conv_27_ref = (long)&ret_var.data[b]; + long arr_conv_27_ref = (long)&ret_var.data[b]; ret_arr_ptr[b] = arr_conv_27_ref; } (*_env)->ReleasePrimitiveArrayCritical(_env, ret_arr, ret_arr_ptr, 0); @@ -6983,8 +7013,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1 LDKChannelManagerReadArgs this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - long ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv); - return ret; + long ret_ = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv); + return ret_; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { @@ -7003,8 +7033,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1 LDKChannelManagerReadArgs this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - long ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv); - return ret; + long ret_ = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv); + return ret_; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { @@ -7023,8 +7053,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1 LDKChannelManagerReadArgs this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - long ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv); - return ret; + long ret_ = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv); + return ret_; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { @@ -7043,8 +7073,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1 LDKChannelManagerReadArgs this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - long ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv); - return ret; + long ret_ = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv); + return ret_; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { @@ -7063,8 +7093,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1 LDKChannelManagerReadArgs this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - long ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv); - return ret; + long ret_ = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv); + return ret_; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { @@ -11076,8 +11106,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1ha LDKMessageHandler this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - long ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv); - return ret; + long ret_ = (long)MessageHandler_get_chan_handler(&this_ptr_conv); + return ret_; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { @@ -11096,8 +11126,8 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1h LDKMessageHandler this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0); - long ret = (long)MessageHandler_get_route_handler(&this_ptr_conv); - return ret; + long ret_ = (long)MessageHandler_get_route_handler(&this_ptr_conv); + return ret_; } JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv * _env, jclass _b, jlong this_ptr, jlong val) { @@ -12433,8 +12463,6 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv * _env, jcl LDKChannelDetails arr_conv_16_conv; arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1)); arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0); - if (arr_conv_16_conv.inner != NULL) - arr_conv_16_conv = ChannelDetails_clone(&arr_conv_16_conv); first_hops_constr.data[q] = arr_conv_16_conv; } (*_env)->ReleaseLongArrayElements (_env, first_hops, first_hops_vals, 0);