Skip to content

Commit 0e8a8e9

Browse files
committed
Update to 0.0.14 step 2
1 parent e1e1c09 commit 0e8a8e9

29 files changed

+1775
-24
lines changed

bindings/LDK/Bindings.swift

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ public class Bindings {
933933
/* RUST_TO_SWIFT_END */
934934
public class func extractNativeLDKC2Tuple_BlockHashChannelMonitorZArray(array: [C2Tuple_BlockHashChannelMonitorZ]) -> [LDKC2Tuple_BlockHashChannelMonitorZ] {
935935
return array.map { entry -> LDKC2Tuple_BlockHashChannelMonitorZ in
936-
entry.cOpaqueStruct!
936+
entry.danglingClone().cOpaqueStruct!
937937
}
938938
}
939939

@@ -949,6 +949,13 @@ public class Bindings {
949949
}
950950
}
951951

952+
internal class func cloneNativeLDKC2Tuple_BlockHashChannelMonitorZArray(array: [LDKC2Tuple_BlockHashChannelMonitorZ]) -> [LDKC2Tuple_BlockHashChannelMonitorZ] {
953+
return array.map { entry -> LDKC2Tuple_BlockHashChannelMonitorZ in
954+
// create a wrapper around the native object, dangle it to make it non-destructive, clone it, and then dangle the clone
955+
C2Tuple_BlockHashChannelMonitorZ(pointer: entry).dangle().clone().dangle().cOpaqueStruct!
956+
}
957+
}
958+
952959

953960
/* SWIFT_TO_RUST_START */
954961
public class func new_LDKCVec_C2Tuple_PublicKeyTypeZZWrapper(array: [LDKC2Tuple_PublicKeyTypeZ]) -> LDKCVec_C2Tuple_PublicKeyTypeZZWrapper {
@@ -1028,7 +1035,7 @@ public class Bindings {
10281035
/* RUST_TO_SWIFT_END */
10291036
public class func extractNativeLDKC2Tuple_PublicKeyTypeZArray(array: [C2Tuple_PublicKeyTypeZ]) -> [LDKC2Tuple_PublicKeyTypeZ] {
10301037
return array.map { entry -> LDKC2Tuple_PublicKeyTypeZ in
1031-
entry.cOpaqueStruct!
1038+
entry.danglingClone().cOpaqueStruct!
10321039
}
10331040
}
10341041

@@ -1044,6 +1051,13 @@ public class Bindings {
10441051
}
10451052
}
10461053

1054+
internal class func cloneNativeLDKC2Tuple_PublicKeyTypeZArray(array: [LDKC2Tuple_PublicKeyTypeZ]) -> [LDKC2Tuple_PublicKeyTypeZ] {
1055+
return array.map { entry -> LDKC2Tuple_PublicKeyTypeZ in
1056+
// create a wrapper around the native object, dangle it to make it non-destructive, clone it, and then dangle the clone
1057+
C2Tuple_PublicKeyTypeZ(pointer: entry).dangle().clone().dangle().cOpaqueStruct!
1058+
}
1059+
}
1060+
10471061

10481062
/* SWIFT_TO_RUST_START */
10491063
public class func new_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZWrapper(array: [LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ]) -> LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZWrapper {
@@ -2023,7 +2037,7 @@ public class Bindings {
20232037
/* RUST_TO_SWIFT_END */
20242038
public class func extractNativeLDKChannelMonitorArray(array: [ChannelMonitor]) -> [LDKChannelMonitor] {
20252039
return array.map { entry -> LDKChannelMonitor in
2026-
entry.cOpaqueStruct!
2040+
entry.danglingClone().cOpaqueStruct!
20272041
}
20282042
}
20292043

@@ -2039,6 +2053,13 @@ public class Bindings {
20392053
}
20402054
}
20412055

2056+
internal class func cloneNativeLDKChannelMonitorArray(array: [LDKChannelMonitor]) -> [LDKChannelMonitor] {
2057+
return array.map { entry -> LDKChannelMonitor in
2058+
// create a wrapper around the native object, dangle it to make it non-destructive, clone it, and then dangle the clone
2059+
ChannelMonitor(pointer: entry).dangle().clone().dangle().cOpaqueStruct!
2060+
}
2061+
}
2062+
20422063

20432064
/* SWIFT_TO_RUST_START */
20442065
public class func new_LDKCVec_EventZWrapper(array: [LDKEvent]) -> LDKCVec_EventZWrapper {
@@ -6036,7 +6057,7 @@ withUnsafePointer(to: scorer.cOpaqueStruct!) { (scorerPointer: UnsafePointer<LDK
60366057
*/
60376058

60386059
public class func get_ldk_swift_bindings_version() -> String {
6039-
return "f740a9b03d24da962d05b9b6d38b2c53f2134b11"
6060+
return "e1e1c09ce5f801f30ca2b644e540821050272436"
60406061
}
60416062

60426063
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
public class Option_ClosureReasonZ: NativeTypeWrapper {
2+
3+
private static var instanceCounter: UInt = 0
4+
internal let instanceNumber: UInt
5+
6+
internal var cOpaqueStruct: LDKCOption_ClosureReasonZ?
7+
8+
/* DEFAULT_CONSTRUCTOR_START */
9+
public init(value: ClosureReason?) {
10+
Self.instanceCounter += 1
11+
self.instanceNumber = Self.instanceCounter
12+
13+
self.cOpaqueStruct = LDKCOption_ClosureReasonZ()
14+
if let value = value {
15+
self.cOpaqueStruct!.tag = LDKCOption_ClosureReasonZ_Some
16+
17+
self.cOpaqueStruct!.some = value.cOpaqueStruct!
18+
} else {
19+
self.cOpaqueStruct!.tag = LDKCOption_ClosureReasonZ_None
20+
}
21+
22+
23+
super.init(conflictAvoidingVariableName: 0)
24+
}
25+
/* DEFAULT_CONSTRUCTOR_END */
26+
27+
public init(pointer: LDKCOption_ClosureReasonZ){
28+
Self.instanceCounter += 1
29+
self.instanceNumber = Self.instanceCounter
30+
self.cOpaqueStruct = pointer
31+
super.init(conflictAvoidingVariableName: 0)
32+
}
33+
34+
public init(pointer: LDKCOption_ClosureReasonZ, anchor: NativeTypeWrapper){
35+
Self.instanceCounter += 1
36+
self.instanceNumber = Self.instanceCounter
37+
self.cOpaqueStruct = pointer
38+
super.init(conflictAvoidingVariableName: 0)
39+
self.dangling = true
40+
try! self.addAnchor(anchor: anchor)
41+
}
42+
43+
/* OPTION_METHODS_START */
44+
45+
public func getValue() -> ClosureReason? {
46+
47+
48+
if self.cOpaqueStruct!.tag == LDKCOption_ClosureReasonZ_None {
49+
return nil
50+
}
51+
if self.cOpaqueStruct!.tag == LDKCOption_ClosureReasonZ_Some {
52+
return ClosureReason(pointer: self.cOpaqueStruct!.some)
53+
}
54+
assert(false, "invalid option enum value")
55+
return nil
56+
57+
58+
}
59+
60+
public class func some(o: ClosureReason) -> Option_ClosureReasonZ {
61+
62+
return Option_ClosureReasonZ(pointer: COption_ClosureReasonZ_some(o.danglingClone().cOpaqueStruct!));
63+
}
64+
65+
public class func none() -> Option_ClosureReasonZ {
66+
67+
return Option_ClosureReasonZ(pointer: COption_ClosureReasonZ_none());
68+
}
69+
70+
internal func free() -> Void {
71+
72+
return COption_ClosureReasonZ_free(self.cOpaqueStruct!);
73+
}
74+
75+
internal func dangle() -> Option_ClosureReasonZ {
76+
self.dangling = true
77+
return self
78+
}
79+
80+
deinit {
81+
if !self.dangling {
82+
Bindings.print("Freeing Option_ClosureReasonZ \(self.instanceNumber).")
83+
self.free()
84+
} else {
85+
Bindings.print("Not freeing Option_ClosureReasonZ \(self.instanceNumber) due to dangle.")
86+
}
87+
}
88+
89+
90+
public func clone() -> Option_ClosureReasonZ {
91+
92+
return Option_ClosureReasonZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKCOption_ClosureReasonZ>) in
93+
COption_ClosureReasonZ_clone(origPointer)
94+
});
95+
}
96+
97+
internal func danglingClone() -> Option_ClosureReasonZ {
98+
let dangledClone = self.clone()
99+
dangledClone.dangling = true
100+
return dangledClone
101+
}
102+
103+
104+
/* OPTION_METHODS_END */
105+
106+
/* TYPE_CLASSES */
107+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
public class Option_EventZ: NativeTypeWrapper {
2+
3+
private static var instanceCounter: UInt = 0
4+
internal let instanceNumber: UInt
5+
6+
internal var cOpaqueStruct: LDKCOption_EventZ?
7+
8+
/* DEFAULT_CONSTRUCTOR_START */
9+
public init(value: Event?) {
10+
Self.instanceCounter += 1
11+
self.instanceNumber = Self.instanceCounter
12+
13+
self.cOpaqueStruct = LDKCOption_EventZ()
14+
if let value = value {
15+
self.cOpaqueStruct!.tag = LDKCOption_EventZ_Some
16+
17+
self.cOpaqueStruct!.some = value.cOpaqueStruct!
18+
} else {
19+
self.cOpaqueStruct!.tag = LDKCOption_EventZ_None
20+
}
21+
22+
23+
super.init(conflictAvoidingVariableName: 0)
24+
}
25+
/* DEFAULT_CONSTRUCTOR_END */
26+
27+
public init(pointer: LDKCOption_EventZ){
28+
Self.instanceCounter += 1
29+
self.instanceNumber = Self.instanceCounter
30+
self.cOpaqueStruct = pointer
31+
super.init(conflictAvoidingVariableName: 0)
32+
}
33+
34+
public init(pointer: LDKCOption_EventZ, anchor: NativeTypeWrapper){
35+
Self.instanceCounter += 1
36+
self.instanceNumber = Self.instanceCounter
37+
self.cOpaqueStruct = pointer
38+
super.init(conflictAvoidingVariableName: 0)
39+
self.dangling = true
40+
try! self.addAnchor(anchor: anchor)
41+
}
42+
43+
/* OPTION_METHODS_START */
44+
45+
public func getValue() -> Event? {
46+
47+
48+
if self.cOpaqueStruct!.tag == LDKCOption_EventZ_None {
49+
return nil
50+
}
51+
if self.cOpaqueStruct!.tag == LDKCOption_EventZ_Some {
52+
return Event(pointer: self.cOpaqueStruct!.some)
53+
}
54+
assert(false, "invalid option enum value")
55+
return nil
56+
57+
58+
}
59+
60+
public class func some(o: Event) -> Option_EventZ {
61+
62+
return Option_EventZ(pointer: COption_EventZ_some(o.danglingClone().cOpaqueStruct!));
63+
}
64+
65+
public class func none() -> Option_EventZ {
66+
67+
return Option_EventZ(pointer: COption_EventZ_none());
68+
}
69+
70+
internal func free() -> Void {
71+
72+
return COption_EventZ_free(self.cOpaqueStruct!);
73+
}
74+
75+
internal func dangle() -> Option_EventZ {
76+
self.dangling = true
77+
return self
78+
}
79+
80+
deinit {
81+
if !self.dangling {
82+
Bindings.print("Freeing Option_EventZ \(self.instanceNumber).")
83+
self.free()
84+
} else {
85+
Bindings.print("Not freeing Option_EventZ \(self.instanceNumber) due to dangle.")
86+
}
87+
}
88+
89+
90+
public func clone() -> Option_EventZ {
91+
92+
return Option_EventZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKCOption_EventZ>) in
93+
COption_EventZ_clone(origPointer)
94+
});
95+
}
96+
97+
internal func danglingClone() -> Option_EventZ {
98+
let dangledClone = self.clone()
99+
dangledClone.dangling = true
100+
return dangledClone
101+
}
102+
103+
104+
/* OPTION_METHODS_END */
105+
106+
/* TYPE_CLASSES */
107+
}

0 commit comments

Comments
 (0)