Skip to content

Commit da65d8d

Browse files
committed
Create namespacing to handle non-binary option value name collisions with top-level classes.
1 parent 2c965bf commit da65d8d

File tree

361 files changed

+23730
-21594
lines changed

Some content is hidden

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

361 files changed

+23730
-21594
lines changed

ci/LDKSwift/Sources/LDKSwift/bindings/Bindings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6932,7 +6932,7 @@ withUnsafePointer(to: Bindings.array_to_tuple32(array: random_seed_bytes)) { (ra
69326932
*/
69336933

69346934
public class func get_ldk_swift_bindings_version() -> String {
6935-
return "bdf5e832523c31577a5d8019c136c806d7e1337e"
6935+
return "2c965bf89139f2fb238b461d0af3d494d4d5384c"
69366936
}
69376937

69386938
}

ci/LDKSwift/Sources/LDKSwift/bindings/options/APIError.swift

Lines changed: 80 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,41 @@
22
import LDKHeaders
33
#endif
44

5-
public class APIError: NativeTypeWrapper {
5+
public typealias APIError = Bindings.APIError
66

7-
private static var instanceCounter: UInt = 0
8-
internal let instanceNumber: UInt
7+
extension Bindings {
98

10-
internal var cOpaqueStruct: LDKAPIError?
9+
public class APIError: NativeTypeWrapper {
1110

12-
11+
private static var instanceCounter: UInt = 0
12+
internal let instanceNumber: UInt
1313

14-
public init(pointer: LDKAPIError){
15-
Self.instanceCounter += 1
16-
self.instanceNumber = Self.instanceCounter
17-
self.cOpaqueStruct = pointer
18-
super.init(conflictAvoidingVariableName: 0)
19-
}
14+
internal var cOpaqueStruct: LDKAPIError?
2015

21-
public init(pointer: LDKAPIError, anchor: NativeTypeWrapper){
22-
Self.instanceCounter += 1
23-
self.instanceNumber = Self.instanceCounter
24-
self.cOpaqueStruct = pointer
25-
super.init(conflictAvoidingVariableName: 0)
26-
self.dangling = true
27-
try! self.addAnchor(anchor: anchor)
28-
}
16+
17+
18+
public init(pointer: LDKAPIError){
19+
Self.instanceCounter += 1
20+
self.instanceNumber = Self.instanceCounter
21+
self.cOpaqueStruct = pointer
22+
super.init(conflictAvoidingVariableName: 0)
23+
}
2924

30-
/* OPTION_METHODS_START */
25+
public init(pointer: LDKAPIError, anchor: NativeTypeWrapper){
26+
Self.instanceCounter += 1
27+
self.instanceNumber = Self.instanceCounter
28+
self.cOpaqueStruct = pointer
29+
super.init(conflictAvoidingVariableName: 0)
30+
self.dangling = true
31+
try! self.addAnchor(anchor: anchor)
32+
}
33+
34+
/* OPTION_METHODS_START */
3135

3236
public enum APIErrorValueType {
3337
case APIMisuseError, FeeRateTooHigh, RouteError, ChannelUnavailable, IncompatibleShutdownScript
3438
}
35-
39+
3640
public func getValueType() -> APIErrorValueType? {
3741
switch self.cOpaqueStruct?.tag {
3842

@@ -50,7 +54,7 @@ public class APIError: NativeTypeWrapper {
5054
return nil
5155
}
5256
}
53-
57+
5458

5559
public func getValueAsAPIMisuseError() -> APIMisuseError? {
5660
if self.cOpaqueStruct?.tag != LDKAPIError_APIMisuseError {
@@ -88,16 +92,16 @@ public class APIError: NativeTypeWrapper {
8892
}
8993

9094

91-
internal func free() -> Void {
92-
93-
return APIError_free(self.cOpaqueStruct!);
94-
}
95+
internal func free() -> Void {
96+
97+
return APIError_free(self.cOpaqueStruct!);
98+
}
9599

96100
internal func dangle() -> APIError {
97101
self.dangling = true
98102
return self
99103
}
100-
104+
101105
deinit {
102106
if !self.dangling {
103107
Bindings.print("Freeing APIError \(self.instanceNumber).")
@@ -108,12 +112,12 @@ public class APIError: NativeTypeWrapper {
108112
}
109113

110114

111-
public func clone() -> APIError {
112-
113-
return APIError(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKAPIError>) in
115+
public func clone() -> APIError {
116+
117+
return APIError(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKAPIError>) in
114118
APIError_clone(origPointer)
115119
});
116-
}
120+
}
117121

118122
internal func danglingClone() -> APIError {
119123
let dangledClone = self.clone()
@@ -122,42 +126,42 @@ APIError_clone(origPointer)
122126
}
123127

124128

125-
public class func apimisuse_error(err: String) -> APIError {
126-
127-
return APIError(pointer: APIError_apimisuse_error(Bindings.new_LDKStr(string: err, chars_is_owned: true)));
128-
}
129+
public class func apimisuse_error(err: String) -> APIError {
130+
131+
return APIError(pointer: APIError_apimisuse_error(Bindings.new_LDKStr(string: err, chars_is_owned: true)));
132+
}
129133

130-
public class func fee_rate_too_high(err: String, feerate: UInt32) -> APIError {
131-
132-
return APIError(pointer: APIError_fee_rate_too_high(Bindings.new_LDKStr(string: err, chars_is_owned: true), feerate));
133-
}
134+
public class func fee_rate_too_high(err: String, feerate: UInt32) -> APIError {
135+
136+
return APIError(pointer: APIError_fee_rate_too_high(Bindings.new_LDKStr(string: err, chars_is_owned: true), feerate));
137+
}
134138

135-
public class func route_error(err: String) -> APIError {
136-
137-
return APIError(pointer: APIError_route_error(Bindings.new_LDKStr(string: err, chars_is_owned: true)));
138-
}
139+
public class func route_error(err: String) -> APIError {
140+
141+
return APIError(pointer: APIError_route_error(Bindings.new_LDKStr(string: err, chars_is_owned: true)));
142+
}
139143

140-
public class func channel_unavailable(err: String) -> APIError {
141-
142-
return APIError(pointer: APIError_channel_unavailable(Bindings.new_LDKStr(string: err, chars_is_owned: true)));
143-
}
144+
public class func channel_unavailable(err: String) -> APIError {
145+
146+
return APIError(pointer: APIError_channel_unavailable(Bindings.new_LDKStr(string: err, chars_is_owned: true)));
147+
}
144148

145-
public class func monitor_update_failed() -> APIError {
146-
147-
return APIError(pointer: APIError_monitor_update_failed());
148-
}
149+
public class func monitor_update_failed() -> APIError {
150+
151+
return APIError(pointer: APIError_monitor_update_failed());
152+
}
149153

150-
public class func incompatible_shutdown_script(script: ShutdownScript) -> APIError {
151-
152-
return APIError(pointer: APIError_incompatible_shutdown_script(script.danglingClone().cOpaqueStruct!));
153-
}
154+
public class func incompatible_shutdown_script(script: Bindings.ShutdownScript) -> APIError {
155+
156+
return APIError(pointer: APIError_incompatible_shutdown_script(script.danglingClone().cOpaqueStruct!));
157+
}
154158

155-
/* OPTION_METHODS_END */
159+
/* OPTION_METHODS_END */
156160

157-
161+
158162

159163
public class APIMisuseError: NativeTypeWrapper {
160-
164+
161165

162166
var cOpaqueStruct: LDKAPIError_LDKAPIMisuseError_Body?;
163167
fileprivate init(pointer: LDKAPIError_LDKAPIMisuseError_Body) {
@@ -171,18 +175,18 @@ APIError_clone(origPointer)
171175
try! self.addAnchor(anchor: anchor)
172176
}
173177

174-
178+
175179

176180
public func getErr() -> String {
177181
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
178182
}
179183

180-
184+
181185
}
182186

183187

184188
public class FeeRateTooHigh: NativeTypeWrapper {
185-
189+
186190

187191
var cOpaqueStruct: LDKAPIError_LDKFeeRateTooHigh_Body?;
188192
fileprivate init(pointer: LDKAPIError_LDKFeeRateTooHigh_Body) {
@@ -196,7 +200,7 @@ APIError_clone(origPointer)
196200
try! self.addAnchor(anchor: anchor)
197201
}
198202

199-
203+
200204

201205
public func getErr() -> String {
202206
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
@@ -206,12 +210,12 @@ APIError_clone(origPointer)
206210
return self.cOpaqueStruct!.feerate
207211
}
208212

209-
213+
210214
}
211215

212216

213217
public class RouteError: NativeTypeWrapper {
214-
218+
215219

216220
var cOpaqueStruct: LDKAPIError_LDKRouteError_Body?;
217221
fileprivate init(pointer: LDKAPIError_LDKRouteError_Body) {
@@ -225,18 +229,18 @@ APIError_clone(origPointer)
225229
try! self.addAnchor(anchor: anchor)
226230
}
227231

228-
232+
229233

230234
public func getErr() -> String {
231235
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
232236
}
233237

234-
238+
235239
}
236240

237241

238242
public class ChannelUnavailable: NativeTypeWrapper {
239-
243+
240244

241245
var cOpaqueStruct: LDKAPIError_LDKChannelUnavailable_Body?;
242246
fileprivate init(pointer: LDKAPIError_LDKChannelUnavailable_Body) {
@@ -250,18 +254,18 @@ APIError_clone(origPointer)
250254
try! self.addAnchor(anchor: anchor)
251255
}
252256

253-
257+
254258

255259
public func getErr() -> String {
256260
return Bindings.LDKStr_to_string(nativeType: self.cOpaqueStruct!.err)
257261
}
258262

259-
263+
260264
}
261265

262266

263267
public class IncompatibleShutdownScript: NativeTypeWrapper {
264-
268+
265269

266270
var cOpaqueStruct: LDKAPIError_LDKIncompatibleShutdownScript_Body?;
267271
fileprivate init(pointer: LDKAPIError_LDKIncompatibleShutdownScript_Body) {
@@ -275,13 +279,15 @@ APIError_clone(origPointer)
275279
try! self.addAnchor(anchor: anchor)
276280
}
277281

282+
278283

279-
280-
public func getScript() -> ShutdownScript {
281-
return ShutdownScript(pointer: self.cOpaqueStruct!.script, anchor: self)
284+
public func getScript() -> Bindings.ShutdownScript {
285+
return Bindings.ShutdownScript(pointer: self.cOpaqueStruct!.script, anchor: self)
282286
}
283287

284-
288+
285289
}
286290

291+
}
292+
287293
}

0 commit comments

Comments
 (0)