X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=java_strings.py;h=1e7ba997083b055cbe04113be14ddb0851b6d90d;hb=32692e00046b7ec16b6a2e20bd54800b2b48d4c0;hp=b93677aa87e0a900c63d4b3ecbe1ac7f5ddf8cd4;hpb=7c6f77d2bd9bffc95dd79caa0397ec63921b2601;p=ldk-java diff --git a/java_strings.py b/java_strings.py index b93677aa..1e7ba997 100644 --- a/java_strings.py +++ b/java_strings.py @@ -56,7 +56,7 @@ public class bindings { Path libpath = new File(tmpdir.toPath().toString(), "liblightningjni.so").toPath(); Files.copy(is, libpath, StandardCopyOption.REPLACE_EXISTING); Runtime.getRuntime().load(libpath.toString()); - } catch (IOException e) { + } catch (Exception e) { System.err.println("Failed to load LDK native library."); System.err.println("System LDK native library load failed with: " + system_load_err); System.err.println("Resource-based LDK native library load failed with: " + e); @@ -115,7 +115,7 @@ import java.util.LinkedList; class CommonBase { long ptr; LinkedList ptrs_to = new LinkedList(); - protected CommonBase(long ptr) { assert ptr > 1024; this.ptr = ptr; } + protected CommonBase(long ptr) { assert ptr < 0 || ptr > 1024; this.ptr = ptr; } } """ @@ -1112,11 +1112,12 @@ import javax.annotation.Nullable; out_opaque_struct_human += self.hu_struct_file_prefix out_opaque_struct_human += "\n/**\n * " + struct_doc_comment.replace("\n", "\n * ") + "\n */\n" out_opaque_struct_human += "@SuppressWarnings(\"unchecked\") // We correctly assign various generic arrays\n" - out_opaque_struct_human += ("public class " + struct_name.replace("LDK","") + " extends CommonBase") + hu_name = struct_name.replace("LDKC2Tuple", "TwoTuple").replace("LDKC3Tuple", "ThreeTuple").replace("LDK", "") + out_opaque_struct_human += ("public class " + hu_name + " extends CommonBase") if struct_name.startswith("LDKLocked"): out_opaque_struct_human += (" implements AutoCloseable") out_opaque_struct_human += (" {\n") - out_opaque_struct_human += ("\t" + struct_name.replace("LDK", "") + "(Object _dummy, long ptr) { super(ptr); }\n") + out_opaque_struct_human += ("\t" + hu_name + "(Object _dummy, long ptr) { super(ptr); }\n") if struct_name.startswith("LDKLocked"): out_opaque_struct_human += ("\t@Override public void close() {\n") else: @@ -1127,8 +1128,10 @@ import javax.annotation.Nullable; out_opaque_struct_human += ("\t}\n\n") return out_opaque_struct_human + def map_tuple(self, struct_name): + return self.map_opaque_struct(struct_name, "A Tuple") - def map_function(self, argument_types, c_call_string, method_name, return_type_info, struct_meth, default_constructor_args, takes_self, takes_self_as_ref, args_known, type_mapping_generator, doc_comment): + def map_function(self, argument_types, c_call_string, method_name, meth_n, return_type_info, struct_meth, default_constructor_args, takes_self, takes_self_as_ref, args_known, type_mapping_generator, doc_comment): out_java = "" out_c = "" out_java_struct = None @@ -1155,7 +1158,6 @@ import javax.annotation.Nullable; if not args_known: out_java_struct += ("\t// Skipped " + method_name + "\n") else: - meth_n = method_name[len(struct_meth) + 1 if len(struct_meth) != 0 else 0:].strip("_") if doc_comment is not None: out_java_struct += "\t/**\n\t * " + doc_comment.replace("\n", "\n\t * ") + "\n\t */\n" if return_type_info.nullable: @@ -1256,7 +1258,7 @@ import javax.annotation.Nullable; out_java_struct += (info.arg_name) out_java_struct += (");\n") if return_type_info.java_ty == "long" and return_type_info.java_hu_ty != "long": - out_java_struct += "\t\tif (ret < 1024) { return null; }\n" + out_java_struct += "\t\tif (ret >= 0 && ret < 1024) { return null; }\n" if return_type_info.to_hu_conv is not None: if not takes_self: