aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2025-03-11 11:55:01 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2025-03-11 11:55:01 +0100
commitaf3161e5265b56a3d33a1ed45597f85c34806928 (patch)
tree332101e2a95aebc09f907a73958de923be4b0a4d
parentb1822d8d07f8ee34cef2e7e74391695dd4e1ea81 (diff)
downloadlanes-af3161e5265b56a3d33a1ed45597f85c34806928.tar.gz
lanes-af3161e5265b56a3d33a1ed45597f85c34806928.tar.bz2
lanes-af3161e5265b56a3d33a1ed45597f85c34806928.zip
Sample module deep test renamed deep_userdata_example
-rw-r--r--deep_userdata_example/deep_userdata_example.args.json (renamed from deep_test/deep_test.args.json)0
-rw-r--r--deep_userdata_example/deep_userdata_example.cpp (renamed from deep_test/deep_test.cpp)4
-rw-r--r--deep_userdata_example/deep_userdata_example.vcxproj (renamed from deep_test/deep_test.vcxproj)2
-rw-r--r--deep_userdata_example/deep_userdata_example.vcxproj.filters (renamed from deep_test/deep_test.vcxproj.filters)0
-rw-r--r--deep_userdata_example/deep_userdata_example.vcxproj.user (renamed from deep_test/deep_test.vcxproj.user)40
-rw-r--r--deep_userdata_example/deeptest.lua159
-rw-r--r--docs/index.html4
-rw-r--r--unit_tests/deep_tests.cpp16
-rw-r--r--unit_tests/shared.cpp6
9 files changed, 195 insertions, 36 deletions
diff --git a/deep_test/deep_test.args.json b/deep_userdata_example/deep_userdata_example.args.json
index a1654a6..a1654a6 100644
--- a/deep_test/deep_test.args.json
+++ b/deep_userdata_example/deep_userdata_example.args.json
diff --git a/deep_test/deep_test.cpp b/deep_userdata_example/deep_userdata_example.cpp
index cbc33ca..a45cc7f 100644
--- a/deep_test/deep_test.cpp
+++ b/deep_userdata_example/deep_userdata_example.cpp
@@ -19,7 +19,7 @@ class MyDeepFactory final : public DeepFactory
19 [[nodiscard]] 19 [[nodiscard]]
20 DeepPrelude* newDeepObjectInternal(lua_State* const L_) const override; 20 DeepPrelude* newDeepObjectInternal(lua_State* const L_) const override;
21 [[nodiscard]] 21 [[nodiscard]]
22 std::string_view moduleName() const override { return std::string_view{ "deep_test" }; } 22 std::string_view moduleName() const override { return std::string_view{ "deep_userdata_example" }; }
23}; 23};
24/*static*/ MyDeepFactory MyDeepFactory::Instance{}; 24/*static*/ MyDeepFactory MyDeepFactory::Instance{};
25 25
@@ -315,7 +315,7 @@ static luaL_Reg const deep_module[] = {
315 315
316// ################################################################################################# 316// #################################################################################################
317 317
318LANES_API int luaopen_deep_test(lua_State* L) 318LANES_API int luaopen_deep_userdata_example(lua_State* L)
319{ 319{
320 luaG_newlib<std::size(deep_module)>(L, deep_module); // M 320 luaG_newlib<std::size(deep_module)>(L, deep_module); // M
321 321
diff --git a/deep_test/deep_test.vcxproj b/deep_userdata_example/deep_userdata_example.vcxproj
index 78706ed..839e5c8 100644
--- a/deep_test/deep_test.vcxproj
+++ b/deep_userdata_example/deep_userdata_example.vcxproj
@@ -857,7 +857,7 @@
857 <ItemGroup> 857 <ItemGroup>
858 <ClCompile Include="..\src\compat.cpp" /> 858 <ClCompile Include="..\src\compat.cpp" />
859 <ClCompile Include="..\src\deep.cpp" /> 859 <ClCompile Include="..\src\deep.cpp" />
860 <ClCompile Include="deep_test.cpp" /> 860 <ClCompile Include="deep_userdata_example.cpp" />
861 </ItemGroup> 861 </ItemGroup>
862 <ItemGroup> 862 <ItemGroup>
863 <ClInclude Include="..\src\compat.hpp" /> 863 <ClInclude Include="..\src\compat.hpp" />
diff --git a/deep_test/deep_test.vcxproj.filters b/deep_userdata_example/deep_userdata_example.vcxproj.filters
index 1e8f8c1..1e8f8c1 100644
--- a/deep_test/deep_test.vcxproj.filters
+++ b/deep_userdata_example/deep_userdata_example.vcxproj.filters
diff --git a/deep_test/deep_test.vcxproj.user b/deep_userdata_example/deep_userdata_example.vcxproj.user
index e798643..01e9a17 100644
--- a/deep_test/deep_test.vcxproj.user
+++ b/deep_userdata_example/deep_userdata_example.vcxproj.user
@@ -4,116 +4,116 @@
4 <LocalDebuggerCommand>$(SolutionDir)..\Lua53\bin\$(Platform)\Debug\lua53.exe</LocalDebuggerCommand> 4 <LocalDebuggerCommand>$(SolutionDir)..\Lua53\bin\$(Platform)\Debug\lua53.exe</LocalDebuggerCommand>
5 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 5 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
6 <LocalDebuggerCommandArguments>deeptest.lua</LocalDebuggerCommandArguments> 6 <LocalDebuggerCommandArguments>deeptest.lua</LocalDebuggerCommandArguments>
7 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 7 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
8 <RemoteDebuggerCommandArguments>deeptest.lua</RemoteDebuggerCommandArguments> 8 <RemoteDebuggerCommandArguments>deeptest.lua</RemoteDebuggerCommandArguments>
9 </PropertyGroup> 9 </PropertyGroup>
10 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.1|x64'"> 10 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.1|x64'">
11 <LocalDebuggerCommand>$(SolutionDir)..\Lua51\bin\$(Platform)\Debug\lua51.exe</LocalDebuggerCommand> 11 <LocalDebuggerCommand>$(SolutionDir)..\Lua51\bin\$(Platform)\Debug\lua51.exe</LocalDebuggerCommand>
12 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 12 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
13 <LocalDebuggerCommandArguments>-i deeptest.lua</LocalDebuggerCommandArguments> 13 <LocalDebuggerCommandArguments>-i deeptest.lua</LocalDebuggerCommandArguments>
14 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 14 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
15 <RemoteDebuggerCommandArguments>-i deeptest.lua</RemoteDebuggerCommandArguments> 15 <RemoteDebuggerCommandArguments>-i deeptest.lua</RemoteDebuggerCommandArguments>
16 </PropertyGroup> 16 </PropertyGroup>
17 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.2|x64'"> 17 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.2|x64'">
18 <LocalDebuggerCommand>$(SolutionDir)..\Lua52\bin\$(Platform)\Debug\lua52.exe</LocalDebuggerCommand> 18 <LocalDebuggerCommand>$(SolutionDir)..\Lua52\bin\$(Platform)\Debug\lua52.exe</LocalDebuggerCommand>
19 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 19 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
20 <LocalDebuggerCommandArguments>-i deeptest.lua</LocalDebuggerCommandArguments> 20 <LocalDebuggerCommandArguments>-i deeptest.lua</LocalDebuggerCommandArguments>
21 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 21 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
22 <RemoteDebuggerCommandArguments>-i deeptest.lua</RemoteDebuggerCommandArguments> 22 <RemoteDebuggerCommandArguments>-i deeptest.lua</RemoteDebuggerCommandArguments>
23 </PropertyGroup> 23 </PropertyGroup>
24 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug LuaJIT 2.1.0-beta3|x64'"> 24 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug LuaJIT 2.1.0-beta3|x64'">
25 <LocalDebuggerCommand>$(SolutionDir)..\LuaJIT-2.1.0-beta3\bin\$(Platform)\luajit210.exe</LocalDebuggerCommand> 25 <LocalDebuggerCommand>$(SolutionDir)..\LuaJIT-2.1.0-beta3\bin\$(Platform)\luajit210.exe</LocalDebuggerCommand>
26 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 26 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
27 <LocalDebuggerCommandArguments>-i</LocalDebuggerCommandArguments> 27 <LocalDebuggerCommandArguments>-i</LocalDebuggerCommandArguments>
28 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 28 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
29 </PropertyGroup> 29 </PropertyGroup>
30 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug LuaJIT 2.0.5|x64'"> 30 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug LuaJIT 2.0.5|x64'">
31 <LocalDebuggerCommand>$(SolutionDir)..\LuaJIT-2.0.5\bin\$(Platform)\luajit205.exe</LocalDebuggerCommand> 31 <LocalDebuggerCommand>$(SolutionDir)..\LuaJIT-2.0.5\bin\$(Platform)\luajit205.exe</LocalDebuggerCommand>
32 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 32 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
33 <LocalDebuggerCommandArguments>-i</LocalDebuggerCommandArguments> 33 <LocalDebuggerCommandArguments>-i</LocalDebuggerCommandArguments>
34 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 34 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
35 </PropertyGroup> 35 </PropertyGroup>
36 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug LuaJIT GIT|x64'"> 36 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug LuaJIT GIT|x64'">
37 <LocalDebuggerCommand>$(SolutionDir)..\LuaJIT-GIT\bin\$(Platform)\luajitgit.exe</LocalDebuggerCommand> 37 <LocalDebuggerCommand>$(SolutionDir)..\LuaJIT-GIT\bin\$(Platform)\luajitgit.exe</LocalDebuggerCommand>
38 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 38 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
39 <LocalDebuggerCommandArguments>-i</LocalDebuggerCommandArguments> 39 <LocalDebuggerCommandArguments>-i</LocalDebuggerCommandArguments>
40 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 40 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
41 </PropertyGroup> 41 </PropertyGroup>
42 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.4|x64'"> 42 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.4|x64'">
43 <LocalDebuggerCommand>$(SolutionDir)..\framework\lua54.exe</LocalDebuggerCommand> 43 <LocalDebuggerCommand>$(SolutionDir)..\framework\lua54.exe</LocalDebuggerCommand>
44 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 44 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
45 <LocalDebuggerCommandArguments>deeptest.lua</LocalDebuggerCommandArguments> 45 <LocalDebuggerCommandArguments>deeptest.lua</LocalDebuggerCommandArguments>
46 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 46 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
47 <RemoteDebuggerCommandArguments>deeptest.lua</RemoteDebuggerCommandArguments> 47 <RemoteDebuggerCommandArguments>deeptest.lua</RemoteDebuggerCommandArguments>
48 </PropertyGroup> 48 </PropertyGroup>
49 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MoonJIT|x64'"> 49 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MoonJIT|x64'">
50 <LocalDebuggerCommand>$(SolutionDir)..\MoonJIT\bin\$(Platform)\moonjit.exe</LocalDebuggerCommand> 50 <LocalDebuggerCommand>$(SolutionDir)..\MoonJIT\bin\$(Platform)\moonjit.exe</LocalDebuggerCommand>
51 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 51 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
52 <LocalDebuggerCommandArguments>-i deeptest.lua</LocalDebuggerCommandArguments> 52 <LocalDebuggerCommandArguments>-i deeptest.lua</LocalDebuggerCommandArguments>
53 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 53 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
54 </PropertyGroup> 54 </PropertyGroup>
55 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release 5.3|x64'"> 55 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release 5.3|x64'">
56 <LocalDebuggerCommand>$(SolutionDir)..\Lua53\bin\$(Platform)\Release\lua53.exe</LocalDebuggerCommand> 56 <LocalDebuggerCommand>$(SolutionDir)..\Lua53\bin\$(Platform)\Release\lua53.exe</LocalDebuggerCommand>
57 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 57 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
58 <LocalDebuggerCommandArguments>-i -- deeptest.lua</LocalDebuggerCommandArguments> 58 <LocalDebuggerCommandArguments>-i -- deeptest.lua</LocalDebuggerCommandArguments>
59 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 59 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
60 </PropertyGroup> 60 </PropertyGroup>
61 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release 5.4|x64'"> 61 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release 5.4|x64'">
62 <LocalDebuggerCommand>$(SolutionDir)..\framework\lua54.exe</LocalDebuggerCommand> 62 <LocalDebuggerCommand>$(SolutionDir)..\framework\lua54.exe</LocalDebuggerCommand>
63 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 63 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
64 <LocalDebuggerCommandArguments>-i -- deeptest.lua</LocalDebuggerCommandArguments> 64 <LocalDebuggerCommandArguments>-i -- deeptest.lua</LocalDebuggerCommandArguments>
65 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 65 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
66 </PropertyGroup> 66 </PropertyGroup>
67 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug LuaJIT 2.1.0-beta3|Win32'"> 67 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug LuaJIT 2.1.0-beta3|Win32'">
68 <LocalDebuggerCommand>$(SolutionDir)..\LuaJIT-2.1.0-beta3\bin\$(Platform)\luajit210.exe</LocalDebuggerCommand> 68 <LocalDebuggerCommand>$(SolutionDir)..\LuaJIT-2.1.0-beta3\bin\$(Platform)\luajit210.exe</LocalDebuggerCommand>
69 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 69 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
70 <LocalDebuggerCommandArguments>-i</LocalDebuggerCommandArguments> 70 <LocalDebuggerCommandArguments>-i</LocalDebuggerCommandArguments>
71 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 71 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
72 </PropertyGroup> 72 </PropertyGroup>
73 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug LuaJIT 2.0.5|Win32'"> 73 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug LuaJIT 2.0.5|Win32'">
74 <LocalDebuggerCommand>$(SolutionDir)..\LuaJIT-2.0.5\bin\$(Platform)\luajit205.exe</LocalDebuggerCommand> 74 <LocalDebuggerCommand>$(SolutionDir)..\LuaJIT-2.0.5\bin\$(Platform)\luajit205.exe</LocalDebuggerCommand>
75 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 75 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
76 <LocalDebuggerCommandArguments>-i</LocalDebuggerCommandArguments> 76 <LocalDebuggerCommandArguments>-i</LocalDebuggerCommandArguments>
77 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 77 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
78 </PropertyGroup> 78 </PropertyGroup>
79 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug LuaJIT GIT|Win32'"> 79 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug LuaJIT GIT|Win32'">
80 <LocalDebuggerCommand>$(SolutionDir)..\LuaJIT-2.0.5\bin\$(Platform)\luajit205.exe</LocalDebuggerCommand> 80 <LocalDebuggerCommand>$(SolutionDir)..\LuaJIT-2.0.5\bin\$(Platform)\luajit205.exe</LocalDebuggerCommand>
81 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 81 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
82 <LocalDebuggerCommandArguments>-i</LocalDebuggerCommandArguments> 82 <LocalDebuggerCommandArguments>-i</LocalDebuggerCommandArguments>
83 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 83 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
84 </PropertyGroup> 84 </PropertyGroup>
85 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release 5.4|Win32'"> 85 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release 5.4|Win32'">
86 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 86 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
87 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 87 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
88 <LocalDebuggerCommand>$(SolutionDir)..\framework\lua54.exe</LocalDebuggerCommand> 88 <LocalDebuggerCommand>$(SolutionDir)..\framework\lua54.exe</LocalDebuggerCommand>
89 </PropertyGroup> 89 </PropertyGroup>
90 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.1|Win32'"> 90 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.1|Win32'">
91 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 91 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
92 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 92 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
93 <LocalDebuggerCommand>$(SolutionDir)..\Lua52\bin\$(Platform)\Debug\lua51.exe</LocalDebuggerCommand> 93 <LocalDebuggerCommand>$(SolutionDir)..\Lua52\bin\$(Platform)\Debug\lua51.exe</LocalDebuggerCommand>
94 </PropertyGroup> 94 </PropertyGroup>
95 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.2|Win32'"> 95 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.2|Win32'">
96 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 96 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
97 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 97 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
98 <LocalDebuggerCommand>$(SolutionDir)..\Lua51\bin\$(Platform)\Debug\lua52.exe</LocalDebuggerCommand> 98 <LocalDebuggerCommand>$(SolutionDir)..\Lua51\bin\$(Platform)\Debug\lua52.exe</LocalDebuggerCommand>
99 </PropertyGroup> 99 </PropertyGroup>
100 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.3|Win32'"> 100 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.3|Win32'">
101 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 101 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
102 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 102 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
103 <LocalDebuggerCommand>$(SolutionDir)..\Lua53\bin\$(Platform)\Debug\lua53.exe</LocalDebuggerCommand> 103 <LocalDebuggerCommand>$(SolutionDir)..\Lua53\bin\$(Platform)\Debug\lua53.exe</LocalDebuggerCommand>
104 </PropertyGroup> 104 </PropertyGroup>
105 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.4|Win32'"> 105 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug 5.4|Win32'">
106 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 106 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
107 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 107 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
108 <LocalDebuggerCommand>$(SolutionDir)..\framework\lua54.exe</LocalDebuggerCommand> 108 <LocalDebuggerCommand>$(SolutionDir)..\framework\lua54.exe</LocalDebuggerCommand>
109 </PropertyGroup> 109 </PropertyGroup>
110 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MoonJIT|Win32'"> 110 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MoonJIT|Win32'">
111 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 111 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
112 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 112 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
113 <LocalDebuggerCommand>$(SolutionDir)..\MoonJIT\bin\$(Platform)\moonjit.exe</LocalDebuggerCommand> 113 <LocalDebuggerCommand>$(SolutionDir)..\MoonJIT\bin\$(Platform)\moonjit.exe</LocalDebuggerCommand>
114 </PropertyGroup> 114 </PropertyGroup>
115 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release 5.3|Win32'"> 115 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release 5.3|Win32'">
116 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_test\</LocalDebuggerWorkingDirectory> 116 <LocalDebuggerWorkingDirectory>$(SolutionDir)Lanes\lanes\deep_userdata_example\</LocalDebuggerWorkingDirectory>
117 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> 117 <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
118 <LocalDebuggerCommand>$(SolutionDir)..\Lua53\bin\$(Platform)\Release\lua53.exe</LocalDebuggerCommand> 118 <LocalDebuggerCommand>$(SolutionDir)..\Lua53\bin\$(Platform)\Release\lua53.exe</LocalDebuggerCommand>
119 </PropertyGroup> 119 </PropertyGroup>
diff --git a/deep_userdata_example/deeptest.lua b/deep_userdata_example/deeptest.lua
new file mode 100644
index 0000000..6ef4b74
--- /dev/null
+++ b/deep_userdata_example/deeptest.lua
@@ -0,0 +1,159 @@
1local lanes = require("lanes").configure{ with_timers = false}
2local l = lanes.linda "my linda"
3
4local table_unpack = table.unpack or unpack -- Lua 5.1 support
5
6-- we will transfer userdata created by this module, so we need to make Lanes aware of it
7local dt = lanes.require "deep_userdata_example"
8
9-- set DEEP to any non-false value to run the Deep Userdata tests. "gc" selects a special test for debug purposes
10DEEP = DEEP or true
11-- set CLONABLE to any non-false value to run the Clonable Userdata tests
12CLONABLE = CLONABLE or true
13
14-- lua 5.1->5.2 support a single table uservalue
15-- lua 5.3->5.4 supports an arbitrary type uservalue
16local test_uvtype = (_VERSION == "Lua 5.4") and "function" or (_VERSION == "Lua 5.3") and "string" or "table"
17-- lua 5.4 supports multiple uservalues
18local nupvals = _VERSION == "Lua 5.4" and 3 or 1
19
20local makeUserValue = function( obj_)
21 if test_uvtype == "table" then
22 return {"some uservalue"}
23 elseif test_uvtype == "string" then
24 return "some uservalue"
25 elseif test_uvtype == "function" then
26 -- a function that pull the userdata as upvalue
27 local f = function()
28 return "-> '" .. tostring( obj_) .. "'"
29 end
30 return f
31 end
32end
33
34local printDeep = function( prefix_, obj_, t_)
35 print( prefix_, obj_)
36 for uvi = 1, nupvals do
37 local uservalue = obj_:getuv(uvi)
38 print ("uv #" .. uvi, type( uservalue), uservalue, type(uservalue) == "function" and uservalue() or "")
39 end
40 if t_ then
41 local count = 0
42 for k, v in ipairs( t_) do
43 print( "t["..tostring(k).."]", v)
44 count = count + 1
45 end
46 -- we should have only 2 indexed entries with the same value
47 assert(count == 2 and t_[1] == t_[2])
48 end
49 print()
50end
51
52local performTest = function( obj_)
53 -- setup the userdata with some value and a uservalue
54 obj_:set( 666)
55 obj_:setuv( 1, makeUserValue( obj_))
56 if nupvals > 1 then
57 -- keep uv #2 as nil
58 obj_:setuv( 3, "ENDUV")
59 end
60
61 local t =
62 {
63 -- two indices with an identical value: we should also have identical values on the other side (even if not the same as the original ones when they are clonables)
64 obj_,
65 obj_,
66 -- this one won't transfer because we don't support full uservalue as keys
67 [obj_] = "val"
68 }
69
70 -- read back the contents of the object
71 printDeep( "immediate:", obj_, t)
72
73 -- send the object in a linda, get it back out, read the contents
74 l:set( "key", obj_, t)
75 -- 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)
76 -- when obj_ is a clonable userdata, we get a different clone everytime we cross a linda or lane barrier
77 local _n, _val1, _val2 = l:get( "key", 2)
78 assert(_n == (_val2 and 2 or 1))
79 printDeep( "out of linda:", _val1, _val2)
80
81 -- send the object in a lane through argument passing, the lane body returns it as return value, read the contents
82 local g = lanes.gen(
83 "package"
84 , {
85 required = { "deep_userdata_example"} -- we will transfer userdata created by this module, so we need to make this lane aware of it
86 }
87 , function( arg_, t_)
88 -- read contents inside lane: arg_ and t_ by argument
89 printDeep( "in lane, as arguments:", arg_, t_)
90 -- read contents inside lane: obj_ and t by upvalue
91 printDeep( "in lane, as upvalues:", obj_, t)
92 -- read contents inside lane: in linda
93 local _n, _val1, _val2 = l:get( "key", 2)
94 assert(_n == (_val2 and 2 or 1))
95 printDeep( "in lane, from linda:", _val1, _val2)
96 return arg_, t_
97 end
98 )
99 h = g( obj_, t)
100 -- 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)
101 -- when obj_ is a clonable userdata, we get a different clone everytime we cross a linda or lane barrier
102 printDeep( "from lane:", h[1], h[2])
103end
104
105if DEEP then
106 print "================================================================"
107 print "DEEP"
108 local d = dt.new_deep(nupvals)
109 if type(DEEP) == "string" then
110 local gc_tests = {
111 thrasher = function(repeat_, size_)
112 print "in thrasher"
113 -- result is a table of repeat_ tables, each containing size_ entries
114 local result = {}
115 for i = 1, repeat_ do
116 local batch_values = {}
117 for j = 1, size_ do
118 table.insert(batch_values, j)
119 end
120 table.insert(result, batch_values)
121 end
122 print "thrasher done"
123 return result
124 end,
125 stack_abuser = function(repeat_, size_)
126 print "in stack_abuser"
127 for i = 1, repeat_ do
128 local batch_values = {}
129 for j = 1, size_ do
130 table.insert(batch_values, j)
131 end
132 -- return size_ values
133 local _ = table_unpack(batch_values)
134 end
135 print "stack_abuser done"
136 return result
137 end
138 }
139 -- have the object call the function from inside one of its functions, to detect if it gets collected from there (while in use!)
140 local testf = gc_tests[DEEP]
141 if testf then
142 local r = d:invoke(gc_tests[DEEP], REPEAT or 10, SIZE or 10)
143 print("invoke -> ", tostring(r))
144 else
145 print("unknown test '" .. DEEP .. "'")
146 end
147 else
148 performTest(d)
149 end
150end
151
152if CLONABLE then
153 print "================================================================"
154 print "CLONABLE"
155 performTest( dt.new_clonable(nupvals))
156end
157
158print "================================================================"
159print "TEST OK" \ No newline at end of file
diff --git a/docs/index.html b/docs/index.html
index 49cb592..d7717dc 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -1832,7 +1832,7 @@ static int clonable_lanesclone(lua_State* L)
1832 <b>NOTE</b>: In the event the source userdata has uservalues, it is not necessary to create them for the clone, Lanes will handle their cloning.<br /> 1832 <b>NOTE</b>: In the event the source userdata has uservalues, it is not necessary to create them for the clone, Lanes will handle their cloning.<br />
1833 Of course, more complex objects may require smarter cloning behavior than a simple <tt>memcpy</tt>. Also, the module initialisation code should make each metatable accessible from the module table itself as in: 1833 Of course, more complex objects may require smarter cloning behavior than a simple <tt>memcpy</tt>. Also, the module initialisation code should make each metatable accessible from the module table itself as in:
1834<table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%"><tr><td><pre> 1834<table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%"><tr><td><pre>
1835int luaopen_deep_test(lua_State* L) 1835int luaopen_deep_userdata_example(lua_State* L)
1836{ 1836{
1837 luaL_newlib(L, deep_module); 1837 luaL_newlib(L, deep_module);
1838 1838
@@ -1898,7 +1898,7 @@ static MyDeepFactory g_MyDeepFactory;
1898 <li><tt>createMetatable()</tt>: should build a metatable for the object. Don't cache the metatable yourself, Lanes takes care of it (<tt>createMetatable</tt> should only be invoked once per state). Just push the metatable on the stack.</li> 1898 <li><tt>createMetatable()</tt>: should build a metatable for the object. Don't cache the metatable yourself, Lanes takes care of it (<tt>createMetatable</tt> should only be invoked once per state). Just push the metatable on the stack.</li>
1899 <li><tt>moduleName()</tt>: requests the name of the module that exports the factory, to be returned. It is necessary so that Lanes can require it in any lane state that receives a userdata. This is to prevent crashes in situations where the module could be unloaded while the factory pointer is still held.</li> 1899 <li><tt>moduleName()</tt>: requests the name of the module that exports the factory, to be returned. It is necessary so that Lanes can require it in any lane state that receives a userdata. This is to prevent crashes in situations where the module could be unloaded while the factory pointer is still held.</li>
1900 </ul> 1900 </ul>
1901 Take a look at <tt>LindaFactory</tt> in <tt>lindafactory.cpp</tt> or <tt>MyDeepFactory</tt> in <tt>deep_test.cpp</tt>. 1901 Take a look at <tt>LindaFactory</tt> in <tt>lindafactory.cpp</tt> or <tt>MyDeepFactory</tt> in <tt>deep_userdata_example.cpp</tt>.
1902 </li> 1902 </li>
1903 <li>Include <tt>"_pch.hpp", "deep.hpp"</tt> and either link against Lanes or statically compile <tt>compat.cpp deep.cpp</tt> into your module if you want to avoid a runtime dependency for users that will use your module without Lanes. 1903 <li>Include <tt>"_pch.hpp", "deep.hpp"</tt> and either link against Lanes or statically compile <tt>compat.cpp deep.cpp</tt> into your module if you want to avoid a runtime dependency for users that will use your module without Lanes.
1904 <li>Instanciate your userdata using <tt>yourFactoryObject.pushDeepUserdata()</tt>, instead of the regular <tt>lua_newuserdata()</tt>. Given a <tt>factory</tt>, it sets up the support structures and returns a state-specific proxy full userdata for accessing your data. This proxy can also be copied over to other lanes.</li> 1904 <li>Instanciate your userdata using <tt>yourFactoryObject.pushDeepUserdata()</tt>, instead of the regular <tt>lua_newuserdata()</tt>. Given a <tt>factory</tt>, it sets up the support structures and returns a state-specific proxy full userdata for accessing your data. This proxy can also be copied over to other lanes.</li>
diff --git a/unit_tests/deep_tests.cpp b/unit_tests/deep_tests.cpp
index 2c9ccdf..e21072c 100644
--- a/unit_tests/deep_tests.cpp
+++ b/unit_tests/deep_tests.cpp
@@ -2,19 +2,19 @@
2#include "shared.h" 2#include "shared.h"
3 3
4// yeah it's dirty, I will do better someday 4// yeah it's dirty, I will do better someday
5#include "../deep_test/deep_test.cpp" 5#include "../deep_userdata_example/deep_userdata_example.cpp"
6 6
7 7
8// ################################################################################################# 8// #################################################################################################
9// ################################################################################################# 9// #################################################################################################
10 10
11TEST_CASE("misc.deep_test") 11TEST_CASE("misc.deep_userdata.example")
12{ 12{
13 LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ true } }; 13 LuaState S{ LuaState::WithBaseLibs{ true }, LuaState::WithFixture{ true } };
14 S.requireSuccess( 14 S.requireSuccess(
15 " lanes = require 'lanes'.configure()" 15 " lanes = require 'lanes'.configure()"
16 " fixture = require 'fixture'" 16 " fixture = require 'fixture'"
17 " deep_test = require 'deep_test'" 17 " due = require 'deep_userdata_example'"
18 ); 18 );
19 19
20 SECTION("garbage collection collects") 20 SECTION("garbage collection collects")
@@ -24,8 +24,8 @@ TEST_CASE("misc.deep_test")
24 if constexpr (LUA_VERSION_NUM >= 503) { // Lua < 5.3 only supports a table uservalue 24 if constexpr (LUA_VERSION_NUM >= 503) { // Lua < 5.3 only supports a table uservalue
25 S.requireSuccess( 25 S.requireSuccess(
26 // create a deep userdata object without referencing it. First uservalue is a function, and should be called on __gc 26 // create a deep userdata object without referencing it. First uservalue is a function, and should be called on __gc
27 " deep_test.new_deep(1):setuv(1, function() collected = collected and collected + 1 or 1 end)" 27 " due.new_deep(1):setuv(1, function() collected = collected and collected + 1 or 1 end)"
28 " deep_test.new_deep(1):setuv(1, function() collected = collected and collected + 1 or 1 end)" 28 " due.new_deep(1):setuv(1, function() collected = collected and collected + 1 or 1 end)"
29 " collectgarbage()" // and collect it 29 " collectgarbage()" // and collect it
30 " assert(collected == 2)" 30 " assert(collected == 2)"
31 ); 31 );
@@ -37,7 +37,7 @@ TEST_CASE("misc.deep_test")
37 SECTION("reference counting") 37 SECTION("reference counting")
38 { 38 {
39 S.requireSuccess( 39 S.requireSuccess(
40 " d = deep_test.new_deep(1)" // create a deep userdata object 40 " d = due.new_deep(1)" // create a deep userdata object
41 " d:set(42)" // set some value 41 " d:set(42)" // set some value
42 " assert(d:refcount() == 1)" 42 " assert(d:refcount() == 1)"
43 ); 43 );
@@ -73,7 +73,7 @@ TEST_CASE("misc.deep_test")
73 SECTION("collection from inside a Linda") 73 SECTION("collection from inside a Linda")
74 { 74 {
75 S.requireSuccess( 75 S.requireSuccess(
76 " d = deep_test.new_deep(1)" // create a deep userdata object 76 " d = due.new_deep(1)" // create a deep userdata object
77 " d:set(42)" // set some value 77 " d:set(42)" // set some value
78 " assert(d:refcount() == 1)" 78 " assert(d:refcount() == 1)"
79 ); 79 );
@@ -89,7 +89,7 @@ TEST_CASE("misc.deep_test")
89 " l = nil" 89 " l = nil"
90 " collectgarbage()" // clears the linda, removes its storage from the keeper 90 " collectgarbage()" // clears the linda, removes its storage from the keeper
91 " lanes.collectgarbage()" // collect garbage inside the keepers too, to finish cleanup 91 " lanes.collectgarbage()" // collect garbage inside the keepers too, to finish cleanup
92 " assert(deep_test.get_deep_count() == 0)" 92 " assert(due.get_deep_count() == 0)"
93 ); 93 );
94 } 94 }
95} \ No newline at end of file 95} \ No newline at end of file
diff --git a/unit_tests/shared.cpp b/unit_tests/shared.cpp
index 0c9516f..08025f2 100644
--- a/unit_tests/shared.cpp
+++ b/unit_tests/shared.cpp
@@ -8,7 +8,7 @@
8// ################################################################################################# 8// #################################################################################################
9// ################################################################################################# 9// #################################################################################################
10 10
11LANES_API int luaopen_deep_test(lua_State* L_); 11LANES_API int luaopen_deep_userdata_example(lua_State* L_);
12 12
13namespace 13namespace
14{ 14{
@@ -70,7 +70,7 @@ namespace
70 // a function that enables any lane to require "fixture" 70 // a function that enables any lane to require "fixture"
71 lua_CFunction sOnStateCreate = +[](lua_State* const L_) { 71 lua_CFunction sOnStateCreate = +[](lua_State* const L_) {
72 PreloadModule(L_, "fixture", luaopen_fixture); 72 PreloadModule(L_, "fixture", luaopen_fixture);
73 PreloadModule(L_, "deep_test", luaopen_deep_test); 73 PreloadModule(L_, "deep_userdata_example", luaopen_deep_userdata_example);
74 return 0; 74 return 0;
75 }; 75 };
76 76
@@ -181,7 +181,7 @@ LuaState::LuaState(WithBaseLibs const withBaseLibs_, WithFixture const withFixtu
181 if (withFixture_) { 181 if (withFixture_) {
182 // make require "fixture" call luaopen_fixture 182 // make require "fixture" call luaopen_fixture
183 local::PreloadModule(L, "fixture", luaopen_fixture); 183 local::PreloadModule(L, "fixture", luaopen_fixture);
184 local::PreloadModule(L, "deep_test", luaopen_deep_test); 184 local::PreloadModule(L, "deep_userdata_example", luaopen_deep_userdata_example);
185 } 185 }
186 STACK_CHECK(L, 0); 186 STACK_CHECK(L, 0);
187} 187}