Skip to content

Commit

Permalink
Make option and result types anchored to the owner value.
Browse files Browse the repository at this point in the history
  • Loading branch information
arik-so committed Aug 28, 2021
1 parent 0b31f2e commit 7c43265
Show file tree
Hide file tree
Showing 245 changed files with 2,788 additions and 295 deletions.
66 changes: 55 additions & 11 deletions bindings/LDK/options/APIError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ public class APIError: NativeTypeWrapper {
super.init(conflictAvoidingVariableName: 0)
}

public init(pointer: LDKAPIError, anchor: NativeTypeWrapper){
Self.instanceCounter += 1
self.instanceNumber = Self.instanceCounter
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
self.dangling = true
try! self.addAnchor(anchor: anchor)
}

/* OPTION_METHODS_START */

public enum APIErrorValueType {
Expand Down Expand Up @@ -43,35 +52,35 @@ public class APIError: NativeTypeWrapper {
if self.cOpaqueStruct?.tag != LDKAPIError_APIMisuseError {
return nil
}
return APIMisuseError(pointer: self.cOpaqueStruct!.api_misuse_error)
return APIMisuseError(pointer: self.cOpaqueStruct!.api_misuse_error, anchor: self)
}

public func getValueAsFeeRateTooHigh() -> FeeRateTooHigh? {
if self.cOpaqueStruct?.tag != LDKAPIError_FeeRateTooHigh {
return nil
}
return FeeRateTooHigh(pointer: self.cOpaqueStruct!.fee_rate_too_high)
return FeeRateTooHigh(pointer: self.cOpaqueStruct!.fee_rate_too_high, anchor: self)
}

public func getValueAsRouteError() -> RouteError? {
if self.cOpaqueStruct?.tag != LDKAPIError_RouteError {
return nil
}
return RouteError(pointer: self.cOpaqueStruct!.route_error)
return RouteError(pointer: self.cOpaqueStruct!.route_error, anchor: self)
}

public func getValueAsChannelUnavailable() -> ChannelUnavailable? {
if self.cOpaqueStruct?.tag != LDKAPIError_ChannelUnavailable {
return nil
}
return ChannelUnavailable(pointer: self.cOpaqueStruct!.channel_unavailable)
return ChannelUnavailable(pointer: self.cOpaqueStruct!.channel_unavailable, anchor: self)
}

public func getValueAsIncompatibleShutdownScript() -> IncompatibleShutdownScript? {
if self.cOpaqueStruct?.tag != LDKAPIError_IncompatibleShutdownScript {
return nil
}
return IncompatibleShutdownScript(pointer: self.cOpaqueStruct!.incompatible_shutdown_script)
return IncompatibleShutdownScript(pointer: self.cOpaqueStruct!.incompatible_shutdown_script, anchor: self)
}


Expand Down Expand Up @@ -143,12 +152,19 @@ APIError_clone(origPointer)



public class APIMisuseError {
public class APIMisuseError: NativeTypeWrapper {


var cOpaqueStruct: LDKAPIError_LDKAPIMisuseError_Body?;
fileprivate init(pointer: LDKAPIError_LDKAPIMisuseError_Body) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
}
fileprivate init(pointer: LDKAPIError_LDKAPIMisuseError_Body, anchor: NativeTypeWrapper) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
self.dangling = true
try! self.addAnchor(anchor: anchor)
}


Expand All @@ -161,12 +177,19 @@ APIError_clone(origPointer)
}


public class FeeRateTooHigh {
public class FeeRateTooHigh: NativeTypeWrapper {


var cOpaqueStruct: LDKAPIError_LDKFeeRateTooHigh_Body?;
fileprivate init(pointer: LDKAPIError_LDKFeeRateTooHigh_Body) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
}
fileprivate init(pointer: LDKAPIError_LDKFeeRateTooHigh_Body, anchor: NativeTypeWrapper) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
self.dangling = true
try! self.addAnchor(anchor: anchor)
}


Expand All @@ -183,12 +206,19 @@ APIError_clone(origPointer)
}


public class RouteError {
public class RouteError: NativeTypeWrapper {


var cOpaqueStruct: LDKAPIError_LDKRouteError_Body?;
fileprivate init(pointer: LDKAPIError_LDKRouteError_Body) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
}
fileprivate init(pointer: LDKAPIError_LDKRouteError_Body, anchor: NativeTypeWrapper) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
self.dangling = true
try! self.addAnchor(anchor: anchor)
}


Expand All @@ -201,12 +231,19 @@ APIError_clone(origPointer)
}


public class ChannelUnavailable {
public class ChannelUnavailable: NativeTypeWrapper {


var cOpaqueStruct: LDKAPIError_LDKChannelUnavailable_Body?;
fileprivate init(pointer: LDKAPIError_LDKChannelUnavailable_Body) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
}
fileprivate init(pointer: LDKAPIError_LDKChannelUnavailable_Body, anchor: NativeTypeWrapper) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
self.dangling = true
try! self.addAnchor(anchor: anchor)
}


Expand All @@ -219,18 +256,25 @@ APIError_clone(origPointer)
}


public class IncompatibleShutdownScript {
public class IncompatibleShutdownScript: NativeTypeWrapper {


var cOpaqueStruct: LDKAPIError_LDKIncompatibleShutdownScript_Body?;
fileprivate init(pointer: LDKAPIError_LDKIncompatibleShutdownScript_Body) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
}
fileprivate init(pointer: LDKAPIError_LDKIncompatibleShutdownScript_Body, anchor: NativeTypeWrapper) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
self.dangling = true
try! self.addAnchor(anchor: anchor)
}



public func getScript() -> ShutdownScript {
return ShutdownScript(pointer: self.cOpaqueStruct!.script).dangle()
return ShutdownScript(pointer: self.cOpaqueStruct!.script, anchor: self)
}


Expand Down
35 changes: 29 additions & 6 deletions bindings/LDK/options/ErrorAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ public class ErrorAction: NativeTypeWrapper {
super.init(conflictAvoidingVariableName: 0)
}

public init(pointer: LDKErrorAction, anchor: NativeTypeWrapper){
Self.instanceCounter += 1
self.instanceNumber = Self.instanceCounter
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
self.dangling = true
try! self.addAnchor(anchor: anchor)
}

/* OPTION_METHODS_START */

public enum ErrorActionValueType {
Expand All @@ -39,7 +48,7 @@ public class ErrorAction: NativeTypeWrapper {
if self.cOpaqueStruct?.tag != LDKErrorAction_DisconnectPeer {
return nil
}
return DisconnectPeer(pointer: self.cOpaqueStruct!.disconnect_peer)
return DisconnectPeer(pointer: self.cOpaqueStruct!.disconnect_peer, anchor: self)
}

public func getValueAsIgnoreAndLog() -> LDKLevel? {
Expand All @@ -53,7 +62,7 @@ public class ErrorAction: NativeTypeWrapper {
if self.cOpaqueStruct?.tag != LDKErrorAction_SendErrorMessage {
return nil
}
return SendErrorMessage(pointer: self.cOpaqueStruct!.send_error_message)
return SendErrorMessage(pointer: self.cOpaqueStruct!.send_error_message, anchor: self)
}


Expand Down Expand Up @@ -115,36 +124,50 @@ ErrorAction_clone(origPointer)



public class DisconnectPeer {
public class DisconnectPeer: NativeTypeWrapper {


var cOpaqueStruct: LDKErrorAction_LDKDisconnectPeer_Body?;
fileprivate init(pointer: LDKErrorAction_LDKDisconnectPeer_Body) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
}
fileprivate init(pointer: LDKErrorAction_LDKDisconnectPeer_Body, anchor: NativeTypeWrapper) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
self.dangling = true
try! self.addAnchor(anchor: anchor)
}



public func getMsg() -> ErrorMessage {
return ErrorMessage(pointer: self.cOpaqueStruct!.msg).dangle()
return ErrorMessage(pointer: self.cOpaqueStruct!.msg, anchor: self)
}


}


public class SendErrorMessage {
public class SendErrorMessage: NativeTypeWrapper {


var cOpaqueStruct: LDKErrorAction_LDKSendErrorMessage_Body?;
fileprivate init(pointer: LDKErrorAction_LDKSendErrorMessage_Body) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
}
fileprivate init(pointer: LDKErrorAction_LDKSendErrorMessage_Body, anchor: NativeTypeWrapper) {
self.cOpaqueStruct = pointer
super.init(conflictAvoidingVariableName: 0)
self.dangling = true
try! self.addAnchor(anchor: anchor)
}



public func getMsg() -> ErrorMessage {
return ErrorMessage(pointer: self.cOpaqueStruct!.msg).dangle()
return ErrorMessage(pointer: self.cOpaqueStruct!.msg, anchor: self)
}


Expand Down
Loading

0 comments on commit 7c43265

Please sign in to comment.