X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=genbindings.py;h=3c9235118f1e3fe4217563c70aabad99f5709aed;hb=4fd49e2371dbec8f26732bd14af0d5c7aa3c1fdd;hp=e0f6389e644c3316ba224a511e13a0dc8dce2e9e;hpb=3971d996187908c0da718c33f32132c114b83208;p=ldk-java diff --git a/genbindings.py b/genbindings.py index e0f6389e..3c923511 100755 --- a/genbindings.py +++ b/genbindings.py @@ -682,7 +682,14 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java: elif ty_info.passed_as_ptr: opaque_arg_conv = opaque_arg_conv + "\n// Warning: we may need a move here but can't clone!" - opaque_ret_conv_suf = ";\nCHECK((((long)" + ty_info.var_name + "_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.\n" + opaque_ret_conv_suf = ";\n" + if not holds_ref and ty_info.is_ptr and (ty_info.java_hu_ty + "_clone") in clone_fns: # is_ptr, not holds_ref implies passing a pointed-to value to java, which needs copied + opaque_ret_conv_suf = opaque_ret_conv_suf + "if (" + ty_info.var_name + "->inner != NULL)\n" + opaque_ret_conv_suf = opaque_ret_conv_suf + "\t" + ty_info.var_name + "_var = " + ty_info.java_hu_ty + "_clone(" + ty_info.var_name + ");\n" + elif not holds_ref and ty_info.is_ptr: + opaque_ret_conv_suf = opaque_ret_conv_suf + "// Warning: we may need a move here but can't clone!\n" + + opaque_ret_conv_suf = opaque_ret_conv_suf + "CHECK((((long)" + ty_info.var_name + "_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.\n" opaque_ret_conv_suf = opaque_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 or ty_info.is_ptr: opaque_ret_conv_suf = opaque_ret_conv_suf + "long " + ty_info.var_name + "_ref = (long)" + ty_info.var_name + "_var.inner & ~1;"