X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c-bindings-gen%2Fsrc%2Ftypes.rs;h=b13db9e648b91f0534733961a5e56d599ecd2a42;hb=c7b284ef5deb5af4b99e64b7c7e1b7d01d7ae33b;hp=5ced9104b030b44aa78fb6a7586565491cdf9a48;hpb=5f056966b2acfa789bcbd575abc657b06d91f68e;p=ldk-c-bindings diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index 5ced910..b13db9e 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -539,6 +539,7 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr let mut imports = HashMap::new(); // Add primitives to the "imports" list: Self::insert_primitive(&mut imports, "bool"); + Self::insert_primitive(&mut imports, "u128"); Self::insert_primitive(&mut imports, "u64"); Self::insert_primitive(&mut imports, "u32"); Self::insert_primitive(&mut imports, "u16"); @@ -797,7 +798,8 @@ impl FullLibraryAST { /// List of manually-generated types which are clonable fn initial_clonable_types() -> HashSet { let mut res = HashSet::new(); - res.insert("crate::c_types::u5".to_owned()); + res.insert("crate::c_types::U5".to_owned()); + res.insert("crate::c_types::U128".to_owned()); res.insert("crate::c_types::FourBytes".to_owned()); res.insert("crate::c_types::TwelveBytes".to_owned()); res.insert("crate::c_types::SixteenBytes".to_owned()); @@ -806,6 +808,7 @@ fn initial_clonable_types() -> HashSet { res.insert("crate::c_types::SecretKey".to_owned()); res.insert("crate::c_types::PublicKey".to_owned()); res.insert("crate::c_types::Transaction".to_owned()); + res.insert("crate::c_types::Witness".to_owned()); res.insert("crate::c_types::TxOut".to_owned()); res.insert("crate::c_types::Signature".to_owned()); res.insert("crate::c_types::RecoverableSignature".to_owned()); @@ -987,7 +990,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "core::num::ParseIntError" => Some("crate::c_types::Error"), "core::str::Utf8Error" => Some("crate::c_types::Error"), - "bitcoin::bech32::u5"|"bech32::u5" => Some("crate::c_types::u5"), + "bitcoin::bech32::u5"|"bech32::u5" => Some("crate::c_types::U5"), + "u128" => Some("crate::c_types::U128"), "core::num::NonZeroU8" => Some("u8"), "secp256k1::PublicKey"|"bitcoin::secp256k1::PublicKey" => Some("crate::c_types::PublicKey"), @@ -1003,6 +1007,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::blockdata::script::Script" if !is_ref => Some("crate::c_types::derived::CVec_u8Z"), "bitcoin::blockdata::transaction::OutPoint" => Some("crate::lightning::chain::transaction::OutPoint"), "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some("crate::c_types::Transaction"), + "bitcoin::Witness" => Some("crate::c_types::Witness"), "bitcoin::blockdata::transaction::TxOut" if !is_ref => Some("crate::c_types::TxOut"), "bitcoin::network::constants::Network" => Some("crate::bitcoin::network::Network"), "bitcoin::util::address::WitnessVersion" => Some("crate::c_types::WitnessVersion"), @@ -1021,10 +1026,12 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { if !is_ref => Some("crate::c_types::ThirtyTwoBytes"), "bitcoin::secp256k1::Message" if !is_ref => Some("crate::c_types::ThirtyTwoBytes"), "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" - |"lightning::ln::channelmanager::PaymentId"|"lightning::chain::keysinterface::KeyMaterial" + |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" + |"lightning::chain::keysinterface::KeyMaterial" if is_ref => Some("*const [u8; 32]"), "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" - |"lightning::ln::channelmanager::PaymentId"|"lightning::chain::keysinterface::KeyMaterial" + |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" + |"lightning::chain::keysinterface::KeyMaterial" if !is_ref => Some("crate::c_types::ThirtyTwoBytes"), "lightning::io::Read" => Some("crate::c_types::u8slice"), @@ -1075,6 +1082,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "std::time::SystemTime" => Some("(::std::time::SystemTime::UNIX_EPOCH + std::time::Duration::from_secs("), "bitcoin::bech32::u5"|"bech32::u5" => Some(""), + "u128" => Some(""), "core::num::NonZeroU8" => Some("core::num::NonZeroU8::new("), "bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" if is_ref => Some("&"), @@ -1091,6 +1099,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::blockdata::script::Script" if !is_ref => Some("::bitcoin::blockdata::script::Script::from("), "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" if is_ref => Some("&"), "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some(""), + "bitcoin::Witness" if is_ref => Some("&"), + "bitcoin::Witness" => Some(""), "bitcoin::blockdata::transaction::OutPoint" => Some("crate::c_types::C_to_bitcoin_outpoint("), "bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(""), "bitcoin::network::constants::Network" => Some(""), @@ -1118,6 +1128,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "lightning::ln::PaymentSecret" if !is_ref => Some("::lightning::ln::PaymentSecret("), "lightning::ln::channelmanager::PaymentId" if !is_ref => Some("::lightning::ln::channelmanager::PaymentId("), "lightning::ln::channelmanager::PaymentId" if is_ref=> Some("&::lightning::ln::channelmanager::PaymentId( unsafe { *"), + "lightning::ln::channelmanager::InterceptId" if !is_ref => Some("::lightning::ln::channelmanager::InterceptId("), + "lightning::ln::channelmanager::InterceptId" if is_ref=> Some("&::lightning::ln::channelmanager::InterceptId( unsafe { *"), "lightning::chain::keysinterface::KeyMaterial" if !is_ref => Some("::lightning::chain::keysinterface::KeyMaterial("), "lightning::chain::keysinterface::KeyMaterial" if is_ref=> Some("&::lightning::chain::keysinterface::KeyMaterial( unsafe { *"), @@ -1164,6 +1176,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "std::time::SystemTime" => Some("))"), "bitcoin::bech32::u5"|"bech32::u5" => Some(".into()"), + "u128" => Some(".into()"), "core::num::NonZeroU8" => Some(").expect(\"Value must be non-zero\")"), "bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" => Some(".into_rust()"), @@ -1177,6 +1190,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::blockdata::script::Script" if is_ref => Some(".to_slice()))"), "bitcoin::blockdata::script::Script" if !is_ref => Some(".into_rust())"), "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some(".into_bitcoin()"), + "bitcoin::Witness" => Some(".into_bitcoin()"), "bitcoin::blockdata::transaction::OutPoint" => Some(")"), "bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(".into_rust()"), "bitcoin::network::constants::Network" => Some(".into_bitcoin()"), @@ -1193,10 +1207,12 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::hash_types::Txid" => Some(".data[..]).unwrap()"), "bitcoin::hash_types::BlockHash" if !is_ref => Some(".data[..]).unwrap()"), "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" - |"lightning::ln::channelmanager::PaymentId"|"lightning::chain::keysinterface::KeyMaterial" + |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" + |"lightning::chain::keysinterface::KeyMaterial" if !is_ref => Some(".data)"), "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" - |"lightning::ln::channelmanager::PaymentId"|"lightning::chain::keysinterface::KeyMaterial" + |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" + |"lightning::chain::keysinterface::KeyMaterial" if is_ref => Some(" })"), // List of traits we map (possibly during processing of other files): @@ -1261,6 +1277,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "core::str::Utf8Error" => Some("crate::c_types::Error { _dummy: 0 } /*"), "bitcoin::bech32::u5"|"bech32::u5" => Some(""), + "u128" => Some(""), "bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" => Some("crate::c_types::PublicKey::from_rust(&"), "bitcoin::secp256k1::ecdsa::Signature" => Some("crate::c_types::Signature::from_rust(&"), @@ -1274,6 +1291,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::blockdata::script::Script" if !is_ref => Some(""), "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" if is_ref => Some("crate::c_types::Transaction::from_bitcoin("), "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some("crate::c_types::Transaction::from_bitcoin(&"), + "bitcoin::Witness" if is_ref => Some("crate::c_types::Witness::from_bitcoin("), + "bitcoin::Witness" if !is_ref => Some("crate::c_types::Witness::from_bitcoin(&"), "bitcoin::blockdata::transaction::OutPoint" => Some("crate::c_types::bitcoin_to_C_outpoint("), "bitcoin::blockdata::transaction::TxOut" if !is_ref => Some("crate::c_types::TxOut::from_rust("), "bitcoin::network::constants::Network" => Some("crate::bitcoin::network::Network::from_bitcoin("), @@ -1290,10 +1309,12 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "), "bitcoin::secp256k1::Message" if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "), "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" - |"lightning::ln::channelmanager::PaymentId"|"lightning::chain::keysinterface::KeyMaterial" + |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" + |"lightning::chain::keysinterface::KeyMaterial" if is_ref => Some("&"), "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" - |"lightning::ln::channelmanager::PaymentId"|"lightning::chain::keysinterface::KeyMaterial" + |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" + |"lightning::chain::keysinterface::KeyMaterial" if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "), "lightning::io::Read" => Some("crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec("), @@ -1341,6 +1362,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "core::str::Utf8Error" => Some("*/"), "bitcoin::bech32::u5"|"bech32::u5" => Some(".into()"), + "u128" => Some(".into()"), "bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" => Some(")"), "bitcoin::secp256k1::ecdsa::Signature" => Some(")"), @@ -1353,6 +1375,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::blockdata::script::Script" if is_ref => Some("[..])"), "bitcoin::blockdata::script::Script" if !is_ref => Some(".into_bytes().into()"), "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some(")"), + "bitcoin::Witness" => Some(")"), "bitcoin::blockdata::transaction::OutPoint" => Some(")"), "bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(")"), "bitcoin::network::constants::Network" => Some(")"), @@ -1369,10 +1392,12 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { if !is_ref => Some(".into_inner() }"), "bitcoin::secp256k1::Message" if !is_ref => Some(".as_ref().clone() }"), "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" - |"lightning::ln::channelmanager::PaymentId"|"lightning::chain::keysinterface::KeyMaterial" + |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" + |"lightning::chain::keysinterface::KeyMaterial" if is_ref => Some(".0"), "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" - |"lightning::ln::channelmanager::PaymentId"|"lightning::chain::keysinterface::KeyMaterial" + |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" + |"lightning::chain::keysinterface::KeyMaterial" if !is_ref => Some(".0 }"), "lightning::io::Read" => Some("))"),