From c5cb0e1d395563bcfcde9bcd3f97beaf8b377203 Mon Sep 17 00:00:00 2001 From: hai007 Date: Tue, 13 Dec 2022 13:07:32 -0800 Subject: [PATCH] Insert placeholder declarations into `winrt/base.h`. PiperOrigin-RevId: 495104919 --- .../generated/base-no-coroutines.patch | 37 +++++++++++++++++++ .../windows/generated/patch_winrt_base.sh | 7 ++++ .../windows/generated/winrt/base.h | 26 +++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 internal/platform/implementation/windows/generated/base-no-coroutines.patch create mode 100755 internal/platform/implementation/windows/generated/patch_winrt_base.sh diff --git a/internal/platform/implementation/windows/generated/base-no-coroutines.patch b/internal/platform/implementation/windows/generated/base-no-coroutines.patch new file mode 100644 index 00000000..60e5fe90 --- /dev/null +++ b/internal/platform/implementation/windows/generated/base-no-coroutines.patch @@ -0,0 +1,37 @@ +*** third_party/nearby/internal/platform/implementation/windows/generated/winrt/base.h 2022-12-07 15:29:09.000000000 -0500 +--- third_party/nearby/internal/platform/implementation/windows/generated/winrt/base-no-coroutines.h 2022-12-07 15:28:53.000000000 -0500 +*************** +*** 35,40 **** +--- 35,66 ---- + #include + #endif + ++ #if defined(_LIBCPP_VERSION) && __cplusplus < 202002 ++ // If the C++ standard is cxx17, coroutines are not available in libc++. ++ // To compile WinRT without coroutines, define some placeholder types. ++ // These placeholders should not be used. If they are used, they should fail. ++ template ++ struct coroutine_handle { ++ coroutine_handle() { throw std::logic_error("Not implemented."); } ++ coroutine_handle(std::nullptr_t __h) { ++ throw std::logic_error("Not implemented."); ++ } ++ static coroutine_handle from_address(void*) { ++ throw std::logic_error("Not implemented."); ++ } ++ void operator()() const { throw std::logic_error("Not implemented."); } ++ void* address() const { throw std::logic_error("Not implemented."); } ++ }; ++ ++ class suspend_always {}; ++ class suspend_never {}; ++ ++ template ++ struct coroutine_traits; ++ ++ } // namespace std::experimental ++ #endif ++ + #ifdef __cpp_lib_coroutine + + #include diff --git a/internal/platform/implementation/windows/generated/patch_winrt_base.sh b/internal/platform/implementation/windows/generated/patch_winrt_base.sh new file mode 100755 index 00000000..ba8e7f2c --- /dev/null +++ b/internal/platform/implementation/windows/generated/patch_winrt_base.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +patch \ + --forward \ + -r - \ + third_party/nearby/internal/platform/implementation/windows/generated/winrt/base.h \ + third_party/nearby/internal/platform/implementation/windows/generated/base-no-coroutines.patch diff --git a/internal/platform/implementation/windows/generated/winrt/base.h b/internal/platform/implementation/windows/generated/winrt/base.h index 189fee09..8b75fbbb 100644 --- a/internal/platform/implementation/windows/generated/winrt/base.h +++ b/internal/platform/implementation/windows/generated/winrt/base.h @@ -35,6 +35,32 @@ #include #endif +#if defined(_LIBCPP_VERSION) && __cplusplus < 202002 +// If the C++ standard is cxx17, coroutines are not available in libc++. +// To compile WinRT without coroutines, define some placeholder types. +// These placeholders should not be used. If they are used, they should fail. +template +struct coroutine_handle { + coroutine_handle() { throw std::logic_error("Not implemented."); } + coroutine_handle(std::nullptr_t __h) { + throw std::logic_error("Not implemented."); + } + static coroutine_handle from_address(void*) { + throw std::logic_error("Not implemented."); + } + void operator()() const { throw std::logic_error("Not implemented."); } + void* address() const { throw std::logic_error("Not implemented."); } +}; + +class suspend_always {}; +class suspend_never {}; + +template +struct coroutine_traits; + +} // namespace std::experimental +#endif + #ifdef __cpp_lib_coroutine #include