From 2c0000d5169cacf950d06637ada1a371cf382896 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Tue, 8 Feb 2022 10:39:48 +0100 Subject: __lanesclone is now called only once with 3 parameters dest, source, size -> BREAKS CUSTOM DEEP USERDATA API --- docs/index.html | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'docs') diff --git a/docs/index.html b/docs/index.html index 290383e..0e1a30b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -70,7 +70,7 @@

- This document was revised on 8-Feb-22, and applies to version 3.15.2. + This document was revised on 8-Feb-22, and applies to version 3.16.0.

@@ -1550,27 +1550,20 @@ events to a common Linda, but... :).

Clonable full userdata in your own apps

Starting with version 3.13.0, a new way of passing full userdata across lanes uses a new __lanesclone metamethod. - When a deep userdata is cloned, Lanes calls __lanesclone twice, in the context of the source lane.
- The first call receives the original as light userdata, as in ud:__lanesclone(), and should return the amount of memory used to create the cloned full userdata.
- The second call receives the clone and original as light userdata, as in clone:__lanesclone(original), and should perform the actual cloning.
- A typical implementation would look like: + When a deep userdata is cloned, Lanes calls __lanesclone once, in the context of the source lane.
+ The call receives the clone and original as light userdata, plus the actual userdata size, as in clone:__lanesclone(original,size), and should perform the actual cloning.
+ A typical implementation would look like (BEWARE, THIS CHANGED WITH VERSION 3.16.0):
 static int clonable_lanesclone( lua_State* L)
 {
 	switch( lua_gettop( L))
 	{
-		case 1: // original:__lanesclone()
-		{
-			// the original (as light userdata), in case you need it to compute the size of the clone
-			struct s_MyClonableUserdata* self = lua_touserdata( L, 1);
-			lua_pushinteger( L, sizeof( struct s_MyClonableUserdata));
-		}
-		return 1;
-
-		case 2: // clone:__lanesclone(original)
+		case 3:
 		{
 			struct s_MyClonableUserdata* self = lua_touserdata( L, 1);
 			struct s_MyClonableUserdata* from = lua_touserdata( L, 2);
+			size_t len = lua_tointeger( L, 3);
+			assert( len == sizeof(struct s_MyClonableUserdata));
 			*self = *from;
 		}
 		return 0;
@@ -1736,9 +1729,7 @@ int luaD_new_clonable( lua_State* L)
 

Change log

- v3.14.0: lane:cancel() rework: opt.cancelstep is gone, hook is installed by lane:cancel() if requested. - - For older stuff see CHANGES. + See CHANGES.

@@ -1754,5 +1745,4 @@ int luaD_new_clonable( lua_State* L)

- -
\ No newline at end of file + \ No newline at end of file -- cgit v1.2.3-55-g6feb