]> git.bitcoin.ninja Git - ldk-java/commitdiff
Update type listing for LDK 0.0.117 bindings and support doubles
authorMatt Corallo <git@bluematt.me>
Sun, 1 Oct 2023 18:41:49 +0000 (18:41 +0000)
committerMatt Corallo <git@bluematt.me>
Sun, 1 Oct 2023 18:42:52 +0000 (18:42 +0000)
csharp_strings.py
genbindings.py
java_strings.py
typescript_strings.py

index ac686bccf1727786aacc13ee16649c3d964a559e..b5f816edea8b9771f9f48a32ae73efd0440d6f41 100644 (file)
@@ -16,6 +16,7 @@ class Consts:
             uint32_t = ['int'],
             uint64_t = ['long'],
             int64_t = ['long'],
+            double = ['double'],
         )
         self.java_type_map = dict(
             String = "string"
index e8ddb657141938b5bf8321c452548b295f0cb821..9f5c9545a6305157ffaac04e9af71edd56bc3bdc 100755 (executable)
@@ -133,27 +133,15 @@ def java_c_types(fn_arg, ret_arr_len):
     rust_obj = None
     arr_access = None
     java_hu_ty = None
-    if fn_arg.startswith("LDKPaymentPreimage") or fn_arg.startswith("LDKPaymentSecret") or fn_arg.startswith("LDKPaymentHash") or fn_arg.startswith("LDKChainHash"):
-        if fn_arg.startswith("LDKPaymentPreimage"):
-            fn_arg = "uint8_t (*" + fn_arg[19:] + ")[32]"
-        elif fn_arg.startswith("LDKPaymentSecret"):
-            fn_arg = "uint8_t (*" + fn_arg[17:] + ")[32]"
-        elif fn_arg.startswith("LDKPaymentHash"):
-            fn_arg = "uint8_t (*" + fn_arg[15:] + ")[32]"
-        elif fn_arg.startswith("LDKChainHash"):
-            fn_arg = "uint8_t (*" + fn_arg[13:] + ")[32]"
-        assert var_is_arr_regex.match(fn_arg[8:])
-        rust_obj = "LDKThirtyTwoBytes"
-        arr_access = "data"
-    elif fn_arg.startswith("LDKThirtyTwoBytes"):
+    if fn_arg.startswith("LDKThirtyTwoBytes"):
         fn_arg = "uint8_t (*" + fn_arg[18:] + ")[32]"
         assert var_is_arr_regex.match(fn_arg[8:])
         rust_obj = "LDKThirtyTwoBytes"
         arr_access = "data"
-    elif fn_arg.startswith("LDKEightU16s"):
-        fn_arg = "uint16_t (*" + fn_arg[13:] + ")[8]"
+    elif fn_arg.startswith("LDKThirtyTwoU16s"):
+        fn_arg = "uint16_t (*" + fn_arg[17:] + ")[32]"
         assert var_is_arr_regex.match(fn_arg[9:])
-        rust_obj = "LDKEightU16s"
+        rust_obj = "LDKThirtyTwoU16s"
         arr_access = "data"
     elif fn_arg.startswith("LDKU128"):
         if fn_arg == "LDKU128":
@@ -165,11 +153,6 @@ def java_c_types(fn_arg, ret_arr_len):
         assert var_is_arr_regex.match(fn_arg[8:])
         rust_obj = "LDKU128"
         arr_access = "le_bytes"
-    elif fn_arg.startswith("LDKTxid"):
-        fn_arg = "uint8_t (*" + fn_arg[8:] + ")[32]"
-        assert var_is_arr_regex.match(fn_arg[8:])
-        rust_obj = "LDKThirtyTwoBytes"
-        arr_access = "data"
     elif fn_arg.startswith("LDKPublicKey"):
         fn_arg = "uint8_t (*" + fn_arg[13:] + ")[33]"
         assert var_is_arr_regex.match(fn_arg[8:])
@@ -180,10 +163,15 @@ def java_c_types(fn_arg, ret_arr_len):
         assert var_is_arr_regex.match(fn_arg[8:])
         rust_obj = "LDKSecretKey"
         arr_access = "bytes"
-    elif fn_arg.startswith("LDKSignature"):
-        fn_arg = "uint8_t (*" + fn_arg[13:] + ")[64]"
+    elif fn_arg.startswith("LDKECDSASignature"):
+        fn_arg = "uint8_t (*" + fn_arg[18:] + ")[64]"
         assert var_is_arr_regex.match(fn_arg[8:])
-        rust_obj = "LDKSignature"
+        rust_obj = "LDKECDSASignature"
+        arr_access = "compact_form"
+    elif fn_arg.startswith("LDKSchnorrSignature"):
+        fn_arg = "uint8_t (*" + fn_arg[20:] + ")[64]"
+        assert var_is_arr_regex.match(fn_arg[8:])
+        rust_obj = "LDKSchnorrSignature"
         arr_access = "compact_form"
     elif fn_arg.startswith("LDKRecoverableSignature"):
         fn_arg = "uint8_t (*" + fn_arg[24:] + ")[68]"
@@ -230,6 +218,9 @@ def java_c_types(fn_arg, ret_arr_len):
         rust_obj = "LDKTransaction"
         assert var_is_arr_regex.match(fn_arg[8:])
         arr_access = "data"
+    elif fn_arg.startswith("LDKTransactionOutputs "):
+        fn_arg = "C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ"
+        rust_obj = "C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ"
     elif fn_arg.startswith("LDKWitness ") or fn_arg == "LDKWitness":
         if len(fn_arg) > 12 and fn_arg[11] == "*":
             fn_arg = "uint8_t (" + fn_arg[11:] + ")[datalen]"
@@ -334,6 +325,14 @@ def java_c_types(fn_arg, ret_arr_len):
         fn_ty_arg = "J"
         fn_arg = fn_arg[7:].strip()
         is_primitive = True
+    elif fn_arg.startswith("double"):
+        mapped_type = consts.c_type_map['double']
+        java_ty = mapped_type[0]
+        c_ty = "double"
+        arr_ty = "double"
+        fn_ty_arg = "D"
+        fn_arg = fn_arg[6:].strip()
+        is_primitive = True
     elif fn_arg.startswith("uint64_t") or fn_arg.startswith("uintptr_t"):
         # TODO: uintptr_t is arch-dependent :(
         mapped_type = consts.c_type_map['uint64_t']
index d12237fe8a4bbbc4ca75dfdab45ce3bad610a5e2..c3e4cb32d9c9d978fdc24ab43a4dc482d8c56ea7 100644 (file)
@@ -18,6 +18,7 @@ class Consts:
             uint32_t = ['int'],
             uint64_t = ['long'],
             int64_t = ['long'],
+            double = ['double'],
         )
         self.java_type_map = dict(
             String = "String"
index ce229cbee5e7881e581e9d8dda9c7f29fc305be3..b9f63b386a9888aac8bc7fa2a47c4ae394ddb53e 100644 (file)
@@ -23,6 +23,7 @@ class Consts:
             uint32_t = ['number', 'number', 'Uint32Array'],
             int64_t = ['bigint', 'bigint', 'BigInt64Array'],
             uint64_t = ['bigint', 'bigint', 'BigUint64Array'],
+            double = ['number', 'number', 'Float64Array'],
         )
         self.java_type_map = dict(
             String = "number"