Skip to content

Commit 1a1a956

Browse files
fromcelticparkfacebook-github-bot
authored andcommitted
JSIExecutor Bundle Splitting Support
Reviewed By: mhorowitz Differential Revision: D6847638 fbshipit-source-id: d9ae3d182d6f07bcac81cfd06dcc19f8139bb1e4
1 parent 854c233 commit 1a1a956

File tree

3 files changed

+8
-33
lines changed

3 files changed

+8
-33
lines changed

ReactCommon/cxxreact/JSCExecutor.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -689,11 +689,14 @@ namespace facebook {
689689
return JSC_JSValueMakeUndefined(m_context);
690690
}
691691

692-
JSValueRef JSCExecutor::nativeRequire(
693-
size_t argumentCount,
694-
const JSValueRef arguments[]) {
695-
uint32_t bundleId, moduleId;
696-
std::tie(bundleId, moduleId) = parseNativeRequireParameters(m_context, arguments, argumentCount);
692+
JSValueRef JSCExecutor::nativeRequire(size_t count, const JSValueRef arguments[]) {
693+
if (count > 2 || count == 0) {
694+
throw std::invalid_argument("Got wrong number of args");
695+
}
696+
697+
uint32_t moduleId = folly::to<uint32_t>(Value(m_context, arguments[0]).getNumberOrThrow());
698+
uint32_t bundleId = count == 2 ? folly::to<uint32_t>(Value(m_context, arguments[1]).getNumberOrThrow()) : 0;
699+
697700
ReactMarker::logMarker(ReactMarker::NATIVE_REQUIRE_START);
698701
loadModule(bundleId, moduleId);
699702
ReactMarker::logMarker(ReactMarker::NATIVE_REQUIRE_STOP);

ReactCommon/cxxreact/JSCUtils.cpp

-20
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,5 @@ String jsStringFromBigString(JSContextRef ctx, const JSBigString& bigstr) {
1515
}
1616
}
1717

18-
std::pair<uint32_t, uint32_t> parseNativeRequireParameters(
19-
const JSGlobalContextRef& context,
20-
const JSValueRef arguments[],
21-
size_t argumentCount) {
22-
uint32_t moduleId = 0, bundleId = 0;
23-
24-
// use "getNumber" & "folly::to" to throw explicitely in case of an overflow
25-
// error during conversion
26-
if (argumentCount == 1) {
27-
moduleId = folly::to<uint32_t>(Value(context, arguments[0]).getNumberOrThrow());
28-
} else if (argumentCount == 2) {
29-
moduleId = folly::to<uint32_t>(Value(context, arguments[0]).getNumberOrThrow());
30-
bundleId = folly::to<uint32_t>(Value(context, arguments[1]).getNumberOrThrow());
31-
} else {
32-
throw std::invalid_argument("Got wrong number of args");
33-
}
34-
35-
return std::make_pair(bundleId, moduleId);
36-
}
37-
3818
}
3919
}

ReactCommon/cxxreact/JSCUtils.h

-8
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,5 @@ namespace react {
1111

1212
String jsStringFromBigString(JSContextRef ctx, const JSBigString& bigstr);
1313

14-
/**
15-
* Parses "nativeRequire" parameters
16-
* and returns pair of "bundle id" & "module id" values
17-
*/
18-
std::pair<uint32_t, uint32_t> parseNativeRequireParameters(const JSGlobalContextRef& context,
19-
const JSValueRef arguments[],
20-
size_t argumentCount);
21-
2214
}
2315
}

0 commit comments

Comments
 (0)