mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-06-19 11:38:35 +08:00
JSIExecutor Bundle Splitting Support
Reviewed By: mhorowitz Differential Revision: D6847638 fbshipit-source-id: d9ae3d182d6f07bcac81cfd06dcc19f8139bb1e4
This commit is contained in:
committed by
Facebook Github Bot
parent
854c2330eb
commit
1a1a956831
@@ -689,11 +689,14 @@ namespace facebook {
|
||||
return JSC_JSValueMakeUndefined(m_context);
|
||||
}
|
||||
|
||||
JSValueRef JSCExecutor::nativeRequire(
|
||||
size_t argumentCount,
|
||||
const JSValueRef arguments[]) {
|
||||
uint32_t bundleId, moduleId;
|
||||
std::tie(bundleId, moduleId) = parseNativeRequireParameters(m_context, arguments, argumentCount);
|
||||
JSValueRef JSCExecutor::nativeRequire(size_t count, const JSValueRef arguments[]) {
|
||||
if (count > 2 || count == 0) {
|
||||
throw std::invalid_argument("Got wrong number of args");
|
||||
}
|
||||
|
||||
uint32_t moduleId = folly::to<uint32_t>(Value(m_context, arguments[0]).getNumberOrThrow());
|
||||
uint32_t bundleId = count == 2 ? folly::to<uint32_t>(Value(m_context, arguments[1]).getNumberOrThrow()) : 0;
|
||||
|
||||
ReactMarker::logMarker(ReactMarker::NATIVE_REQUIRE_START);
|
||||
loadModule(bundleId, moduleId);
|
||||
ReactMarker::logMarker(ReactMarker::NATIVE_REQUIRE_STOP);
|
||||
|
||||
@@ -15,25 +15,5 @@ String jsStringFromBigString(JSContextRef ctx, const JSBigString& bigstr) {
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<uint32_t, uint32_t> parseNativeRequireParameters(
|
||||
const JSGlobalContextRef& context,
|
||||
const JSValueRef arguments[],
|
||||
size_t argumentCount) {
|
||||
uint32_t moduleId = 0, bundleId = 0;
|
||||
|
||||
// use "getNumber" & "folly::to" to throw explicitely in case of an overflow
|
||||
// error during conversion
|
||||
if (argumentCount == 1) {
|
||||
moduleId = folly::to<uint32_t>(Value(context, arguments[0]).getNumberOrThrow());
|
||||
} else if (argumentCount == 2) {
|
||||
moduleId = folly::to<uint32_t>(Value(context, arguments[0]).getNumberOrThrow());
|
||||
bundleId = folly::to<uint32_t>(Value(context, arguments[1]).getNumberOrThrow());
|
||||
} else {
|
||||
throw std::invalid_argument("Got wrong number of args");
|
||||
}
|
||||
|
||||
return std::make_pair(bundleId, moduleId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,5 @@ namespace react {
|
||||
|
||||
String jsStringFromBigString(JSContextRef ctx, const JSBigString& bigstr);
|
||||
|
||||
/**
|
||||
* Parses "nativeRequire" parameters
|
||||
* and returns pair of "bundle id" & "module id" values
|
||||
*/
|
||||
std::pair<uint32_t, uint32_t> parseNativeRequireParameters(const JSGlobalContextRef& context,
|
||||
const JSValueRef arguments[],
|
||||
size_t argumentCount);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user