UNPKG

3.55 kBtext/x-cView Raw
1/*
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#if __OBJC__
9# import <Foundation/Foundation.h>
10#endif
11
12/**
13 * Make global functions usable in C++
14 */
15#if defined(__cplusplus)
16#define RCT_EXTERN extern "C" __attribute__((visibility("default")))
17#define RCT_EXTERN_C_BEGIN extern "C" {
18#define RCT_EXTERN_C_END }
19#else
20#define RCT_EXTERN extern __attribute__((visibility("default")))
21#define RCT_EXTERN_C_BEGIN
22#define RCT_EXTERN_C_END
23#endif
24
25/**
26 * The RCT_DEBUG macro can be used to exclude error checking and logging code
27 * from release builds to improve performance and reduce binary size.
28 */
29#ifndef RCT_DEBUG
30#if DEBUG
31#define RCT_DEBUG 1
32#else
33#define RCT_DEBUG 0
34#endif
35#endif
36
37/**
38 * The RCT_DEV macro can be used to enable or disable development tools
39 * such as the debug executors, dev menu, red box, etc.
40 */
41#ifndef RCT_DEV
42#if DEBUG
43#define RCT_DEV 1
44#else
45#define RCT_DEV 0
46#endif
47#endif
48
49/**
50 * RCT_DEV_MENU can be used to toggle the dev menu separately from RCT_DEV.
51 * By default though, it will inherit from RCT_DEV.
52 */
53#ifndef RCT_DEV_MENU
54#define RCT_DEV_MENU RCT_DEV
55#endif
56
57#ifndef RCT_ENABLE_INSPECTOR
58#if RCT_DEV && __has_include(<React/RCTInspectorDevServerHelper.h>)
59#define RCT_ENABLE_INSPECTOR 1
60#else
61#define RCT_ENABLE_INSPECTOR 0
62#endif
63#endif
64
65#ifndef ENABLE_PACKAGER_CONNECTION
66#if RCT_DEV && (__has_include("RCTPackagerConnection.h") || __has_include(<React/RCTPackagerConnection.h>))
67#define ENABLE_PACKAGER_CONNECTION 1
68#else
69#define ENABLE_PACKAGER_CONNECTION 0
70#endif
71#endif
72
73#if RCT_DEV
74#define RCT_IF_DEV(...) __VA_ARGS__
75#else
76#define RCT_IF_DEV(...)
77#endif
78
79#ifndef RCT_PROFILE
80#define RCT_PROFILE RCT_DEV
81#endif
82
83/**
84 * Add the default Metro packager port number
85 */
86#ifndef RCT_METRO_PORT
87#define RCT_METRO_PORT 8081
88#else
89// test if RCT_METRO_PORT is empty
90#define RCT_METRO_PORT_DO_EXPAND(VAL) VAL ## 1
91#define RCT_METRO_PORT_EXPAND(VAL) RCT_METRO_PORT_DO_EXPAND(VAL)
92#if !defined(RCT_METRO_PORT) || (RCT_METRO_PORT_EXPAND(RCT_METRO_PORT) == 1)
93// Only here if RCT_METRO_PORT is not defined
94// OR RCT_METRO_PORT is the empty string
95#undef RCT_METRO_PORT
96#define RCT_METRO_PORT 8081
97#endif
98#endif
99
100/**
101 * Add the default packager name
102 */
103#ifndef RCT_PACKAGER_NAME
104#define RCT_PACKAGER_NAME @"Metro"
105#endif
106
107/**
108 * By default, only raise an NSAssertion in debug mode
109 * (custom assert functions will still be called).
110 */
111#ifndef RCT_NSASSERT
112#define RCT_NSASSERT RCT_DEBUG
113#endif
114
115/**
116 * Concat two literals. Supports macro expansions,
117 * e.g. RCT_CONCAT(foo, __FILE__).
118 */
119#define RCT_CONCAT2(A, B) A ## B
120#define RCT_CONCAT(A, B) RCT_CONCAT2(A, B)
121
122/**
123 * This attribute is used for static analysis.
124 */
125#if !defined RCT_DYNAMIC
126#if __has_attribute(objc_dynamic)
127#define RCT_DYNAMIC __attribute__((objc_dynamic))
128#else
129#define RCT_DYNAMIC
130#endif
131#endif
132
133/**
134 * Throw an assertion for unimplemented methods.
135 */
136#define RCT_NOT_IMPLEMENTED(method) \
137_Pragma("clang diagnostic push") \
138_Pragma("clang diagnostic ignored \"-Wmissing-method-return-type\"") \
139_Pragma("clang diagnostic ignored \"-Wunused-parameter\"") \
140RCT_EXTERN NSException *_RCTNotImplementedException(SEL, Class); \
141method NS_UNAVAILABLE { @throw _RCTNotImplementedException(_cmd, [self class]); } \
142_Pragma("clang diagnostic pop")
143
144/**
145 * Check if WebKit iOS 10.0 APIs are available.
146 */
147#define WEBKIT_IOS_10_APIS_AVAILABLE __has_include(<WebKit/WKAudiovisualMediaTypes.h>)