2016-11-21 12:30:04 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2016-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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "JSCWrapper.h"
|
|
|
|
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
|
2016-11-23 19:33:44 +00:00
|
|
|
// TODO: use glog in OSS too
|
|
|
|
#if __has_include(<glog/logging.h>)
|
|
|
|
#define USE_GLOG 1
|
2016-11-21 12:30:04 +00:00
|
|
|
#include <glog/logging.h>
|
2016-11-23 19:33:44 +00:00
|
|
|
#else
|
|
|
|
#define USE_GLOG 0
|
|
|
|
#endif
|
|
|
|
|
2016-11-21 12:30:04 +00:00
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
|
|
|
static const JSCWrapper* s_customWrapper = nullptr;
|
|
|
|
|
2016-11-28 20:40:43 +00:00
|
|
|
bool isCustomJSCWrapperSet() {
|
|
|
|
return s_customWrapper != nullptr;
|
|
|
|
}
|
|
|
|
|
2016-11-22 17:38:22 +00:00
|
|
|
const JSCWrapper* customJSCWrapper() {
|
2016-11-23 19:33:44 +00:00
|
|
|
#if USE_GLOG
|
2016-11-22 17:38:22 +00:00
|
|
|
CHECK(s_customWrapper != nullptr) << "Accessing custom JSC wrapper before it's set";
|
2016-11-23 19:33:44 +00:00
|
|
|
#endif
|
2016-11-22 17:38:22 +00:00
|
|
|
return s_customWrapper;
|
|
|
|
}
|
2016-11-21 12:30:04 +00:00
|
|
|
|
|
|
|
void setCustomJSCWrapper(const JSCWrapper* wrapper) {
|
2016-11-23 19:33:44 +00:00
|
|
|
#if USE_GLOG
|
2016-11-21 12:30:04 +00:00
|
|
|
CHECK(s_customWrapper == nullptr) << "Can't set custom JSC wrapper multiple times";
|
2016-11-23 19:33:44 +00:00
|
|
|
#endif
|
2016-11-21 12:30:04 +00:00
|
|
|
s_customWrapper = wrapper;
|
|
|
|
}
|
|
|
|
|
|
|
|
} }
|
|
|
|
|
|
|
|
#endif
|