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

Add type to most array, set and dictionarry #270

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion Channel/Tests/EDOChannelPoolTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ - (void)testAsyncCreateChannels {

for (int i = 0; i < 10; i++) {
UInt16 port = i % 2 == 0 ? host1.socketPort.port : host2.socketPort.port;
NSMutableSet *set = i % 2 == 0 ? set1 : set2;
NSMutableSet<EDOSocketChannel *> *set = i % 2 == 0 ? set1 : set2;
EDOHostPort *hostPort = [EDOHostPort hostPortWithLocalPort:port];
id<EDOChannel> socketChannel = [channelPool channelWithPort:hostPort error:nil];

Expand Down
6 changes: 3 additions & 3 deletions Device/Sources/EDODeviceConnector.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ @interface EDODeviceConnector ()
/** The detector to detect iOS device attachment/detachment events. */
@property(nonatomic) EDODeviceDetector *detector;
/** The connected device info of mappings from device serial strings to auto-assigned device IDs. */
@property(nonatomic) NSMutableDictionary *deviceInfo;
@property(nonatomic) NSMutableDictionary<NSString*, NSNumber*>  *deviceInfo;
@end

@implementation EDODeviceConnector {
Expand Down Expand Up @@ -69,7 +69,7 @@ + (EDODeviceConnector *)sharedConnector {
// Wait for a short time to detect all connected devices when listening just starts.
sleep(kDeviceDetectTime);
}
__block NSArray *result;
__block NSArray<NSString*> *result;
dispatch_sync(_syncQueue, ^{
result = [self.deviceInfo.allKeys copy];
});
Expand Down Expand Up @@ -153,7 +153,7 @@ - (void)handleBroadcastPacket:(NSDictionary *)packet {
userInfo:userInfo];
} else if ([messageType isEqualToString:kEDOMessageTypeDetachedKey]) {
NSNumber *deviceID = packet[kEDOMessageDeviceIDKey];
NSMutableArray *keysToRemove = [[NSMutableArray alloc] init];
NSMutableArray<NSString*> *keysToRemove = [[NSMutableArray alloc] init];
dispatch_sync(_syncQueue, ^{
for (NSString *serialNumberString in self.deviceInfo) {
if ([self.deviceInfo[serialNumberString] isEqualToNumber:deviceID]) {
Expand Down
2 changes: 1 addition & 1 deletion Device/Tests/EDODeviceConnectorTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// Exposes the internal property for test purpose.
@interface EDODeviceConnector ()
@property(nonatomic) EDODeviceDetector *detector;
@property(nonatomic) NSMutableDictionary *deviceInfo;
@property(nonatomic) NSMutableDictionary<NSString*, NSNumber*> *deviceInfo;
@end

@interface EDODeviceConnectorTest : XCTestCase
Expand Down
2 changes: 1 addition & 1 deletion Service/Sources/EDOHostService+Handlers.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ + (NSDictionary *)handlers {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
handlers = [[NSMutableDictionary alloc] init];
NSArray *requestClasses = @[
NSArray<class> *requestClasses = @[
[EDOClassRequest class],
[EDOInvocationRequest class],
[EDOMethodSignatureRequest class],
Expand Down
6 changes: 3 additions & 3 deletions Service/Sources/EDOInvocationMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder {
forKey:kEDOInvocationCoderReturnValueKey];
_exception = [aDecoder decodeObjectOfClass:[EDORemoteException class]
forKey:kEDOInvocationCoderExceptionKey];
NSSet *anyClasses =
NSSet<Class> *anyClasses =
[NSSet setWithObjects:[EDOBlockObject class], [NSObject class], [EDOObject class], nil];
_outValues = [aDecoder decodeObjectOfClasses:anyClasses forKey:kEDOInvocationCoderOutValuesKey];
}
Expand Down Expand Up @@ -515,7 +515,7 @@ - (instancetype)initWithTarget:(EDOPointerType)target
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
NSSet *anyClasses =
NSSet<Class> *anyClasses =
[NSSet setWithObjects:[EDOBlockObject class], [EDOObject class], [NSObject class], nil];
_target = [aDecoder decodeInt64ForKey:kEDOInvocationCoderTargetKey];
_selectorName = [aDecoder decodeObjectOfClass:[NSString class]
Expand All @@ -542,4 +542,4 @@ - (NSString *)description {
self.messageID, self.target, self.selectorName];
}

@end
@end
2 changes: 1 addition & 1 deletion Service/Sources/EDOParameter.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder {
// EDOParameter can carry any type of object as long as it's serializable, so it whitelists all
// the types inheriting from NSObject. EDOObject and EDOBlockObject are NSProxy's and need to be
// whitelisted as well.
NSSet *anyClasses =
NSSet<Class> *anyClasses =
[NSSet setWithObjects:[EDOBlockObject class], [EDOObject class], [NSObject class], nil];
_value = [aDecoder decodeObjectOfClasses:anyClasses forKey:kEDOParameterCoderValueKey];
_valueObjCType = [aDecoder decodeObjectOfClass:[NSString class]
Expand Down
2 changes: 1 addition & 1 deletion Service/Tests/FunctionalTests/EDOServiceUIBlockTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ - (void)testBlockResolveToLocalAddress {
- (void)testBlockByValueAndOutArgument {
EDOTestDummy *remoteDummy = [EDOClientService rootObjectWithPort:EDOTEST_APP_SERVICE_PORT];

NSArray *arrayReturn = [remoteDummy returnWithBlockObject:^id(EDOTestDummy *dummy) {
NSArray<NSNumber*> *arrayReturn = [remoteDummy returnWithBlockObject:^id(EDOTestDummy *dummy) {
// Use NSClassFromString to fetch EDOObject to make it private here.
XCTAssertEqual([dummy class], NSClassFromString(@"EDOObject"));
XCTAssertEqual(dummy.value, 10);
Expand Down
8 changes: 4 additions & 4 deletions Service/Tests/FunctionalTests/EDOServiceUITest.m
Original file line number Diff line number Diff line change
Expand Up @@ -401,17 +401,17 @@ - (void)testIsKindOfClassOnlyResolvesInSameProcess {
- (void)testRemoteObjectCopy {
[self launchApplicationWithPort:EDOTEST_APP_SERVICE_PORT initValue:5];
EDOTestDummy *dummy = [EDOClientService rootObjectWithPort:EDOTEST_APP_SERVICE_PORT];
NSArray *remoteArray = [dummy returnArray];
NSArray *remoteArrayCopy;
NSArray<NSNumber*> *remoteArray = [dummy returnArray];
NSArra<NSNumber*>y *remoteArrayCopy;
XCTAssertNoThrow(remoteArrayCopy = [remoteArray copy]);
XCTAssertEqual(remoteArray, remoteArrayCopy);
}

- (void)testRemoteObjectMutableCopy {
[self launchApplicationWithPort:EDOTEST_APP_SERVICE_PORT initValue:5];
EDOTestDummy *dummy = [EDOClientService rootObjectWithPort:EDOTEST_APP_SERVICE_PORT];
NSArray *remoteArray = [dummy returnArray];
NSMutableArray *remoteArrayCopy = [remoteArray mutableCopy];
NSArray<NSNumber*> *remoteArray = [dummy returnArray];
NSMutableArray<NSNumber*> *remoteArrayCopy = [remoteArray mutableCopy];
XCTAssertNotEqual(remoteArray, remoteArrayCopy);
XCTAssertEqualObjects(remoteArray, remoteArrayCopy);
[remoteArrayCopy addObject:@"test"];
Expand Down
6 changes: 3 additions & 3 deletions Service/Tests/PerfTests/EDOServicePerfTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ - (void)testIteratingReturnByValueResultLotsTimes {
assertPerformBlockWithWeight:1
executions:10
block:^(EDOTestDummy *remoteDummy) {
NSArray *result = [[remoteDummy returnByValue] returnLargeArray];
NSArray<NSNumber *> *result = [[remoteDummy returnByValue] returnLargeArray];
for (NSInteger i = 0; i < 1000; i++) {
XCTAssert(((NSNumber *)result[i]).integerValue == i);
}
Expand All @@ -203,7 +203,7 @@ - (void)testIteratingReturnByValueResultLotsTimes {
[self assertPerformBlockWithWeight:1000
executions:10
block:^(EDOTestDummy *remoteDummy) {
NSArray *result = [remoteDummy returnLargeArray];
NSArray<NSNumber *> *result = [remoteDummy returnLargeArray];
for (NSInteger i = 0; i < 1000; i++) {
XCTAssert(((NSNumber *)result[i]).integerValue == i);
}
Expand All @@ -212,7 +212,7 @@ - (void)testIteratingReturnByValueResultLotsTimes {
}

- (void)testIteratingPassByValueParameterLotsTimes {
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:1000];
NSMutableArray<NSNumber *> *array = [[NSMutableArray alloc] initWithCapacity:1000];
for (int i = 0; i < 1000; i++) {
[array addObject:@(i)];
}
Expand Down
4 changes: 2 additions & 2 deletions Service/Tests/TestsBundle/EDOTestDummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ typedef EDOTestDummy * (^EDOMultiTypesHandler)(EDOTestDummyStruct, int, id, EDOT
- (BOOL)returnBoolWithError:(NSError **)errorOrNil;
- (NSString *)returnClassNameWithObject:(id)object;
- (NSInteger)returnCountWithArray:(NSArray *)value;
- (NSInteger)returnSumWithArray:(NSArray *)value;
- (NSInteger)returnSumWithArrayAndProxyCheck:(NSArray *)value;
- (NSInteger)returnSumWithArray:(NSArray<NSNumber*> *)value;
- (NSInteger)returnSumWithArrayAndProxyCheck:(NSArray<NSNumber*> *)value;
- (int *)returnIntPointer;

/**
Expand Down
4 changes: 2 additions & 2 deletions Service/Tests/TestsBundle/EDOTestDummy.m
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,15 @@ - (NSInteger)returnCountWithArray:(NSArray *)value {
return value.count;
}

- (NSInteger)returnSumWithArray:(NSArray *)value {
- (NSInteger)returnSumWithArray:(NSArray<NSNumber*> *)value {
NSInteger result = 0;
for (NSNumber *number in value) {
result += number.integerValue;
}
return result;
}

- (NSInteger)returnSumWithArrayAndProxyCheck:(NSArray *)value {
- (NSInteger)returnSumWithArrayAndProxyCheck:(NSArray<NSNumber*> *)value {
NSAssert(!value.isProxy,
@"This method is to test pass-by-value. The parameter should not be a proxy.");
return [self returnSumWithArray:value];
Expand Down
22 changes: 11 additions & 11 deletions Service/Tests/UnitTests/EDOServiceTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,9 @@ - (void)testEDOEqual {

- (void)testEDOAsDictKey {
EDOTestDummy *dummyOnBackground = self.rootObjectOnBackground;
NSSet *returnSet = [dummyOnBackground returnSet];
NSArray *returnArray = [dummyOnBackground returnArray];
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
NSSet<NSNumber *> *returnSet = [dummyOnBackground returnSet];
NSArray<NSNumber *> *returnArray = [dummyOnBackground returnArray];
NSMutableDictionary<NSString *, NSNumber *> *dictionary = [[NSMutableDictionary alloc] init];

XCTAssertNil(dictionary[returnSet]);
XCTAssertNoThrow(dictionary[returnSet] = @1);
Expand All @@ -707,8 +707,8 @@ - (void)testEDOAsDictKey {

- (void)testEDOAsCFDictKey {
EDOTestDummy *dummyOnBackground = self.rootObjectOnBackground;
NSSet *returnSet = [dummyOnBackground returnSet];
NSArray *returnArray = [dummyOnBackground returnArray];
NSSet<NSNumber *> *returnSet = [dummyOnBackground returnSet];
NSArray<NSNumber *> *returnArray = [dummyOnBackground returnArray];
CFMutableDictionaryRef cfDictionary = CFDictionaryCreateMutable(
NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);

Expand Down Expand Up @@ -751,8 +751,8 @@ - (void)testFailToEnableNonNSCodingTypetoBeValueType {

- (void)testEDOReturnsAsValueType {
EDOTestDummy *dummyOnBackground = self.rootObjectOnBackground;
NSArray *returnArray = [[dummyOnBackground returnByValue] returnArray];
NSArray *localArray = @[ @1, @2, @3, @4 ];
NSArray<NSNumber *> *returnArray = [[dummyOnBackground returnByValue] returnArray];
NSArray<NSNumber *> *localArray = @[ @1, @2, @3, @4 ];
XCTAssertEqual([returnArray class], [localArray class]);
XCTAssertTrue([returnArray isEqualToArray:localArray]);
}
Expand All @@ -771,25 +771,25 @@ - (void)testEDOPassByValue {

- (void)testEDOPassByValueWithRemoteObject {
EDOTestDummy *dummyOnBackground = self.rootObjectOnBackground;
NSArray *array = [dummyOnBackground returnArray];
NSArray<NSNumber *> *array = [dummyOnBackground returnArray];
XCTAssertEqual([dummyOnBackground returnCountWithArray:[array passByValue]], 4);
}

- (void)testEDOPassByValueNestedWithReturnByValue {
EDOTestDummy *dummyOnBackground = self.rootObjectOnBackground;
NSArray *array = [dummyOnBackground returnArray];
NSArray<NSNumber *> *array = [dummyOnBackground returnArray];
XCTAssertEqual([dummyOnBackground returnCountWithArray:[[array returnByValue] passByValue]], 4);
}

- (void)testEDOPassByValueNestedWithPassByValue {
EDOTestDummy *dummyOnBackground = self.rootObjectOnBackground;
NSArray *array = [dummyOnBackground returnArray];
NSArray<NSNumber *> *array = [dummyOnBackground returnArray];
XCTAssertEqual([dummyOnBackground returnCountWithArray:[[array passByValue] passByValue]], 4);
}

- (void)testEDOReturnByValueNestedWithPassByValue {
EDOTestDummy *dummyOnBackground = self.rootObjectOnBackground;
NSArray *array = [dummyOnBackground returnArray];
NSArray<NSNumber *> *array = [dummyOnBackground returnArray];
XCTAssertEqual([dummyOnBackground returnCountWithArray:[[array passByValue] returnByValue]], 4);
}

Expand Down