From a79aeab27e2bb2bcca0f262e6c02b4528d9ac5de Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 3 Mar 2022 02:29:17 +0000 Subject: [PATCH] [Java] Handle UInt5 array conversion --- java_strings.py | 2 ++ src/main/java/org/ldk/util/InternalUtils.java | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/java_strings.py b/java_strings.py index 2fcf836d..cc1a3617 100644 --- a/java_strings.py +++ b/java_strings.py @@ -630,6 +630,8 @@ import javax.annotation.Nullable; return arr_name + " != null ? Arrays.stream(" + arr_name + ").mapToLong(" + conv_name + " -> " + elem_ty.from_hu_conv[0] + ").toArray() : null" elif elem_ty.java_ty == "long": return arr_name + " != null ? Arrays.stream(" + arr_name + ").map(" + conv_name + " -> " + elem_ty.from_hu_conv[0] + ").toArray() : null" + elif elem_ty.java_hu_ty == "UInt5": + return arr_name + " != null ? InternalUtils.convUInt5Array(" + arr_name + ") : null" else: return arr_name + " != null ? Arrays.stream(" + arr_name + ").map(" + conv_name + " -> " + elem_ty.from_hu_conv[0] + ").toArray(" + arr_ty.java_ty + "::new) : null" diff --git a/src/main/java/org/ldk/util/InternalUtils.java b/src/main/java/org/ldk/util/InternalUtils.java index 692639d4..f26c2ae0 100644 --- a/src/main/java/org/ldk/util/InternalUtils.java +++ b/src/main/java/org/ldk/util/InternalUtils.java @@ -7,4 +7,12 @@ public class InternalUtils { } return arr; } + + public static byte[] convUInt5Array(UInt5[] u5s) { + byte[] res = new byte[u5s.length]; + for (int i = 0; i < u5s.length; i++) { + res[i] = u5s[i].getVal(); + } + return res; + } } -- 2.39.5