From 050e14dd7fa04e2262ae6b1cc984d76c4149b664 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Thu, 24 Jun 2021 17:47:20 +0200 Subject: correctly transfer the uservalue of a deep userdata --- deep_test/deep_test.c | 5 ++++- deep_test/deep_test.vcxproj | 3 +++ deep_test/deep_test.vcxproj.filters | 6 ++++++ deep_test/deep_test.vcxproj.user | 2 +- deep_test/deeptest.lua | 10 +++++++++- 5 files changed, 23 insertions(+), 3 deletions(-) (limited to 'deep_test') diff --git a/deep_test/deep_test.c b/deep_test/deep_test.c index c400cac..dabc84d 100644 --- a/deep_test/deep_test.c +++ b/deep_test/deep_test.c @@ -126,7 +126,10 @@ static void* deep_test_id( lua_State* L, enum eDeepOp op_) int luaD_new_deep( lua_State* L) { - return luaG_newdeepuserdata( L, deep_test_id); + int nuv = (int) luaL_optinteger( L, 1, 0); + // no additional parameter to luaG_newdeepuserdata! + lua_settop( L, 0); + return luaG_newdeepuserdata( L, deep_test_id, nuv); } // ################################################################################################ diff --git a/deep_test/deep_test.vcxproj b/deep_test/deep_test.vcxproj index d94b855..67d3afd 100644 --- a/deep_test/deep_test.vcxproj +++ b/deep_test/deep_test.vcxproj @@ -181,6 +181,7 @@ true $(SolutionDir)Lanes\lanes\src;$(SolutionDir)..\lualib;%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb + _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) xcopy /R /F /Y /I "$(TargetPath)" $(SolutionDir)..\framework\ @@ -230,12 +231,14 @@ + + diff --git a/deep_test/deep_test.vcxproj.filters b/deep_test/deep_test.vcxproj.filters index 93f6148..be47da9 100644 --- a/deep_test/deep_test.vcxproj.filters +++ b/deep_test/deep_test.vcxproj.filters @@ -27,6 +27,9 @@ Lanes + + Lanes + @@ -38,6 +41,9 @@ Lanes + + Lanes + diff --git a/deep_test/deep_test.vcxproj.user b/deep_test/deep_test.vcxproj.user index f6a2db8..70871df 100644 --- a/deep_test/deep_test.vcxproj.user +++ b/deep_test/deep_test.vcxproj.user @@ -3,7 +3,7 @@ D:\Boulot\anubis\Lua\framework\lua53.exe WindowsLocalDebugger - -i -- deeptest.lua + -i D:\Boulot\anubis\Lua\bindings\Lanes\lanes\deep_test\ 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 local performTest = function( obj_) -- setup the userdata with some value and a uservalue obj_:set( 666) - obj_:setuv( 1, makeUserValue( obj_)) + -- lua 5.1->5.2 support a single table uservalue + -- lua 5.3 supports an arbitrary type uservalue + obj_:setuv( 1, makeUserValue( obj_)) + -- lua 5.4 supports multiple uservalues of arbitrary types + -- obj_:setuv( 2, "ENDUV") -- read back the contents of the object print( "immediate:", obj_, obj_:getuv( 1)) -- send the object in a linda, get it back out, read the contents l:set( "key", obj_) + -- 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) + -- when obj_ is a clonable userdata, we get a different clone everytime we cross a linda or lane barrier local out = l:get( "key") print( "out of linda:", out, out:getuv( 1)) @@ -46,6 +52,8 @@ local performTest = function( obj_) end ) h = g( obj_) + -- 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) + -- when obj_ is a clonable userdata, we get a different clone everytime we cross a linda or lane barrier local from_lane = h[1] print( "from lane:", from_lane, from_lane:getuv( 1)) end -- cgit v1.2.3-55-g6feb