Add util methods file for methods not associated with a known struct
authorMatt Corallo <git@bluematt.me>
Sat, 30 Jan 2021 04:23:03 +0000 (23:23 -0500)
committerMatt Corallo <git@bluematt.me>
Mon, 1 Feb 2021 01:08:52 +0000 (20:08 -0500)
genbindings.py
java_strings.py
typescript_strings.py

index acc757b19b89cd71792805f3c6b611695fd5db33..eefc9937464fe31e879b8ff393e31725a0248290 100755 (executable)
@@ -426,8 +426,13 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java:
         else:
             write_c(out_c_delta)
 
+        out_java_struct = None
         if ("LDK" + struct_meth in opaque_structs or "LDK" + struct_meth in trait_structs) and not is_free:
             out_java_struct = open(f"{sys.argv[3]}/structs/{struct_meth}{consts.file_ext}", "a")
+        elif method_name.startswith("C2Tuple_") and method_name.endswith("_read"):
+            struct_meth = method_name.rsplit("_", 1)[0]
+            out_java_struct = open(f"{sys.argv[3]}/structs/UtilMethods{consts.file_ext}", "a")
+        if out_java_struct is not None:
             out_java_struct.write(out_java_struct_delta)
 
     def map_unitary_enum(struct_name, field_lines):
@@ -905,3 +910,5 @@ with open(sys.argv[4], "w") as out_c:
     out_c.write(consts.c_file_pfx)
     out_c.write(consts.init_str())
     out_c.write(c_file)
+with open(f"{sys.argv[3]}/structs/UtilMethods{consts.file_ext}", "a") as util:
+    util.write(consts.util_fn_sfx)
index e1ea1e868e0b60655949ddb4b073a524aa1deed4..9c8b2b9444b5098833a5a8fa8544610f8eeac576 100644 (file)
@@ -51,6 +51,13 @@ public class bindings {
 
         self.bindings_footer = "}\n"
 
+        self.util_fn_pfx = """package org.ldk.structs;
+import org.ldk.impl.bindings;
+import java.util.Arrays;
+
+public class UtilMethods {
+"""
+        self.util_fn_sfx = "}"
         self.common_base = """package org.ldk.structs;
 import java.util.LinkedList;
 class CommonBase {
index cb1f3828fc06dd4211043435082216d1992d663c..82412e0147f191e9e187df7fe46ecb7b1b8e7a64 100644 (file)
@@ -82,6 +82,9 @@ public static native long new_empty_slice_vec();
         }
         """
 
+        self.util_fn_pfx = ""
+        self.util_fn_sfx = ""
+
         self.common_base = """
             export default class CommonBase {
                 ptr: number;