Skip to content

Commit

Permalink
Add macOS tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi committed Oct 21, 2023
1 parent 123c61e commit 0d0084c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/react-native/React/CxxBridge/JSCExecutorFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ class JSCExecutorFactory : public JSExecutorFactory {
explicit JSCExecutorFactory(JSIExecutor::RuntimeInstaller runtimeInstaller)
: runtimeInstaller_(std::move(runtimeInstaller)) {}

// [macOS
void setEnableDebugger(bool enableDebugger);

void setDebuggerName(const std::string &debuggerName);
// macOS]

std::unique_ptr<JSExecutor> createJSExecutor(
std::shared_ptr<ExecutorDelegate> delegate,
Expand All @@ -28,8 +30,10 @@ class JSCExecutorFactory : public JSExecutorFactory {
private:
JSIExecutor::RuntimeInstaller runtimeInstaller_;

// [macOS
bool enableDebugger_ = true;
std::string debuggerName_ = "JSC React Native";
// macOS]
};

} // namespace react
Expand Down
6 changes: 5 additions & 1 deletion packages/react-native/React/CxxBridge/JSCExecutorFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,27 @@
namespace facebook {
namespace react {

// [macOS
void JSCExecutorFactory::setEnableDebugger(bool enableDebugger) {
enableDebugger_ = enableDebugger;
}

void JSCExecutorFactory::setDebuggerName(const std::string &debuggerName) {
debuggerName_ = debuggerName;
}
// macOS]

std::unique_ptr<JSExecutor> JSCExecutorFactory::createJSExecutor(
std::shared_ptr<ExecutorDelegate> delegate,
std::shared_ptr<MessageQueueThread> __unused jsQueue)
{
// [macOS
facebook::jsc::runtimeConfig rc = {
.enableDebugger = enableDebugger_,
.debuggerName = debuggerName_,
};
return std::make_unique<JSIExecutor>(facebook::jsc::makeJSCRuntime(std::move(rc)), delegate, JSIExecutor::defaultTimeoutInvoker, runtimeInstaller_);
// macOS]
return std::make_unique<JSIExecutor>(facebook::jsc::makeJSCRuntime(std::move(rc)), delegate, JSIExecutor::defaultTimeoutInvoker, runtimeInstaller_); // [macOS]
}

} // namespace react
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/ReactCommon/cxxreact/JSExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class RN_EXPORT JSExecutor {
}

/**
* Returns whether or not the underlying executor supports debugging.
* Returns whether or not the underlying executor supports debugging. // [macOS]
*/
virtual bool isInspectable() {
return false;
Expand Down
12 changes: 9 additions & 3 deletions packages/react-native/ReactCommon/jsc/JSCRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ class JSCRuntime : public jsi::Runtime {
public:
// Creates new context in new context group
JSCRuntime();
// [macOS
// Creates new context in new context group with config
JSCRuntime(facebook::jsc::runtimeConfig &rc);
// macOS]
// Retains ctx
JSCRuntime(JSGlobalContextRef ctx);
~JSCRuntime();
Expand Down Expand Up @@ -394,6 +396,7 @@ JSCRuntime::JSCRuntime()
JSGlobalContextRelease(ctx_);
}

// [macOS
JSCRuntime::JSCRuntime(facebook::jsc::runtimeConfig &rc)
: JSCRuntime() {
#ifdef _JSC_HAS_INSPECTABLE
Expand All @@ -404,6 +407,7 @@ JSCRuntime::JSCRuntime(facebook::jsc::runtimeConfig &rc)
JSGlobalContextSetName(ctx_, JSStringCreateWithUTF8CString(rc.debuggerName.c_str()));

}
// macOS]

JSCRuntime::JSCRuntime(JSGlobalContextRef ctx)
: ctx_(JSGlobalContextRetain(ctx)),
Expand Down Expand Up @@ -494,11 +498,11 @@ std::string JSCRuntime::description() {
}

bool JSCRuntime::isInspectable() {
#ifdef _JSC_HAS_INSPECTABLE
#ifdef _JSC_HAS_INSPECTABLE // [macOS
return JSGlobalContextIsInspectable(ctx_);
#else
#else // macOS]
return false;
#endif
#endif // [macOS]
}

namespace {
Expand Down Expand Up @@ -1584,9 +1588,11 @@ std::unique_ptr<jsi::Runtime> makeJSCRuntime() {
return std::make_unique<JSCRuntime>();
}

// [macOS
std::unique_ptr<jsi::Runtime> makeJSCRuntime(facebook::jsc::runtimeConfig rc) {
return std::make_unique<JSCRuntime>(rc);
}
// macOS]

} // namespace jsc
} // namespace facebook
4 changes: 3 additions & 1 deletion packages/react-native/ReactCommon/jsc/JSCRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
namespace facebook {
namespace jsc {

// [macOS
struct runtimeConfig {
bool enableDebugger;
std::string debuggerName;
};
// macOS]

std::unique_ptr<jsi::Runtime> makeJSCRuntime();

std::unique_ptr<jsi::Runtime> makeJSCRuntime(facebook::jsc::runtimeConfig rc);
std::unique_ptr<jsi::Runtime> makeJSCRuntime(facebook::jsc::runtimeConfig rc); // [macOS]

} // namespace jsc
} // namespace facebook

0 comments on commit 0d0084c

Please sign in to comment.