Skip to content

Commit fa0b45c

Browse files
nicklockwoodfacebook-github-bot-4
authored and
facebook-github-bot-4
committed
Replaced RCTSparseArray with NSDictionary
Reviewed By: jspahrsummers Differential Revision: D2651920 fb-gh-sync-id: 953e2ea33abfc7a3a553da95b13e9ab2bccc5a1c
1 parent 5a34a09 commit fa0b45c

Some content is hidden

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

67 files changed

+338
-547
lines changed

Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj

+12-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
1497CFAF1B21F5E400C1F8F2 /* RCTConvert_NSURLTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFA71B21F5E400C1F8F2 /* RCTConvert_NSURLTests.m */; };
3333
1497CFB01B21F5E400C1F8F2 /* RCTConvert_UIFontTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFA81B21F5E400C1F8F2 /* RCTConvert_UIFontTests.m */; };
3434
1497CFB11B21F5E400C1F8F2 /* RCTEventDispatcherTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFA91B21F5E400C1F8F2 /* RCTEventDispatcherTests.m */; };
35-
1497CFB21B21F5E400C1F8F2 /* RCTSparseArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFAA1B21F5E400C1F8F2 /* RCTSparseArrayTests.m */; };
3635
1497CFB31B21F5E400C1F8F2 /* RCTUIManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFAB1B21F5E400C1F8F2 /* RCTUIManagerTests.m */; };
3736
14AADF051AC3DBB1002390C9 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14AADF041AC3DB95002390C9 /* libReact.a */; };
3837
14B6DA821B276C5900BF4DD1 /* libRCTTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58005BEE1ABA80530062E044 /* libRCTTest.a */; };
@@ -209,7 +208,6 @@
209208
1497CFA71B21F5E400C1F8F2 /* RCTConvert_NSURLTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTConvert_NSURLTests.m; sourceTree = "<group>"; };
210209
1497CFA81B21F5E400C1F8F2 /* RCTConvert_UIFontTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTConvert_UIFontTests.m; sourceTree = "<group>"; };
211210
1497CFA91B21F5E400C1F8F2 /* RCTEventDispatcherTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTEventDispatcherTests.m; sourceTree = "<group>"; };
212-
1497CFAA1B21F5E400C1F8F2 /* RCTSparseArrayTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSparseArrayTests.m; sourceTree = "<group>"; };
213211
1497CFAB1B21F5E400C1F8F2 /* RCTUIManagerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTUIManagerTests.m; sourceTree = "<group>"; };
214212
14AADEFF1AC3DB95002390C9 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../../React/React.xcodeproj; sourceTree = "<group>"; };
215213
14D6D7021B220AE3001FB087 /* NSNotificationCenter+OCMAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNotificationCenter+OCMAdditions.h"; sourceTree = "<group>"; };
@@ -400,7 +398,6 @@
400398
13DF61B51B67A45000EDB188 /* RCTMethodArgumentTests.m */,
401399
1393D0371B68CD1300E1B601 /* RCTModuleMethodTests.m */,
402400
138D6A161B53CD440074A87E /* RCTShadowViewTests.m */,
403-
1497CFAA1B21F5E400C1F8F2 /* RCTSparseArrayTests.m */,
404401
1497CFAB1B21F5E400C1F8F2 /* RCTUIManagerTests.m */,
405402
143BC57E1B21E18100462512 /* Info.plist */,
406403
14D6D7101B220EB3001FB087 /* libOCMock.a */,
@@ -852,7 +849,6 @@
852849
1497CFB01B21F5E400C1F8F2 /* RCTConvert_UIFontTests.m in Sources */,
853850
144D21241B2204C5006DB32B /* RCTImageUtilTests.m in Sources */,
854851
1393D0381B68CD1300E1B601 /* RCTModuleMethodTests.m in Sources */,
855-
1497CFB21B21F5E400C1F8F2 /* RCTSparseArrayTests.m in Sources */,
856852
1300627F1B59179B0043FE5A /* RCTGzipTests.m in Sources */,
857853
1497CFAF1B21F5E400C1F8F2 /* RCTConvert_NSURLTests.m in Sources */,
858854
1497CFAE1B21F5E400C1F8F2 /* RCTContextExecutorTests.m in Sources */,
@@ -991,6 +987,12 @@
991987
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.internal.uiexplorer.local;
992988
PRODUCT_NAME = UIExplorer;
993989
TARGETED_DEVICE_FAMILY = "1,2";
990+
WARNING_CFLAGS = (
991+
"-Wextra",
992+
"-Wall",
993+
"-Wincompatible-pointer-types",
994+
"-Wincompatible-pointer-types-discards-qualifiers",
995+
);
994996
};
995997
name = Debug;
996998
};
@@ -1011,6 +1013,12 @@
10111013
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.internal.uiexplorer.local;
10121014
PRODUCT_NAME = UIExplorer;
10131015
TARGETED_DEVICE_FAMILY = "1,2";
1016+
WARNING_CFLAGS = (
1017+
"-Wextra",
1018+
"-Wall",
1019+
"-Wincompatible-pointer-types",
1020+
"-Wincompatible-pointer-types-discards-qualifiers",
1021+
);
10141022
};
10151023
name = Release;
10161024
};

Examples/UIExplorer/UIExplorerIntegrationTests/RCTUIManagerScenarioTests.m

+13-14
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#import <UIKit/UIKit.h>
1616
#import <XCTest/XCTest.h>
17-
#import "RCTSparseArray.h"
1817
#import "RCTUIManager.h"
1918
#import "UIView+React.h"
2019

@@ -26,9 +25,9 @@ - (void)_manageChildren:(NSNumber *)containerReactTag
2625
addChildReactTags:(NSArray *)addChildReactTags
2726
addAtIndices:(NSArray *)addAtIndices
2827
removeAtIndices:(NSArray *)removeAtIndices
29-
registry:(RCTSparseArray *)registry;
28+
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry;
3029

31-
@property (nonatomic, readonly) RCTSparseArray *viewRegistry;
30+
@property (nonatomic, readonly) NSMutableDictionary<NSNumber *, UIView *> *viewRegistry;
3231

3332
@end
3433

@@ -50,13 +49,13 @@ - (void)setUp
5049
for (NSInteger i = 1; i <= 20; i++) {
5150
UIView *registeredView = [UIView new];
5251
registeredView.reactTag = @(i);
53-
_uiManager.viewRegistry[i] = registeredView;
52+
_uiManager.viewRegistry[@(i)] = registeredView;
5453
}
5554
}
5655

5756
- (void)testManagingChildrenToAddViews
5857
{
59-
UIView *containerView = _uiManager.viewRegistry[20];
58+
UIView *containerView = _uiManager.viewRegistry[@20];
6059
NSMutableArray *addedViews = [NSMutableArray array];
6160

6261
NSArray *tagsToAdd = @[@1, @2, @3, @4, @5];
@@ -72,7 +71,7 @@ - (void)testManagingChildrenToAddViews
7271
addChildReactTags:tagsToAdd
7372
addAtIndices:addAtIndices
7473
removeAtIndices:nil
75-
registry:_uiManager.viewRegistry];
74+
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)_uiManager.viewRegistry];
7675

7776
XCTAssertTrue([[containerView reactSubviews] count] == 5,
7877
@"Expect to have 5 react subviews after calling manage children \
@@ -86,7 +85,7 @@ - (void)testManagingChildrenToAddViews
8685

8786
- (void)testManagingChildrenToRemoveViews
8887
{
89-
UIView *containerView = _uiManager.viewRegistry[20];
88+
UIView *containerView = _uiManager.viewRegistry[@20];
9089
NSMutableArray *removedViews = [NSMutableArray array];
9190

9291
NSArray *removeAtIndices = @[@0, @4, @8, @12, @16];
@@ -95,7 +94,7 @@ - (void)testManagingChildrenToRemoveViews
9594
[removedViews addObject:_uiManager.viewRegistry[reactTag]];
9695
}
9796
for (NSInteger i = 2; i < 20; i++) {
98-
UIView *view = _uiManager.viewRegistry[i];
97+
UIView *view = _uiManager.viewRegistry[@(i)];
9998
[containerView addSubview:view];
10099
}
101100

@@ -106,7 +105,7 @@ - (void)testManagingChildrenToRemoveViews
106105
addChildReactTags:nil
107106
addAtIndices:nil
108107
removeAtIndices:removeAtIndices
109-
registry:_uiManager.viewRegistry];
108+
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)_uiManager.viewRegistry];
110109

111110
XCTAssertEqual(containerView.reactSubviews.count, (NSUInteger)13,
112111
@"Expect to have 13 react subviews after calling manage children\
@@ -119,7 +118,7 @@ - (void)testManagingChildrenToRemoveViews
119118
_uiManager.viewRegistry[view.reactTag] = view;
120119
}
121120
for (NSInteger i = 2; i < 20; i++) {
122-
UIView *view = _uiManager.viewRegistry[i];
121+
UIView *view = _uiManager.viewRegistry[@(i)];
123122
if (![removedViews containsObject:view]) {
124123
XCTAssertTrue([view superview] == containerView,
125124
@"Should not have removed view with react tag %ld during delete but did", (long)i);
@@ -138,7 +137,7 @@ - (void)testManagingChildrenToRemoveViews
138137
// [11,5,1,2,7,8,12,10]
139138
- (void)testManagingChildrenToAddRemoveAndMove
140139
{
141-
UIView *containerView = _uiManager.viewRegistry[20];
140+
UIView *containerView = _uiManager.viewRegistry[@20];
142141

143142
NSArray *removeAtIndices = @[@2, @3, @5, @8];
144143
NSArray *addAtIndices = @[@0, @6];
@@ -155,7 +154,7 @@ - (void)testManagingChildrenToAddRemoveAndMove
155154
}
156155

157156
for (NSInteger i = 1; i < 11; i++) {
158-
UIView *view = _uiManager.viewRegistry[i];
157+
UIView *view = _uiManager.viewRegistry[@(i)];
159158
[containerView addSubview:view];
160159
}
161160

@@ -165,7 +164,7 @@ - (void)testManagingChildrenToAddRemoveAndMove
165164
addChildReactTags:tagsToAdd
166165
addAtIndices:addAtIndices
167166
removeAtIndices:removeAtIndices
168-
registry:_uiManager.viewRegistry];
167+
registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)_uiManager.viewRegistry];
169168

170169
XCTAssertTrue([[containerView reactSubviews] count] == 8,
171170
@"Expect to have 8 react subviews after calling manage children,\
@@ -180,7 +179,7 @@ - (void)testManagingChildrenToAddRemoveAndMove
180179

181180
// Clean up after ourselves
182181
for (NSInteger i = 1; i < 13; i++) {
183-
UIView *view = _uiManager.viewRegistry[i];
182+
UIView *view = _uiManager.viewRegistry[@(i)];
184183
[view removeFromSuperview];
185184
}
186185
for (UIView *view in viewsToRemove) {

Examples/UIExplorer/UIExplorerUnitTests/RCTBridgeTests.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ - (void)setUp;
3131

3232
@interface TestExecutor : NSObject <RCTJavaScriptExecutor>
3333

34-
@property (nonatomic, readonly, copy) NSMutableDictionary *injectedStuff;
34+
@property (nonatomic, readonly, copy) NSMutableDictionary<NSString *, id> *injectedStuff;
3535

3636
@end
3737

@@ -137,7 +137,7 @@ - (void)testHookRegistration
137137
RUN_RUNLOOP_WHILE(!(injectedStuff = executor.injectedStuff[@"__fbBatchedBridgeConfig"]));
138138

139139
__block NSNumber *testModuleID = nil;
140-
__block NSDictionary *testConstants = nil;
140+
__block NSDictionary<NSString *, id> *testConstants = nil;
141141
__block NSNumber *testMethodID = nil;
142142

143143
NSArray *remoteModuleConfig = RCTJSONParse(injectedStuff, NULL)[@"remoteModuleConfig"];
@@ -165,7 +165,7 @@ - (void)testCallNativeMethod
165165
RUN_RUNLOOP_WHILE(!(injectedStuff = executor.injectedStuff[@"__fbBatchedBridgeConfig"]));
166166

167167
__block NSNumber *testModuleID = nil;
168-
__block NSDictionary *testConstants = nil;
168+
__block NSDictionary<NSString *, id> *testConstants = nil;
169169
__block NSNumber *testMethodID = nil;
170170

171171
NSArray *remoteModuleConfig = RCTJSONParse(injectedStuff, NULL)[@"remoteModuleConfig"];
@@ -211,7 +211,7 @@ - (void)DISABLED_testBadArgumentsCount
211211
XCTAssertNotNil(callback);
212212
}
213213

214-
- (NSDictionary *)constantsToExport
214+
- (NSDictionary<NSString *, id> *)constantsToExport
215215
{
216216
return @{@"eleventyMillion": @42};
217217
}

Examples/UIExplorer/UIExplorerUnitTests/RCTEventDispatcherTests.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ @interface RCTTestEvent : RCTBaseEvent
2626

2727
@implementation RCTTestEvent
2828

29-
- (instancetype)initWithViewTag:(NSNumber *)viewTag eventName:(NSString *)eventName body:(NSDictionary *)body
29+
- (instancetype)initWithViewTag:(NSNumber *)viewTag eventName:(NSString *)eventName body:(NSDictionary<NSString *, id> *)body
3030
{
3131
if (self = [super initWithViewTag:viewTag eventName:eventName body:body]) {
3232
self.canCoalesce = YES;
@@ -50,7 +50,7 @@ @implementation RCTEventDispatcherTests
5050
RCTEventDispatcher *_eventDispatcher;
5151

5252
NSString *_eventName;
53-
NSDictionary *_body;
53+
NSDictionary<NSString *, id> *_body;
5454
RCTTestEvent *_testEvent;
5555
NSString *_JSMethod;
5656
}

Examples/UIExplorer/UIExplorerUnitTests/RCTGzipTests.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
@interface RCTNetworking (Private)
2222

23-
- (void)buildRequest:(NSDictionary *)query
23+
- (void)buildRequest:(NSDictionary<NSString *, id> *)query
2424
completionBlock:(void (^)(NSURLRequest *request))block;
2525

2626
@end

Examples/UIExplorer/UIExplorerUnitTests/RCTJSONTests.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ @implementation RCTJSONTests
2323

2424
- (void)testEncodingObject
2525
{
26-
NSDictionary *obj = @{@"foo": @"bar"};
26+
NSDictionary<NSString *, id> *obj = @{@"foo": @"bar"};
2727
NSString *json = @"{\"foo\":\"bar\"}";
2828
XCTAssertEqualObjects(json, RCTJSONStringify(obj, NULL));
2929
}
3030

3131
- (void)testEncodingArray
3232
{
33-
NSArray *array = @[@"foo", @"bar"];
33+
NSArray<id> *array = @[@"foo", @"bar"];
3434
NSString *json = @"[\"foo\",\"bar\"]";
3535
XCTAssertEqualObjects(json, RCTJSONStringify(array, NULL));
3636
}
@@ -44,14 +44,14 @@ - (void)testEncodingString
4444

4545
- (void)testDecodingObject
4646
{
47-
NSDictionary *obj = @{@"foo": @"bar"};
47+
NSDictionary<NSString *, id> *obj = @{@"foo": @"bar"};
4848
NSString *json = @"{\"foo\":\"bar\"}";
4949
XCTAssertEqualObjects(obj, RCTJSONParse(json, NULL));
5050
}
5151

5252
- (void)testDecodingArray
5353
{
54-
NSArray *array = @[@"foo", @"bar"];
54+
NSArray<id> *array = @[@"foo", @"bar"];
5555
NSString *json = @"[\"foo\",\"bar\"]";
5656
XCTAssertEqualObjects(array, RCTJSONParse(json, NULL));
5757
}
@@ -66,14 +66,14 @@ - (void)testDecodingString
6666
- (void)testDecodingMutableArray
6767
{
6868
NSString *json = @"[1,2,3]";
69-
NSMutableArray *array = RCTJSONParseMutable(json, NULL);
69+
NSMutableArray<id> *array = RCTJSONParseMutable(json, NULL);
7070
XCTAssertNoThrow([array addObject:@4]);
7171
XCTAssertEqualObjects(array, (@[@1, @2, @3, @4]));
7272
}
7373

7474
- (void)testLeadingWhitespace
7575
{
76-
NSDictionary *obj = @{@"foo": @"bar"};
76+
NSDictionary<NSString *, id> *obj = @{@"foo": @"bar"};
7777
NSString *json = @" \r\n\t{\"foo\":\"bar\"}";
7878
XCTAssertEqualObjects(obj, RCTJSONParse(json, NULL));
7979
}

Examples/UIExplorer/UIExplorerUnitTests/RCTSparseArrayTests.m

-55
This file was deleted.

0 commit comments

Comments
 (0)