Fix global constructor warning
Reviewed By: davidaurelio Differential Revision: D4220267 fbshipit-source-id: 37a6ff51609aaa129683d57f853f59758ff55012
This commit is contained in:
parent
3ba3b39fdc
commit
333cf3bc99
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
#include <glog/logging.h>
|
#include <glog/logging.h>
|
||||||
#include <objc/runtime.h>
|
#include <objc/runtime.h>
|
||||||
|
|
||||||
|
@ -38,82 +39,12 @@ namespace react {
|
||||||
|
|
||||||
static const JSCWrapper* s_customWrapper = nullptr;
|
static const JSCWrapper* s_customWrapper = nullptr;
|
||||||
|
|
||||||
static JSCWrapper s_systemWrapper = {
|
static JSCWrapper s_systemWrapper = {};
|
||||||
.JSGlobalContextCreateInGroup = JSGlobalContextCreateInGroup,
|
|
||||||
.JSGlobalContextRelease = JSGlobalContextRelease,
|
|
||||||
.JSGlobalContextSetName = JSGlobalContextSetName,
|
|
||||||
|
|
||||||
.JSContextGetGlobalContext = JSContextGetGlobalContext,
|
const JSCWrapper* customJSCWrapper() {
|
||||||
.JSContextGetGlobalObject = JSContextGetGlobalObject,
|
CHECK(s_customWrapper != nullptr) << "Accessing custom JSC wrapper before it's set";
|
||||||
|
return s_customWrapper;
|
||||||
.JSEvaluateScript = JSEvaluateScript,
|
}
|
||||||
.JSEvaluateBytecodeBundle =
|
|
||||||
(decltype(&JSEvaluateBytecodeBundle))Unimplemented_JSEvaluateBytecodeBundle,
|
|
||||||
|
|
||||||
.JSStringCreateWithUTF8CString = JSStringCreateWithUTF8CString,
|
|
||||||
.JSStringCreateWithCFString = JSStringCreateWithCFString,
|
|
||||||
#if WITH_FBJSCEXTENSIONS
|
|
||||||
.JSStringCreateWithUTF8CStringExpectAscii =
|
|
||||||
(decltype(&JSStringCreateWithUTF8CStringExpectAscii))Unimplemented_JSStringCreateWithUTF8CStringExpectAscii,
|
|
||||||
#endif
|
|
||||||
.JSStringCopyCFString = JSStringCopyCFString,
|
|
||||||
.JSStringGetCharactersPtr = JSStringGetCharactersPtr,
|
|
||||||
.JSStringGetLength = JSStringGetLength,
|
|
||||||
.JSStringGetMaximumUTF8CStringSize = JSStringGetMaximumUTF8CStringSize,
|
|
||||||
.JSStringIsEqualToUTF8CString = JSStringIsEqualToUTF8CString,
|
|
||||||
.JSStringRelease = JSStringRelease,
|
|
||||||
.JSStringRetain = JSStringRetain,
|
|
||||||
|
|
||||||
.JSClassCreate = JSClassCreate,
|
|
||||||
.JSClassRelease = JSClassRelease,
|
|
||||||
|
|
||||||
.JSObjectCallAsConstructor = JSObjectCallAsConstructor,
|
|
||||||
.JSObjectCallAsFunction = JSObjectCallAsFunction,
|
|
||||||
.JSObjectGetPrivate = JSObjectGetPrivate,
|
|
||||||
.JSObjectGetProperty = JSObjectGetProperty,
|
|
||||||
.JSObjectGetPropertyAtIndex = JSObjectGetPropertyAtIndex,
|
|
||||||
.JSObjectIsConstructor = JSObjectIsConstructor,
|
|
||||||
.JSObjectIsFunction = JSObjectIsFunction,
|
|
||||||
.JSObjectMake = JSObjectMake,
|
|
||||||
.JSObjectMakeArray = JSObjectMakeArray,
|
|
||||||
.JSObjectMakeError = JSObjectMakeError,
|
|
||||||
.JSObjectMakeFunctionWithCallback = JSObjectMakeFunctionWithCallback,
|
|
||||||
.JSObjectSetPrivate = JSObjectSetPrivate,
|
|
||||||
.JSObjectSetProperty = JSObjectSetProperty,
|
|
||||||
|
|
||||||
.JSObjectCopyPropertyNames = JSObjectCopyPropertyNames,
|
|
||||||
.JSPropertyNameArrayGetCount = JSPropertyNameArrayGetCount,
|
|
||||||
.JSPropertyNameArrayGetNameAtIndex = JSPropertyNameArrayGetNameAtIndex,
|
|
||||||
.JSPropertyNameArrayRelease = JSPropertyNameArrayRelease,
|
|
||||||
|
|
||||||
.JSValueCreateJSONString = JSValueCreateJSONString,
|
|
||||||
.JSValueGetType = JSValueGetType,
|
|
||||||
.JSValueMakeFromJSONString = JSValueMakeFromJSONString,
|
|
||||||
.JSValueMakeBoolean = JSValueMakeBoolean,
|
|
||||||
.JSValueMakeNull = JSValueMakeNull,
|
|
||||||
.JSValueMakeNumber = JSValueMakeNumber,
|
|
||||||
.JSValueMakeString = JSValueMakeString,
|
|
||||||
.JSValueMakeUndefined = JSValueMakeUndefined,
|
|
||||||
.JSValueProtect = JSValueProtect,
|
|
||||||
.JSValueToBoolean = JSValueToBoolean,
|
|
||||||
.JSValueToNumber = JSValueToNumber,
|
|
||||||
.JSValueToObject = JSValueToObject,
|
|
||||||
.JSValueToStringCopy = JSValueToStringCopy,
|
|
||||||
.JSValueUnprotect = JSValueUnprotect,
|
|
||||||
|
|
||||||
.JSSamplingProfilerEnabled = JSSamplingProfilerEnabled,
|
|
||||||
.JSPokeSamplingProfiler =
|
|
||||||
(decltype(&JSPokeSamplingProfiler))Unimplemented_JSPokeSamplingProfiler,
|
|
||||||
.JSStartSamplingProfilingOnMainJSCThread =
|
|
||||||
(decltype(&JSStartSamplingProfilingOnMainJSCThread))Unimplemented_JSStartSamplingProfilingOnMainJSCThread,
|
|
||||||
|
|
||||||
.configureJSCForIOS = (decltype(&configureJSCForIOS))Unimplemented_configureJSCForIOS,
|
|
||||||
|
|
||||||
.JSBytecodeFileFormatVersion = -1,
|
|
||||||
|
|
||||||
.JSContext = nullptr,
|
|
||||||
.JSValue = nullptr,
|
|
||||||
};
|
|
||||||
|
|
||||||
void setCustomJSCWrapper(const JSCWrapper* wrapper) {
|
void setCustomJSCWrapper(const JSCWrapper* wrapper) {
|
||||||
CHECK(s_customWrapper == nullptr) << "Can't set custom JSC wrapper multiple times";
|
CHECK(s_customWrapper == nullptr) << "Can't set custom JSC wrapper multiple times";
|
||||||
|
@ -125,17 +56,91 @@ const JSCWrapper* systemJSCWrapper() {
|
||||||
// Some fields are lazily initialized
|
// Some fields are lazily initialized
|
||||||
static std::once_flag flag;
|
static std::once_flag flag;
|
||||||
std::call_once(flag, []() {
|
std::call_once(flag, []() {
|
||||||
s_systemWrapper.JSContext = objc_getClass("JSContext");
|
s_systemWrapper = {
|
||||||
s_systemWrapper.JSValue = objc_getClass("JSValue");
|
.JSGlobalContextCreateInGroup = JSGlobalContextCreateInGroup,
|
||||||
|
.JSGlobalContextRelease = JSGlobalContextRelease,
|
||||||
|
.JSGlobalContextSetName = JSGlobalContextSetName,
|
||||||
|
|
||||||
|
.JSContextGetGlobalContext = JSContextGetGlobalContext,
|
||||||
|
.JSContextGetGlobalObject = JSContextGetGlobalObject,
|
||||||
|
|
||||||
|
.JSEvaluateScript = JSEvaluateScript,
|
||||||
|
.JSEvaluateBytecodeBundle =
|
||||||
|
(decltype(&JSEvaluateBytecodeBundle))
|
||||||
|
Unimplemented_JSEvaluateBytecodeBundle,
|
||||||
|
|
||||||
|
.JSStringCreateWithUTF8CString = JSStringCreateWithUTF8CString,
|
||||||
|
.JSStringCreateWithCFString = JSStringCreateWithCFString,
|
||||||
|
#if WITH_FBJSCEXTENSIONS
|
||||||
|
.JSStringCreateWithUTF8CStringExpectAscii =
|
||||||
|
(decltype(&JSStringCreateWithUTF8CStringExpectAscii))
|
||||||
|
Unimplemented_JSStringCreateWithUTF8CStringExpectAscii,
|
||||||
|
#endif
|
||||||
|
.JSStringCopyCFString = JSStringCopyCFString,
|
||||||
|
.JSStringGetCharactersPtr = JSStringGetCharactersPtr,
|
||||||
|
.JSStringGetLength = JSStringGetLength,
|
||||||
|
.JSStringGetMaximumUTF8CStringSize = JSStringGetMaximumUTF8CStringSize,
|
||||||
|
.JSStringIsEqualToUTF8CString = JSStringIsEqualToUTF8CString,
|
||||||
|
.JSStringRelease = JSStringRelease,
|
||||||
|
.JSStringRetain = JSStringRetain,
|
||||||
|
|
||||||
|
.JSClassCreate = JSClassCreate,
|
||||||
|
.JSClassRelease = JSClassRelease,
|
||||||
|
|
||||||
|
.JSObjectCallAsConstructor = JSObjectCallAsConstructor,
|
||||||
|
.JSObjectCallAsFunction = JSObjectCallAsFunction,
|
||||||
|
.JSObjectGetPrivate = JSObjectGetPrivate,
|
||||||
|
.JSObjectGetProperty = JSObjectGetProperty,
|
||||||
|
.JSObjectGetPropertyAtIndex = JSObjectGetPropertyAtIndex,
|
||||||
|
.JSObjectIsConstructor = JSObjectIsConstructor,
|
||||||
|
.JSObjectIsFunction = JSObjectIsFunction,
|
||||||
|
.JSObjectMake = JSObjectMake,
|
||||||
|
.JSObjectMakeArray = JSObjectMakeArray,
|
||||||
|
.JSObjectMakeError = JSObjectMakeError,
|
||||||
|
.JSObjectMakeFunctionWithCallback = JSObjectMakeFunctionWithCallback,
|
||||||
|
.JSObjectSetPrivate = JSObjectSetPrivate,
|
||||||
|
.JSObjectSetProperty = JSObjectSetProperty,
|
||||||
|
|
||||||
|
.JSObjectCopyPropertyNames = JSObjectCopyPropertyNames,
|
||||||
|
.JSPropertyNameArrayGetCount = JSPropertyNameArrayGetCount,
|
||||||
|
.JSPropertyNameArrayGetNameAtIndex = JSPropertyNameArrayGetNameAtIndex,
|
||||||
|
.JSPropertyNameArrayRelease = JSPropertyNameArrayRelease,
|
||||||
|
|
||||||
|
.JSValueCreateJSONString = JSValueCreateJSONString,
|
||||||
|
.JSValueGetType = JSValueGetType,
|
||||||
|
.JSValueMakeFromJSONString = JSValueMakeFromJSONString,
|
||||||
|
.JSValueMakeBoolean = JSValueMakeBoolean,
|
||||||
|
.JSValueMakeNull = JSValueMakeNull,
|
||||||
|
.JSValueMakeNumber = JSValueMakeNumber,
|
||||||
|
.JSValueMakeString = JSValueMakeString,
|
||||||
|
.JSValueMakeUndefined = JSValueMakeUndefined,
|
||||||
|
.JSValueProtect = JSValueProtect,
|
||||||
|
.JSValueToBoolean = JSValueToBoolean,
|
||||||
|
.JSValueToNumber = JSValueToNumber,
|
||||||
|
.JSValueToObject = JSValueToObject,
|
||||||
|
.JSValueToStringCopy = JSValueToStringCopy,
|
||||||
|
.JSValueUnprotect = JSValueUnprotect,
|
||||||
|
|
||||||
|
.JSSamplingProfilerEnabled = JSSamplingProfilerEnabled,
|
||||||
|
.JSPokeSamplingProfiler =
|
||||||
|
(decltype(&JSPokeSamplingProfiler))
|
||||||
|
Unimplemented_JSPokeSamplingProfiler,
|
||||||
|
.JSStartSamplingProfilingOnMainJSCThread =
|
||||||
|
(decltype(&JSStartSamplingProfilingOnMainJSCThread))
|
||||||
|
Unimplemented_JSStartSamplingProfilingOnMainJSCThread,
|
||||||
|
|
||||||
|
.configureJSCForIOS =
|
||||||
|
(decltype(&configureJSCForIOS))Unimplemented_configureJSCForIOS,
|
||||||
|
|
||||||
|
.JSContext = objc_getClass("JSContext"),
|
||||||
|
.JSValue = objc_getClass("JSValue"),
|
||||||
|
|
||||||
|
.JSBytecodeFileFormatVersion = -1,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
return &s_systemWrapper;
|
return &s_systemWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
const JSCWrapper* customJSCWrapper() {
|
|
||||||
CHECK(s_customWrapper != nullptr) << "Accessing custom JSC wrapper before it's set";
|
|
||||||
return s_customWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,7 +30,7 @@ extern JSValueRef JSPokeSamplingProfiler(JSContextRef);
|
||||||
namespace facebook {
|
namespace facebook {
|
||||||
namespace react {
|
namespace react {
|
||||||
|
|
||||||
#define JSC_WRAPPER_METHOD(m) const decltype(&m) m
|
#define JSC_WRAPPER_METHOD(m) decltype(&m) m
|
||||||
|
|
||||||
struct JSCWrapper {
|
struct JSCWrapper {
|
||||||
// JSGlobalContext
|
// JSGlobalContext
|
||||||
|
@ -49,9 +49,9 @@ struct JSCWrapper {
|
||||||
// JSString
|
// JSString
|
||||||
JSC_WRAPPER_METHOD(JSStringCreateWithUTF8CString);
|
JSC_WRAPPER_METHOD(JSStringCreateWithUTF8CString);
|
||||||
JSC_WRAPPER_METHOD(JSStringCreateWithCFString);
|
JSC_WRAPPER_METHOD(JSStringCreateWithCFString);
|
||||||
#if WITH_FBJSCEXTENSIONS
|
#if WITH_FBJSCEXTENSIONS
|
||||||
JSC_WRAPPER_METHOD(JSStringCreateWithUTF8CStringExpectAscii);
|
JSC_WRAPPER_METHOD(JSStringCreateWithUTF8CStringExpectAscii);
|
||||||
#endif
|
#endif
|
||||||
JSC_WRAPPER_METHOD(JSStringCopyCFString);
|
JSC_WRAPPER_METHOD(JSStringCopyCFString);
|
||||||
JSC_WRAPPER_METHOD(JSStringGetCharactersPtr);
|
JSC_WRAPPER_METHOD(JSStringGetCharactersPtr);
|
||||||
JSC_WRAPPER_METHOD(JSStringGetLength);
|
JSC_WRAPPER_METHOD(JSStringGetLength);
|
||||||
|
@ -112,7 +112,7 @@ struct JSCWrapper {
|
||||||
Class JSContext;
|
Class JSContext;
|
||||||
Class JSValue;
|
Class JSValue;
|
||||||
|
|
||||||
const int32_t JSBytecodeFileFormatVersion;
|
int32_t JSBytecodeFileFormatVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
Loading…
Reference in New Issue