Skip to content
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

[ECO-4968] Added missed NS_SWIFT_SENDABLE #1973

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Ably.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@
844B9CCF2C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
844B9CD02C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
844B9CD12C807BC400A260E8 /* ARTDeviceDetails+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
845381F42C930A8C0085834E /* ARTBaseQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 845381F32C930A8C0085834E /* ARTBaseQuery.h */; settings = {ATTRIBUTES = (Private, ); }; };
845381F52C930A8C0085834E /* ARTBaseQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 845381F32C930A8C0085834E /* ARTBaseQuery.h */; settings = {ATTRIBUTES = (Private, ); }; };
845381F62C930A8C0085834E /* ARTBaseQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 845381F32C930A8C0085834E /* ARTBaseQuery.h */; settings = {ATTRIBUTES = (Private, ); }; };
845381F82C930B9D0085834E /* ARTBaseQuery.m in Sources */ = {isa = PBXBuildFile; fileRef = 845381F72C930B9D0085834E /* ARTBaseQuery.m */; };
845381F92C930B9D0085834E /* ARTBaseQuery.m in Sources */ = {isa = PBXBuildFile; fileRef = 845381F72C930B9D0085834E /* ARTBaseQuery.m */; };
845381FA2C930B9D0085834E /* ARTBaseQuery.m in Sources */ = {isa = PBXBuildFile; fileRef = 845381F72C930B9D0085834E /* ARTBaseQuery.m */; };
848ED97326E50D0F0087E800 /* ObjcppTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 848ED97226E50D0F0087E800 /* ObjcppTest.mm */; settings = {COMPILER_FLAGS = "-fmodules"; }; };
848ED97426E50D0F0087E800 /* ObjcppTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 848ED97226E50D0F0087E800 /* ObjcppTest.mm */; settings = {COMPILER_FLAGS = "-fmodules"; }; };
848ED97526E50D0F0087E800 /* ObjcppTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 848ED97226E50D0F0087E800 /* ObjcppTest.mm */; settings = {COMPILER_FLAGS = "-fmodules"; }; };
Expand Down Expand Up @@ -1245,6 +1251,8 @@
8412FDE32661AC37001FE9E6 /* msgpack.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = msgpack.xcframework; path = Carthage/Build/msgpack.xcframework; sourceTree = "<group>"; };
8412FDF42661AC7B001FE9E6 /* Nimble.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Nimble.xcframework; path = Carthage/Build/Nimble.xcframework; sourceTree = "<group>"; };
844B9CCE2C807BC400A260E8 /* ARTDeviceDetails+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ARTDeviceDetails+Private.h"; path = "PrivateHeaders/Ably/ARTDeviceDetails+Private.h"; sourceTree = "<group>"; };
845381F32C930A8C0085834E /* ARTBaseQuery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARTBaseQuery.h; path = include/Ably/ARTBaseQuery.h; sourceTree = "<group>"; };
845381F72C930B9D0085834E /* ARTBaseQuery.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTBaseQuery.m; sourceTree = "<group>"; };
848ED97226E50D0F0087E800 /* ObjcppTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ObjcppTest.mm; sourceTree = "<group>"; };
850BFB4A1B79323C009D0ADD /* ARTPaginatedResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARTPaginatedResult.h; path = include/Ably/ARTPaginatedResult.h; sourceTree = "<group>"; };
850BFB4B1B79323C009D0ADD /* ARTPaginatedResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTPaginatedResult.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2125,6 +2133,8 @@
96BF61571A35B52C004CF2B3 /* ARTHttp.m */,
D7588AF11BFF91B800BB8279 /* ARTURLSessionServerTrust.h */,
D7588AF21BFF91B800BB8279 /* ARTURLSessionServerTrust.m */,
845381F32C930A8C0085834E /* ARTBaseQuery.h */,
845381F72C930B9D0085834E /* ARTBaseQuery.m */,
D746AE1A1BBB5207003ECEF8 /* ARTDataQuery.h */,
D746AE1B1BBB5207003ECEF8 /* ARTDataQuery+Private.h */,
D746AE1C1BBB5207003ECEF8 /* ARTDataQuery.m */,
Expand Down Expand Up @@ -2232,6 +2242,7 @@
EB91213E1CA0AD6600BA0A40 /* ARTMsgPackEncoder.h in Headers */,
96A507BD1A3791490077CDF8 /* ARTRealtime.h in Headers */,
21088DC32A5354F10033C722 /* ARTConnectRetryState.h in Headers */,
845381F42C930A8C0085834E /* ARTBaseQuery.h in Headers */,
EB5E058D1C77027600A48B39 /* ARTCrypto+Private.h in Headers */,
2132C2F529D5BE05000C4355 /* ARTRetrySequence.h in Headers */,
D72C67DF201AB74000978EBB /* ARTPushActivationStateMachine+Private.h in Headers */,
Expand Down Expand Up @@ -2472,6 +2483,7 @@
D710D4A921949ADF008F54AD /* ARTRestChannels.h in Headers */,
D710D4D821949BF9008F54AD /* ARTRealtimePresence.h in Headers */,
D710D48F21949AAE008F54AD /* ARTRest.h in Headers */,
845381F52C930A8C0085834E /* ARTBaseQuery.h in Headers */,
D710D5B821949D4F008F54AD /* ARTAuthOptions+Private.h in Headers */,
2124B79429DB13C400AD8361 /* ARTInternalLog.h in Headers */,
D710D51D21949C42008F54AD /* ARTDeviceStorage.h in Headers */,
Expand Down Expand Up @@ -2642,6 +2654,7 @@
D710D4AF21949AE0008F54AD /* ARTRestChannels.h in Headers */,
D710D4E821949BFB008F54AD /* ARTRealtimePresence.h in Headers */,
D710D49121949AAF008F54AD /* ARTRest.h in Headers */,
845381F62C930A8C0085834E /* ARTBaseQuery.h in Headers */,
D710D5C821949D50008F54AD /* ARTAuthOptions+Private.h in Headers */,
2124B79529DB13C400AD8361 /* ARTInternalLog.h in Headers */,
D710D52F21949C44008F54AD /* ARTDeviceStorage.h in Headers */,
Expand Down Expand Up @@ -3177,6 +3190,7 @@
D7DF738B1EA645300013CD36 /* ARTLocalDeviceStorage.m in Sources */,
D7B621911E4A6E0200684474 /* ARTPush.m in Sources */,
D70C36C6233E6831002FD6E3 /* ARTFormEncode.m in Sources */,
845381F82C930B9D0085834E /* ARTBaseQuery.m in Sources */,
D7AE18D31E5B410F00478D82 /* ARTPushChannelSubscriptions.m in Sources */,
1CD8DCA01B1C7315007EAF36 /* ARTDefault.m in Sources */,
211A610729DA05D700D169C5 /* ARTAttachRequestParams.m in Sources */,
Expand Down Expand Up @@ -3417,6 +3431,7 @@
D710D5D621949D78008F54AD /* ARTChannel.m in Sources */,
D70C36C7233E6831002FD6E3 /* ARTFormEncode.m in Sources */,
D710D5D121949D78008F54AD /* ARTAuthDetails.m in Sources */,
845381F92C930B9D0085834E /* ARTBaseQuery.m in Sources */,
D710D4EC21949C0D008F54AD /* ARTRealtime.m in Sources */,
D710D4ED21949C0D008F54AD /* ARTRealtimeChannel.m in Sources */,
211A610829DA05D700D169C5 /* ARTAttachRequestParams.m in Sources */,
Expand Down Expand Up @@ -3541,6 +3556,7 @@
D70C36C8233E6831002FD6E3 /* ARTFormEncode.m in Sources */,
D710D5F721949D79008F54AD /* ARTAuthDetails.m in Sources */,
D710D4FC21949C0E008F54AD /* ARTRealtime.m in Sources */,
845381FA2C930B9D0085834E /* ARTBaseQuery.m in Sources */,
D710D4FD21949C0E008F54AD /* ARTRealtimeChannel.m in Sources */,
D710D65621949E77008F54AD /* ARTNSDictionary+ARTDictionaryUtil.m in Sources */,
211A610929DA05D700D169C5 /* ARTAttachRequestParams.m in Sources */,
Expand Down
13 changes: 13 additions & 0 deletions Source/ARTBaseQuery.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#import "ARTBaseQuery.h"

@implementation ARTBaseQuery

- (void)throwIfFrozen {
if (self.isFrozen) {
@throw [NSException exceptionWithName:NSObjectInaccessibleException
reason:[NSString stringWithFormat:@"%@: You can't change query after you've passed it to the receiver.", self.class]
userInfo:nil];
}
}

@end
56 changes: 54 additions & 2 deletions Source/ARTDataQuery.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#import "ARTDataQuery+Private.h"
#import "ARTRealtimeChannel+Private.h"

@implementation ARTDataQuery
@implementation ARTDataQuery {
NSDate *_start;
NSDate *_end;
uint16_t _limit;
ARTQueryDirection _direction;
}

- (instancetype)init {
if (self = [super init]) {
Expand Down Expand Up @@ -38,9 +43,47 @@ - (NSMutableArray *)asQueryItems:(NSError *_Nullable*)error {
return items;
}

- (NSDate *)start {
return _start;
}

- (void)setStart:(NSDate *)value {
[self throwIfFrozen];
_start = value;
}

- (NSDate *)end {
return _end;
}

- (void)setEnd:(NSDate *)value {
[self throwIfFrozen];
_end = value;
}

- (uint16_t)limit {
return _limit;
}

- (void)setLimit:(uint16_t)value {
[self throwIfFrozen];
_limit = value;
}

- (ARTQueryDirection)direction {
return _direction;
}

- (void)setDirection:(ARTQueryDirection)value {
[self throwIfFrozen];
_direction = value;
}

@end

@implementation ARTRealtimeHistoryQuery
@implementation ARTRealtimeHistoryQuery {
BOOL _untilAttach;
}

- (NSMutableArray *)asQueryItems:(NSError **)errorPtr {
NSMutableArray *items = [super asQueryItems:errorPtr];
Expand All @@ -58,4 +101,13 @@ - (NSMutableArray *)asQueryItems:(NSError **)errorPtr {
return items;
}

- (BOOL)untilAttach {
return _untilAttach;
}

- (void)setUntilAttach:(BOOL)value {
[self throwIfFrozen];
_untilAttach = value;
}

@end
15 changes: 14 additions & 1 deletion Source/ARTRealtimePresence.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

#pragma mark - ARTRealtimePresenceQuery

@implementation ARTRealtimePresenceQuery
@implementation ARTRealtimePresenceQuery {
BOOL _waitForSync;
}

- (instancetype)initWithLimit:(NSUInteger)limit clientId:(NSString *)clientId connectionId:(NSString *)connectionId {
self = [super initWithLimit:limit clientId:clientId connectionId:connectionId];
Expand All @@ -29,6 +31,15 @@ - (instancetype)initWithLimit:(NSUInteger)limit clientId:(NSString *)clientId co
return self;
}

- (BOOL)waitForSync {
return _waitForSync;
}

- (void)setWaitForSync:(BOOL)value {
[self throwIfFrozen];
_waitForSync = value;
}

@end

@implementation ARTRealtimePresence {
Expand Down Expand Up @@ -221,6 +232,8 @@ - (void)get:(ARTRealtimePresenceQuery *)query callback:(ARTPresenceMessagesCallb
};
}

query.frozen = true;

dispatch_async(_queue, ^{
switch (self->_channel.state_nosync) {
case ARTRealtimeChannelDetached:
Expand Down
2 changes: 2 additions & 0 deletions Source/ARTRest.m
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,8 @@ - (BOOL)stats:(ARTStatsQuery *)query callback:(ARTPaginatedStatsCallback)callbac
});
};
}

query.frozen = true;

if (query.limit > 1000) {
if (errorPtr) {
Expand Down
2 changes: 2 additions & 0 deletions Source/ARTRestChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ - (BOOL)history:(ARTDataQuery *)query callback:(ARTPaginatedMessagesCallback)cal
});
};
}

query.frozen = true;

__block BOOL ret;
dispatch_sync(_queue, ^{
Expand Down
37 changes: 36 additions & 1 deletion Source/ARTRestPresence.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#import "ARTChannel.h"
#import "ARTDataQuery.h"

@implementation ARTPresenceQuery
@implementation ARTPresenceQuery {
NSUInteger _limit;
NSString *_clientId;
NSString *_connectionId;
}

- (instancetype)init {
return [self initWithClientId:nil connectionId:nil];
Expand Down Expand Up @@ -49,6 +53,33 @@ - (NSMutableArray *)asQueryItems {
return items;
}

- (NSUInteger)limit {
return _limit;
}

- (void)setLimit:(NSUInteger)value {
[self throwIfFrozen];
_limit = value;
}

- (NSString *)clientId {
return _clientId;
}

- (void)setClientId:(NSString *)value {
[self throwIfFrozen];
_clientId = value;
}

- (NSString *)connectionId {
return _connectionId;
}

- (void)setConnectionId:(NSString *)value {
[self throwIfFrozen];
_connectionId = value;
}

@end

@implementation ARTRestPresence {
Expand Down Expand Up @@ -130,6 +161,8 @@ - (BOOL)get:(ARTPresenceQuery *)query callback:(ARTPaginatedPresenceCallback)cal
};
}

query.frozen = true;

if (query.limit > 1000) {
if (errorPtr) {
*errorPtr = [NSError errorWithDomain:ARTAblyErrorDomain
Expand Down Expand Up @@ -175,6 +208,8 @@ - (BOOL)history:(ARTDataQuery *)query callback:(ARTPaginatedPresenceCallback)cal
};
}

query.frozen = true;

if (query.limit > 1000) {
if (errorPtr) {
*errorPtr = [NSError errorWithDomain:ARTAblyErrorDomain
Expand Down
13 changes: 12 additions & 1 deletion Source/ARTStats.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#import "ARTStats.h"
#import "ARTDataQuery+Private.h"

@implementation ARTStatsQuery
@implementation ARTStatsQuery {
ARTStatsGranularity _unit;
}

- (instancetype)init {
if (self = [super init]) {
Expand Down Expand Up @@ -34,6 +36,15 @@ - (NSMutableArray *)asQueryItems:(NSError **)error {
return items;
}

- (ARTStatsGranularity)unit {
return _unit;
}

- (void)setUnit:(ARTStatsGranularity)value {
[self throwIfFrozen];
_unit = value;
}

@end

@implementation ARTStatsMessageCount
Expand Down
1 change: 1 addition & 0 deletions Source/Ably.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ framework module Ably {
header "ARTChannels+Private.h"
header "ARTConnection+Private.h"
header "ARTConnectionDetails+Private.h"
header "ARTBaseQuery.h"
header "ARTDataQuery+Private.h"
header "ARTDefault+Private.h"
header "ARTEventEmitter+Private.h"
Expand Down
10 changes: 10 additions & 0 deletions Source/include/Ably/ARTBaseQuery.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#import <Foundation/Foundation.h>

/// :nodoc:
@interface ARTBaseQuery : NSObject

@property (nonatomic, getter=isFrozen) BOOL frozen;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this property part of the public API?


- (void)throwIfFrozen;

@end
6 changes: 4 additions & 2 deletions Source/include/Ably/ARTDataQuery.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>

#import <Ably/ARTBaseQuery.h>
#import <Ably/ARTTypes.h>

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -14,7 +14,8 @@ typedef NS_ENUM(NSUInteger, ARTQueryDirection) {
/**
This object is used for providing parameters into methods with paginated results.
*/
@interface ARTDataQuery : NSObject
NS_SWIFT_SENDABLE
@interface ARTDataQuery : ARTBaseQuery

/**
* The time from which the data items are retrieved.
Expand All @@ -41,6 +42,7 @@ typedef NS_ENUM(NSUInteger, ARTQueryDirection) {
/**
This object is used for providing parameters into `ARTRealtimePresence`'s methods with paginated results.
*/
NS_SWIFT_SENDABLE
@interface ARTRealtimeHistoryQuery : ARTDataQuery

/**
Expand Down
1 change: 1 addition & 0 deletions Source/include/Ably/ARTRealtimeChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ ART_EMBED_INTERFACE_EVENT_EMITTER(ARTChannelEvent, ARTChannelStateChange *)
/**
* Describes the properties of the channel state.
*/
NS_SWIFT_SENDABLE
umair-ably marked this conversation as resolved.
Show resolved Hide resolved
@interface ARTChannelProperties : NSObject
/**
* Starts unset when a channel is instantiated, then updated with the `channelSerial` from each `ARTChannelEventAttached` event that matches the channel. Used as the value for `ARTRealtimeHistoryQuery.untilAttach`.
Expand Down
1 change: 1 addition & 0 deletions Source/include/Ably/ARTRealtimePresence.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
This object is used for providing parameters into `ARTRealtimePresence`'s methods with paginated results.
*/
NS_SWIFT_SENDABLE
@interface ARTRealtimePresenceQuery : ARTPresenceQuery

/**
Expand Down
4 changes: 3 additions & 1 deletion Source/include/Ably/ARTRestPresence.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#import <Ably/ARTPresence.h>
#import <Ably/ARTDataQuery.h>
#import <Ably/ARTBaseQuery.h>

@class ARTRestChannel;

Expand All @@ -10,7 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
/**
This object is used for providing parameters into `ARTRestPresence`'s methods with paginated results.
*/
@interface ARTPresenceQuery : NSObject
NS_SWIFT_SENDABLE
@interface ARTPresenceQuery : ARTBaseQuery

/**
* An upper limit on the number of messages returned. The default is 100, and the maximum is 1000.
Expand Down
Loading
Loading