Skip to content

Commit f5d2c73

Browse files
committed
Update hard-coded type definitions
1 parent a200dc3 commit f5d2c73

File tree

1 file changed

+41
-33
lines changed

1 file changed

+41
-33
lines changed

c-bindings-gen/src/types.rs

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
10711071
"bitcoin::bech32::u5"|"bech32::u5" => Some("crate::c_types::U5"),
10721072
"u128" => Some("crate::c_types::U128"),
10731073
"core::num::NonZeroU8" => Some("u8"),
1074+
"core::num::NonZeroU64" => Some("u64"),
10741075

10751076
"secp256k1::PublicKey"|"bitcoin::secp256k1::PublicKey" => Some("crate::c_types::PublicKey"),
10761077
"bitcoin::key::TweakedPublicKey" => Some("crate::c_types::TweakedPublicKey"),
@@ -1113,21 +1114,21 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
11131114
if is_ref => Some("*const [u8; 32]"),
11141115

11151116
// Newtypes that we just expose in their original form.
1116-
"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"
1117+
"bitcoin::Txid"|"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"
11171118
if is_ref => Some("*const [u8; 32]"),
1118-
"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"
1119+
"bitcoin::Txid"|"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"|"bitcoin::hashes::sha256::Hash"
11191120
if !is_ref => Some("crate::c_types::ThirtyTwoBytes"),
11201121
"bitcoin::secp256k1::Message" if !is_ref => Some("crate::c_types::ThirtyTwoBytes"),
11211122
"bitcoin::secp256k1::Message" if is_ref => Some("*const [u8; 32]"),
1122-
"lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret"
1123+
"lightning::ln::types::PaymentHash"|"lightning::ln::types::PaymentPreimage"
1124+
|"lightning::ln::types::PaymentSecret"
11231125
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
11241126
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
1125-
|"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId"
11261127
if is_ref => Some("*const [u8; 32]"),
1127-
"lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret"
1128+
"lightning::ln::types::PaymentHash"|"lightning::ln::types::PaymentPreimage"
1129+
|"lightning::ln::types::PaymentSecret"
11281130
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
11291131
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
1130-
|"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId"
11311132
if !is_ref => Some("crate::c_types::ThirtyTwoBytes"),
11321133

11331134
"lightning::io::Read" => Some("crate::c_types::u8slice"),
@@ -1182,6 +1183,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
11821183
"bitcoin::bech32::u5"|"bech32::u5" => Some(""),
11831184
"u128" => Some(""),
11841185
"core::num::NonZeroU8" => Some("core::num::NonZeroU8::new("),
1186+
"core::num::NonZeroU64" => Some("core::num::NonZeroU64::new("),
11851187

11861188
"bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" if is_ref => Some("&"),
11871189
"bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" => Some(""),
@@ -1231,21 +1233,21 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
12311233
Some("&bitcoin::hash_types::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *"),
12321234

12331235
// Newtypes that we just expose in their original form.
1234-
"bitcoin::hash_types::Txid" if is_ref => Some("&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*"),
1235-
"bitcoin::hash_types::Txid" if !is_ref => Some("::bitcoin::hash_types::Txid::from_slice(&"),
1236+
"bitcoin::Txid"|"bitcoin::hash_types::Txid" if is_ref => Some("&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*"),
1237+
"bitcoin::Txid"|"bitcoin::hash_types::Txid" if !is_ref => Some("::bitcoin::hash_types::Txid::from_slice(&"),
12361238
"bitcoin::hash_types::BlockHash"|"bitcoin::BlockHash" => Some("::bitcoin::hash_types::BlockHash::from_slice(&"),
12371239
"bitcoin::blockdata::constants::ChainHash" => Some("::bitcoin::blockdata::constants::ChainHash::from(&"),
1238-
"lightning::ln::PaymentHash" if !is_ref => Some("::lightning::ln::PaymentHash("),
1239-
"lightning::ln::PaymentHash" if is_ref => Some("&::lightning::ln::PaymentHash(unsafe { *"),
1240-
"lightning::ln::PaymentPreimage" if !is_ref => Some("::lightning::ln::PaymentPreimage("),
1241-
"lightning::ln::PaymentPreimage" if is_ref => Some("&::lightning::ln::PaymentPreimage(unsafe { *"),
1242-
"lightning::ln::PaymentSecret" if !is_ref => Some("::lightning::ln::PaymentSecret("),
1240+
"bitcoin::hashes::sha256::Hash" if is_ref => Some("&::bitcoin::hashes::sha256::Hash::from_slice(&unsafe { &*"),
1241+
"bitcoin::hashes::sha256::Hash" => Some("::bitcoin::hashes::sha256::Hash::from_slice(&"),
1242+
"lightning::ln::types::PaymentHash" if !is_ref => Some("::lightning::ln::types::PaymentHash("),
1243+
"lightning::ln::types::PaymentHash" if is_ref => Some("&::lightning::ln::types::PaymentHash(unsafe { *"),
1244+
"lightning::ln::types::PaymentPreimage" if !is_ref => Some("::lightning::ln::types::PaymentPreimage("),
1245+
"lightning::ln::types::PaymentPreimage" if is_ref => Some("&::lightning::ln::types::PaymentPreimage(unsafe { *"),
1246+
"lightning::ln::types::PaymentSecret" if !is_ref => Some("::lightning::ln::types::PaymentSecret("),
12431247
"lightning::ln::channelmanager::PaymentId" if !is_ref => Some("::lightning::ln::channelmanager::PaymentId("),
12441248
"lightning::ln::channelmanager::PaymentId" if is_ref=> Some("&::lightning::ln::channelmanager::PaymentId( unsafe { *"),
12451249
"lightning::ln::channelmanager::InterceptId" if !is_ref => Some("::lightning::ln::channelmanager::InterceptId("),
12461250
"lightning::ln::channelmanager::InterceptId" if is_ref=> Some("&::lightning::ln::channelmanager::InterceptId( unsafe { *"),
1247-
"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId" if !is_ref => Some("::lightning::ln::ChannelId("),
1248-
"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId" if is_ref => Some("&::lightning::ln::ChannelId(unsafe { *"),
12491251
"lightning::sign::KeyMaterial" if !is_ref => Some("::lightning::sign::KeyMaterial("),
12501252
"lightning::sign::KeyMaterial" if is_ref=> Some("&::lightning::sign::KeyMaterial( unsafe { *"),
12511253
"lightning::chain::ClaimId" if !is_ref => Some("::lightning::chain::ClaimId("),
@@ -1299,6 +1301,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
12991301
"bitcoin::bech32::u5"|"bech32::u5" => Some(".into()"),
13001302
"u128" => Some(".into()"),
13011303
"core::num::NonZeroU8" => Some(").expect(\"Value must be non-zero\")"),
1304+
"core::num::NonZeroU64" => Some(").expect(\"Value must be non-zero\")"),
13021305

13031306
"bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" => Some(".into_rust()"),
13041307
"bitcoin::key::TweakedPublicKey" => Some(".into_rust()"),
@@ -1337,19 +1340,20 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
13371340
if is_ref => Some(" }.clone()))"),
13381341

13391342
// Newtypes that we just expose in their original form.
1340-
"bitcoin::hash_types::Txid" if is_ref => Some(" }[..]).unwrap()"),
1341-
"bitcoin::hash_types::Txid" => Some(".data[..]).unwrap()"),
1343+
"bitcoin::Txid"|"bitcoin::hash_types::Txid" if is_ref => Some(" }[..]).unwrap()"),
1344+
"bitcoin::Txid"|"bitcoin::hash_types::Txid" => Some(".data[..]).unwrap()"),
13421345
"bitcoin::hash_types::BlockHash"|"bitcoin::BlockHash" if !is_ref => Some(".data[..]).unwrap()"),
13431346
"bitcoin::blockdata::constants::ChainHash" if !is_ref => Some(".data)"),
1344-
"lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret"
1347+
"bitcoin::hashes::sha256::Hash" => Some(" }[..]).unwrap()"),
1348+
"lightning::ln::types::PaymentHash"|"lightning::ln::types::PaymentPreimage"
1349+
|"lightning::ln::types::PaymentSecret"
13451350
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
13461351
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
1347-
|"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId"
13481352
if !is_ref => Some(".data)"),
1349-
"lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret"
1353+
"lightning::ln::types::PaymentHash"|"lightning::ln::types::PaymentPreimage"
1354+
|"lightning::ln::types::PaymentSecret"
13501355
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
13511356
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
1352-
|"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId"
13531357
if is_ref => Some(" })"),
13541358

13551359
// List of traits we map (possibly during processing of other files):
@@ -1389,6 +1393,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
13891393
"[u8; 16]" if !is_ref => Some("crate::c_types::SixteenBytes { data: "),
13901394
"[u8; 12]" if !is_ref => Some("crate::c_types::TwelveBytes { data: "),
13911395
"[u8; 4]" if !is_ref => Some("crate::c_types::FourBytes { data: "),
1396+
"[u8; 3]" if !is_ref => Some("crate::c_types::ThreeBytes { data: "),
13921397
"[u8; 3]" if is_ref => Some(""),
13931398
"[u16; 32]" if !is_ref => Some("crate::c_types::ThirtyTwoU16s { data: "),
13941399

@@ -1418,6 +1423,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
14181423

14191424
"bitcoin::bech32::u5"|"bech32::u5" => Some(""),
14201425
"u128" => Some(""),
1426+
"core::num::NonZeroU64" => Some(""),
14211427

14221428
"bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" => Some("crate::c_types::PublicKey::from_rust(&"),
14231429
"bitcoin::key::TweakedPublicKey" => Some("crate::c_types::TweakedPublicKey::from_rust(&"),
@@ -1457,21 +1463,21 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
14571463
if !is_ref => Some("crate::c_types::TwentyBytes { data: *"),
14581464

14591465
// Newtypes that we just expose in their original form.
1460-
"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"
1466+
"bitcoin::Txid"|"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"|"bitcoin::hashes::sha256::Hash"
14611467
if is_ref => Some(""),
1462-
"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"
1468+
"bitcoin::Txid"|"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"|"bitcoin::hashes::sha256::Hash"
14631469
if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: *"),
14641470
"bitcoin::secp256k1::Message" if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "),
14651471
"bitcoin::secp256k1::Message" if is_ref => Some(""),
1466-
"lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret"
1472+
"lightning::ln::types::PaymentHash"|"lightning::ln::types::PaymentPreimage"
1473+
|"lightning::ln::types::PaymentSecret"
14671474
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
14681475
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
1469-
|"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId"
14701476
if is_ref => Some("&"),
1471-
"lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret"
1477+
"lightning::ln::types::PaymentHash"|"lightning::ln::types::PaymentPreimage"
1478+
|"lightning::ln::types::PaymentSecret"
14721479
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
14731480
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
1474-
|"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId"
14751481
if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "),
14761482

14771483
"lightning::io::Read" => Some("crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec("),
@@ -1495,6 +1501,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
14951501
"[u8; 16]" if !is_ref => Some(" }"),
14961502
"[u8; 12]" if !is_ref => Some(" }"),
14971503
"[u8; 4]" if !is_ref => Some(" }"),
1504+
"[u8; 3]" if !is_ref => Some(" }"),
14981505
"[u8; 3]" if is_ref => Some(""),
14991506
"[u16; 32]" if !is_ref => Some(" }"),
15001507

@@ -1524,6 +1531,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
15241531

15251532
"bitcoin::bech32::u5"|"bech32::u5" => Some(".into()"),
15261533
"u128" => Some(".into()"),
1534+
"core::num::NonZeroU64" => Some(".into()"),
15271535

15281536
"bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" => Some(")"),
15291537
"bitcoin::key::TweakedPublicKey" => Some(")"),
@@ -1559,21 +1567,21 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
15591567
if !is_ref => Some(".as_ref() }"),
15601568

15611569
// Newtypes that we just expose in their original form.
1562-
"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"
1570+
"bitcoin::Txid"|"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"|"bitcoin::hashes::sha256::Hash"
15631571
if is_ref => Some(".as_ref()"),
1564-
"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"
1572+
"bitcoin::Txid"|"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash"|"bitcoin::hashes::sha256::Hash"
15651573
if !is_ref => Some(".as_ref() }"),
15661574
"bitcoin::secp256k1::Message" if !is_ref => Some(".as_ref().clone() }"),
15671575
"bitcoin::secp256k1::Message" if is_ref => Some(".as_ref()"),
1568-
"lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret"
1576+
"lightning::ln::types::PaymentHash"|"lightning::ln::types::PaymentPreimage"
1577+
|"lightning::ln::types::PaymentSecret"
15691578
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
15701579
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
1571-
|"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId"
15721580
if is_ref => Some(".0"),
1573-
"lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret"
1581+
"lightning::ln::types::PaymentHash"|"lightning::ln::types::PaymentPreimage"
1582+
|"lightning::ln::types::PaymentSecret"
15741583
|"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId"
15751584
|"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId"
1576-
|"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId"
15771585
if !is_ref => Some(".0 }"),
15781586

15791587
"lightning::io::Read" => Some("))"),

0 commit comments

Comments
 (0)