projects
/
ldk-java
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
490adea
)
Update Result mapping to use new `_is_ok` function in the C bindings
author
Matt Corallo
<git@bluematt.me>
Sun, 28 Nov 2021 23:17:59 +0000
(23:17 +0000)
committer
Matt Corallo
<git@bluematt.me>
Wed, 1 Dec 2021 14:14:13 +0000
(14:14 +0000)
genbindings.py
patch
|
blob
|
history
diff --git
a/genbindings.py
b/genbindings.py
index 1d01ac6cff1f16a16fc48073f9defd98705acf0a..d8d00158b438489fd589209e4e531b8092c6f4ba 100755
(executable)
--- a/
genbindings.py
+++ b/
genbindings.py
@@
-672,7
+672,7
@@
with open(sys.argv[1]) as in_h, open(f"{sys.argv[2]}/bindings{consts.file_ext}",
out_java_struct.write("\t\tif (ptr != 0) { bindings." + struct_name.replace("LDK","") + "_free(ptr); } super.finalize();\n")
out_java_struct.write("\t}\n\n")
out_java_struct.write("\tstatic " + human_ty + " constr_from_ptr(long ptr) {\n")
out_java_struct.write("\t\tif (ptr != 0) { bindings." + struct_name.replace("LDK","") + "_free(ptr); } super.finalize();\n")
out_java_struct.write("\t}\n\n")
out_java_struct.write("\tstatic " + human_ty + " constr_from_ptr(long ptr) {\n")
- out_java_struct.write("\t\tif (bindings." + struct_name
+ "_result
_ok(ptr)) {\n")
+ out_java_struct.write("\t\tif (bindings." + struct_name
.replace("LDK", "") + "_is
_ok(ptr)) {\n")
out_java_struct.write("\t\t\treturn new " + human_ty + "_OK(null, ptr);\n")
out_java_struct.write("\t\t} else {\n")
out_java_struct.write("\t\t\treturn new " + human_ty + "_Err(null, ptr);\n")
out_java_struct.write("\t\t\treturn new " + human_ty + "_OK(null, ptr);\n")
out_java_struct.write("\t\t} else {\n")
out_java_struct.write("\t\t\treturn new " + human_ty + "_Err(null, ptr);\n")
@@
-687,11
+687,6
@@
with open(sys.argv[1]) as in_h, open(f"{sys.argv[2]}/bindings{consts.file_ext}",
if not err_map.is_native_primitive and (err_map.rust_obj.replace("LDK", "") + "_clone" not in clone_fns):
can_clone = False
if not err_map.is_native_primitive and (err_map.rust_obj.replace("LDK", "") + "_clone" not in clone_fns):
can_clone = False
- out_java.write("\tpublic static native boolean " + struct_name + "_result_ok(long arg);\n")
- write_c(consts.c_fn_ty_pfx + "jboolean " + consts.c_fn_name_define_pfx(struct_name + "_result_ok", True) + consts.ptr_c_ty + " arg) {\n")
- write_c("\treturn ((" + struct_name + "*)arg)->result_ok;\n")
- write_c("}\n")
-
out_java.write("\tpublic static native " + res_map.java_ty + " " + struct_name + "_get_ok(long arg);\n")
write_c(consts.c_fn_ty_pfx + res_map.c_ty + " " + consts.c_fn_name_define_pfx(struct_name + "_get_ok", True) + consts.ptr_c_ty + " arg) {\n")
write_c("\t" + struct_name + " *val = (" + struct_name + "*)(arg & ~1);\n")
out_java.write("\tpublic static native " + res_map.java_ty + " " + struct_name + "_get_ok(long arg);\n")
write_c(consts.c_fn_ty_pfx + res_map.c_ty + " " + consts.c_fn_name_define_pfx(struct_name + "_get_ok", True) + consts.ptr_c_ty + " arg) {\n")
write_c("\t" + struct_name + " *val = (" + struct_name + "*)(arg & ~1);\n")