Skip methods we can't use anyway
[ldk-java] / genbindings.py
index 7382cdccd08dde633a4fb8136249a5162ebb6f56..93b3e77df816c02ed584e049ec7a5bac74cd2ec6 100755 (executable)
@@ -409,6 +409,8 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg
                 if not arg_conv_info.rust_obj in trait_structs and not arg_conv_info.rust_obj in unitary_enums:
                     print(re_match.group(2) + " bad - " + arg_conv_info.rust_obj)
                     args_known = False
+            if arg_conv_info.arg_conv is not None and "Warning" in arg_conv_info.arg_conv:
+                args_known = False
             arg_names.append(arg_conv_info)
 
         out_java_struct = None
@@ -498,9 +500,9 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg
                 if info.arg_name == "this_arg":
                     out_java_struct.write("this.ptr")
                 elif info.passed_as_ptr and info.rust_obj in opaque_structs:
-                    out_java_struct.write(info.arg_name + ".ptr & ~1")
+                    out_java_struct.write(info.arg_name + " == null ? 0 : " + info.arg_name + ".ptr & ~1")
                 elif info.passed_as_ptr and info.rust_obj in trait_structs:
-                    out_java_struct.write(info.arg_name + ".ptr")
+                    out_java_struct.write(info.arg_name + " == null ? 0 : " + info.arg_name + ".ptr")
                 else:
                     out_java_struct.write(info.arg_name)
             out_java_struct.write(")")
@@ -807,6 +809,7 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg
                 elif fn_line.group(2) == "free":
                     out_c.write("\t\t.free = " + struct_name + "_JCalls_free,\n")
                 else:
+                    clone_fns.add(struct_name + "_clone")
                     out_c.write("\t\t.clone = " + struct_name + "_JCalls_clone,\n")
             for var_line in field_var_lines:
                 if var_line.group(1) in trait_structs: