From 180a90297897d892457398e6fab53dc33a5006bd Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 2 Mar 2021 13:32:46 +0100 Subject: [PATCH] parser-inc: Add some missing C++11/14/17/20 stdlib stubs --- dtool/src/parser-inc/bit | 9 +++++++ dtool/src/parser-inc/condition_variable | 11 +++++++++ dtool/src/parser-inc/coroutine | 31 +++++++++++++++++++++++++ dtool/src/parser-inc/forward_list | 9 +++++++ dtool/src/parser-inc/future | 27 +++++++++++++++++++++ dtool/src/parser-inc/mutex | 1 + dtool/src/parser-inc/new | 10 ++++++++ dtool/src/parser-inc/shared_mutex | 7 ++++++ dtool/src/parser-inc/thread | 21 +++++++++++++++++ dtool/src/parser-inc/type_traits | 19 +++++++++++++++ 10 files changed, 145 insertions(+) create mode 100644 dtool/src/parser-inc/bit create mode 100644 dtool/src/parser-inc/condition_variable create mode 100644 dtool/src/parser-inc/coroutine create mode 100644 dtool/src/parser-inc/forward_list create mode 100644 dtool/src/parser-inc/future create mode 100644 dtool/src/parser-inc/shared_mutex create mode 100644 dtool/src/parser-inc/thread diff --git a/dtool/src/parser-inc/bit b/dtool/src/parser-inc/bit new file mode 100644 index 0000000000..663e519ad0 --- /dev/null +++ b/dtool/src/parser-inc/bit @@ -0,0 +1,9 @@ +#pragma once + +namespace std { + enum class endian { + little, + big, + native, + }; +}; diff --git a/dtool/src/parser-inc/condition_variable b/dtool/src/parser-inc/condition_variable new file mode 100644 index 0000000000..ea8bb08a96 --- /dev/null +++ b/dtool/src/parser-inc/condition_variable @@ -0,0 +1,11 @@ +#pragma once + +namespace std { + class condition_variable; + class condition_variable_any; + + enum class cv_status { + no_timeout, + timeout, + }; +} diff --git a/dtool/src/parser-inc/coroutine b/dtool/src/parser-inc/coroutine new file mode 100644 index 0000000000..731fe7a034 --- /dev/null +++ b/dtool/src/parser-inc/coroutine @@ -0,0 +1,31 @@ +#pragma once + +namespace std { + template + struct coroutine_traits; + + template + struct coroutine_handle; + + template struct hash; + template struct hash>; + + struct noop_coroutine_promise; + + template<> struct coroutine_handle; + using noop_coroutine_handle = coroutine_handle; + + noop_coroutine_handle noop_coroutine() noexcept; + + struct suspend_never { + constexpr bool await_ready() const noexcept { return true; } + constexpr void await_suspend(coroutine_handle<>) const noexcept {} + constexpr void await_resume() const noexcept {} + }; + + struct suspend_always { + constexpr bool await_ready() const noexcept { return false; } + constexpr void await_suspend(coroutine_handle<>) const noexcept {} + constexpr void await_resume() const noexcept {} + }; +} diff --git a/dtool/src/parser-inc/forward_list b/dtool/src/parser-inc/forward_list new file mode 100644 index 0000000000..a938094eb2 --- /dev/null +++ b/dtool/src/parser-inc/forward_list @@ -0,0 +1,9 @@ +#pragma once + +#include +#include + +namespace std { + template struct allocator; + template> class forward_list; +} diff --git a/dtool/src/parser-inc/future b/dtool/src/parser-inc/future new file mode 100644 index 0000000000..894d5ab021 --- /dev/null +++ b/dtool/src/parser-inc/future @@ -0,0 +1,27 @@ +#pragma once + +namespace std { + enum class future_status { + ready, + timeout, + deferred + }; + + class future_error; + + template class promise; + template class promise; + template<> class promise; + + template class future; + template class future; + template<> class future; + + template class shared_future; + template class shared_future; + template<> class shared_future; + + template class packaged_task; + template + class packaged_task; +} diff --git a/dtool/src/parser-inc/mutex b/dtool/src/parser-inc/mutex index b05214e512..2f80275f7d 100644 --- a/dtool/src/parser-inc/mutex +++ b/dtool/src/parser-inc/mutex @@ -22,6 +22,7 @@ namespace std { inline constexpr adopt_lock_t adopt_lock {}; template class lock_guard; + template class scoped_lock; template class unique_lock; struct once_flag; diff --git a/dtool/src/parser-inc/new b/dtool/src/parser-inc/new index 2771be683a..512e0b9fce 100644 --- a/dtool/src/parser-inc/new +++ b/dtool/src/parser-inc/new @@ -1,5 +1,7 @@ #pragma once +#include + namespace std { class bad_alloc; class bad_array_new_length; @@ -10,4 +12,12 @@ namespace std { extern const nothrow_t nothrow; using new_handler = void (*)(); + + inline constexpr size_t hardware_destructive_interference_size; + inline constexpr size_t hardware_constructive_interference_size; + + struct destroying_delete_t { + explicit destroying_delete_t() = default; + }; + inline constexpr destroying_delete_t destroying_delete {}; } diff --git a/dtool/src/parser-inc/shared_mutex b/dtool/src/parser-inc/shared_mutex new file mode 100644 index 0000000000..9d613a9f7e --- /dev/null +++ b/dtool/src/parser-inc/shared_mutex @@ -0,0 +1,7 @@ +#pragma once + +namespace std { + class shared_mutex; + class shared_timed_mutex; + template class shared_lock; +} diff --git a/dtool/src/parser-inc/thread b/dtool/src/parser-inc/thread new file mode 100644 index 0000000000..dd49b6579e --- /dev/null +++ b/dtool/src/parser-inc/thread @@ -0,0 +1,21 @@ +#pragma once + +#include + +namespace std { + class thread { + public: + class id; + }; + + class jthread { + public: + using id = thread::id; + }; + + template struct hash; + template<> struct hash; + + namespace this_thread { + } +} diff --git a/dtool/src/parser-inc/type_traits b/dtool/src/parser-inc/type_traits index 7e55b03fbc..97e3313459 100644 --- a/dtool/src/parser-inc/type_traits +++ b/dtool/src/parser-inc/type_traits @@ -14,6 +14,9 @@ namespace std { typedef integral_constant true_type; typedef integral_constant false_type; + template + using bool_constant = integral_constant; + template struct is_same : std::false_type {}; @@ -86,6 +89,9 @@ namespace std { template struct is_convertible : integral_constant {}; + template + struct is_aggregate; + template struct add_cv { typedef const volatile T type; }; template struct add_const { typedef const T type; }; template struct add_volatile { typedef volatile T type; }; @@ -93,4 +99,17 @@ namespace std { template struct add_lvalue_reference { typedef T &type; }; template struct add_rvalue_reference { typedef T &&type; }; template struct add_pointer { typedef T *type; }; + + constexpr bool is_constant_evaluated() noexcept; + + template + struct type_identity { + using type = T; + }; + + template + using type_identity_t = typename type_identity::type; + + template + using void_t = void; }