From 719e2a8f67090e2c063cbefe2a613aa63205284b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 29 Jan 2021 23:23:03 -0500 Subject: [PATCH] Add util methods file for methods not associated with a known struct --- genbindings.py | 7 +++++++ java_strings.py | 7 +++++++ typescript_strings.py | 3 +++ 3 files changed, 17 insertions(+) diff --git a/genbindings.py b/genbindings.py index acc757b1..eefc9937 100755 --- a/genbindings.py +++ b/genbindings.py @@ -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) diff --git a/java_strings.py b/java_strings.py index e1ea1e86..9c8b2b94 100644 --- a/java_strings.py +++ b/java_strings.py @@ -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 { diff --git a/typescript_strings.py b/typescript_strings.py index cb1f3828..82412e01 100644 --- a/typescript_strings.py +++ b/typescript_strings.py @@ -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; -- 2.30.2