expand c type conversions to other integer array types
authorArik Sosman <git@arik.io>
Thu, 14 Jan 2021 11:14:32 +0000 (03:14 -0800)
committerArik Sosman <git@arik.io>
Thu, 14 Jan 2021 11:14:32 +0000 (03:14 -0800)
genbindings.py
java_strings.py
typescript_strings.py

index 4b242aab1fca67926cb7019a2d60a95a0c36ce67..2443dac65feaed290d4088dd00ad106f0fb21901 100755 (executable)
@@ -185,27 +185,30 @@ def java_c_types(fn_arg, ret_arr_len):
         fn_arg = fn_arg[4:].strip()
         is_primitive = True
     elif fn_arg.startswith("uint8_t"):
-        mapped_type = consts.c_type_map['byte']
+        mapped_type = consts.c_type_map['uint8_t']
         java_ty = mapped_type[0]
         c_ty = "int8_t"
         fn_ty_arg = "B"
         fn_arg = fn_arg[7:].strip()
         is_primitive = True
     elif fn_arg.startswith("uint16_t"):
-        java_ty = "short"
+        mapped_type = consts.c_type_map['uint16_t']
+        java_ty = mapped_type[0]
         c_ty = "jshort"
         fn_ty_arg = "S"
         fn_arg = fn_arg[8:].strip()
         is_primitive = True
     elif fn_arg.startswith("uint32_t"):
-        java_ty = "int"
+        mapped_type = consts.c_type_map['uint32_t']
+        java_ty = mapped_type[0]
         c_ty = "int32_t"
         fn_ty_arg = "I"
         fn_arg = fn_arg[8:].strip()
         is_primitive = True
     elif fn_arg.startswith("uint64_t") or fn_arg.startswith("uintptr_t"):
         # TODO: uintptr_t is arch-dependent :(
-        java_ty = "long"
+        mapped_type = consts.c_type_map['long']
+        java_ty = mapped_type[0]
         c_ty = "int64_t"
         fn_ty_arg = "J"
         if fn_arg.startswith("uint64_t"):
index 0a479de3c594402c97d5e780057ae58fa1ba8669..968cb0f1b7320d87e0f821b1572010c8d14d2a33 100644 (file)
@@ -4,7 +4,10 @@ class Consts:
     def __init__(self, DEBUG):
 
         self.c_type_map = dict(
-            byte = ['byte'],
+            uint8_t = ['byte'],
+            uint16_t = ['short'],
+            uint32_t = ['int'],
+            long = ['long'],
         )
 
         self.common_base = """package org.ldk.structs;
index 35331d89355a6f245d31fea201e59aff04a1ce26..f687f12568e4be158c97ca25169b617b9b39cb03 100644 (file)
@@ -10,7 +10,10 @@ class Consts:
     def __init__(self, DEBUG):
 
         self.c_type_map = dict(
-            byte = ['number', 'Uint8Array'],
+            uint8_t = ['number', 'Uint8Array'],
+            uint16_t = ['number', 'Uint16Array'],
+            uint32_t = ['number', 'Uint32Array'],
+            long = ['number'],
         )
 
         self.common_base = """