X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c-bindings-gen%2Fsrc%2Ftypes.rs;h=029fc63f807b721c9add26e21488d69c86f9c62c;hb=8dc4d5c556cafa326969474c17f34c77e8abcc0c;hp=a678e7ad20cec973ce165dcf981ae0a2a1de5037;hpb=74572ba409540b7a311767ef50c759627e0d7b0d;p=ldk-c-bindings diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index a678e7a..029fc63 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -668,7 +668,7 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr // Now that we've resolved the path to the path as-imported, check whether the path // is actually a pub(.*) use statement and map it to the real path. let path_tmp = path.clone(); - let crate_name = path_tmp.splitn(1, "::").next().unwrap(); + let crate_name = path_tmp.splitn(2, "::").next().unwrap(); let mut module_riter = path_tmp.rsplitn(2, "::"); let obj = module_riter.next().unwrap(); if let Some(module_path) = module_riter.next() { @@ -808,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()); @@ -1006,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"), @@ -1024,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"), @@ -1095,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(""), @@ -1122,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 { *"), @@ -1182,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()"), @@ -1198,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): @@ -1280,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("), @@ -1296,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("), @@ -1360,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(")"), @@ -1376,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("))"), @@ -2359,7 +2377,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { write!(w, "let mut local_{}{} = ", ident, if (!to_c && needs_ref_map) || (to_c && $container_type == "Option" && contains_slice) {"_base"} else { "" }).unwrap(); if prefix_location == ContainerPrefixLocation::OutsideConv { - var_prefix(w, $args_iter().next().unwrap(), generics, is_ref, ptr_for_ref, true); + var_prefix(w, $args_iter().next().unwrap(), generics, is_ref, true, true); } write!(w, "{}{}", prefix, var).unwrap();