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 | |
| 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')
| -rw-r--r-- | deep_test/deep_test.c | 5 | ||||
| -rw-r--r-- | deep_test/deep_test.vcxproj | 3 | ||||
| -rw-r--r-- | deep_test/deep_test.vcxproj.filters | 6 | ||||
| -rw-r--r-- | deep_test/deep_test.vcxproj.user | 2 | ||||
| -rw-r--r-- | deep_test/deeptest.lua | 10 |
5 files changed, 23 insertions, 3 deletions
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_) | |||
| 126 | 126 | ||
| 127 | int luaD_new_deep( lua_State* L) | 127 | int luaD_new_deep( lua_State* L) |
| 128 | { | 128 | { |
| 129 | return luaG_newdeepuserdata( L, deep_test_id); | 129 | int nuv = (int) luaL_optinteger( L, 1, 0); |
| 130 | // no additional parameter to luaG_newdeepuserdata! | ||
| 131 | lua_settop( L, 0); | ||
| 132 | return luaG_newdeepuserdata( L, deep_test_id, nuv); | ||
| 130 | } | 133 | } |
| 131 | 134 | ||
| 132 | // ################################################################################################ | 135 | // ################################################################################################ |
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 @@ | |||
| 181 | <ConformanceMode>true</ConformanceMode> | 181 | <ConformanceMode>true</ConformanceMode> |
| 182 | <AdditionalIncludeDirectories>$(SolutionDir)Lanes\lanes\src;$(SolutionDir)..\lualib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | 182 | <AdditionalIncludeDirectories>$(SolutionDir)Lanes\lanes\src;$(SolutionDir)..\lualib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
| 183 | <ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName> | 183 | <ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName> |
| 184 | <PreprocessorDefinitions>_WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
| 184 | </ClCompile> | 185 | </ClCompile> |
| 185 | <PostBuildEvent> | 186 | <PostBuildEvent> |
| 186 | <Command>xcopy /R /F /Y /I "$(TargetPath)" $(SolutionDir)..\framework\</Command> | 187 | <Command>xcopy /R /F /Y /I "$(TargetPath)" $(SolutionDir)..\framework\</Command> |
| @@ -230,12 +231,14 @@ | |||
| 230 | <ItemGroup> | 231 | <ItemGroup> |
| 231 | <ClCompile Include="..\src\compat.c" /> | 232 | <ClCompile Include="..\src\compat.c" /> |
| 232 | <ClCompile Include="..\src\deep.c" /> | 233 | <ClCompile Include="..\src\deep.c" /> |
| 234 | <ClCompile Include="..\src\tools.c" /> | ||
| 233 | <ClCompile Include="..\src\universe.c" /> | 235 | <ClCompile Include="..\src\universe.c" /> |
| 234 | <ClCompile Include="deep_test.c" /> | 236 | <ClCompile Include="deep_test.c" /> |
| 235 | </ItemGroup> | 237 | </ItemGroup> |
| 236 | <ItemGroup> | 238 | <ItemGroup> |
| 237 | <ClInclude Include="..\src\compat.h" /> | 239 | <ClInclude Include="..\src\compat.h" /> |
| 238 | <ClInclude Include="..\src\deep.h" /> | 240 | <ClInclude Include="..\src\deep.h" /> |
| 241 | <ClInclude Include="..\src\tools.h" /> | ||
| 239 | <ClInclude Include="..\src\universe.h" /> | 242 | <ClInclude Include="..\src\universe.h" /> |
| 240 | </ItemGroup> | 243 | </ItemGroup> |
| 241 | <ItemGroup> | 244 | <ItemGroup> |
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 @@ | |||
| 27 | <ClCompile Include="..\src\compat.c"> | 27 | <ClCompile Include="..\src\compat.c"> |
| 28 | <Filter>Lanes</Filter> | 28 | <Filter>Lanes</Filter> |
| 29 | </ClCompile> | 29 | </ClCompile> |
| 30 | <ClCompile Include="..\src\tools.c"> | ||
| 31 | <Filter>Lanes</Filter> | ||
| 32 | </ClCompile> | ||
| 30 | </ItemGroup> | 33 | </ItemGroup> |
| 31 | <ItemGroup> | 34 | <ItemGroup> |
| 32 | <ClInclude Include="..\src\deep.h"> | 35 | <ClInclude Include="..\src\deep.h"> |
| @@ -38,6 +41,9 @@ | |||
| 38 | <ClInclude Include="..\src\compat.h"> | 41 | <ClInclude Include="..\src\compat.h"> |
| 39 | <Filter>Lanes</Filter> | 42 | <Filter>Lanes</Filter> |
| 40 | </ClInclude> | 43 | </ClInclude> |
| 44 | <ClInclude Include="..\src\tools.h"> | ||
| 45 | <Filter>Lanes</Filter> | ||
| 46 | </ClInclude> | ||
| 41 | </ItemGroup> | 47 | </ItemGroup> |
| 42 | <ItemGroup> | 48 | <ItemGroup> |
| 43 | <None Include="deeptest.lua"> | 49 | <None Include="deeptest.lua"> |
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 @@ | |||
| 3 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.3|x64'"> | 3 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.3|x64'"> |
| 4 | <LocalDebuggerCommand>D:\Boulot\anubis\Lua\framework\lua53.exe</LocalDebuggerCommand> | 4 | <LocalDebuggerCommand>D:\Boulot\anubis\Lua\framework\lua53.exe</LocalDebuggerCommand> |
| 5 | <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> | 5 | <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> |
| 6 | <LocalDebuggerCommandArguments>-i -- deeptest.lua</LocalDebuggerCommandArguments> | 6 | <LocalDebuggerCommandArguments>-i</LocalDebuggerCommandArguments> |
| 7 | <LocalDebuggerWorkingDirectory>D:\Boulot\anubis\Lua\bindings\Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> | 7 | <LocalDebuggerWorkingDirectory>D:\Boulot\anubis\Lua\bindings\Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> |
| 8 | </PropertyGroup> | 8 | </PropertyGroup> |
| 9 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.4|x64'"> | 9 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.4|x64'"> |
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 |
