Move JSCHelpers.h and Value.h into separate package

Reviewed By: javache

Differential Revision: D3950748

fbshipit-source-id: 6315ea07f3217b485aeb4374b5f6e36333957848
This commit is contained in:
Alexander Blom 2016-11-01 11:38:43 -07:00 коммит произвёл Facebook Github Bot
Родитель 95cb4ea752
Коммит ddb8cb7cf0
34 изменённых файлов: 168 добавлений и 54 удалений

Просмотреть файл

@ -7,7 +7,7 @@
#include <fb/fbjni.h>
#include <cxxreact/ExecutorToken.h>
#include <cxxreact/noncopyable.h>
#include <jschelpers/noncopyable.h>
using namespace facebook::jni;

Просмотреть файл

@ -9,7 +9,7 @@
#include <folly/Memory.h>
#include <fb/fbjni.h>
#include <cxxreact/JSCHelpers.h>
#include <jschelpers/JSCHelpers.h>
#include "JNativeRunnable.h"
@ -93,4 +93,3 @@ std::unique_ptr<JMessageQueueThread> JMessageQueueThread::currentMessageQueueThr
}
} }

Просмотреть файл

@ -2,7 +2,7 @@
#include "JSCPerfLogging.h"
#include <cxxreact/JSCHelpers.h>
#include <jschelpers/JSCHelpers.h>
#include <fb/log.h>
#include <fb/fbjni.h>

Просмотреть файл

@ -6,7 +6,7 @@
#include <algorithm>
#include <fb/log.h>
#include <cxxreact/Value.h>
#include <jschelpers/Value.h>
namespace facebook {
namespace react {

Просмотреть файл

@ -6,7 +6,7 @@
#include <cxxreact/Executor.h>
#include <cxxreact/JSCExecutor.h>
#include <cxxreact/Platform.h>
#include <cxxreact/Value.h>
#include <jschelpers/Value.h>
#include "CatalystInstanceImpl.h"
#include "JavaScriptExecutorHolder.h"
#include "JSCPerfLogging.h"

Просмотреть файл

@ -9,7 +9,6 @@ LOCAL_SRC_FILES := \
Executor.cpp \
Instance.cpp \
JSCExecutor.cpp \
JSCHelpers.cpp \
JSCLegacyProfiler.cpp \
JSCLegacyTracing.cpp \
JSCMemory.cpp \
@ -21,8 +20,7 @@ LOCAL_SRC_FILES := \
ModuleRegistry.cpp \
NativeToJsBridge.cpp \
Platform.cpp \
Value.cpp \
Unicode.cpp \
JSCUtils.cpp \
LOCAL_C_INCLUDES := $(LOCAL_PATH)/..
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
@ -35,6 +33,7 @@ CXX11_FLAGS := -std=c++11
LOCAL_CFLAGS += $(CXX11_FLAGS)
LOCAL_EXPORT_CPPFLAGS := $(CXX11_FLAGS)
LOCAL_STATIC_LIBRARIES := jschelpers
LOCAL_SHARED_LIBRARIES := libfb libfolly_json libjsc libglog
include $(BUILD_STATIC_LIBRARY)
@ -43,3 +42,4 @@ $(call import-module,fb)
$(call import-module,folly)
$(call import-module,jsc)
$(call import-module,glog)
$(call import-module,jschelpers)

Просмотреть файл

@ -115,7 +115,6 @@ CXXREACT_PUBLIC_HEADERS = [
'ExecutorTokenFactory.h',
'Instance.h',
'JSCExecutor.h',
'JSCHelpers.h',
'JSCNativeModules.h',
'JSCWebWorker.h',
'JSModulesUnbundle.h',
@ -124,11 +123,8 @@ CXXREACT_PUBLIC_HEADERS = [
'ModuleRegistry.h',
'NativeModule.h',
'NativeToJsBridge.h',
'noncopyable.h',
'Platform.h',
'SystraceSection.h',
'Unicode.h',
'Value.h',
]
react_library(
@ -153,6 +149,7 @@ react_library(
deps = [
':module',
'//xplat/fbsystrace:fbsystrace',
react_native_xplat_target('jschelpers:jschelpers'),
react_native_xplat_target('microprofiler:microprofiler'),
],
visibility = [ 'PUBLIC' ],

Просмотреть файл

@ -11,6 +11,8 @@
#include <folly/dynamic.h>
#include "JSModulesUnbundle.h"
namespace facebook {
namespace react {

Просмотреть файл

@ -16,12 +16,14 @@
#include <fcntl.h>
#include <sys/time.h>
#include "JSCHelpers.h"
#include <jschelpers/JSCHelpers.h>
#include <jschelpers/Value.h>
#include "Platform.h"
#include "SystraceSection.h"
#include "Value.h"
#include "JSCNativeModules.h"
#include "JSCSamplingProfiler.h"
#include "JSCUtils.h"
#include "JSModulesUnbundle.h"
#include "ModuleRegistry.h"

Просмотреть файл

@ -11,10 +11,11 @@
#include <folly/json.h>
#include <folly/Optional.h>
#include <jschelpers/JSCHelpers.h>
#include <jschelpers/Value.h>
#include "Executor.h"
#include "ExecutorToken.h"
#include "JSCHelpers.h"
#include "Value.h"
#include "JSCNativeModules.h"
namespace facebook {

Просмотреть файл

@ -7,9 +7,9 @@
#include <JavaScriptCore/JavaScript.h>
#include <JavaScriptCore/API/JSProfilerPrivate.h>
#include <jsc_legacy_profiler.h>
#include "JSCHelpers.h"
#include <jschelpers/JSCHelpers.h>
#include <jschelpers/Value.h>
#include "JSCLegacyProfiler.h"
#include "Value.h"
static JSValueRef nativeProfilerStart(
JSContextRef ctx,

Просмотреть файл

@ -9,7 +9,8 @@
#include <fbsystrace.h>
#include "JSCHelpers.h"
#include <jschelpers/JSCHelpers.h>
#include "JSCTracing.h"
static const char *ENABLED_FBSYSTRACE_PROFILE_NAME = "__fbsystrace__";

Просмотреть файл

@ -7,9 +7,8 @@
#include <stdio.h>
#include <string.h>
#include <JavaScriptCore/API/JSProfilerPrivate.h>
#include "JSCHelpers.h"
#include "Value.h"
#include <jschelpers/JSCHelpers.h>
#include <jschelpers/Value.h>
static JSValueRef nativeCaptureHeap(
JSContextRef ctx,
@ -43,7 +42,7 @@ void addNativeMemoryHooks(JSGlobalContextRef ctx) {
#ifdef WITH_FB_MEMORY_PROFILING
installGlobalFunction(ctx, "nativeCaptureHeap", nativeCaptureHeap);
#endif // WITH_FB_MEMORY_PROFILING
}
} }

Просмотреть файл

@ -7,7 +7,8 @@
#include <memory>
#include <string>
#include "Value.h"
#include <jschelpers/Value.h>
#include "ModuleRegistry.h"
namespace facebook {

Просмотреть файл

@ -7,8 +7,8 @@
#include <JavaScriptCore/JSPerfStats.h>
#include <JavaScriptCore/JSValueRef.h>
#include "JSCHelpers.h"
#include "Value.h"
#include <jschelpers/JSCHelpers.h>
#include <jschelpers/Value.h>
static JSValueRef nativeGetHeapStats(
JSContextRef ctx,

Просмотреть файл

@ -7,9 +7,8 @@
#include <stdio.h>
#include <string.h>
#include <JavaScriptCore/API/JSProfilerPrivate.h>
#include "JSCHelpers.h"
#include "Value.h"
#include <jschelpers/JSCHelpers.h>
#include <jschelpers/Value.h>
namespace facebook {
namespace react {

Просмотреть файл

@ -9,7 +9,7 @@
#include <fbsystrace.h>
#include <sys/types.h>
#include <unistd.h>
#include "JSCHelpers.h"
#include <jschelpers/JSCHelpers.h>
using std::min;

Просмотреть файл

@ -0,0 +1,17 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#include "JSCUtils.h"
namespace facebook {
namespace react {
String jsStringFromBigString(const JSBigString& bigstr) {
if (bigstr.isAscii()) {
return String::createExpectingAscii(bigstr.c_str(), bigstr.size());
} else {
return String(bigstr.c_str());
}
}
}
}

Просмотреть файл

@ -0,0 +1,15 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#pragma once
#include <jschelpers/Value.h>
#include "Executor.h"
namespace facebook {
namespace react {
String jsStringFromBigString(const JSBigString& bigstr);
}
}

Просмотреть файл

@ -9,10 +9,11 @@
#include <folly/Memory.h>
#include "JSCHelpers.h"
#include <jschelpers/JSCHelpers.h>
#include <jschelpers/Value.h>
#include "MessageQueueThread.h"
#include "Platform.h"
#include "Value.h"
#include "JSCUtils.h"
#include <glog/logging.h>
@ -122,7 +123,7 @@ JSValueRef JSCWebWorker::nativePostMessage(
}
webWorker->postMessageToOwner(msg);
return JSValueMakeUndefined(ctx);
}

Просмотреть файл

@ -9,7 +9,7 @@
#include <JavaScriptCore/JSValueRef.h>
#include "Value.h"
#include <jschelpers/Value.h>
namespace facebook {
namespace react {
@ -51,7 +51,7 @@ public:
~JSCWebWorker();
/**
* Post a message to be received by the worker on its thread. This must be called from
* Post a message to be received by the worker on its thread. This must be called from
* ownerMessageQueueThread_.
*/
void postMessage(JSValueRef msg);

Просмотреть файл

@ -6,7 +6,7 @@
#include <string>
#include <stdexcept>
#include "noncopyable.h"
#include <jschelpers/noncopyable.h>
namespace facebook {
namespace react {

Просмотреть файл

@ -9,6 +9,8 @@
#include <folly/dynamic.h>
#include <jschelpers/Value.h>
#include "Executor.h"
#include "ExecutorToken.h"
#include "JSCExecutor.h"
@ -16,7 +18,6 @@
#include "MessageQueueThread.h"
#include "MethodCall.h"
#include "NativeModule.h"
#include "Value.h"
namespace folly {

Просмотреть файл

@ -37,6 +37,7 @@ if THIS_IS_FBOBJC:
deps = [
'//xplat/third-party/gmock:gtest',
react_native_xplat_target('cxxreact:bridge'),
react_native_xplat_target('jschelpers:jschelpers'),
],
visibility = [react_native_xplat_target('cxxreact/...')],
)

Просмотреть файл

@ -2,7 +2,7 @@
#include <string>
#include <gtest/gtest.h>
#include <folly/json.h>
#include <cxxreact/Value.h>
#include <jschelpers/Value.h>
#ifdef WITH_FBJSCEXTENSION
#undef ASSERT
@ -105,4 +105,3 @@ TEST(Value, BadUtf16) {
JSGlobalContextRelease(ctx);
}
#endif

Просмотреть файл

@ -0,0 +1,29 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := jschelpers
LOCAL_SRC_FILES := \
JSCHelpers.cpp \
Unicode.cpp \
Value.cpp \
LOCAL_C_INCLUDES := $(LOCAL_PATH)/..
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_CFLAGS := \
-DLOG_TAG=\"ReactNative\"
LOCAL_CFLAGS += -Wall -Werror -fexceptions -frtti
CXX11_FLAGS := -std=c++11
LOCAL_CFLAGS += $(CXX11_FLAGS)
LOCAL_EXPORT_CPPFLAGS := $(CXX11_FLAGS)
LOCAL_SHARED_LIBRARIES := libfolly_json libjsc libglog
include $(BUILD_STATIC_LIBRARY)
$(call import-module,folly)
$(call import-module,jsc)
$(call import-module,glog)

Просмотреть файл

@ -0,0 +1,57 @@
EXPORTED_HEADERS = [
'JSCHelpers.h',
'Value.h',
'noncopyable.h',
'Unicode.h',
]
if THIS_IS_FBANDROID:
include_defs('//ReactAndroid/DEFS')
cxx_library(
name = 'jschelpers',
force_static = True,
# We depend on JSC, support the same platforms
supported_platforms_regex = '^android-(armv7|x86)$',
compiler_flags = [
'-Wall',
'-fexceptions',
'-fvisibility=hidden',
'-std=c++1y',
],
exported_headers = EXPORTED_HEADERS,
headers = glob(['*.h'], excludes=EXPORTED_HEADERS),
header_namespace = 'jschelpers',
srcs = glob(['*.cpp']),
deps = JSC_DEPS + [
'//xplat/folly:molly',
],
visibility = [
'PUBLIC',
],
)
elif THIS_IS_FBOBJC:
ios_library(
name = 'jschelpers',
inherited_buck_flags = STATIC_LIBRARY_IOS_FLAGS,
compiler_flags = [
'-Wall',
'-fexceptions',
'-fvisibility=hidden',
'-std=c++1y',
],
exported_headers = EXPORTED_HEADERS,
headers = glob(['*.h'], excludes=EXPORTED_HEADERS),
header_namespace = 'jschelpers',
srcs = glob(['*.cpp']),
frameworks = [
'$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework',
],
deps = [
'//xplat/folly:molly',
],
visibility = [
'PUBLIC',
],
)

Просмотреть файл

@ -2,11 +2,14 @@
#include "JSCHelpers.h"
#ifdef WITH_FBSYSTRACE
#include <fbsystrace.h>
#endif
#include <JavaScriptCore/JSStringRef.h>
#include <folly/String.h>
#include <glog/logging.h>
#include "SystraceSection.h"
#include "Value.h"
namespace facebook {
@ -52,16 +55,10 @@ JSValueRef makeJSCException(
return JSValueToObject(ctx, exceptionString, NULL);
}
String jsStringFromBigString(const JSBigString& bigstr) {
if (bigstr.isAscii()) {
return String::createExpectingAscii(bigstr.c_str(), bigstr.size());
} else {
return String(bigstr.c_str());
}
}
JSValueRef evaluateScript(JSContextRef context, JSStringRef script, JSStringRef source) {
SystraceSection s("evaluateScript");
#ifdef WITH_FBSYSTRACE
fbsystrace::FbSystraceSection s(TRACE_TAG_REACT_CXX_BRIDGE, "evaluateScript");
#endif
JSValueRef exn, result;
result = JSEvaluateScript(context, script, NULL, source, 0, &exn);
if (result == nullptr) {

Просмотреть файл

@ -2,7 +2,6 @@
#pragma once
#include "Executor.h"
#include "Value.h"
#include <JavaScriptCore/JSContextRef.h>
@ -47,8 +46,6 @@ JSValueRef makeJSCException(
JSContextRef ctx,
const char* exception_text);
String jsStringFromBigString(const JSBigString& bigstr);
JSValueRef evaluateScript(
JSContextRef ctx,
JSStringRef script,

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -45,7 +45,6 @@ private:
std::string stack_;
};
class String : public noncopyable {
public:
explicit String(const char* utf8) :