[Java] Handle UInt5 array conversion
authorMatt Corallo <git@bluematt.me>
Thu, 3 Mar 2022 02:29:17 +0000 (02:29 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 3 Mar 2022 06:25:45 +0000 (06:25 +0000)
java_strings.py
src/main/java/org/ldk/util/InternalUtils.java

index 2fcf836d23b900bcf87bd3b7e5875c5ee0c52523..cc1a361702794047eec6026db366d63ff94771a2 100644 (file)
@@ -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"
 
index 692639d4686475479b8ad79a2aa45218e85f18ab..f26c2ae06daa140816fdb9cb16da1d6aecedcb86 100644 (file)
@@ -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;
+    }
 }