Skip to content

Commit

Permalink
JSIExecutor Bundle Splitting Support
Browse files Browse the repository at this point in the history
Reviewed By: mhorowitz

Differential Revision: D6847638

fbshipit-source-id: d9ae3d182d6f07bcac81cfd06dcc19f8139bb1e4
  • Loading branch information
fromcelticpark authored and facebook-github-bot committed Feb 9, 2018
1 parent 854c233 commit 1a1a956
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 33 deletions.
13 changes: 8 additions & 5 deletions ReactCommon/cxxreact/JSCExecutor.cpp
Expand Up @@ -689,11 +689,14 @@ namespace facebook {
return JSC_JSValueMakeUndefined(m_context); return JSC_JSValueMakeUndefined(m_context);
} }


JSValueRef JSCExecutor::nativeRequire( JSValueRef JSCExecutor::nativeRequire(size_t count, const JSValueRef arguments[]) {
size_t argumentCount, if (count > 2 || count == 0) {
const JSValueRef arguments[]) { throw std::invalid_argument("Got wrong number of args");
uint32_t bundleId, moduleId; }
std::tie(bundleId, moduleId) = parseNativeRequireParameters(m_context, arguments, argumentCount);
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); ReactMarker::logMarker(ReactMarker::NATIVE_REQUIRE_START);
loadModule(bundleId, moduleId); loadModule(bundleId, moduleId);
ReactMarker::logMarker(ReactMarker::NATIVE_REQUIRE_STOP); ReactMarker::logMarker(ReactMarker::NATIVE_REQUIRE_STOP);
Expand Down
20 changes: 0 additions & 20 deletions ReactCommon/cxxreact/JSCUtils.cpp
Expand Up @@ -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);
}

} }
} }
8 changes: 0 additions & 8 deletions ReactCommon/cxxreact/JSCUtils.h
Expand Up @@ -11,13 +11,5 @@ namespace react {


String jsStringFromBigString(JSContextRef ctx, const JSBigString& bigstr); 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);

} }
} }

0 comments on commit 1a1a956

Please sign in to comment.