X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=genbindings.py;h=f47cce3699d823ab2f972ba47e161f2d69791fef;hb=9254f751c55dd40afd17bc129cb72f6af3d35ee8;hp=20c09fab9496340064defc9e75fb7edd6583d552;hpb=6884c87ff29249df35c246e86e4d6e38bc930d34;p=ldk-java diff --git a/genbindings.py b/genbindings.py index 20c09fab..f47cce36 100755 --- a/genbindings.py +++ b/genbindings.py @@ -201,7 +201,7 @@ def java_c_types(fn_arg, ret_arr_len): elif fn_arg.startswith("uint16_t"): mapped_type = consts.c_type_map['uint16_t'] java_ty = mapped_type[0] - c_ty = "jshort" + c_ty = "int16_t" fn_ty_arg = "S" fn_arg = fn_arg[8:].strip() is_primitive = True @@ -214,7 +214,7 @@ def java_c_types(fn_arg, ret_arr_len): is_primitive = True elif fn_arg.startswith("uint64_t") or fn_arg.startswith("uintptr_t"): # TODO: uintptr_t is arch-dependent :( - mapped_type = consts.c_type_map['long'] + mapped_type = consts.c_type_map['uint64_t'] java_ty = mapped_type[0] c_ty = "int64_t" fn_ty_arg = "J" @@ -919,20 +919,8 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java: if is_opaque: opaque_structs.add(struct_name) with open(f"{sys.argv[3]}/structs/{struct_name.replace('LDK', '')}{consts.file_ext}", "w") as out_java_struct: - out_java_struct.write(consts.hu_struct_file_prefix) - out_java_struct.write("public class " + struct_name.replace("LDK","") + " extends CommonBase") - if struct_name.startswith("LDKLocked"): - out_java_struct.write(" implements AutoCloseable") - out_java_struct.write(" {\n") - out_java_struct.write("\t" + struct_name.replace("LDK", "") + "(Object _dummy, long ptr) { super(ptr); }\n") - if struct_name.startswith("LDKLocked"): - out_java_struct.write("\t@Override public void close() {\n") - else: - out_java_struct.write("\t@Override @SuppressWarnings(\"deprecation\")\n") - out_java_struct.write("\tprotected void finalize() throws Throwable {\n") - out_java_struct.write("\t\tsuper.finalize();\n") - out_java_struct.write("\t\tif (ptr != 0) { bindings." + struct_name.replace("LDK","") + "_free(ptr); }\n") - out_java_struct.write("\t}\n\n") + out_opaque_struct_human = consts.map_opaque_struct(struct_name) + out_java_struct.write(out_opaque_struct_human) elif result_contents is not None: assert result_contents in result_ptr_struct_items res_ty, err_ty = result_ptr_struct_items[result_contents]