diff options
author | Benoit Germain <bnt.germain@gmail.com> | 2022-02-08 10:39:48 +0100 |
---|---|---|
committer | Benoit Germain <bnt.germain@gmail.com> | 2022-02-08 10:39:48 +0100 |
commit | 92cc9c500f195c9f6b31aa1e62cf7fd63e886dba (patch) | |
tree | 0d7f483a605ed7ef4637daf5b3cfb78c1dc8dfb8 | |
parent | 75d9181dc86d55753d832ab986fcb48ea157f43f (diff) | |
download | lanes-92cc9c500f195c9f6b31aa1e62cf7fd63e886dba.tar.gz lanes-92cc9c500f195c9f6b31aa1e62cf7fd63e886dba.tar.bz2 lanes-92cc9c500f195c9f6b31aa1e62cf7fd63e886dba.zip |
__lanesclone is now called only once with 3 parameters dest, source, size -> BREAKS CUSTOM DEEP USERDATA API
-rw-r--r-- | index.html | 28 |
1 files changed, 9 insertions, 19 deletions
@@ -70,7 +70,7 @@ | |||
70 | </p> | 70 | </p> |
71 | 71 | ||
72 | <p> | 72 | <p> |
73 | This document was revised on 8-Feb-22, and applies to version <tt>3.15.2</tt>. | 73 | This document was revised on 8-Feb-22, and applies to version <tt>3.16.0</tt>. |
74 | </p> | 74 | </p> |
75 | </font> | 75 | </font> |
76 | </center> | 76 | </center> |
@@ -1550,27 +1550,20 @@ events to a common Linda, but... :).</font> | |||
1550 | <h3 id="clonable_userdata">Clonable full userdata in your own apps</h3> | 1550 | <h3 id="clonable_userdata">Clonable full userdata in your own apps</h3> |
1551 | <p> | 1551 | <p> |
1552 | Starting with version 3.13.0, a new way of passing full userdata across lanes uses a new <tt>__lanesclone</tt> metamethod. | 1552 | Starting with version 3.13.0, a new way of passing full userdata across lanes uses a new <tt>__lanesclone</tt> metamethod. |
1553 | When a deep userdata is cloned, Lanes calls <tt>__lanesclone</tt> twice, in the context of the source lane.</br> | 1553 | When a deep userdata is cloned, Lanes calls <tt>__lanesclone</tt> once, in the context of the source lane.</br> |
1554 | The first call receives the original as light userdata, as in <tt>ud:__lanesclone()</tt>, and should return the amount of memory used to create the cloned full userdata.</br> | 1554 | The call receives the clone and original as light userdata, plus the actual userdata size, as in <tt>clone:__lanesclone(original,size)</tt>, and should perform the actual cloning.</br> |
1555 | The second call receives the clone and original as light userdata, as in <tt>clone:__lanesclone(original)</tt>, and should perform the actual cloning.</br> | 1555 | A typical implementation would look like (BEWARE, THIS CHANGED WITH VERSION 3.16.0): |
1556 | A typical implementation would look like: | ||
1557 | <table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%"><tr><td><pre> | 1556 | <table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%"><tr><td><pre> |
1558 | static int clonable_lanesclone( lua_State* L) | 1557 | static int clonable_lanesclone( lua_State* L) |
1559 | { | 1558 | { |
1560 | switch( lua_gettop( L)) | 1559 | switch( lua_gettop( L)) |
1561 | { | 1560 | { |
1562 | case 1: // original:__lanesclone() | 1561 | case 3: |
1563 | { | ||
1564 | // the original (as light userdata), in case you need it to compute the size of the clone | ||
1565 | struct s_MyClonableUserdata* self = lua_touserdata( L, 1); | ||
1566 | lua_pushinteger( L, sizeof( struct s_MyClonableUserdata)); | ||
1567 | } | ||
1568 | return 1; | ||
1569 | |||
1570 | case 2: // clone:__lanesclone(original) | ||
1571 | { | 1562 | { |
1572 | struct s_MyClonableUserdata* self = lua_touserdata( L, 1); | 1563 | struct s_MyClonableUserdata* self = lua_touserdata( L, 1); |
1573 | struct s_MyClonableUserdata* from = lua_touserdata( L, 2); | 1564 | struct s_MyClonableUserdata* from = lua_touserdata( L, 2); |
1565 | size_t len = lua_tointeger( L, 3); | ||
1566 | assert( len == sizeof(struct s_MyClonableUserdata)); | ||
1574 | *self = *from; | 1567 | *self = *from; |
1575 | } | 1568 | } |
1576 | return 0; | 1569 | return 0; |
@@ -1736,9 +1729,7 @@ int luaD_new_clonable( lua_State* L) | |||
1736 | <h2 id="changes">Change log</h2> | 1729 | <h2 id="changes">Change log</h2> |
1737 | 1730 | ||
1738 | <p> | 1731 | <p> |
1739 | v3.14.0: lane:cancel() rework: opt.cancelstep is gone, hook is installed by lane:cancel() if requested. | 1732 | See CHANGES. |
1740 | |||
1741 | For older stuff see CHANGES. | ||
1742 | </p> | 1733 | </p> |
1743 | 1734 | ||
1744 | <!-- footnotes +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 1735 | <!-- footnotes +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
@@ -1754,5 +1745,4 @@ int luaD_new_clonable( lua_State* L) | |||
1754 | </p> | 1745 | </p> |
1755 | 1746 | ||
1756 | </body> | 1747 | </body> |
1757 | </html> | 1748 | </html> \ No newline at end of file |
1758 | </pre></pre></pre></pre></pre></pre></pre> \ No newline at end of file | ||