diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2025-02-05 16:24:35 +0100 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2025-02-05 16:24:35 +0100 |
commit | 887fc613dd943d1221d5a2a3b96cee37c0d81248 (patch) | |
tree | 7151029f79e115d8822291644e11244def30079d /src | |
parent | 05e4cce366cccf92ad88f80695efa548fae187de (diff) | |
download | lanes-887fc613dd943d1221d5a2a3b96cee37c0d81248.tar.gz lanes-887fc613dd943d1221d5a2a3b96cee37c0d81248.tar.bz2 lanes-887fc613dd943d1221d5a2a3b96cee37c0d81248.zip |
All enums are [[nodiscard]]
Diffstat (limited to 'src')
-rw-r--r-- | src/allocator.hpp | 6 | ||||
-rw-r--r-- | src/cancel.hpp | 6 | ||||
-rw-r--r-- | src/compat.hpp | 6 | ||||
-rw-r--r-- | src/deep.hpp | 2 | ||||
-rw-r--r-- | src/intercopycontext.cpp | 2 | ||||
-rw-r--r-- | src/intercopycontext.hpp | 4 | ||||
-rw-r--r-- | src/keeper.hpp | 4 | ||||
-rw-r--r-- | src/lane.cpp | 1 | ||||
-rw-r--r-- | src/lane.hpp | 7 | ||||
-rw-r--r-- | src/linda.hpp | 2 | ||||
-rw-r--r-- | src/tools.cpp | 2 | ||||
-rw-r--r-- | src/tools.hpp | 3 |
12 files changed, 25 insertions, 20 deletions
diff --git a/src/allocator.hpp b/src/allocator.hpp index 16db1e6..c073391 100644 --- a/src/allocator.hpp +++ b/src/allocator.hpp | |||
@@ -68,18 +68,18 @@ namespace lanes { | |||
68 | } | 68 | } |
69 | 69 | ||
70 | [[nodiscard]] | 70 | [[nodiscard]] |
71 | void* alloc(size_t const nsize_) | 71 | void* alloc(size_t const nsize_) const |
72 | { | 72 | { |
73 | return allocF(allocUD, nullptr, 0, nsize_); | 73 | return allocF(allocUD, nullptr, 0, nsize_); |
74 | } | 74 | } |
75 | 75 | ||
76 | [[nodiscard]] | 76 | [[nodiscard]] |
77 | void* alloc(void* const ptr_, size_t const osize_, size_t const nsize_) | 77 | void* alloc(void* const ptr_, size_t const osize_, size_t const nsize_) const |
78 | { | 78 | { |
79 | return allocF(allocUD, ptr_, osize_, nsize_); | 79 | return allocF(allocUD, ptr_, osize_, nsize_); |
80 | } | 80 | } |
81 | 81 | ||
82 | void free(void* const ptr_, size_t const osize_) | 82 | void free(void* const ptr_, size_t const osize_) const |
83 | { | 83 | { |
84 | std::ignore = allocF(allocUD, ptr_, osize_, 0); | 84 | std::ignore = allocF(allocUD, ptr_, osize_, 0); |
85 | } | 85 | } |
diff --git a/src/cancel.hpp b/src/cancel.hpp index 65ccf8d..0d59c52 100644 --- a/src/cancel.hpp +++ b/src/cancel.hpp | |||
@@ -6,20 +6,20 @@ | |||
6 | // ################################################################################################# | 6 | // ################################################################################################# |
7 | 7 | ||
8 | // Lane cancellation request modes | 8 | // Lane cancellation request modes |
9 | enum class CancelRequest : uint8_t | 9 | enum class [[nodiscard]] CancelRequest : uint8_t |
10 | { | 10 | { |
11 | None, // no pending cancel request | 11 | None, // no pending cancel request |
12 | Soft, // user wants the lane to cancel itself manually on cancel_test() | 12 | Soft, // user wants the lane to cancel itself manually on cancel_test() |
13 | Hard // user wants the lane to be interrupted (meaning code won't return from those functions) from inside linda:send/receive calls | 13 | Hard // user wants the lane to be interrupted (meaning code won't return from those functions) from inside linda:send/receive calls |
14 | }; | 14 | }; |
15 | 15 | ||
16 | struct CancelOp | 16 | struct [[nodiscard]] CancelOp |
17 | { | 17 | { |
18 | CancelRequest mode; | 18 | CancelRequest mode; |
19 | LuaHookMask hookMask; | 19 | LuaHookMask hookMask; |
20 | }; | 20 | }; |
21 | 21 | ||
22 | enum class CancelResult : uint8_t | 22 | enum class [[nodiscard]] CancelResult : uint8_t |
23 | { | 23 | { |
24 | Timeout, | 24 | Timeout, |
25 | Cancelled | 25 | Cancelled |
diff --git a/src/compat.hpp b/src/compat.hpp index 0c7c5bb..d864ae9 100644 --- a/src/compat.hpp +++ b/src/compat.hpp | |||
@@ -34,7 +34,7 @@ | |||
34 | // ################################################################################################# | 34 | // ################################################################################################# |
35 | 35 | ||
36 | // a strong-typed wrapper over lua types to see them easier in a debugger | 36 | // a strong-typed wrapper over lua types to see them easier in a debugger |
37 | enum class LuaType | 37 | enum class [[nodiscard]] LuaType |
38 | { | 38 | { |
39 | NONE = LUA_TNONE, | 39 | NONE = LUA_TNONE, |
40 | NIL = LUA_TNIL, | 40 | NIL = LUA_TNIL, |
@@ -49,7 +49,7 @@ enum class LuaType | |||
49 | CDATA = 10 // LuaJIT CDATA | 49 | CDATA = 10 // LuaJIT CDATA |
50 | }; | 50 | }; |
51 | 51 | ||
52 | enum class LuaHookMask | 52 | enum class [[nodiscard]] LuaHookMask |
53 | { | 53 | { |
54 | None = 0, | 54 | None = 0, |
55 | Call = LUA_MASKCALL, | 55 | Call = LUA_MASKCALL, |
@@ -113,7 +113,7 @@ inline int luaL_optint(lua_State* L_, StackIndex n_, lua_Integer d_) | |||
113 | // ################################################################################################# | 113 | // ################################################################################################# |
114 | 114 | ||
115 | // a strong-typed wrapper over lua error codes to see them easier in a debugger | 115 | // a strong-typed wrapper over lua error codes to see them easier in a debugger |
116 | enum class LuaError | 116 | enum class [[nodiscard]] LuaError |
117 | { | 117 | { |
118 | OK = LUA_OK, | 118 | OK = LUA_OK, |
119 | YIELD = LUA_YIELD, | 119 | YIELD = LUA_YIELD, |
diff --git a/src/deep.hpp b/src/deep.hpp index f8cfa0d..7d61f42 100644 --- a/src/deep.hpp +++ b/src/deep.hpp | |||
@@ -9,7 +9,7 @@ | |||
9 | #include "uniquekey.hpp" | 9 | #include "uniquekey.hpp" |
10 | 10 | ||
11 | // forwards | 11 | // forwards |
12 | enum class LookupMode; | 12 | enum class [[nodiscard]] LookupMode; |
13 | class DeepFactory; | 13 | class DeepFactory; |
14 | class Universe; | 14 | class Universe; |
15 | 15 | ||
diff --git a/src/intercopycontext.cpp b/src/intercopycontext.cpp index 6b3d282..da4340e 100644 --- a/src/intercopycontext.cpp +++ b/src/intercopycontext.cpp | |||
@@ -156,7 +156,7 @@ static constexpr RegistryUniqueKey kMtIdRegKey{ 0xA8895DCF4EC3FE3Cull }; | |||
156 | 156 | ||
157 | // get a unique ID for metatable at [i]. | 157 | // get a unique ID for metatable at [i]. |
158 | [[nodiscard]] | 158 | [[nodiscard]] |
159 | static lua_Integer get_mt_id(Universe* U_, lua_State* L_, StackIndex const idx_) | 159 | static lua_Integer get_mt_id(Universe* const U_, lua_State* const L_, StackIndex const idx_) |
160 | { | 160 | { |
161 | StackIndex const _absidx{ luaG_absindex(L_, idx_) }; | 161 | StackIndex const _absidx{ luaG_absindex(L_, idx_) }; |
162 | 162 | ||
diff --git a/src/intercopycontext.hpp b/src/intercopycontext.hpp index cc84017..ece4674 100644 --- a/src/intercopycontext.hpp +++ b/src/intercopycontext.hpp | |||
@@ -7,14 +7,14 @@ class Universe; | |||
7 | 7 | ||
8 | // ################################################################################################# | 8 | // ################################################################################################# |
9 | 9 | ||
10 | enum class VT | 10 | enum class [[nodiscard]] VT |
11 | { | 11 | { |
12 | NORMAL, // keep this one first so that it's the value we get when we default-construct | 12 | NORMAL, // keep this one first so that it's the value we get when we default-construct |
13 | KEY, | 13 | KEY, |
14 | METATABLE | 14 | METATABLE |
15 | }; | 15 | }; |
16 | 16 | ||
17 | enum class InterCopyResult | 17 | enum class [[nodiscard]] InterCopyResult |
18 | { | 18 | { |
19 | Success, | 19 | Success, |
20 | NotEnoughValues, | 20 | NotEnoughValues, |
diff --git a/src/keeper.hpp b/src/keeper.hpp index 4b16c2b..17b56de 100644 --- a/src/keeper.hpp +++ b/src/keeper.hpp | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | // forwards | 5 | // forwards |
6 | class Linda; | 6 | class Linda; |
7 | enum class LookupMode; | 7 | enum class [[nodiscard]] LookupMode; |
8 | class Universe; | 8 | class Universe; |
9 | 9 | ||
10 | DECLARE_UNIQUE_TYPE(KeeperState,lua_State*); | 10 | DECLARE_UNIQUE_TYPE(KeeperState,lua_State*); |
@@ -13,7 +13,7 @@ DECLARE_UNIQUE_TYPE(KeeperIndex, int); | |||
13 | 13 | ||
14 | // ################################################################################################# | 14 | // ################################################################################################# |
15 | 15 | ||
16 | enum class LindaRestrict | 16 | enum class [[nodiscard]] LindaRestrict |
17 | { | 17 | { |
18 | None, | 18 | None, |
19 | SetGet, | 19 | SetGet, |
diff --git a/src/lane.cpp b/src/lane.cpp index c3f2996..5b05b4e 100644 --- a/src/lane.cpp +++ b/src/lane.cpp | |||
@@ -923,6 +923,7 @@ void Lane::applyDebugName() const | |||
923 | 923 | ||
924 | // ################################################################################################# | 924 | // ################################################################################################# |
925 | 925 | ||
926 | [[nodiscard]] | ||
926 | CancelResult Lane::cancel(CancelOp const op_, std::chrono::time_point<std::chrono::steady_clock> const until_, WakeLane const wakeLane_, int const hookCount_) | 927 | CancelResult Lane::cancel(CancelOp const op_, std::chrono::time_point<std::chrono::steady_clock> const until_, WakeLane const wakeLane_, int const hookCount_) |
927 | { | 928 | { |
928 | // this is a hook installed with lua_sethook: can't capture anything to be convertible to lua_Hook | 929 | // this is a hook installed with lua_sethook: can't capture anything to be convertible to lua_Hook |
diff --git a/src/lane.hpp b/src/lane.hpp index 4b0acab..4b5188c 100644 --- a/src/lane.hpp +++ b/src/lane.hpp | |||
@@ -44,7 +44,7 @@ static constexpr std::string_view kLaneMetatableName{ "Lane" }; | |||
44 | #define kLanesCoreLibName kLanesLibName ".core" | 44 | #define kLanesCoreLibName kLanesLibName ".core" |
45 | 45 | ||
46 | // for cancel() argument | 46 | // for cancel() argument |
47 | enum class WakeLane | 47 | enum class [[nodiscard]] WakeLane |
48 | { | 48 | { |
49 | No, | 49 | No, |
50 | Yes | 50 | Yes |
@@ -60,7 +60,7 @@ class Lane final | |||
60 | Running, Suspended, Waiting: Thread is inside the Lua VM. | 60 | Running, Suspended, Waiting: Thread is inside the Lua VM. |
61 | Done, Error, Cancelled: Thread execution is outside the Lua VM. It can be lua_close()d. | 61 | Done, Error, Cancelled: Thread execution is outside the Lua VM. It can be lua_close()d. |
62 | */ | 62 | */ |
63 | enum class Status | 63 | enum class [[nodiscard]] Status |
64 | { | 64 | { |
65 | Pending, | 65 | Pending, |
66 | Running, | 66 | Running, |
@@ -73,7 +73,7 @@ class Lane final | |||
73 | }; | 73 | }; |
74 | using enum Status; | 74 | using enum Status; |
75 | 75 | ||
76 | enum class ErrorTraceLevel | 76 | enum class [[nodiscard]] ErrorTraceLevel |
77 | { | 77 | { |
78 | Minimal, // no error handler function when running the lane body | 78 | Minimal, // no error handler function when running the lane body |
79 | Basic, // lane body errors caught by a error handler | 79 | Basic, // lane body errors caught by a error handler |
@@ -163,6 +163,7 @@ class Lane final | |||
163 | public: | 163 | public: |
164 | 164 | ||
165 | void applyDebugName() const; | 165 | void applyDebugName() const; |
166 | [[nodiscard]] | ||
166 | CancelResult cancel(CancelOp op_, std::chrono::time_point<std::chrono::steady_clock> until_, WakeLane wakeLane_, int hookCount_); | 167 | CancelResult cancel(CancelOp op_, std::chrono::time_point<std::chrono::steady_clock> until_, WakeLane wakeLane_, int hookCount_); |
167 | void closeState() | 168 | void closeState() |
168 | { | 169 | { |
diff --git a/src/linda.hpp b/src/linda.hpp index 33fc504..01ca7e1 100644 --- a/src/linda.hpp +++ b/src/linda.hpp | |||
@@ -40,7 +40,7 @@ class Linda final | |||
40 | } | 40 | } |
41 | }; | 41 | }; |
42 | 42 | ||
43 | enum class Status | 43 | enum class [[nodiscard]] Status |
44 | { | 44 | { |
45 | Active, | 45 | Active, |
46 | Cancelled | 46 | Cancelled |
diff --git a/src/tools.cpp b/src/tools.cpp index f3be85c..ee6d720 100644 --- a/src/tools.cpp +++ b/src/tools.cpp | |||
@@ -67,6 +67,7 @@ static int dummy_writer([[maybe_unused]] lua_State* const L_, [[maybe_unused]] v | |||
67 | * +-----------------+-------------------+------------+----------+ | 67 | * +-----------------+-------------------+------------+----------+ |
68 | */ | 68 | */ |
69 | 69 | ||
70 | [[nodiscard]] | ||
70 | FuncSubType luaG_getfuncsubtype(lua_State* const L_, StackIndex const i_) | 71 | FuncSubType luaG_getfuncsubtype(lua_State* const L_, StackIndex const i_) |
71 | { | 72 | { |
72 | if (lua_tocfunction(L_, i_)) { // nullptr for LuaJIT-fast && bytecode functions | 73 | if (lua_tocfunction(L_, i_)) { // nullptr for LuaJIT-fast && bytecode functions |
@@ -93,6 +94,7 @@ FuncSubType luaG_getfuncsubtype(lua_State* const L_, StackIndex const i_) | |||
93 | namespace tools { | 94 | namespace tools { |
94 | 95 | ||
95 | // inspired from tconcat() in ltablib.c | 96 | // inspired from tconcat() in ltablib.c |
97 | [[nodiscard]] | ||
96 | std::string_view PushFQN(lua_State* const L_, StackIndex const t_, TableIndex const last_) | 98 | std::string_view PushFQN(lua_State* const L_, StackIndex const t_, TableIndex const last_) |
97 | { | 99 | { |
98 | STACK_CHECK_START_REL(L_, 0); | 100 | STACK_CHECK_START_REL(L_, 0); |
diff --git a/src/tools.hpp b/src/tools.hpp index 9a62cda..2b8c5b5 100644 --- a/src/tools.hpp +++ b/src/tools.hpp | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | class Universe; | 5 | class Universe; |
6 | 6 | ||
7 | enum class LookupMode | 7 | enum class [[nodiscard]] LookupMode |
8 | { | 8 | { |
9 | LaneBody, // send the lane body directly from the source to the destination lane. keep this one first so that it's the value we get when we default-construct | 9 | LaneBody, // send the lane body directly from the source to the destination lane. keep this one first so that it's the value we get when we default-construct |
10 | ToKeeper, // send a function from a lane to a keeper state | 10 | ToKeeper, // send a function from a lane to a keeper state |
@@ -20,6 +20,7 @@ enum class [[nodiscard]] FuncSubType | |||
20 | FastJIT | 20 | FastJIT |
21 | }; | 21 | }; |
22 | 22 | ||
23 | [[nodiscard]] | ||
23 | FuncSubType luaG_getfuncsubtype(lua_State* L_, StackIndex i_); | 24 | FuncSubType luaG_getfuncsubtype(lua_State* L_, StackIndex i_); |
24 | 25 | ||
25 | // ################################################################################################# | 26 | // ################################################################################################# |