diff options
| -rw-r--r-- | src/core/hle/service/cmif_serialization.h | 6 | ||||
| -rw-r--r-- | src/core/hle/service/cmif_types.h | 27 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/core/hle/service/cmif_serialization.h b/src/core/hle/service/cmif_serialization.h index 315475e71..e985fe317 100644 --- a/src/core/hle/service/cmif_serialization.h +++ b/src/core/hle/service/cmif_serialization.h | |||
| @@ -115,6 +115,11 @@ struct ArgumentTraits { | |||
| 115 | static constexpr ArgumentType Type = ArgumentType::InData; | 115 | static constexpr ArgumentType Type = ArgumentType::InData; |
| 116 | }; | 116 | }; |
| 117 | 117 | ||
| 118 | template <typename... Ts> | ||
| 119 | consteval bool ConstIfReference() { | ||
| 120 | return ((!std::is_reference_v<Ts> || std::is_const_v<std::remove_reference_t<Ts>>) && ... && true); | ||
| 121 | } | ||
| 122 | |||
| 118 | struct RequestLayout { | 123 | struct RequestLayout { |
| 119 | u32 copy_handle_count; | 124 | u32 copy_handle_count; |
| 120 | u32 move_handle_count; | 125 | u32 move_handle_count; |
| @@ -435,6 +440,7 @@ void CmifReplyWrapImpl(HLERequestContext& ctx, T& t, Result (T::*f)(A...)) { | |||
| 435 | } | 440 | } |
| 436 | const bool is_domain = Domain ? ctx.GetManager()->IsDomain() : false; | 441 | const bool is_domain = Domain ? ctx.GetManager()->IsDomain() : false; |
| 437 | 442 | ||
| 443 | static_assert(ConstIfReference<A...>(), "Arguments taken by reference must be const"); | ||
| 438 | using MethodArguments = std::tuple<std::remove_cvref_t<A>...>; | 444 | using MethodArguments = std::tuple<std::remove_cvref_t<A>...>; |
| 439 | 445 | ||
| 440 | OutTemporaryBuffers buffers{}; | 446 | OutTemporaryBuffers buffers{}; |
diff --git a/src/core/hle/service/cmif_types.h b/src/core/hle/service/cmif_types.h index dc06169f4..84f4c2456 100644 --- a/src/core/hle/service/cmif_types.h +++ b/src/core/hle/service/cmif_types.h | |||
| @@ -4,10 +4,9 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <span> | ||
| 7 | 8 | ||
| 8 | #include "common/common_funcs.h" | ||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "core/hle/service/hle_ipc.h" | ||
| 11 | 10 | ||
| 12 | namespace Service { | 11 | namespace Service { |
| 13 | 12 | ||
| @@ -22,8 +21,10 @@ class Out { | |||
| 22 | public: | 21 | public: |
| 23 | using Type = T; | 22 | using Type = T; |
| 24 | 23 | ||
| 24 | /* implicit */ Out(const Out& t) : raw(t.raw) {} | ||
| 25 | /* implicit */ Out(AutoOut<Type>& t) : raw(&t.raw) {} | 25 | /* implicit */ Out(AutoOut<Type>& t) : raw(&t.raw) {} |
| 26 | /* implicit */ Out(Type* t) : raw(t) {} | 26 | /* implicit */ Out(Type* t) : raw(t) {} |
| 27 | Out& operator=(const Out&) = delete; | ||
| 27 | 28 | ||
| 28 | Type* Get() const { | 29 | Type* Get() const { |
| 29 | return raw; | 30 | return raw; |
| @@ -37,6 +38,10 @@ public: | |||
| 37 | return raw; | 38 | return raw; |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 41 | operator Type*() const { | ||
| 42 | return raw; | ||
| 43 | } | ||
| 44 | |||
| 40 | private: | 45 | private: |
| 41 | Type* raw; | 46 | Type* raw; |
| 42 | }; | 47 | }; |
| @@ -113,8 +118,10 @@ class OutCopyHandle { | |||
| 113 | public: | 118 | public: |
| 114 | using Type = T*; | 119 | using Type = T*; |
| 115 | 120 | ||
| 121 | /* implicit */ OutCopyHandle(const OutCopyHandle& t) : raw(t.raw) {} | ||
| 116 | /* implicit */ OutCopyHandle(AutoOut<Type>& t) : raw(&t.raw) {} | 122 | /* implicit */ OutCopyHandle(AutoOut<Type>& t) : raw(&t.raw) {} |
| 117 | /* implicit */ OutCopyHandle(Type* t) : raw(t) {} | 123 | /* implicit */ OutCopyHandle(Type* t) : raw(t) {} |
| 124 | OutCopyHandle& operator=(const OutCopyHandle&) = delete; | ||
| 118 | 125 | ||
| 119 | Type* Get() const { | 126 | Type* Get() const { |
| 120 | return raw; | 127 | return raw; |
| @@ -128,6 +135,10 @@ public: | |||
| 128 | return raw; | 135 | return raw; |
| 129 | } | 136 | } |
| 130 | 137 | ||
| 138 | operator Type*() const { | ||
| 139 | return raw; | ||
| 140 | } | ||
| 141 | |||
| 131 | private: | 142 | private: |
| 132 | Type* raw; | 143 | Type* raw; |
| 133 | }; | 144 | }; |
| @@ -137,8 +148,10 @@ class OutMoveHandle { | |||
| 137 | public: | 148 | public: |
| 138 | using Type = T*; | 149 | using Type = T*; |
| 139 | 150 | ||
| 151 | /* implicit */ OutMoveHandle(const OutMoveHandle& t) : raw(t.raw) {} | ||
| 140 | /* implicit */ OutMoveHandle(AutoOut<Type>& t) : raw(&t.raw) {} | 152 | /* implicit */ OutMoveHandle(AutoOut<Type>& t) : raw(&t.raw) {} |
| 141 | /* implicit */ OutMoveHandle(Type* t) : raw(t) {} | 153 | /* implicit */ OutMoveHandle(Type* t) : raw(t) {} |
| 154 | OutMoveHandle& operator=(const OutMoveHandle&) = delete; | ||
| 142 | 155 | ||
| 143 | Type* Get() const { | 156 | Type* Get() const { |
| 144 | return raw; | 157 | return raw; |
| @@ -152,6 +165,10 @@ public: | |||
| 152 | return raw; | 165 | return raw; |
| 153 | } | 166 | } |
| 154 | 167 | ||
| 168 | operator Type*() const { | ||
| 169 | return raw; | ||
| 170 | } | ||
| 171 | |||
| 155 | private: | 172 | private: |
| 156 | Type* raw; | 173 | Type* raw; |
| 157 | }; | 174 | }; |
| @@ -248,8 +265,10 @@ public: | |||
| 248 | static constexpr BufferAttr Attr = static_cast<BufferAttr>(A | BufferAttr_In | BufferAttr_FixedSize); | 265 | static constexpr BufferAttr Attr = static_cast<BufferAttr>(A | BufferAttr_In | BufferAttr_FixedSize); |
| 249 | using Type = T; | 266 | using Type = T; |
| 250 | 267 | ||
| 268 | /* implicit */ OutLargeData(const OutLargeData& t) : raw(t.raw) {} | ||
| 251 | /* implicit */ OutLargeData(Type* t) : raw(t) {} | 269 | /* implicit */ OutLargeData(Type* t) : raw(t) {} |
| 252 | /* implicit */ OutLargeData(AutoOut<T>& t) : raw(&t.raw) {} | 270 | /* implicit */ OutLargeData(AutoOut<T>& t) : raw(&t.raw) {} |
| 271 | OutLargeData& operator=(const OutLargeData&) = delete; | ||
| 253 | 272 | ||
| 254 | Type* Get() const { | 273 | Type* Get() const { |
| 255 | return raw; | 274 | return raw; |
| @@ -263,6 +282,10 @@ public: | |||
| 263 | return raw; | 282 | return raw; |
| 264 | } | 283 | } |
| 265 | 284 | ||
| 285 | operator Type*() const { | ||
| 286 | return raw; | ||
| 287 | } | ||
| 288 | |||
| 266 | private: | 289 | private: |
| 267 | Type* raw; | 290 | Type* raw; |
| 268 | }; | 291 | }; |