@@ -147,7 +147,7 @@ pub fn export_status(attrs: &[syn::Attribute]) -> ExportStatus {
147
147
}
148
148
149
149
pub fn assert_simple_bound ( bound : & syn:: TraitBound ) {
150
- if bound. paren_token . is_some ( ) || bound . lifetimes . is_some ( ) { unimplemented ! ( ) ; }
150
+ if bound. paren_token . is_some ( ) { unimplemented ! ( ) ; }
151
151
if let syn:: TraitBoundModifier :: Maybe ( _) = bound. modifier { unimplemented ! ( ) ; }
152
152
}
153
153
@@ -936,6 +936,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
936
936
"bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some ( "crate::c_types::RecoverableSignature" ) ,
937
937
"bitcoin::secp256k1::SecretKey" if is_ref => Some ( "*const [u8; 32]" ) ,
938
938
"bitcoin::secp256k1::SecretKey" if !is_ref => Some ( "crate::c_types::SecretKey" ) ,
939
+ "bitcoin::secp256k1::Scalar" if is_ref => Some ( "*const crate::c_types::BigEndianScalar" ) ,
940
+ "bitcoin::secp256k1::Scalar" if !is_ref => Some ( "crate::c_types::BigEndianScalar" ) ,
941
+ "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some ( "crate::c_types::ThirtyTwoBytes" ) ,
942
+
939
943
"bitcoin::blockdata::script::Script" if is_ref => Some ( "crate::c_types::u8slice" ) ,
940
944
"bitcoin::blockdata::script::Script" if !is_ref => Some ( "crate::c_types::derived::CVec_u8Z" ) ,
941
945
"bitcoin::blockdata::transaction::OutPoint" => Some ( "crate::lightning::chain::transaction::OutPoint" ) ,
@@ -1021,6 +1025,9 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
1021
1025
"bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some ( "" ) ,
1022
1026
"bitcoin::secp256k1::SecretKey" if is_ref => Some ( "&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *" ) ,
1023
1027
"bitcoin::secp256k1::SecretKey" if !is_ref => Some ( "" ) ,
1028
+ "bitcoin::secp256k1::Scalar" if !is_ref => Some ( "" ) ,
1029
+ "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some ( "::bitcoin::secp256k1::ecdh::SharedSecret::from_bytes(" ) ,
1030
+
1024
1031
"bitcoin::blockdata::script::Script" if is_ref => Some ( "&::bitcoin::blockdata::script::Script::from(Vec::from(" ) ,
1025
1032
"bitcoin::blockdata::script::Script" if !is_ref => Some ( "::bitcoin::blockdata::script::Script::from(" ) ,
1026
1033
"bitcoin::blockdata::transaction::Transaction" |"bitcoin::Transaction" if is_ref => Some ( "&" ) ,
@@ -1104,6 +1111,9 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
1104
1111
"bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some ( ".into_rust()" ) ,
1105
1112
"bitcoin::secp256k1::SecretKey" if !is_ref => Some ( ".into_rust()" ) ,
1106
1113
"bitcoin::secp256k1::SecretKey" if is_ref => Some ( "}[..]).unwrap()" ) ,
1114
+ "bitcoin::secp256k1::Scalar" if !is_ref => Some ( ".into_rust()" ) ,
1115
+ "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some ( ".data)" ) ,
1116
+
1107
1117
"bitcoin::blockdata::script::Script" if is_ref => Some ( ".to_slice()))" ) ,
1108
1118
"bitcoin::blockdata::script::Script" if !is_ref => Some ( ".into_rust())" ) ,
1109
1119
"bitcoin::blockdata::transaction::Transaction" |"bitcoin::Transaction" => Some ( ".into_bitcoin()" ) ,
@@ -1196,6 +1206,9 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
1196
1206
"bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some ( "crate::c_types::RecoverableSignature::from_rust(&" ) ,
1197
1207
"bitcoin::secp256k1::SecretKey" if is_ref => Some ( "" ) ,
1198
1208
"bitcoin::secp256k1::SecretKey" if !is_ref => Some ( "crate::c_types::SecretKey::from_rust(" ) ,
1209
+ "bitcoin::secp256k1::Scalar" if !is_ref => Some ( "crate::c_types::BigEndianScalar::from_rust(" ) ,
1210
+ "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some ( "crate::c_types::ThirtyTwoBytes { data: " ) ,
1211
+
1199
1212
"bitcoin::blockdata::script::Script" if is_ref => Some ( "crate::c_types::u8slice::from_slice(&" ) ,
1200
1213
"bitcoin::blockdata::script::Script" if !is_ref => Some ( "" ) ,
1201
1214
"bitcoin::blockdata::transaction::Transaction" |"bitcoin::Transaction" if is_ref => Some ( "crate::c_types::Transaction::from_bitcoin(" ) ,
@@ -1273,6 +1286,9 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
1273
1286
"bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some ( ")" ) ,
1274
1287
"bitcoin::secp256k1::SecretKey" if !is_ref => Some ( ")" ) ,
1275
1288
"bitcoin::secp256k1::SecretKey" if is_ref => Some ( ".as_ref()" ) ,
1289
+ "bitcoin::secp256k1::Scalar" if !is_ref => Some ( ")" ) ,
1290
+ "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some ( ".secret_bytes() }" ) ,
1291
+
1276
1292
"bitcoin::blockdata::script::Script" if is_ref => Some ( "[..])" ) ,
1277
1293
"bitcoin::blockdata::script::Script" if !is_ref => Some ( ".into_bytes().into()" ) ,
1278
1294
"bitcoin::blockdata::transaction::Transaction" |"bitcoin::Transaction" => Some ( ")" ) ,
@@ -1381,7 +1397,19 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
1381
1397
if let Some ( resolved) = self . maybe_resolve_path ( & p. path , generics) {
1382
1398
if self . c_type_has_inner_from_path ( & resolved) { return true ; }
1383
1399
if self . is_primitive ( & resolved) { return false ; }
1384
- if self . c_type_from_path ( & resolved, false , false ) . is_some ( ) { true } else { false }
1400
+ // We want to move to using `Option_` mappings where possible rather than
1401
+ // manual mappings, as it makes downstream bindings simpler and is more
1402
+ // clear for users. Thus, we default to false but override for a few
1403
+ // types which had mappings defined when we were avoiding the `Option_`s.
1404
+ match & resolved as & str {
1405
+ "lightning::ln::PaymentSecret" => true ,
1406
+ "lightning::ln::PaymentHash" => true ,
1407
+ "lightning::ln::PaymentPreimage" => true ,
1408
+ "lightning::ln::channelmanager::PaymentId" => true ,
1409
+ "bitcoin::hash_types::BlockHash" => true ,
1410
+ "secp256k1::PublicKey" |"bitcoin::secp256k1::PublicKey" => true ,
1411
+ _ => false ,
1412
+ }
1385
1413
} else { unimplemented ! ( ) ; }
1386
1414
} ,
1387
1415
syn:: Type :: Tuple ( _) => false ,
@@ -1456,7 +1484,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
1456
1484
( ".is_none() { core::ptr::null_mut() } else { " . to_owned( ) , format!( "({}.unwrap())" , var_access) )
1457
1485
] , " }" , ContainerPrefixLocation :: OutsideConv ) ) ;
1458
1486
}
1459
- } else if self . is_primitive ( & inner_path ) || self . c_type_from_path ( & inner_path , false , false ) . is_none ( ) {
1487
+ } else if ! self . is_transparent_container ( "Option" , is_ref , [ single_contained . unwrap ( ) ] . iter ( ) . map ( |a| * a ) , generics ) {
1460
1488
if self . is_primitive ( & inner_path) || ( !is_contained_ref && !is_ref) || only_contained_has_inner {
1461
1489
let inner_name = self . get_c_mangled_container_type ( vec ! [ single_contained. unwrap( ) ] , generics, "Option" ) . unwrap ( ) ;
1462
1490
return Some ( ( "if " , vec ! [
0 commit comments