From af3161e5265b56a3d33a1ed45597f85c34806928 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Tue, 11 Mar 2025 11:55:01 +0100 Subject: Sample module deep test renamed deep_userdata_example --- docs/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/index.html b/docs/index.html index 49cb592..d7717dc 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1832,7 +1832,7 @@ static int clonable_lanesclone(lua_State* L) NOTE: In the event the source userdata has uservalues, it is not necessary to create them for the clone, Lanes will handle their cloning.
Of course, more complex objects may require smarter cloning behavior than a simple memcpy. Also, the module initialisation code should make each metatable accessible from the module table itself as in:
-int luaopen_deep_test(lua_State* L)
+int luaopen_deep_userdata_example(lua_State* L)
 {
 	luaL_newlib(L, deep_module);
 
@@ -1898,7 +1898,7 @@ static MyDeepFactory g_MyDeepFactory;
 			
  • createMetatable(): should build a metatable for the object. Don't cache the metatable yourself, Lanes takes care of it (createMetatable should only be invoked once per state). Just push the metatable on the stack.
  • moduleName(): requests the name of the module that exports the factory, to be returned. It is necessary so that Lanes can require it in any lane state that receives a userdata. This is to prevent crashes in situations where the module could be unloaded while the factory pointer is still held.
  • - Take a look at LindaFactory in lindafactory.cpp or MyDeepFactory in deep_test.cpp. + Take a look at LindaFactory in lindafactory.cpp or MyDeepFactory in deep_userdata_example.cpp.
  • Include "_pch.hpp", "deep.hpp" and either link against Lanes or statically compile compat.cpp deep.cpp into your module if you want to avoid a runtime dependency for users that will use your module without Lanes.
  • Instanciate your userdata using yourFactoryObject.pushDeepUserdata(), instead of the regular lua_newuserdata(). Given a factory, it sets up the support structures and returns a state-specific proxy full userdata for accessing your data. This proxy can also be copied over to other lanes.
  • -- cgit v1.2.3-55-g6feb