Permalink
Browse files

Replaced RCTSparseArray with NSDictionary

Reviewed By: jspahrsummers

Differential Revision: D2651920

fb-gh-sync-id: 953e2ea33abfc7a3a553da95b13e9ab2bccc5a1c
  • Loading branch information...
nicklockwood authored and facebook-github-bot-4 committed Nov 14, 2015
1 parent 5a34a09 commit fa0b45c58b248bad33a339484ac83aaf757c831d
Showing with 338 additions and 547 deletions.
  1. +12 −4 Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj
  2. +13 −14 Examples/UIExplorer/UIExplorerIntegrationTests/RCTUIManagerScenarioTests.m
  3. +4 −4 Examples/UIExplorer/UIExplorerUnitTests/RCTBridgeTests.m
  4. +2 −2 Examples/UIExplorer/UIExplorerUnitTests/RCTEventDispatcherTests.m
  5. +1 −1 Examples/UIExplorer/UIExplorerUnitTests/RCTGzipTests.m
  6. +6 −6 Examples/UIExplorer/UIExplorerUnitTests/RCTJSONTests.m
  7. +0 −55 Examples/UIExplorer/UIExplorerUnitTests/RCTSparseArrayTests.m
  8. +10 −11 Examples/UIExplorer/UIExplorerUnitTests/RCTUIManagerTests.m
  9. +39 −38 Libraries/CameraRoll/RCTCameraRollManager.m
  10. +6 −4 Libraries/CameraRoll/RCTImagePickerManager.m
  11. +2 −2 Libraries/CameraRoll/RCTPhotoLibraryImageLoader.m
  12. +4 −4 Libraries/Geolocation/RCTLocationObserver.m
  13. +3 −3 Libraries/Image/RCTGIFImageDecoder.m
  14. +1 −1 Libraries/Image/RCTImageStoreManager.m
  15. +1 −1 Libraries/Image/RCTImageUtils.m
  16. +2 −2 Libraries/LinkingIOS/RCTLinkingManager.m
  17. +1 −1 Libraries/Network/RCTFileRequestHandler.m
  18. +16 −16 Libraries/Network/RCTNetworking.m
  19. +6 −6 Libraries/PushNotificationIOS/RCTPushNotificationManager.m
  20. +3 −3 Libraries/RCTTest/RCTTestModule.m
  21. +11 −4 Libraries/RCTTest/RCTTestRunner.h
  22. +11 −3 Libraries/RCTTest/RCTTestRunner.m
  23. +1 −1 Libraries/Settings/RCTSettingsManager.m
  24. +4 −5 Libraries/Text/RCTShadowText.m
  25. +2 −3 Libraries/Text/RCTTextFieldManager.m
  26. +5 −6 Libraries/Text/RCTTextManager.m
  27. +4 −4 Libraries/Text/RCTTextView.m
  28. +2 −3 Libraries/Text/RCTTextViewManager.m
  29. +1 −1 Libraries/WebSocket/RCTSRWebSocket.m
  30. +12 −13 Libraries/WebSocket/RCTWebSocketExecutor.m
  31. +4 −5 Libraries/WebSocket/RCTWebSocketModule.m
  32. +1 −1 React/Base/RCTAssert.h
  33. +2 −2 React/Base/RCTAssert.m
  34. +1 −2 React/Base/RCTBatchedBridge.m
  35. +1 −1 React/Base/RCTBridgeModule.h
  36. +1 −1 React/Base/RCTLog.m
  37. +0 −38 React/Base/RCTSparseArray.h
  38. +0 −123 React/Base/RCTSparseArray.m
  39. +3 −3 React/Base/RCTUtils.h
  40. +8 −8 React/Base/RCTUtils.m
  41. +1 −1 React/Modules/RCTAccessibilityManager.h
  42. +9 −9 React/Modules/RCTAccessibilityManager.m
  43. +1 −1 React/Modules/RCTSourceCode.m
  44. +5 −6 React/Modules/RCTTiming.m
  45. +47 −47 React/Modules/RCTUIManager.m
  46. +2 −3 React/Profiler/RCTPerfMonitor.m
  47. +0 −6 React/React.xcodeproj/project.pbxproj
  48. +5 −4 React/Views/RCTComponentData.h
  49. +12 −13 React/Views/RCTComponentData.m
  50. +1 −1 React/Views/RCTDatePickerManager.m
  51. +3 −3 React/Views/RCTModalHostView.m
  52. +2 −2 React/Views/RCTNavigatorManager.m
  53. +1 −1 React/Views/RCTPickerManager.m
  54. +1 −1 React/Views/RCTProgressViewManager.m
  55. +1 −1 React/Views/RCTScrollView.m
  56. +3 −4 React/Views/RCTScrollViewManager.m
  57. +1 −1 React/Views/RCTSegmentedControlManager.m
  58. +4 −4 React/Views/RCTShadowView.h
  59. +7 −8 React/Views/RCTShadowView.m
  60. +2 −2 React/Views/RCTView.m
  61. +4 −4 React/Views/RCTViewManager.h
  62. +3 −3 React/Views/RCTViewManager.m
  63. +1 −1 React/Views/RCTWebView.h
  64. +6 −6 React/Views/RCTWebView.m
  65. +6 −6 React/Views/RCTWebViewManager.m
  66. +2 −2 React/Views/UIView+React.h
  67. +2 −2 React/Views/UIView+React.m
@@ -32,7 +32,6 @@
1497CFAF1B21F5E400C1F8F2 /* RCTConvert_NSURLTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFA71B21F5E400C1F8F2 /* RCTConvert_NSURLTests.m */; };
1497CFB01B21F5E400C1F8F2 /* RCTConvert_UIFontTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFA81B21F5E400C1F8F2 /* RCTConvert_UIFontTests.m */; };
1497CFB11B21F5E400C1F8F2 /* RCTEventDispatcherTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFA91B21F5E400C1F8F2 /* RCTEventDispatcherTests.m */; };
- 1497CFB21B21F5E400C1F8F2 /* RCTSparseArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFAA1B21F5E400C1F8F2 /* RCTSparseArrayTests.m */; };
1497CFB31B21F5E400C1F8F2 /* RCTUIManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFAB1B21F5E400C1F8F2 /* RCTUIManagerTests.m */; };
14AADF051AC3DBB1002390C9 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14AADF041AC3DB95002390C9 /* libReact.a */; };
14B6DA821B276C5900BF4DD1 /* libRCTTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58005BEE1ABA80530062E044 /* libRCTTest.a */; };
@@ -209,7 +208,6 @@
1497CFA71B21F5E400C1F8F2 /* RCTConvert_NSURLTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTConvert_NSURLTests.m; sourceTree = "<group>"; };
1497CFA81B21F5E400C1F8F2 /* RCTConvert_UIFontTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTConvert_UIFontTests.m; sourceTree = "<group>"; };
1497CFA91B21F5E400C1F8F2 /* RCTEventDispatcherTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTEventDispatcherTests.m; sourceTree = "<group>"; };
- 1497CFAA1B21F5E400C1F8F2 /* RCTSparseArrayTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSparseArrayTests.m; sourceTree = "<group>"; };
1497CFAB1B21F5E400C1F8F2 /* RCTUIManagerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTUIManagerTests.m; sourceTree = "<group>"; };
14AADEFF1AC3DB95002390C9 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../../React/React.xcodeproj; sourceTree = "<group>"; };
14D6D7021B220AE3001FB087 /* NSNotificationCenter+OCMAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNotificationCenter+OCMAdditions.h"; sourceTree = "<group>"; };
@@ -400,7 +398,6 @@
13DF61B51B67A45000EDB188 /* RCTMethodArgumentTests.m */,
1393D0371B68CD1300E1B601 /* RCTModuleMethodTests.m */,
138D6A161B53CD440074A87E /* RCTShadowViewTests.m */,
- 1497CFAA1B21F5E400C1F8F2 /* RCTSparseArrayTests.m */,
1497CFAB1B21F5E400C1F8F2 /* RCTUIManagerTests.m */,
143BC57E1B21E18100462512 /* Info.plist */,
14D6D7101B220EB3001FB087 /* libOCMock.a */,
@@ -852,7 +849,6 @@
1497CFB01B21F5E400C1F8F2 /* RCTConvert_UIFontTests.m in Sources */,
144D21241B2204C5006DB32B /* RCTImageUtilTests.m in Sources */,
1393D0381B68CD1300E1B601 /* RCTModuleMethodTests.m in Sources */,
- 1497CFB21B21F5E400C1F8F2 /* RCTSparseArrayTests.m in Sources */,
1300627F1B59179B0043FE5A /* RCTGzipTests.m in Sources */,
1497CFAF1B21F5E400C1F8F2 /* RCTConvert_NSURLTests.m in Sources */,
1497CFAE1B21F5E400C1F8F2 /* RCTContextExecutorTests.m in Sources */,
@@ -991,6 +987,12 @@
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.internal.uiexplorer.local;
PRODUCT_NAME = UIExplorer;
TARGETED_DEVICE_FAMILY = "1,2";
+ WARNING_CFLAGS = (
+ "-Wextra",
+ "-Wall",
+ "-Wincompatible-pointer-types",
+ "-Wincompatible-pointer-types-discards-qualifiers",
+ );
};
name = Debug;
};
@@ -1011,6 +1013,12 @@
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.internal.uiexplorer.local;
PRODUCT_NAME = UIExplorer;
TARGETED_DEVICE_FAMILY = "1,2";
+ WARNING_CFLAGS = (
+ "-Wextra",
+ "-Wall",
+ "-Wincompatible-pointer-types",
+ "-Wincompatible-pointer-types-discards-qualifiers",
+ );
};
name = Release;
};
@@ -14,7 +14,6 @@
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
-#import "RCTSparseArray.h"
#import "RCTUIManager.h"
#import "UIView+React.h"
@@ -26,9 +25,9 @@ - (void)_manageChildren:(NSNumber *)containerReactTag
addChildReactTags:(NSArray *)addChildReactTags
addAtIndices:(NSArray *)addAtIndices
removeAtIndices:(NSArray *)removeAtIndices
- registry:(RCTSparseArray *)registry;
+ registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)registry;
-@property (nonatomic, readonly) RCTSparseArray *viewRegistry;
+@property (nonatomic, readonly) NSMutableDictionary<NSNumber *, UIView *> *viewRegistry;
@end
@@ -50,13 +49,13 @@ - (void)setUp
for (NSInteger i = 1; i <= 20; i++) {
UIView *registeredView = [UIView new];
registeredView.reactTag = @(i);
- _uiManager.viewRegistry[i] = registeredView;
+ _uiManager.viewRegistry[@(i)] = registeredView;
}
}
- (void)testManagingChildrenToAddViews
{
- UIView *containerView = _uiManager.viewRegistry[20];
+ UIView *containerView = _uiManager.viewRegistry[@20];
NSMutableArray *addedViews = [NSMutableArray array];
NSArray *tagsToAdd = @[@1, @2, @3, @4, @5];
@@ -72,7 +71,7 @@ - (void)testManagingChildrenToAddViews
addChildReactTags:tagsToAdd
addAtIndices:addAtIndices
removeAtIndices:nil
- registry:_uiManager.viewRegistry];
+ registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)_uiManager.viewRegistry];
XCTAssertTrue([[containerView reactSubviews] count] == 5,
@"Expect to have 5 react subviews after calling manage children \
@@ -86,7 +85,7 @@ - (void)testManagingChildrenToAddViews
- (void)testManagingChildrenToRemoveViews
{
- UIView *containerView = _uiManager.viewRegistry[20];
+ UIView *containerView = _uiManager.viewRegistry[@20];
NSMutableArray *removedViews = [NSMutableArray array];
NSArray *removeAtIndices = @[@0, @4, @8, @12, @16];
@@ -95,7 +94,7 @@ - (void)testManagingChildrenToRemoveViews
[removedViews addObject:_uiManager.viewRegistry[reactTag]];
}
for (NSInteger i = 2; i < 20; i++) {
- UIView *view = _uiManager.viewRegistry[i];
+ UIView *view = _uiManager.viewRegistry[@(i)];
[containerView addSubview:view];
}
@@ -106,7 +105,7 @@ - (void)testManagingChildrenToRemoveViews
addChildReactTags:nil
addAtIndices:nil
removeAtIndices:removeAtIndices
- registry:_uiManager.viewRegistry];
+ registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)_uiManager.viewRegistry];
XCTAssertEqual(containerView.reactSubviews.count, (NSUInteger)13,
@"Expect to have 13 react subviews after calling manage children\
@@ -119,7 +118,7 @@ - (void)testManagingChildrenToRemoveViews
_uiManager.viewRegistry[view.reactTag] = view;
}
for (NSInteger i = 2; i < 20; i++) {
- UIView *view = _uiManager.viewRegistry[i];
+ UIView *view = _uiManager.viewRegistry[@(i)];
if (![removedViews containsObject:view]) {
XCTAssertTrue([view superview] == containerView,
@"Should not have removed view with react tag %ld during delete but did", (long)i);
@@ -138,7 +137,7 @@ - (void)testManagingChildrenToRemoveViews
// [11,5,1,2,7,8,12,10]
- (void)testManagingChildrenToAddRemoveAndMove
{
- UIView *containerView = _uiManager.viewRegistry[20];
+ UIView *containerView = _uiManager.viewRegistry[@20];
NSArray *removeAtIndices = @[@2, @3, @5, @8];
NSArray *addAtIndices = @[@0, @6];
@@ -155,7 +154,7 @@ - (void)testManagingChildrenToAddRemoveAndMove
}
for (NSInteger i = 1; i < 11; i++) {
- UIView *view = _uiManager.viewRegistry[i];
+ UIView *view = _uiManager.viewRegistry[@(i)];
[containerView addSubview:view];
}
@@ -165,7 +164,7 @@ - (void)testManagingChildrenToAddRemoveAndMove
addChildReactTags:tagsToAdd
addAtIndices:addAtIndices
removeAtIndices:removeAtIndices
- registry:_uiManager.viewRegistry];
+ registry:(NSMutableDictionary<NSNumber *, id<RCTComponent>> *)_uiManager.viewRegistry];
XCTAssertTrue([[containerView reactSubviews] count] == 8,
@"Expect to have 8 react subviews after calling manage children,\
@@ -180,7 +179,7 @@ - (void)testManagingChildrenToAddRemoveAndMove
// Clean up after ourselves
for (NSInteger i = 1; i < 13; i++) {
- UIView *view = _uiManager.viewRegistry[i];
+ UIView *view = _uiManager.viewRegistry[@(i)];
[view removeFromSuperview];
}
for (UIView *view in viewsToRemove) {
@@ -31,7 +31,7 @@ - (void)setUp;
@interface TestExecutor : NSObject <RCTJavaScriptExecutor>
-@property (nonatomic, readonly, copy) NSMutableDictionary *injectedStuff;
+@property (nonatomic, readonly, copy) NSMutableDictionary<NSString *, id> *injectedStuff;
@end
@@ -137,7 +137,7 @@ - (void)testHookRegistration
RUN_RUNLOOP_WHILE(!(injectedStuff = executor.injectedStuff[@"__fbBatchedBridgeConfig"]));
__block NSNumber *testModuleID = nil;
- __block NSDictionary *testConstants = nil;
+ __block NSDictionary<NSString *, id> *testConstants = nil;
__block NSNumber *testMethodID = nil;
NSArray *remoteModuleConfig = RCTJSONParse(injectedStuff, NULL)[@"remoteModuleConfig"];
@@ -165,7 +165,7 @@ - (void)testCallNativeMethod
RUN_RUNLOOP_WHILE(!(injectedStuff = executor.injectedStuff[@"__fbBatchedBridgeConfig"]));
__block NSNumber *testModuleID = nil;
- __block NSDictionary *testConstants = nil;
+ __block NSDictionary<NSString *, id> *testConstants = nil;
__block NSNumber *testMethodID = nil;
NSArray *remoteModuleConfig = RCTJSONParse(injectedStuff, NULL)[@"remoteModuleConfig"];
@@ -211,7 +211,7 @@ - (void)DISABLED_testBadArgumentsCount
XCTAssertNotNil(callback);
}
-- (NSDictionary *)constantsToExport
+- (NSDictionary<NSString *, id> *)constantsToExport
{
return @{@"eleventyMillion": @42};
}
@@ -26,7 +26,7 @@ @interface RCTTestEvent : RCTBaseEvent
@implementation RCTTestEvent
-- (instancetype)initWithViewTag:(NSNumber *)viewTag eventName:(NSString *)eventName body:(NSDictionary *)body
+- (instancetype)initWithViewTag:(NSNumber *)viewTag eventName:(NSString *)eventName body:(NSDictionary<NSString *, id> *)body
{
if (self = [super initWithViewTag:viewTag eventName:eventName body:body]) {
self.canCoalesce = YES;
@@ -50,7 +50,7 @@ @implementation RCTEventDispatcherTests
RCTEventDispatcher *_eventDispatcher;
NSString *_eventName;
- NSDictionary *_body;
+ NSDictionary<NSString *, id> *_body;
RCTTestEvent *_testEvent;
NSString *_JSMethod;
}
@@ -20,7 +20,7 @@
@interface RCTNetworking (Private)
-- (void)buildRequest:(NSDictionary *)query
+- (void)buildRequest:(NSDictionary<NSString *, id> *)query
completionBlock:(void (^)(NSURLRequest *request))block;
@end
@@ -23,14 +23,14 @@ @implementation RCTJSONTests
- (void)testEncodingObject
{
- NSDictionary *obj = @{@"foo": @"bar"};
+ NSDictionary<NSString *, id> *obj = @{@"foo": @"bar"};
NSString *json = @"{\"foo\":\"bar\"}";
XCTAssertEqualObjects(json, RCTJSONStringify(obj, NULL));
}
- (void)testEncodingArray
{
- NSArray *array = @[@"foo", @"bar"];
+ NSArray<id> *array = @[@"foo", @"bar"];
NSString *json = @"[\"foo\",\"bar\"]";
XCTAssertEqualObjects(json, RCTJSONStringify(array, NULL));
}
@@ -44,14 +44,14 @@ - (void)testEncodingString
- (void)testDecodingObject
{
- NSDictionary *obj = @{@"foo": @"bar"};
+ NSDictionary<NSString *, id> *obj = @{@"foo": @"bar"};
NSString *json = @"{\"foo\":\"bar\"}";
XCTAssertEqualObjects(obj, RCTJSONParse(json, NULL));
}
- (void)testDecodingArray
{
- NSArray *array = @[@"foo", @"bar"];
+ NSArray<id> *array = @[@"foo", @"bar"];
NSString *json = @"[\"foo\",\"bar\"]";
XCTAssertEqualObjects(array, RCTJSONParse(json, NULL));
}
@@ -66,14 +66,14 @@ - (void)testDecodingString
- (void)testDecodingMutableArray
{
NSString *json = @"[1,2,3]";
- NSMutableArray *array = RCTJSONParseMutable(json, NULL);
+ NSMutableArray<id> *array = RCTJSONParseMutable(json, NULL);
XCTAssertNoThrow([array addObject:@4]);
XCTAssertEqualObjects(array, (@[@1, @2, @3, @4]));
}
- (void)testLeadingWhitespace
{
- NSDictionary *obj = @{@"foo": @"bar"};
+ NSDictionary<NSString *, id> *obj = @{@"foo": @"bar"};
NSString *json = @" \r\n\t{\"foo\":\"bar\"}";
XCTAssertEqualObjects(obj, RCTJSONParse(json, NULL));
}
@@ -1,55 +0,0 @@
-/**
- * The examples provided by Facebook are for non-commercial testing and
- * evaluation purposes only.
- *
- * Facebook reserves all rights not expressly granted.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
- * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#import <XCTest/XCTest.h>
-
-#import "RCTSparseArray.h"
-#import "UIView+React.h"
-
-@interface RCTSparseArrayTests : XCTestCase
-
-@end
-
-@implementation RCTSparseArrayTests
-
-- (void)testDictionary
-{
- id<RCTComponent> myView = [UIView new];
- myView.reactTag = @4;
-
- id<RCTComponent> myOtherView = [UIView new];
- myOtherView.reactTag = @5;
-
- RCTSparseArray *registry = [RCTSparseArray new];
- XCTAssertNil(registry[@4], @"how did you have a view when none are registered?");
- XCTAssertNil(registry[@5], @"how did you have a view when none are registered?");
-
- registry[myView.reactTag] = myView;
- XCTAssertEqual(registry[@4], myView);
- XCTAssertNil(registry[@5], @"didn't register other view yet");
-
- registry[myOtherView.reactTag] = myOtherView;
- XCTAssertEqual(registry[@4], myView);
- XCTAssertEqual(registry[@5], myOtherView);
-
- registry[myView.reactTag] = nil;
- XCTAssertNil(registry[@4]);
- XCTAssertEqual(registry[@5], myOtherView);
-
- registry[myOtherView.reactTag] = nil;
- XCTAssertNil(registry[@4], @"how did you have a view when none are registered?");
- XCTAssertNil(registry[@5], @"how did you have a view when none are registered?");
-}
-
-@end
Oops, something went wrong.

0 comments on commit fa0b45c

Please sign in to comment.