@@ -40,12 +40,17 @@ If you are just here to use the library, you can get by without having to worry
4040
4141Example Usage Lua5.4.4:
4242``` C#
43+ // test1.csproj
44+ // <PropertyGroup>
45+ // ...
46+ // <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
47+ // </PropertyGroup>
4348using Lua54 ;
4449using static Lua54 .Lua ;
4550
46- namespace LuaNET ;
51+ namespace TestLua ;
4752
48- class Project
53+ public class Test1
4954{
5055
5156 public static int lfunc (lua_State L )
@@ -59,7 +64,7 @@ class Project
5964 public static void Main (String [] args )
6065 {
6166 lua_State L = luaL_newstate ();
62- if (L .Handle == UIntPtr . Zero )
67+ if (L .Handle == 0 )
6368 {
6469 Console .WriteLine (" Unable to create context!" );
6570 }
@@ -76,12 +81,17 @@ class Project
7681
7782Example Usage LuaJIT:
7883``` C#
84+ // test2.csproj
85+ // <PropertyGroup>
86+ // ...
87+ // <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88+ // </PropertyGroup>
7989using LuaJIT ;
8090using static LuaJIT .Lua ;
8191
82- namespace LuaNET ;
92+ namespace TestLua ;
8393
84- class Project
94+ public class Test2
8595{
8696
8797 public static int lfunc (lua_State L )
@@ -95,7 +105,7 @@ class Project
95105 public static void Main (String [] args )
96106 {
97107 lua_State L = luaL_newstate ();
98- if (L .Handle == UIntPtr . Zero )
108+ if (L .Handle == 0 )
99109 {
100110 Console .WriteLine (" Unable to create context!" );
101111 }
@@ -112,7 +122,7 @@ class Project
112122
113123Example Usage NativeAOT DLL Library:
114124``` C#
115- // test2 .csproj
125+ // test3 .csproj
116126// <PropertyGroup>
117127// ...
118128// <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -123,9 +133,9 @@ using System.Runtime.InteropServices;
123133using LuaJIT ;
124134using static LuaJIT .Lua ;
125135
126- namespace test2 ;
136+ namespace TestLua ;
127137
128- public unsafe class Test2
138+ public unsafe class Test3
129139{
130140
131141 [UnmanagedCallersOnly ]
@@ -151,26 +161,27 @@ public unsafe class Test2
151161
152162}
153163
154- // test1.csproj
155-
164+ // test4.csproj
165+ // <PropertyGroup>
166+ // ...
167+ // <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
168+ // </PropertyGroup>
156169using LuaJIT ;
157170using static LuaJIT .Lua ;
158171
159- namespace test1 ;
172+ namespace test4 ;
160173
161174public class Test1
162175{
163176
164177 public static void Main (string [] args )
165178 {
166179 lua_State L = luaL_newstate ();
167- if (L .Handle == UIntPtr . Zero )
180+ if (L .Handle == 0 )
168181 {
169182 Console .WriteLine (" Unable to create context!" );
170183 }
171184 luaL_openlibs (L );
172-
173- // require("test2.dll");
174185 lua_getglobal (L , " require" );
175186 lua_pushstring (L , " test2" );
176187 int result = lua_pcall (L , 1 , 0 , 0 );
@@ -179,11 +190,9 @@ public class Test1
179190 string ? err = luaL_checkstring (L , 1 );
180191 if (err != null )
181192 {
182- Console .WriteLine ($" 1 Error Result: {err }" );
193+ Console .WriteLine ($" 1 Result: {err }" );
183194 }
184195 }
185-
186- // print(_G.test2.GetHello())
187196 lua_getglobal (L , " test2" );
188197 lua_getglobal (L , " print" );
189198 lua_getfield (L , 1 , " GetHello" );
@@ -193,7 +202,7 @@ public class Test1
193202 string ? err = luaL_checkstring (L , 1 );
194203 if (err != null )
195204 {
196- Console .WriteLine ($" 2 Error Result: {err }" );
205+ Console .WriteLine ($" 2 Result: {err }" );
197206 }
198207 }
199208 result = lua_pcall (L , 1 , 0 , 0 );
@@ -202,10 +211,9 @@ public class Test1
202211 string ? err = luaL_checkstring (L , 1 );
203212 if (err != null )
204213 {
205- Console .WriteLine ($" 3 Error Result: {err }" );
214+ Console .WriteLine ($" 3 Result: {err }" );
206215 }
207216 }
208- // pop test2
209217 lua_pop (L , 1 );
210218
211219 lua_close (L );
0 commit comments