Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab4ba4b

Browse files
committed
Did the following:
- Corrected luaL_reg struct where members were not public - Added AsLuaLReg function to assist in making luaL_Reg libraries - Bumped lua544 to lua546 Added new function lua_closethread(lua_State, lua_State) Made a note that lua_resetthread(lua_State) is deprecated Bumped version Amended copyright No breaking changes
1 parent b940228 commit ab4ba4b

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

src/Lua51.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public struct lua_Debug {
3838

3939
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
4040
public struct luaL_Reg {
41-
string name;
42-
charp func;
41+
public string name;
42+
public charp func;
4343
};
4444

4545
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
@@ -57,6 +57,8 @@ public struct luaL_Buffer {
5757
public delegate voidp lua_Alloc(voidp ud, voidp ptr, size_t osize, size_t nsize);
5858
public delegate void lua_Hook(lua_State L, lua_Debug ar);
5959

60+
public static unsafe luaL_Reg AsLuaLReg(string name, delegate*unmanaged<lua_State, int> func) => new luaL_Reg { name = name, func = (nint) func };
61+
6062
public const string LUA_PATH = "LUA_PATH";
6163
public const string LUA_CPATH = "LUA_CPATH";
6264
public const string LUA_INIT = "LUA_INIT";

src/Lua52.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public struct luaL_Buffer {
6262
public delegate voidp lua_Alloc(voidp ud, voidp ptr, size_t osize, size_t nsize);
6363
public delegate void lua_Hook(lua_State L, lua_Debug ar);
6464

65+
public static unsafe luaL_Reg AsLuaLReg(string name, delegate*unmanaged<lua_State, int> func) => new luaL_Reg { name = name, func = (nint) func };
66+
6567
public const string LUA_LDIR = "!\\lua\\";
6668
public const string LUA_CDIR = "!\\";
6769
public const string LUA_PATH_DEFAULT = LUA_LDIR + "?.lua;" + LUA_LDIR + "?\\init.lua;" + LUA_CDIR + "?.lua;" + LUA_CDIR + "?\\init.lua;" + ".\\?.lua";

src/Lua53.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public struct luaL_Buffer {
6464
public delegate voidp lua_Alloc(voidp ud, voidp ptr, size_t osize, size_t nsize);
6565
public delegate void lua_Hook(lua_State L, lua_Debug ar);
6666

67+
public static unsafe luaL_Reg AsLuaLReg(string name, delegate*unmanaged<lua_State, int> func) => new luaL_Reg { name = name, func = (nint) func };
68+
6769
public const int LUAI_BITSINT = 32;
6870

6971
public const int LUA_INT_INT = 1;

src/Lua54.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public struct lua_KContext
2323
public static class Lua
2424
{
2525

26-
private const string DllName = "Lua544.dll";
26+
private const string DllName = "Lua546.dll";
2727
private const CallingConvention Convention = CallingConvention.Cdecl;
2828

2929
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
@@ -72,6 +72,8 @@ public struct luaL_Buffer {
7272
public delegate void lua_WarnFunction(voidp ud, string msg, int tocont);
7373
public delegate void lua_Hook(lua_State L, lua_Debug ar);
7474

75+
public static unsafe luaL_Reg AsLuaLReg(string name, delegate*unmanaged<lua_State, int> func) => new luaL_Reg { name = name, func = (nint) func };
76+
7577
public const int LUAI_IS32INT = 1;
7678

7779
public const int LUA_INT_INT = 1;
@@ -120,14 +122,14 @@ public struct luaL_Buffer {
120122

121123
public const string LUA_VERSION_MAJOR = "5";
122124
public const string LUA_VERSION_MINOR = "4";
123-
public const string LUA_VERSION_RELEASE = "4";
125+
public const string LUA_VERSION_RELEASE = "6";
124126

125127
public const int LUA_VERSION_NUM = 504;
126-
public const int LUA_VERSION_RELEASE_NUM = LUA_VERSION_NUM * 100 + 4;
128+
public const int LUA_VERSION_RELEASE_NUM = LUA_VERSION_NUM * 100 + 6;
127129

128130
public const string LUA_VERSION = "Lua " + LUA_VERSION_MAJOR + "." + LUA_VERSION_MINOR;
129131
public const string LUA_RELEASE = LUA_VERSION + "." + LUA_VERSION_RELEASE;
130-
public const string LUA_COPYRIGHT = LUA_RELEASE + " Copyright (C) 1994-2022 Lua.org, PUC-Rio";
132+
public const string LUA_COPYRIGHT = LUA_RELEASE + " Copyright (C) 1994-2023 Lua.org, PUC-Rio";
131133
public const string LUA_AUTHORS = "R. Ierusalimschy, L. H. de Figueiredo, W. Celes";
132134

133135
public const string LUA_SIGNATURE = "\x1bLua";
@@ -181,7 +183,10 @@ public static lua_State lua_newstate(lua_Alloc? f, voidp ud)
181183
public static extern lua_State lua_newthread(lua_State L);
182184

183185
[DllImport(DllName, CallingConvention = Convention)]
184-
public static extern int lua_resetthread(lua_State L);
186+
public static extern int lua_closethread(lua_State L, lua_State from);
187+
188+
[DllImport(DllName, CallingConvention = Convention)]
189+
public static extern int lua_resetthread(lua_State L); // deprecated
185190

186191
[DllImport(DllName, CallingConvention = Convention, EntryPoint = "lua_atpanic")]
187192
public static extern charp _lua_atpanic(lua_State L, charp panicf);

src/LuaJIT.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public struct lua_Debug {
3737

3838
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
3939
public struct luaL_Reg {
40-
string name;
41-
charp func;
40+
public string? name;
41+
public charp func;
4242
};
4343

4444
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
@@ -56,6 +56,8 @@ public struct luaL_Buffer {
5656
public delegate voidp lua_Alloc(voidp ud, voidp ptr, size_t osize, size_t nsize);
5757
public delegate void lua_Hook(lua_State L, lua_Debug ar);
5858

59+
public static unsafe luaL_Reg AsLuaLReg(string name, delegate*unmanaged<lua_State, int> func) => new luaL_Reg { name = name, func = (nint) func };
60+
5961
public const string LUAJIT_VERSION = "LuaJIT 2.1.0-beta3";
6062
public const int LUAJIT_VERSION_NUM = 20100;
6163
public const string LUAJIT_VERSION_SYM = "luaJIT_version_2_1_0_beta3";

0 commit comments

Comments
 (0)