Skip to content

Commit 7c43265

Browse files
committed
Make option and result types anchored to the owner value.
1 parent 0b31f2e commit 7c43265

File tree

245 files changed

+2788
-295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+2788
-295
lines changed

bindings/LDK/options/APIError.swift

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ public class APIError: NativeTypeWrapper {
1414
super.init(conflictAvoidingVariableName: 0)
1515
}
1616

17+
public init(pointer: LDKAPIError, anchor: NativeTypeWrapper){
18+
Self.instanceCounter += 1
19+
self.instanceNumber = Self.instanceCounter
20+
self.cOpaqueStruct = pointer
21+
super.init(conflictAvoidingVariableName: 0)
22+
self.dangling = true
23+
try! self.addAnchor(anchor: anchor)
24+
}
25+
1726
/* OPTION_METHODS_START */
1827

1928
public enum APIErrorValueType {
@@ -43,35 +52,35 @@ public class APIError: NativeTypeWrapper {
4352
if self.cOpaqueStruct?.tag != LDKAPIError_APIMisuseError {
4453
return nil
4554
}
46-
return APIMisuseError(pointer: self.cOpaqueStruct!.api_misuse_error)
55+
return APIMisuseError(pointer: self.cOpaqueStruct!.api_misuse_error, anchor: self)
4756
}
4857

4958
public func getValueAsFeeRateTooHigh() -> FeeRateTooHigh? {
5059
if self.cOpaqueStruct?.tag != LDKAPIError_FeeRateTooHigh {
5160
return nil
5261
}
53-
return FeeRateTooHigh(pointer: self.cOpaqueStruct!.fee_rate_too_high)
62+
return FeeRateTooHigh(pointer: self.cOpaqueStruct!.fee_rate_too_high, anchor: self)
5463
}
5564

5665
public func getValueAsRouteError() -> RouteError? {
5766
if self.cOpaqueStruct?.tag != LDKAPIError_RouteError {
5867
return nil
5968
}
60-
return RouteError(pointer: self.cOpaqueStruct!.route_error)
69+
return RouteError(pointer: self.cOpaqueStruct!.route_error, anchor: self)
6170
}
6271

6372
public func getValueAsChannelUnavailable() -> ChannelUnavailable? {
6473
if self.cOpaqueStruct?.tag != LDKAPIError_ChannelUnavailable {
6574
return nil
6675
}
67-
return ChannelUnavailable(pointer: self.cOpaqueStruct!.channel_unavailable)
76+
return ChannelUnavailable(pointer: self.cOpaqueStruct!.channel_unavailable, anchor: self)
6877
}
6978

7079
public func getValueAsIncompatibleShutdownScript() -> IncompatibleShutdownScript? {
7180
if self.cOpaqueStruct?.tag != LDKAPIError_IncompatibleShutdownScript {
7281
return nil
7382
}
74-
return IncompatibleShutdownScript(pointer: self.cOpaqueStruct!.incompatible_shutdown_script)
83+
return IncompatibleShutdownScript(pointer: self.cOpaqueStruct!.incompatible_shutdown_script, anchor: self)
7584
}
7685

7786

@@ -143,12 +152,19 @@ APIError_clone(origPointer)
143152

144153

145154

146-
public class APIMisuseError {
155+
public class APIMisuseError: NativeTypeWrapper {
147156

148157

149158
var cOpaqueStruct: LDKAPIError_LDKAPIMisuseError_Body?;
150159
fileprivate init(pointer: LDKAPIError_LDKAPIMisuseError_Body) {
151160
self.cOpaqueStruct = pointer
161+
super.init(conflictAvoidingVariableName: 0)
162+
}
163+
fileprivate init(pointer: LDKAPIError_LDKAPIMisuseError_Body, anchor: NativeTypeWrapper) {
164+
self.cOpaqueStruct = pointer
165+
super.init(conflictAvoidingVariableName: 0)
166+
self.dangling = true
167+
try! self.addAnchor(anchor: anchor)
152168
}
153169

154170

@@ -161,12 +177,19 @@ APIError_clone(origPointer)
161177
}
162178

163179

164-
public class FeeRateTooHigh {
180+
public class FeeRateTooHigh: NativeTypeWrapper {
165181

166182

167183
var cOpaqueStruct: LDKAPIError_LDKFeeRateTooHigh_Body?;
168184
fileprivate init(pointer: LDKAPIError_LDKFeeRateTooHigh_Body) {
169185
self.cOpaqueStruct = pointer
186+
super.init(conflictAvoidingVariableName: 0)
187+
}
188+
fileprivate init(pointer: LDKAPIError_LDKFeeRateTooHigh_Body, anchor: NativeTypeWrapper) {
189+
self.cOpaqueStruct = pointer
190+
super.init(conflictAvoidingVariableName: 0)
191+
self.dangling = true
192+
try! self.addAnchor(anchor: anchor)
170193
}
171194

172195

@@ -183,12 +206,19 @@ APIError_clone(origPointer)
183206
}
184207

185208

186-
public class RouteError {
209+
public class RouteError: NativeTypeWrapper {
187210

188211

189212
var cOpaqueStruct: LDKAPIError_LDKRouteError_Body?;
190213
fileprivate init(pointer: LDKAPIError_LDKRouteError_Body) {
191214
self.cOpaqueStruct = pointer
215+
super.init(conflictAvoidingVariableName: 0)
216+
}
217+
fileprivate init(pointer: LDKAPIError_LDKRouteError_Body, anchor: NativeTypeWrapper) {
218+
self.cOpaqueStruct = pointer
219+
super.init(conflictAvoidingVariableName: 0)
220+
self.dangling = true
221+
try! self.addAnchor(anchor: anchor)
192222
}
193223

194224

@@ -201,12 +231,19 @@ APIError_clone(origPointer)
201231
}
202232

203233

204-
public class ChannelUnavailable {
234+
public class ChannelUnavailable: NativeTypeWrapper {
205235

206236

207237
var cOpaqueStruct: LDKAPIError_LDKChannelUnavailable_Body?;
208238
fileprivate init(pointer: LDKAPIError_LDKChannelUnavailable_Body) {
209239
self.cOpaqueStruct = pointer
240+
super.init(conflictAvoidingVariableName: 0)
241+
}
242+
fileprivate init(pointer: LDKAPIError_LDKChannelUnavailable_Body, anchor: NativeTypeWrapper) {
243+
self.cOpaqueStruct = pointer
244+
super.init(conflictAvoidingVariableName: 0)
245+
self.dangling = true
246+
try! self.addAnchor(anchor: anchor)
210247
}
211248

212249

@@ -219,18 +256,25 @@ APIError_clone(origPointer)
219256
}
220257

221258

222-
public class IncompatibleShutdownScript {
259+
public class IncompatibleShutdownScript: NativeTypeWrapper {
223260

224261

225262
var cOpaqueStruct: LDKAPIError_LDKIncompatibleShutdownScript_Body?;
226263
fileprivate init(pointer: LDKAPIError_LDKIncompatibleShutdownScript_Body) {
227264
self.cOpaqueStruct = pointer
265+
super.init(conflictAvoidingVariableName: 0)
266+
}
267+
fileprivate init(pointer: LDKAPIError_LDKIncompatibleShutdownScript_Body, anchor: NativeTypeWrapper) {
268+
self.cOpaqueStruct = pointer
269+
super.init(conflictAvoidingVariableName: 0)
270+
self.dangling = true
271+
try! self.addAnchor(anchor: anchor)
228272
}
229273

230274

231275

232276
public func getScript() -> ShutdownScript {
233-
return ShutdownScript(pointer: self.cOpaqueStruct!.script).dangle()
277+
return ShutdownScript(pointer: self.cOpaqueStruct!.script, anchor: self)
234278
}
235279

236280

bindings/LDK/options/ErrorAction.swift

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ public class ErrorAction: NativeTypeWrapper {
1414
super.init(conflictAvoidingVariableName: 0)
1515
}
1616

17+
public init(pointer: LDKErrorAction, anchor: NativeTypeWrapper){
18+
Self.instanceCounter += 1
19+
self.instanceNumber = Self.instanceCounter
20+
self.cOpaqueStruct = pointer
21+
super.init(conflictAvoidingVariableName: 0)
22+
self.dangling = true
23+
try! self.addAnchor(anchor: anchor)
24+
}
25+
1726
/* OPTION_METHODS_START */
1827

1928
public enum ErrorActionValueType {
@@ -39,7 +48,7 @@ public class ErrorAction: NativeTypeWrapper {
3948
if self.cOpaqueStruct?.tag != LDKErrorAction_DisconnectPeer {
4049
return nil
4150
}
42-
return DisconnectPeer(pointer: self.cOpaqueStruct!.disconnect_peer)
51+
return DisconnectPeer(pointer: self.cOpaqueStruct!.disconnect_peer, anchor: self)
4352
}
4453

4554
public func getValueAsIgnoreAndLog() -> LDKLevel? {
@@ -53,7 +62,7 @@ public class ErrorAction: NativeTypeWrapper {
5362
if self.cOpaqueStruct?.tag != LDKErrorAction_SendErrorMessage {
5463
return nil
5564
}
56-
return SendErrorMessage(pointer: self.cOpaqueStruct!.send_error_message)
65+
return SendErrorMessage(pointer: self.cOpaqueStruct!.send_error_message, anchor: self)
5766
}
5867

5968

@@ -115,36 +124,50 @@ ErrorAction_clone(origPointer)
115124

116125

117126

118-
public class DisconnectPeer {
127+
public class DisconnectPeer: NativeTypeWrapper {
119128

120129

121130
var cOpaqueStruct: LDKErrorAction_LDKDisconnectPeer_Body?;
122131
fileprivate init(pointer: LDKErrorAction_LDKDisconnectPeer_Body) {
123132
self.cOpaqueStruct = pointer
133+
super.init(conflictAvoidingVariableName: 0)
134+
}
135+
fileprivate init(pointer: LDKErrorAction_LDKDisconnectPeer_Body, anchor: NativeTypeWrapper) {
136+
self.cOpaqueStruct = pointer
137+
super.init(conflictAvoidingVariableName: 0)
138+
self.dangling = true
139+
try! self.addAnchor(anchor: anchor)
124140
}
125141

126142

127143

128144
public func getMsg() -> ErrorMessage {
129-
return ErrorMessage(pointer: self.cOpaqueStruct!.msg).dangle()
145+
return ErrorMessage(pointer: self.cOpaqueStruct!.msg, anchor: self)
130146
}
131147

132148

133149
}
134150

135151

136-
public class SendErrorMessage {
152+
public class SendErrorMessage: NativeTypeWrapper {
137153

138154

139155
var cOpaqueStruct: LDKErrorAction_LDKSendErrorMessage_Body?;
140156
fileprivate init(pointer: LDKErrorAction_LDKSendErrorMessage_Body) {
141157
self.cOpaqueStruct = pointer
158+
super.init(conflictAvoidingVariableName: 0)
159+
}
160+
fileprivate init(pointer: LDKErrorAction_LDKSendErrorMessage_Body, anchor: NativeTypeWrapper) {
161+
self.cOpaqueStruct = pointer
162+
super.init(conflictAvoidingVariableName: 0)
163+
self.dangling = true
164+
try! self.addAnchor(anchor: anchor)
142165
}
143166

144167

145168

146169
public func getMsg() -> ErrorMessage {
147-
return ErrorMessage(pointer: self.cOpaqueStruct!.msg).dangle()
170+
return ErrorMessage(pointer: self.cOpaqueStruct!.msg, anchor: self)
148171
}
149172

150173

0 commit comments

Comments
 (0)