From: Matt Corallo Date: Sun, 1 Oct 2023 18:41:49 +0000 (+0000) Subject: Update type listing for LDK 0.0.117 bindings and support doubles X-Git-Tag: v0.0.117.0~14 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=997a742c60ecadf6667779d409e0b35e03521c0d;p=ldk-java Update type listing for LDK 0.0.117 bindings and support doubles --- diff --git a/csharp_strings.py b/csharp_strings.py index ac686bcc..b5f816ed 100644 --- a/csharp_strings.py +++ b/csharp_strings.py @@ -16,6 +16,7 @@ class Consts: uint32_t = ['int'], uint64_t = ['long'], int64_t = ['long'], + double = ['double'], ) self.java_type_map = dict( String = "string" diff --git a/genbindings.py b/genbindings.py index e8ddb657..9f5c9545 100755 --- a/genbindings.py +++ b/genbindings.py @@ -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'] diff --git a/java_strings.py b/java_strings.py index d12237fe..c3e4cb32 100644 --- a/java_strings.py +++ b/java_strings.py @@ -18,6 +18,7 @@ class Consts: uint32_t = ['int'], uint64_t = ['long'], int64_t = ['long'], + double = ['double'], ) self.java_type_map = dict( String = "String" diff --git a/typescript_strings.py b/typescript_strings.py index ce229cbe..b9f63b38 100644 --- a/typescript_strings.py +++ b/typescript_strings.py @@ -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"