2015-03-23 20:28:42 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2015-03-01 23:33:55 +00:00
|
|
|
#import <tgmath.h>
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
#import <CoreGraphics/CoreGraphics.h>
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
|
|
|
#import "RCTAssert.h"
|
2015-04-21 12:26:51 +00:00
|
|
|
#import "RCTDefines.h"
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
// Utility functions for JSON object <-> string serialization/deserialization
|
2015-04-21 12:26:51 +00:00
|
|
|
RCT_EXTERN NSString *RCTJSONStringify(id jsonObject, NSError **error);
|
|
|
|
RCT_EXTERN id RCTJSONParse(NSString *jsonString, NSError **error);
|
2015-06-03 23:57:08 +00:00
|
|
|
RCT_EXTERN id RCTJSONParseMutable(NSString *jsonString, NSError **error);
|
|
|
|
RCT_EXTERN id RCTJSONParseWithOptions(NSString *jsonString, NSError **error, NSJSONReadingOptions options);
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2015-05-06 07:11:31 +00:00
|
|
|
// Strip non JSON-safe values from an object graph
|
|
|
|
RCT_EXTERN id RCTJSONClean(id object);
|
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
// Get MD5 hash of a string (TODO: currently unused. Remove?)
|
2015-04-21 12:26:51 +00:00
|
|
|
RCT_EXTERN NSString *RCTMD5Hash(NSString *string);
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
// Get screen metrics in a thread-safe way
|
2015-04-21 12:26:51 +00:00
|
|
|
RCT_EXTERN CGFloat RCTScreenScale(void);
|
|
|
|
RCT_EXTERN CGSize RCTScreenSize(void);
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
// Round float coordinates to nearest whole screen pixel (not point)
|
2015-04-21 12:26:51 +00:00
|
|
|
RCT_EXTERN CGFloat RCTRoundPixelValue(CGFloat value);
|
|
|
|
RCT_EXTERN CGFloat RCTCeilPixelValue(CGFloat value);
|
|
|
|
RCT_EXTERN CGFloat RCTFloorPixelValue(CGFloat value);
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
// Method swizzling
|
2015-04-21 12:26:51 +00:00
|
|
|
RCT_EXTERN void RCTSwapClassMethods(Class cls, SEL original, SEL replacement);
|
|
|
|
RCT_EXTERN void RCTSwapInstanceMethods(Class cls, SEL original, SEL replacement);
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
// Module subclass support
|
2015-04-21 12:26:51 +00:00
|
|
|
RCT_EXTERN BOOL RCTClassOverridesClassMethod(Class cls, SEL selector);
|
|
|
|
RCT_EXTERN BOOL RCTClassOverridesInstanceMethod(Class cls, SEL selector);
|
2015-03-01 23:33:55 +00:00
|
|
|
|
2015-03-11 19:06:03 +00:00
|
|
|
// Creates a standardized error object
|
|
|
|
// TODO(#6472857): create NSErrors and automatically convert them over the bridge.
|
2015-04-21 12:26:51 +00:00
|
|
|
RCT_EXTERN NSDictionary *RCTMakeError(NSString *message, id toStringify, NSDictionary *extraData);
|
|
|
|
RCT_EXTERN NSDictionary *RCTMakeAndLogError(NSString *message, id toStringify, NSDictionary *extraData);
|
2015-04-27 10:50:07 +00:00
|
|
|
|
|
|
|
// Returns YES if React is running in a test environment
|
|
|
|
RCT_EXTERN BOOL RCTRunningInTestEnvironment(void);
|
2015-05-22 14:17:08 +00:00
|
|
|
|
|
|
|
// Return YES if image has an alpha component
|
|
|
|
RCT_EXTERN BOOL RCTImageHasAlpha(CGImageRef image);
|
2015-06-09 13:46:49 +00:00
|
|
|
|
2015-06-09 19:25:24 +00:00
|
|
|
// Create an NSError in the NCTErrorDomain
|
|
|
|
RCT_EXTERN NSError *RCTErrorWithMessage(NSString *message);
|
|
|
|
|
|
|
|
// Convert nil values to NSNull, and vice-versa
|
2015-06-09 13:46:49 +00:00
|
|
|
RCT_EXTERN id RCTNullIfNil(id value);
|
|
|
|
RCT_EXTERN id RCTNilIfNull(id value);
|