aboutsummaryrefslogtreecommitdiff
path: root/deep_userdata_example
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2025-07-04 13:50:53 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2025-07-04 13:50:53 +0200
commit042055968ab0c48faec607889814e38c50c09efa (patch)
tree4ec067a03ffcb720d8bf38968d5f84ccec8230d0 /deep_userdata_example
parent963afcbb3d9dac47b84552ed11e53a0641ad924d (diff)
downloadlanes-042055968ab0c48faec607889814e38c50c09efa.tar.gz
lanes-042055968ab0c48faec607889814e38c50c09efa.tar.bz2
lanes-042055968ab0c48faec607889814e38c50c09efa.zip
Changed lua wrapper prefixes from luaG_ to luaW_ (w as in wrapper!)
Diffstat (limited to 'deep_userdata_example')
-rw-r--r--deep_userdata_example/deep_userdata_example.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/deep_userdata_example/deep_userdata_example.cpp b/deep_userdata_example/deep_userdata_example.cpp
index 075cfbe..e87c48f 100644
--- a/deep_userdata_example/deep_userdata_example.cpp
+++ b/deep_userdata_example/deep_userdata_example.cpp
@@ -25,7 +25,7 @@ class MyDeepFactory final : public DeepFactory
25 25
26// ################################################################################################# 26// #################################################################################################
27 27
28// a lanes-deep userdata. needs DeepPrelude and luaG_newdeepuserdata from Lanes code. 28// a lanes-deep userdata. needs DeepPrelude and luaW_newdeepuserdata from Lanes code.
29struct MyDeepUserdata : public DeepPrelude // Deep userdata MUST start with a DeepPrelude 29struct MyDeepUserdata : public DeepPrelude // Deep userdata MUST start with a DeepPrelude
30{ 30{
31 std::atomic<int> inUse{}; 31 std::atomic<int> inUse{};
@@ -82,7 +82,7 @@ static int deep_tostring(lua_State* const L_)
82{ 82{
83 MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L_, StackIndex{ 1 })) }; 83 MyDeepUserdata* const _self{ static_cast<MyDeepUserdata*>(MyDeepFactory::Instance.toDeep(L_, StackIndex{ 1 })) };
84 _self->inUse.fetch_add(1, std::memory_order_seq_cst); 84 _self->inUse.fetch_add(1, std::memory_order_seq_cst);
85 luaG_pushstring(L_, "%p:deep(%d)", _self, _self->val); 85 luaW_pushstring(L_, "%p:deep(%d)", _self, _self->val);
86 _self->inUse.fetch_sub(1, std::memory_order_seq_cst); 86 _self->inUse.fetch_sub(1, std::memory_order_seq_cst);
87 return 1; 87 return 1;
88} 88}
@@ -241,7 +241,7 @@ static int clonable_getuv(lua_State* const L_)
241static int clonable_tostring(lua_State* const L_) 241static int clonable_tostring(lua_State* const L_)
242{ 242{
243 MyClonableUserdata* _self = static_cast<MyClonableUserdata*>(lua_touserdata(L_, 1)); 243 MyClonableUserdata* _self = static_cast<MyClonableUserdata*>(lua_touserdata(L_, 1));
244 luaG_pushstring(L_, "%p:clonable(%d)", lua_topointer(L_, 1), _self->val); 244 luaW_pushstring(L_, "%p:clonable(%d)", lua_topointer(L_, 1), _self->val);
245 return 1; 245 return 1;
246} 246}
247 247
@@ -299,7 +299,7 @@ int luaD_new_clonable(lua_State* L)
299{ 299{
300 UserValueCount const _nuv{ static_cast<int>(luaL_optinteger(L, 1, 1)) }; 300 UserValueCount const _nuv{ static_cast<int>(luaL_optinteger(L, 1, 1)) };
301 lua_newuserdatauv(L, sizeof(MyClonableUserdata), _nuv); 301 lua_newuserdatauv(L, sizeof(MyClonableUserdata), _nuv);
302 luaG_setmetatable(L, "clonable"); 302 luaW_setmetatable(L, "clonable");
303 return 1; 303 return 1;
304} 304}
305 305
@@ -317,12 +317,12 @@ static luaL_Reg const deep_module[] = {
317 317
318LANES_API int luaopen_deep_userdata_example(lua_State* L) 318LANES_API int luaopen_deep_userdata_example(lua_State* L)
319{ 319{
320 luaG_newlib<std::size(deep_module)>(L, deep_module); // M 320 luaW_newlib<std::size(deep_module)>(L, deep_module); // M
321 321
322 // preregister the metatables for the types we can instantiate so that Lanes can know about them 322 // preregister the metatables for the types we can instantiate so that Lanes can know about them
323 if (luaL_newmetatable(L, "clonable")) // M mt 323 if (luaL_newmetatable(L, "clonable")) // M mt
324 { 324 {
325 luaG_registerlibfuncs(L, clonable_mt); 325 luaW_registerlibfuncs(L, clonable_mt);
326 lua_pushvalue(L, -1); // M mt mt 326 lua_pushvalue(L, -1); // M mt mt
327 lua_setfield(L, -2, "__index"); // M mt 327 lua_setfield(L, -2, "__index"); // M mt
328 } 328 }
@@ -330,7 +330,7 @@ LANES_API int luaopen_deep_userdata_example(lua_State* L)
330 330
331 if (luaL_newmetatable(L, "deep")) // mt 331 if (luaL_newmetatable(L, "deep")) // mt
332 { 332 {
333 luaG_registerlibfuncs(L, deep_mt); 333 luaW_registerlibfuncs(L, deep_mt);
334 lua_pushvalue(L, -1); // mt mt 334 lua_pushvalue(L, -1); // mt mt
335 lua_setfield(L, -2, "__index"); // mt 335 lua_setfield(L, -2, "__index"); // mt
336 } 336 }