Improve definition of RCTNilIfNull

Reviewed By: fkgozali

Differential Revision: D5479733

fbshipit-source-id: 460845f79a970dd6614b11de3ce8898ea17ae1dc
This commit is contained in:
Pieter De Baets 2017-08-09 03:16:31 -07:00 committed by Facebook Github Bot
parent 55117ea607
commit 0241cb76d1
1 changed files with 2 additions and 1 deletions

View File

@ -96,7 +96,8 @@ RCT_EXTERN NSError *RCTErrorWithMessage(NSString *message);
// Convert nil values to NSNull, and vice-versa
#define RCTNullIfNil(value) (value ?: (id)kCFNull)
#define RCTNilIfNull(value) (value == (id)kCFNull ? nil : value)
#define RCTNilIfNull(value) \
({ __typeof__(value) t = (value); (id)t == (id)kCFNull ? (__typeof(value))nil : t; })
// Convert NaN or infinite values to zero, as these aren't JSON-safe
RCT_EXTERN double RCTZeroIfNaN(double value);