summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar liamwhite2024-02-04 09:48:33 -0500
committerGravatar GitHub2024-02-04 09:48:33 -0500
commit4cccbe7989a6a2571ffb1a21790f3884786c557a (patch)
treee0cebe568f7bc8597a019b75ecc6d4b3b653e206
parentMerge pull request #12901 from Kelebek1/timezone_firmware_fix (diff)
parentcmif_serialization: enforce const for references (diff)
downloadyuzu-4cccbe7989a6a2571ffb1a21790f3884786c557a.tar.gz
yuzu-4cccbe7989a6a2571ffb1a21790f3884786c557a.tar.xz
yuzu-4cccbe7989a6a2571ffb1a21790f3884786c557a.zip
Merge pull request #12892 from liamwhite/serialization-stuff
cmif_serialization: enforce const for references
-rw-r--r--src/core/hle/service/cmif_serialization.h6
-rw-r--r--src/core/hle/service/cmif_types.h27
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
118template <typename... Ts>
119consteval bool ConstIfReference() {
120 return ((!std::is_reference_v<Ts> || std::is_const_v<std::remove_reference_t<Ts>>) && ... && true);
121}
122
118struct RequestLayout { 123struct 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
12namespace Service { 11namespace Service {
13 12
@@ -22,8 +21,10 @@ class Out {
22public: 21public:
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
40private: 45private:
41 Type* raw; 46 Type* raw;
42}; 47};
@@ -113,8 +118,10 @@ class OutCopyHandle {
113public: 118public:
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
131private: 142private:
132 Type* raw; 143 Type* raw;
133}; 144};
@@ -137,8 +148,10 @@ class OutMoveHandle {
137public: 148public:
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
155private: 172private:
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
266private: 289private:
267 Type* raw; 290 Type* raw;
268}; 291};