From bf7418f90d2b549c2502e07c1ca076c5a5f8c98a Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:19:57 -0800 Subject: [PATCH] Fixes to bridging/base.h for MSVC compatibility --- .../ReactCommon/react/bridging/Base.h | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/packages/react-native/ReactCommon/react/bridging/Base.h b/packages/react-native/ReactCommon/react/bridging/Base.h index 2858ea7833bf65..2c67d46f2ff830 100644 --- a/packages/react-native/ReactCommon/react/bridging/Base.h +++ b/packages/react-native/ReactCommon/react/bridging/Base.h @@ -63,8 +63,8 @@ using bridging_t = typename detail::bridging_wrapper::type; template , int> = 0> auto fromJs(jsi::Runtime& rt, T&& value, const std::shared_ptr&) - -> decltype(static_cast(convert(rt, std::forward(value)))) { - return convert(rt, std::forward(value)); + -> decltype(static_cast(std::move(convert(rt, std::forward(value))))) { + return static_cast(std::move(convert(rt, std::forward(value)))); } template @@ -121,7 +121,7 @@ auto toJs( template inline constexpr bool supportsFromJs = false; -template +template inline constexpr bool supportsFromJs< T, Arg, @@ -130,10 +130,19 @@ inline constexpr bool supportsFromJs< std::declval(), nullptr))>> = true; +template +inline constexpr bool supportsFromJs< + T, + jsi::Value, + std::void_t( + std::declval(), + std::declval(), + nullptr))>> = true; + template inline constexpr bool supportsToJs = false; -template +template inline constexpr bool supportsToJs< T, Ret, @@ -148,5 +157,20 @@ inline constexpr bool supportsToJs< nullptr)), Ret>; +template +inline constexpr bool supportsToJs< + T, + jsi::Value, + std::void_t(), + std::declval(), + nullptr))>> = + std::is_convertible_v< + decltype(toJs( + std::declval(), + std::declval(), + nullptr)), + jsi::Value>; + } // namespace bridging } // namespace facebook::react