@@ -65,6 +65,15 @@ open class NativeTypeWrapper: Hashable {
65
65
66
66
}
67
67
68
+ open class NativeTraitWrapper : NativeTypeWrapper {
69
+
70
+ public func activate( ) -> Self {
71
+ Bindings . cacheInstance ( instance: self )
72
+ return self
73
+ }
74
+
75
+ }
76
+
68
77
public class Bindings {
69
78
70
79
internal static var minimumPrintSeverity : PrintSeverity = . WARNING
@@ -6233,7 +6242,7 @@ withUnsafePointer(to: network.cOpaqueStruct!) { (networkPointer: UnsafePointer<L
6233
6242
withUnsafePointer ( to: scorer. cOpaqueStruct!) { ( scorerPointer: UnsafePointer < LDKScore > ) in
6234
6243
withUnsafePointer ( to: Bindings . array_to_tuple32 ( array: random_seed_bytes) ) { ( random_seed_bytesPointer: UnsafePointer < ( UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 , UInt8 ) > ) in
6235
6244
6236
- Result_RouteLightningErrorZ ( pointer: find_route ( Bindings . new_LDKPublicKey ( array: our_node_pubkey) , route_paramsPointer, networkPointer, first_hopsPointer, logger. cOpaqueStruct!, scorerPointer, random_seed_bytesPointer) )
6245
+ Result_RouteLightningErrorZ ( pointer: find_route ( Bindings . new_LDKPublicKey ( array: our_node_pubkey) , route_paramsPointer, networkPointer, first_hopsPointer, logger. activate ( ) . cOpaqueStruct!, scorerPointer, random_seed_bytesPointer) )
6237
6246
6238
6247
}
6239
6248
}
@@ -6255,7 +6264,7 @@ withUnsafePointer(to: Bindings.array_to_tuple32(array: random_seed_bytes)) { (ra
6255
6264
}
6256
6265
6257
6266
return
6258
- Result_InvoiceSignOrCreationErrorZ ( pointer: create_phantom_invoice ( amt_msat. danglingClone ( ) . cOpaqueStruct!, Bindings . new_LDKStr ( string: description, chars_is_owned: true ) , Bindings . new_LDKThirtyTwoBytes ( array: payment_hash) , Bindings . new_LDKThirtyTwoBytes ( array: payment_secret) , phantom_route_hintsWrapper. dangle ( ) . cOpaqueStruct!, keys_manager. cOpaqueStruct!, network) )
6267
+ Result_InvoiceSignOrCreationErrorZ ( pointer: create_phantom_invoice ( amt_msat. danglingClone ( ) . cOpaqueStruct!, Bindings . new_LDKStr ( string: description, chars_is_owned: true ) , Bindings . new_LDKThirtyTwoBytes ( array: payment_hash) , Bindings . new_LDKThirtyTwoBytes ( array: payment_secret) , phantom_route_hintsWrapper. dangle ( ) . cOpaqueStruct!, keys_manager. activate ( ) . cOpaqueStruct!, network) )
6259
6268
6260
6269
6261
6270
}
@@ -6273,7 +6282,7 @@ withUnsafePointer(to: Bindings.array_to_tuple32(array: random_seed_bytes)) { (ra
6273
6282
}
6274
6283
6275
6284
return
6276
- Result_InvoiceSignOrCreationErrorZ ( pointer: create_phantom_invoice_with_description_hash ( amt_msat. danglingClone ( ) . cOpaqueStruct!, description_hash. danglingClone ( ) . cOpaqueStruct!, Bindings . new_LDKThirtyTwoBytes ( array: payment_hash) , Bindings . new_LDKThirtyTwoBytes ( array: payment_secret) , phantom_route_hintsWrapper. dangle ( ) . cOpaqueStruct!, keys_manager. cOpaqueStruct!, network) )
6285
+ Result_InvoiceSignOrCreationErrorZ ( pointer: create_phantom_invoice_with_description_hash ( amt_msat. danglingClone ( ) . cOpaqueStruct!, description_hash. danglingClone ( ) . cOpaqueStruct!, Bindings . new_LDKThirtyTwoBytes ( array: payment_hash) , Bindings . new_LDKThirtyTwoBytes ( array: payment_secret) , phantom_route_hintsWrapper. dangle ( ) . cOpaqueStruct!, keys_manager. activate ( ) . cOpaqueStruct!, network) )
6277
6286
6278
6287
6279
6288
}
@@ -6282,7 +6291,7 @@ withUnsafePointer(to: Bindings.array_to_tuple32(array: random_seed_bytes)) { (ra
6282
6291
6283
6292
return withUnsafePointer ( to: channelmanager. cOpaqueStruct!) { ( channelmanagerPointer: UnsafePointer < LDKChannelManager > ) in
6284
6293
6285
- Result_InvoiceSignOrCreationErrorZ ( pointer: create_invoice_from_channelmanager ( channelmanagerPointer, keys_manager. cOpaqueStruct!, network, amt_msat. danglingClone ( ) . cOpaqueStruct!, Bindings . new_LDKStr ( string: description, chars_is_owned: true ) ) )
6294
+ Result_InvoiceSignOrCreationErrorZ ( pointer: create_invoice_from_channelmanager ( channelmanagerPointer, keys_manager. activate ( ) . cOpaqueStruct!, network, amt_msat. danglingClone ( ) . cOpaqueStruct!, Bindings . new_LDKStr ( string: description, chars_is_owned: true ) ) )
6286
6295
6287
6296
}
6288
6297
@@ -6292,7 +6301,7 @@ withUnsafePointer(to: Bindings.array_to_tuple32(array: random_seed_bytes)) { (ra
6292
6301
6293
6302
return withUnsafePointer ( to: channelmanager. cOpaqueStruct!) { ( channelmanagerPointer: UnsafePointer < LDKChannelManager > ) in
6294
6303
6295
- Result_InvoiceSignOrCreationErrorZ ( pointer: create_invoice_from_channelmanager_with_description_hash ( channelmanagerPointer, keys_manager. cOpaqueStruct!, network, amt_msat. danglingClone ( ) . cOpaqueStruct!, description_hash. danglingClone ( ) . cOpaqueStruct!) )
6304
+ Result_InvoiceSignOrCreationErrorZ ( pointer: create_invoice_from_channelmanager_with_description_hash ( channelmanagerPointer, keys_manager. activate ( ) . cOpaqueStruct!, network, amt_msat. danglingClone ( ) . cOpaqueStruct!, description_hash. danglingClone ( ) . cOpaqueStruct!) )
6296
6305
6297
6306
}
6298
6307
@@ -6302,7 +6311,7 @@ withUnsafePointer(to: Bindings.array_to_tuple32(array: random_seed_bytes)) { (ra
6302
6311
6303
6312
return withUnsafePointer ( to: channelmanager. cOpaqueStruct!) { ( channelmanagerPointer: UnsafePointer < LDKChannelManager > ) in
6304
6313
6305
- Result_InvoiceSignOrCreationErrorZ ( pointer: create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch ( channelmanagerPointer, keys_manager. cOpaqueStruct!, network, amt_msat. danglingClone ( ) . cOpaqueStruct!, description_hash. danglingClone ( ) . cOpaqueStruct!, duration_since_epoch) )
6314
+ Result_InvoiceSignOrCreationErrorZ ( pointer: create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch ( channelmanagerPointer, keys_manager. activate ( ) . cOpaqueStruct!, network, amt_msat. danglingClone ( ) . cOpaqueStruct!, description_hash. danglingClone ( ) . cOpaqueStruct!, duration_since_epoch) )
6306
6315
6307
6316
}
6308
6317
@@ -6312,39 +6321,35 @@ withUnsafePointer(to: Bindings.array_to_tuple32(array: random_seed_bytes)) { (ra
6312
6321
6313
6322
return withUnsafePointer ( to: channelmanager. cOpaqueStruct!) { ( channelmanagerPointer: UnsafePointer < LDKChannelManager > ) in
6314
6323
6315
- Result_InvoiceSignOrCreationErrorZ ( pointer: create_invoice_from_channelmanager_and_duration_since_epoch ( channelmanagerPointer, keys_manager. cOpaqueStruct!, network, amt_msat. danglingClone ( ) . cOpaqueStruct!, Bindings . new_LDKStr ( string: description, chars_is_owned: true ) , duration_since_epoch) )
6324
+ Result_InvoiceSignOrCreationErrorZ ( pointer: create_invoice_from_channelmanager_and_duration_since_epoch ( channelmanagerPointer, keys_manager. activate ( ) . cOpaqueStruct!, network, amt_msat. danglingClone ( ) . cOpaqueStruct!, Bindings . new_LDKStr ( string: description, chars_is_owned: true ) , duration_since_epoch) )
6316
6325
6317
6326
}
6318
6327
6319
6328
}
6320
6329
6321
6330
/* STATIC_METHODS_END */
6322
6331
6323
- static var nativelyExposedInstances = [ String : NativeTypeWrapper ] ( )
6332
+ static var nativelyExposedInstances = [ UInt : NativeTraitWrapper ] ( )
6324
6333
6325
- public class func instanceToPointer( instance: NativeTypeWrapper ) -> UnsafeMutableRawPointer {
6326
- let pointer = Unmanaged . passUnretained ( instance) . toOpaque ( )
6327
- instance. pointerDebugDescription = pointer. debugDescription
6328
- Self . nativelyExposedInstances [ pointer. debugDescription] = instance
6334
+ public class func cacheInstance( instance: NativeTraitWrapper ) {
6335
+ Self . nativelyExposedInstances [ instance. globalInstanceNumber] = instance
6336
+ }
6337
+
6338
+ public class func instanceToPointer( instance: NativeTraitWrapper ) -> UnsafeMutableRawPointer {
6339
+ let pointer = UnsafeMutableRawPointer ( bitPattern: instance. globalInstanceNumber) !
6340
+ // don't automatically cache the trait instance
6341
+ // Self.nativelyExposedInstances[instance.globalInstanceNumber] = instance
6329
6342
return pointer
6330
6343
}
6331
6344
6332
- public class func pointerToInstance< T: NativeTypeWrapper > ( pointer: UnsafeRawPointer , sourceMarker: String ? ) -> T {
6333
-
6334
- let callStack = Thread . callStackSymbols
6335
- let caller = sourceMarker ?? callStack [ 1 ]
6336
- // print("Retrieving instance from pointer for caller: \(caller)")
6337
- // let value = Unmanaged<T>.fromOpaque(pointer).takeUnretainedValue()
6338
- let value = Self . nativelyExposedInstances [ pointer. debugDescription] as! T
6339
- // print("Instance retrieved for caller: \(caller)")
6345
+ public class func pointerToInstance< T: NativeTraitWrapper > ( pointer: UnsafeRawPointer , sourceMarker: String ? ) -> T {
6346
+ let key = UInt ( bitPattern: pointer)
6347
+ let value = Self . nativelyExposedInstances [ key] as! T
6340
6348
return value
6341
6349
}
6342
6350
6343
6351
public class func removeInstancePointer( instance: NativeTypeWrapper ) -> Bool {
6344
- guard let debugDescription = instance. pointerDebugDescription else {
6345
- return false
6346
- }
6347
- Self . nativelyExposedInstances. removeValue ( forKey: debugDescription)
6352
+ Self . nativelyExposedInstances. removeValue ( forKey: instance. globalInstanceNumber)
6348
6353
instance. pointerDebugDescription = nil
6349
6354
return true
6350
6355
}
@@ -6491,14 +6496,14 @@ withUnsafePointer(to: Bindings.array_to_tuple32(array: random_seed_bytes)) { (ra
6491
6496
}
6492
6497
}
6493
6498
*/
6494
-
6499
+
6495
6500
public class func get_ldk_swift_bindings_version( ) -> String {
6496
- return " e8cb2170ad6613f76c8a5a95941b8b8e2f90b5e1 "
6501
+ return " b058a25ba435d31e8885e804c0a65425e456ea10 "
6497
6502
}
6498
6503
6499
6504
}
6500
6505
6501
- public class InstanceCrashSimulator : NativeTypeWrapper {
6506
+ public class InstanceCrashSimulator : NativeTraitWrapper {
6502
6507
6503
6508
public init ( ) {
6504
6509
super. init ( conflictAvoidingVariableName: 0 )
0 commit comments