aboutsummaryrefslogtreecommitdiff
path: root/src/tools.h
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-04-16 18:06:02 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-04-16 18:06:02 +0200
commitbbb4f99918d00308b52af3289c29624bfeb0066b (patch)
treeaebfba19ae4bb2bddc2beaa18f80a64d254b4ae6 /src/tools.h
parentd6f5a7795360e3c2a6fc2d424904b6daa1f2accd (diff)
downloadlanes-bbb4f99918d00308b52af3289c29624bfeb0066b.tar.gz
lanes-bbb4f99918d00308b52af3289c29624bfeb0066b.tar.bz2
lanes-bbb4f99918d00308b52af3289c29624bfeb0066b.zip
some dead code elimination and other trifles
Diffstat (limited to 'src/tools.h')
-rw-r--r--src/tools.h48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/tools.h b/src/tools.h
index 06646d3..ddf5c67 100644
--- a/src/tools.h
+++ b/src/tools.h
@@ -6,13 +6,7 @@
6// forwards 6// forwards
7class Universe; 7class Universe;
8 8
9// ################################################################################################ 9// #################################################################################################
10
11#ifdef _DEBUG
12void luaG_dump(lua_State* L);
13#endif // _DEBUG
14
15// ################################################################################################
16 10
17void push_registry_subtable_mode(lua_State* L, UniqueKey key_, const char* mode_); 11void push_registry_subtable_mode(lua_State* L, UniqueKey key_, const char* mode_);
18void push_registry_subtable(lua_State* L, UniqueKey key_); 12void push_registry_subtable(lua_State* L, UniqueKey key_);
@@ -31,12 +25,13 @@ enum class InterCopyResult
31 Error 25 Error
32}; 26};
33 27
34// ################################################################################################ 28// #################################################################################################
35 29
36using CacheIndex = Unique<int>; 30using CacheIndex = Unique<int>;
37using SourceIndex = Unique<int>; 31using SourceIndex = Unique<int>;
38struct InterCopyContext 32class InterCopyContext
39{ 33{
34 public:
40 35
41 Universe* const U; 36 Universe* const U;
42 Dest const L2; 37 Dest const L2;
@@ -47,35 +42,50 @@ struct InterCopyContext
47 LookupMode const mode; 42 LookupMode const mode;
48 char const* name; // that one can change when we reuse the context 43 char const* name; // that one can change when we reuse the context
49 44
50 [[nodiscard]] bool inter_copy_one() const;
51
52 private: 45 private:
53 46
54 [[nodiscard]] bool inter_copy_userdata() const; 47 // for use in copy_cached_func
55 [[nodiscard]] bool inter_copy_function() const;
56 [[nodiscard]] bool inter_copy_table() const;
57 [[nodiscard]] bool copyclone() const;
58 [[nodiscard]] bool copydeep() const;
59 [[nodiscard]] bool push_cached_metatable() const;
60 void copy_func() const; 48 void copy_func() const;
49 void lookup_native_func() const;
50
51 // for use in inter_copy_function
61 void copy_cached_func() const; 52 void copy_cached_func() const;
53 [[nodiscard]] bool lookup_table() const;
54
55 // for use in inter_copy_table
62 void inter_copy_keyvaluepair() const; 56 void inter_copy_keyvaluepair() const;
57 [[nodiscard]] bool push_cached_metatable() const;
58
59 // for use in inter_copy_userdata
60 [[nodiscard]] bool copyclone() const;
61 [[nodiscard]] bool copydeep() const;
62
63 // copying a single Lua stack item
64 [[nodiscard]] bool inter_copy_boolean() const;
65 [[nodiscard]] bool inter_copy_function() const;
66 [[nodiscard]] bool inter_copy_lightuserdata() const;
67 [[nodiscard]] bool inter_copy_nil() const;
68 [[nodiscard]] bool inter_copy_number() const;
69 [[nodiscard]] bool inter_copy_string() const;
70 [[nodiscard]] bool inter_copy_table() const;
71 [[nodiscard]] bool inter_copy_userdata() const;
63 72
64 public: 73 public:
65 74
75 [[nodiscard]] bool inter_copy_one() const;
66 [[nodiscard]] InterCopyResult inter_copy_package() const; 76 [[nodiscard]] InterCopyResult inter_copy_package() const;
67 [[nodiscard]] InterCopyResult inter_copy(int n_) const; 77 [[nodiscard]] InterCopyResult inter_copy(int n_) const;
68 [[nodiscard]] InterCopyResult inter_move(int n_) const; 78 [[nodiscard]] InterCopyResult inter_move(int n_) const;
69}; 79};
70 80
71// ################################################################################################ 81// #################################################################################################
72 82
73[[nodiscard]] int luaG_nameof(lua_State* L); 83[[nodiscard]] int luaG_nameof(lua_State* L);
74 84
75void populate_func_lookup_table(lua_State* L, int _i, char const* _name); 85void populate_func_lookup_table(lua_State* L, int _i, char const* _name);
76void initialize_allocator_function(Universe* U, lua_State* L); 86void initialize_allocator_function(Universe* U, lua_State* L);
77 87
78// ################################################################################################ 88// #################################################################################################
79 89
80// crc64/we of string "CONFIG_REGKEY" generated at http://www.nitrxgen.net/hashgen/ 90// crc64/we of string "CONFIG_REGKEY" generated at http://www.nitrxgen.net/hashgen/
81static constexpr UniqueKey CONFIG_REGKEY{ 0x31cd24894eae8624ull }; // registry key to access the configuration 91static constexpr UniqueKey CONFIG_REGKEY{ 0x31cd24894eae8624ull }; // registry key to access the configuration