diff options
author | Benoit Germain <bnt.germain@gmail.com> | 2021-06-24 17:47:20 +0200 |
---|---|---|
committer | Benoit Germain <bnt.germain@gmail.com> | 2021-06-24 17:47:20 +0200 |
commit | 050e14dd7fa04e2262ae6b1cc984d76c4149b664 (patch) | |
tree | 8b7cead727e2b9e545dbbd458ef4009eb099db92 /deep_test/deeptest.lua | |
parent | 4e8242de0c5d8c853201ec49dacf5aa9a5b0f7d3 (diff) | |
download | lanes-050e14dd7fa04e2262ae6b1cc984d76c4149b664.tar.gz lanes-050e14dd7fa04e2262ae6b1cc984d76c4149b664.tar.bz2 lanes-050e14dd7fa04e2262ae6b1cc984d76c4149b664.zip |
correctly transfer the uservalue of a deep userdata
Diffstat (limited to 'deep_test/deeptest.lua')
-rw-r--r-- | deep_test/deeptest.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/deep_test/deeptest.lua b/deep_test/deeptest.lua index b3e523f..92cd372 100644 --- a/deep_test/deeptest.lua +++ b/deep_test/deeptest.lua | |||
@@ -23,13 +23,19 @@ end | |||
23 | local performTest = function( obj_) | 23 | local performTest = function( obj_) |
24 | -- setup the userdata with some value and a uservalue | 24 | -- setup the userdata with some value and a uservalue |
25 | obj_:set( 666) | 25 | obj_:set( 666) |
26 | obj_:setuv( 1, makeUserValue( obj_)) | 26 | -- lua 5.1->5.2 support a single table uservalue |
27 | -- lua 5.3 supports an arbitrary type uservalue | ||
28 | obj_:setuv( 1, makeUserValue( obj_)) | ||
29 | -- lua 5.4 supports multiple uservalues of arbitrary types | ||
30 | -- obj_:setuv( 2, "ENDUV") | ||
27 | 31 | ||
28 | -- read back the contents of the object | 32 | -- read back the contents of the object |
29 | print( "immediate:", obj_, obj_:getuv( 1)) | 33 | print( "immediate:", obj_, obj_:getuv( 1)) |
30 | 34 | ||
31 | -- send the object in a linda, get it back out, read the contents | 35 | -- send the object in a linda, get it back out, read the contents |
32 | l:set( "key", obj_) | 36 | l:set( "key", obj_) |
37 | -- when obj_ is a deep userdata, out is the same userdata as obj_ (not another one pointing on the same deep memory block) because of an internal cache table [deep*] -> proxy) | ||
38 | -- when obj_ is a clonable userdata, we get a different clone everytime we cross a linda or lane barrier | ||
33 | local out = l:get( "key") | 39 | local out = l:get( "key") |
34 | print( "out of linda:", out, out:getuv( 1)) | 40 | print( "out of linda:", out, out:getuv( 1)) |
35 | 41 | ||
@@ -46,6 +52,8 @@ local performTest = function( obj_) | |||
46 | end | 52 | end |
47 | ) | 53 | ) |
48 | h = g( obj_) | 54 | h = g( obj_) |
55 | -- when obj_ is a deep userdata, from_lane is the same userdata as obj_ (not another one pointing on the same deep memory block) because of an internal cache table [deep*] -> proxy) | ||
56 | -- when obj_ is a clonable userdata, we get a different clone everytime we cross a linda or lane barrier | ||
49 | local from_lane = h[1] | 57 | local from_lane = h[1] |
50 | print( "from lane:", from_lane, from_lane:getuv( 1)) | 58 | print( "from lane:", from_lane, from_lane:getuv( 1)) |
51 | end | 59 | end |