[ReactNative] Use RCTNullIfNill and (id)kCFNull

Summary:
@public

Use consistent `null` handling:

`value || null`                ->  `RCTNullIfNil(value)`
`value == null ? nil : value`  ->  `RCTNilIfNull(value)`
`[NSNull null]`                ->  `(id)kCFNull`

Test Plan: The tests should be enough.
This commit is contained in:
Tadeu Zagallo
2015-06-12 11:05:01 -07:00
parent 696b31f1a4
commit 2a7adfb815
13 changed files with 41 additions and 37 deletions

View File

@@ -57,7 +57,7 @@ static uint64_t _get_time_nanoseconds(void)
JSContextGroupRef group = JSContextGroupCreate();
JSGlobalContextRef context = JSGlobalContextCreateInGroup(group, NULL);
id message = @[@[@1, @2, @3, @4], @[@{@"a": @1}, @{@"b": @2}], [NSNull null]];
id message = @[@[@1, @2, @3, @4], @[@{@"a": @1}, @{@"b": @2}], (id)kCFNull];
NSString *code = RCTJSONStringify(message, NULL);
JSStringRef script = JSStringCreateWithCFString((__bridge CFStringRef)code);
JSValueRef error = NULL;

View File

@@ -28,7 +28,7 @@ TEST_PATH(name, _input, [[[NSBundle mainBundle] bundlePath] stringByAppendingPat
// Basic tests
TEST_URL(basic, @"http://example.com", @"http://example.com")
TEST_URL(null, [NSNull null], nil)
TEST_URL(null, (id)kCFNull, nil)
// Local files
TEST_PATH(fileURL, @"file:///blah/hello.jsbundle", @"/blah/hello.jsbundle")