diff options
| author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-04-16 18:06:02 +0200 |
|---|---|---|
| committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-04-16 18:06:02 +0200 |
| commit | bbb4f99918d00308b52af3289c29624bfeb0066b (patch) | |
| tree | aebfba19ae4bb2bddc2beaa18f80a64d254b4ae6 /deep_test | |
| parent | d6f5a7795360e3c2a6fc2d424904b6daa1f2accd (diff) | |
| download | lanes-bbb4f99918d00308b52af3289c29624bfeb0066b.tar.gz lanes-bbb4f99918d00308b52af3289c29624bfeb0066b.tar.bz2 lanes-bbb4f99918d00308b52af3289c29624bfeb0066b.zip | |
some dead code elimination and other trifles
Diffstat (limited to 'deep_test')
| -rw-r--r-- | deep_test/deep_test.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/deep_test/deep_test.cpp b/deep_test/deep_test.cpp index b11445b..3a58d81 100644 --- a/deep_test/deep_test.cpp +++ b/deep_test/deep_test.cpp | |||
| @@ -20,7 +20,7 @@ class MyDeepFactory : public DeepFactory | |||
| 20 | 20 | ||
| 21 | static MyDeepFactory g_MyDeepFactory; | 21 | static MyDeepFactory g_MyDeepFactory; |
| 22 | 22 | ||
| 23 | // ################################################################################################ | 23 | // ################################################################################################# |
| 24 | 24 | ||
| 25 | // a lanes-deep userdata. needs DeepPrelude and luaG_newdeepuserdata from Lanes code. | 25 | // a lanes-deep userdata. needs DeepPrelude and luaG_newdeepuserdata from Lanes code. |
| 26 | struct MyDeepUserdata : public DeepPrelude // Deep userdata MUST start with a DeepPrelude | 26 | struct MyDeepUserdata : public DeepPrelude // Deep userdata MUST start with a DeepPrelude |
| @@ -28,7 +28,7 @@ struct MyDeepUserdata : public DeepPrelude // Deep userdata MUST start with a De | |||
| 28 | lua_Integer val{ 0 }; | 28 | lua_Integer val{ 0 }; |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | // ################################################################################################ | 31 | // ################################################################################################# |
| 32 | 32 | ||
| 33 | DeepPrelude* MyDeepFactory::newDeepObjectInternal(lua_State* L) const | 33 | DeepPrelude* MyDeepFactory::newDeepObjectInternal(lua_State* L) const |
| 34 | { | 34 | { |
| @@ -36,7 +36,7 @@ DeepPrelude* MyDeepFactory::newDeepObjectInternal(lua_State* L) const | |||
| 36 | return deep_test; | 36 | return deep_test; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | // ################################################################################################ | 39 | // ################################################################################################# |
| 40 | 40 | ||
| 41 | void MyDeepFactory::deleteDeepObjectInternal(lua_State* L, DeepPrelude* o_) const | 41 | void MyDeepFactory::deleteDeepObjectInternal(lua_State* L, DeepPrelude* o_) const |
| 42 | { | 42 | { |
| @@ -44,7 +44,7 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* L, DeepPrelude* o_) cons | |||
| 44 | delete deep_test; | 44 | delete deep_test; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | // ################################################################################################ | 47 | // ################################################################################################# |
| 48 | 48 | ||
| 49 | [[nodiscard]] static int deep_set(lua_State* L) | 49 | [[nodiscard]] static int deep_set(lua_State* L) |
| 50 | { | 50 | { |
| @@ -54,7 +54,7 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* L, DeepPrelude* o_) cons | |||
| 54 | return 0; | 54 | return 0; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | // ################################################################################################ | 57 | // ################################################################################################# |
| 58 | 58 | ||
| 59 | [[nodiscard]] static int deep_setuv(lua_State* L) | 59 | [[nodiscard]] static int deep_setuv(lua_State* L) |
| 60 | { | 60 | { |
| @@ -65,7 +65,7 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* L, DeepPrelude* o_) cons | |||
| 65 | return 1; | 65 | return 1; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | // ################################################################################################ | 68 | // ################################################################################################# |
| 69 | 69 | ||
| 70 | // won't actually do anything as deep userdata don't have uservalue slots | 70 | // won't actually do anything as deep userdata don't have uservalue slots |
| 71 | [[nodiscard]] static int deep_getuv(lua_State* L) | 71 | [[nodiscard]] static int deep_getuv(lua_State* L) |
| @@ -76,7 +76,7 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* L, DeepPrelude* o_) cons | |||
| 76 | return 1; | 76 | return 1; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | // ################################################################################################ | 79 | // ################################################################################################# |
| 80 | 80 | ||
| 81 | [[nodiscard]] static int deep_tostring(lua_State* L) | 81 | [[nodiscard]] static int deep_tostring(lua_State* L) |
| 82 | { | 82 | { |
| @@ -85,7 +85,7 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* L, DeepPrelude* o_) cons | |||
| 85 | return 1; | 85 | return 1; |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | // ################################################################################################ | 88 | // ################################################################################################# |
| 89 | 89 | ||
| 90 | [[nodiscard]] static int deep_gc(lua_State* L) | 90 | [[nodiscard]] static int deep_gc(lua_State* L) |
| 91 | { | 91 | { |
| @@ -93,7 +93,7 @@ void MyDeepFactory::deleteDeepObjectInternal(lua_State* L, DeepPrelude* o_) cons | |||
| 93 | return 0; | 93 | return 0; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | // ################################################################################################ | 96 | // ################################################################################################# |
| 97 | 97 | ||
| 98 | static luaL_Reg const deep_mt[] = | 98 | static luaL_Reg const deep_mt[] = |
| 99 | { | 99 | { |
| @@ -105,7 +105,7 @@ static luaL_Reg const deep_mt[] = | |||
| 105 | { nullptr, nullptr } | 105 | { nullptr, nullptr } |
| 106 | }; | 106 | }; |
| 107 | 107 | ||
| 108 | // ################################################################################################ | 108 | // ################################################################################################# |
| 109 | 109 | ||
| 110 | int luaD_new_deep( lua_State* L) | 110 | int luaD_new_deep( lua_State* L) |
| 111 | { | 111 | { |
| @@ -114,15 +114,15 @@ int luaD_new_deep( lua_State* L) | |||
| 114 | return g_MyDeepFactory.pushDeepUserdata(Dest{ L }, nuv); | 114 | return g_MyDeepFactory.pushDeepUserdata(Dest{ L }, nuv); |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | // ################################################################################################ | 117 | // ################################################################################################# |
| 118 | // ################################################################################################ | 118 | // ################################################################################################# |
| 119 | 119 | ||
| 120 | struct MyClonableUserdata | 120 | struct MyClonableUserdata |
| 121 | { | 121 | { |
| 122 | lua_Integer val; | 122 | lua_Integer val; |
| 123 | }; | 123 | }; |
| 124 | 124 | ||
| 125 | // ################################################################################################ | 125 | // ################################################################################################# |
| 126 | 126 | ||
| 127 | [[nodiscard]] static int clonable_set(lua_State* L) | 127 | [[nodiscard]] static int clonable_set(lua_State* L) |
| 128 | { | 128 | { |
| @@ -132,7 +132,7 @@ struct MyClonableUserdata | |||
| 132 | return 0; | 132 | return 0; |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | // ################################################################################################ | 135 | // ################################################################################################# |
| 136 | 136 | ||
| 137 | [[nodiscard]] static int clonable_setuv(lua_State* L) | 137 | [[nodiscard]] static int clonable_setuv(lua_State* L) |
| 138 | { | 138 | { |
| @@ -143,7 +143,7 @@ struct MyClonableUserdata | |||
| 143 | return 1; | 143 | return 1; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | // ################################################################################################ | 146 | // ################################################################################################# |
| 147 | 147 | ||
| 148 | [[nodiscard]] static int clonable_getuv(lua_State* L) | 148 | [[nodiscard]] static int clonable_getuv(lua_State* L) |
| 149 | { | 149 | { |
| @@ -153,7 +153,7 @@ struct MyClonableUserdata | |||
| 153 | return 1; | 153 | return 1; |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | // ################################################################################################ | 156 | // ################################################################################################# |
| 157 | 157 | ||
| 158 | [[nodiscard]] static int clonable_tostring(lua_State* L) | 158 | [[nodiscard]] static int clonable_tostring(lua_State* L) |
| 159 | { | 159 | { |
| @@ -162,7 +162,7 @@ struct MyClonableUserdata | |||
| 162 | return 1; | 162 | return 1; |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | // ################################################################################################ | 165 | // ################################################################################################# |
| 166 | 166 | ||
| 167 | [[nodiscard]] static int clonable_gc(lua_State* L) | 167 | [[nodiscard]] static int clonable_gc(lua_State* L) |
| 168 | { | 168 | { |
| @@ -170,7 +170,7 @@ struct MyClonableUserdata | |||
| 170 | return 0; | 170 | return 0; |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | // ################################################################################################ | 173 | // ################################################################################################# |
| 174 | 174 | ||
| 175 | // this is all we need to make a userdata lanes-clonable. no dependency on Lanes code. | 175 | // this is all we need to make a userdata lanes-clonable. no dependency on Lanes code. |
| 176 | [[nodiscard]] static int clonable_lanesclone(lua_State* L) | 176 | [[nodiscard]] static int clonable_lanesclone(lua_State* L) |
| @@ -193,7 +193,7 @@ struct MyClonableUserdata | |||
| 193 | return 0; | 193 | return 0; |
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | // ################################################################################################ | 196 | // ################################################################################################# |
| 197 | 197 | ||
| 198 | static luaL_Reg const clonable_mt[] = | 198 | static luaL_Reg const clonable_mt[] = |
| 199 | { | 199 | { |
| @@ -206,7 +206,7 @@ static luaL_Reg const clonable_mt[] = | |||
| 206 | { nullptr, nullptr } | 206 | { nullptr, nullptr } |
| 207 | }; | 207 | }; |
| 208 | 208 | ||
| 209 | // ################################################################################################ | 209 | // ################################################################################################# |
| 210 | 210 | ||
| 211 | int luaD_new_clonable( lua_State* L) | 211 | int luaD_new_clonable( lua_State* L) |
| 212 | { | 212 | { |
| @@ -216,8 +216,8 @@ int luaD_new_clonable( lua_State* L) | |||
| 216 | return 1; | 216 | return 1; |
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | // ################################################################################################ | 219 | // ################################################################################################# |
| 220 | // ################################################################################################ | 220 | // ################################################################################################# |
| 221 | 221 | ||
| 222 | static luaL_Reg const deep_module[] = | 222 | static luaL_Reg const deep_module[] = |
| 223 | { | 223 | { |
| @@ -226,14 +226,14 @@ static luaL_Reg const deep_module[] = | |||
| 226 | { nullptr, nullptr } | 226 | { nullptr, nullptr } |
| 227 | }; | 227 | }; |
| 228 | 228 | ||
| 229 | // ################################################################################################ | 229 | // ################################################################################################# |
| 230 | 230 | ||
| 231 | LANES_API int luaopen_deep_test(lua_State* L) | 231 | LANES_API int luaopen_deep_test(lua_State* L) |
| 232 | { | 232 | { |
| 233 | luaL_newlib( L, deep_module); // M | 233 | luaL_newlib( L, deep_module); // M |
| 234 | 234 | ||
| 235 | // preregister the metatables for the types we can instantiate so that Lanes can know about them | 235 | // preregister the metatables for the types we can instantiate so that Lanes can know about them |
| 236 | if( luaL_newmetatable( L, "clonable")) // M mt | 236 | if (luaL_newmetatable( L, "clonable")) // M mt |
| 237 | { | 237 | { |
| 238 | luaL_setfuncs( L, clonable_mt, 0); | 238 | luaL_setfuncs( L, clonable_mt, 0); |
| 239 | lua_pushvalue(L, -1); // M mt mt | 239 | lua_pushvalue(L, -1); // M mt mt |
| @@ -241,7 +241,7 @@ LANES_API int luaopen_deep_test(lua_State* L) | |||
| 241 | } | 241 | } |
| 242 | lua_setfield(L, -2, "__clonableMT"); // M | 242 | lua_setfield(L, -2, "__clonableMT"); // M |
| 243 | 243 | ||
| 244 | if( luaL_newmetatable( L, "deep")) // mt | 244 | if (luaL_newmetatable( L, "deep")) // mt |
| 245 | { | 245 | { |
| 246 | luaL_setfuncs( L, deep_mt, 0); | 246 | luaL_setfuncs( L, deep_mt, 0); |
| 247 | lua_pushvalue(L, -1); // mt mt | 247 | lua_pushvalue(L, -1); // mt mt |
