Skip to content

Commit

Permalink
Fixes to bridging/base.h for MSVC compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
acoates-ms committed Nov 21, 2024
1 parent aae3e03 commit bf7418f
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions packages/react-native/ReactCommon/react/bridging/Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ using bridging_t = typename detail::bridging_wrapper<T>::type;

template <typename R, typename T, std::enable_if_t<is_jsi_v<T>, int> = 0>
auto fromJs(jsi::Runtime& rt, T&& value, const std::shared_ptr<CallInvoker>&)
-> decltype(static_cast<R>(convert(rt, std::forward<T>(value)))) {
return convert(rt, std::forward<T>(value));
-> decltype(static_cast<R>(std::move(convert(rt, std::forward<T>(value))))) {
return static_cast<R>(std::move(convert(rt, std::forward<T>(value))));
}

template <typename R, typename T>
Expand Down Expand Up @@ -121,7 +121,7 @@ auto toJs(
template <typename, typename = jsi::Value, typename = void>
inline constexpr bool supportsFromJs = false;

template <typename T, typename Arg = jsi::Value>
template <typename T, typename Arg>
inline constexpr bool supportsFromJs<
T,
Arg,
Expand All @@ -130,10 +130,19 @@ inline constexpr bool supportsFromJs<
std::declval<Arg>(),
nullptr))>> = true;

template <typename T>
inline constexpr bool supportsFromJs<
T,
jsi::Value,
std::void_t<decltype(fromJs<T>(
std::declval<jsi::Runtime &>(),
std::declval<jsi::Value>(),
nullptr))>> = true;

template <typename, typename = jsi::Value, typename = void>
inline constexpr bool supportsToJs = false;

template <typename T, typename Ret = jsi::Value>
template <typename T, typename Ret>
inline constexpr bool supportsToJs<
T,
Ret,
Expand All @@ -148,5 +157,20 @@ inline constexpr bool supportsToJs<
nullptr)),
Ret>;

template <typename T>
inline constexpr bool supportsToJs<
T,
jsi::Value,
std::void_t<decltype(toJs(
std::declval<jsi::Runtime&>(),
std::declval<T>(),
nullptr))>> =
std::is_convertible_v<
decltype(toJs(
std::declval<jsi::Runtime&>(),
std::declval<T>(),
nullptr)),
jsi::Value>;

} // namespace bridging
} // namespace facebook::react

0 comments on commit bf7418f

Please sign in to comment.