-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor EndpointInfo in Swift #3195
base: main
Are you sure you want to change the base?
Conversation
@@ -15,10 +15,12 @@ class CommunicatorI: LocalObject<ICECommunicator>, Communicator { | |||
self.initData = initData | |||
do { | |||
classGraphDepthMax = try initData.properties!.getIcePropertyAsInt("Ice.ClassGraphDepthMax") | |||
precondition(classGraphDepthMax >= 1 && classGraphDepthMax <= 0x7FFF_FFFF, "Ice.ClassGraphDepthMax must be >= 0 and <= 0x7FFF_FFFF") | |||
precondition( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to Swift format more often.
@@ -2,77 +2,155 @@ | |||
|
|||
import Foundation | |||
|
|||
/// The user-level interface to an endpoint. | |||
public protocol Endpoint: AnyObject, CustomStringConvertible { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved at the top of Endpoint.swift. Didn't change this protocol.
/// | ||
/// - returns: `String` - The string representation of the endpoint. | ||
func toString() -> String | ||
public init(underlying: EndpointInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logically "protected", but this is not available in Swift.
} | ||
|
||
#if TARGET_OS_IPHONE | ||
#if TARGET_OS_IPHONE // TODO: remove conditional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IceIAP::EndpointInfo and ConnectionInfo classes are tiny classes that don't need be conditional.
rawBytes:rawBytes]; | ||
} | ||
|
||
// TODO: we should never return null from this factory function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning null will result in a crash.
|
||
@interface ICEEndpointInfo () | ||
@property(nonatomic, readonly) std::shared_ptr<Ice::EndpointInfo> info; | ||
+ (id)createEndpointInfo:(std::shared_ptr<Ice::EndpointInfo>)infoPtr NS_RETURNS_RETAINED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about this signature, in particular the NS_RETURNS_RETAINED. Is this correct?
The object we return is a Swift object. It does not (but could) derive from NSObject.
This PR converts the Swift EndpointInfo into classes like in C++ and C#.