Skip to content

Commit 4fa0733

Browse files
authored
Merge pull request #34 from tilkinsc/33-lua_getinfo-and-lua_getstack-incorrect-parameters
fix: luaL_register needs array of luaL_Reg instead of a singular one
2 parents 06395e5 + cd51955 commit 4fa0733

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/Lua51.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,10 +602,10 @@ public static void luaL_setn(lua_State L, int i, int j)
602602
public const int LUA_ERRFILE = LUA_ERRERR + 1;
603603

604604
[DllImport(DllName, CallingConvention = Convention)]
605-
public static extern void luaL_openlib(lua_State L, string libname, luaL_Reg l, int nup);
605+
public static extern void luaL_openlib(lua_State L, string libname, luaL_Reg[] l, int nup);
606606

607607
[DllImport(DllName, CallingConvention = Convention)]
608-
public static extern void luaL_register(lua_State L, string libname, luaL_Reg l);
608+
public static extern void luaL_register(lua_State L, string libname, luaL_Reg[] l);
609609

610610
[DllImport(DllName, CallingConvention = Convention)]
611611
public static extern int luaL_getmetafield(lua_State L, int obj, string e);

src/LuaJIT.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public struct luaL_Buffer {
6666
public delegate nuint lua_Alloc(nuint ud, nuint ptr, size_t osize, size_t nsize);
6767
public delegate void lua_Hook(lua_State L, lua_Debug ar);
6868

69-
public static unsafe luaL_Reg AsLuaLReg(string name, delegate*unmanaged<lua_State, int> func) => new() { name = name, func = (nint) func };
69+
public static unsafe luaL_Reg AsLuaLReg(string name, delegate*unmanaged<lua_State, int> func) => new() { name = name, func = (nint) func };
7070

7171
public const string LUAJIT_VERSION = "LuaJIT 2.1.0-beta3";
7272
public const int LUAJIT_VERSION_NUM = 20100;
@@ -562,10 +562,10 @@ public static int lua_getgccount(lua_State L)
562562
public const int LUA_MASKCOUNT = 1 << LUA_HOOKCOUNT;
563563

564564
[DllImport(DllName, CallingConvention = Convention)]
565-
public static extern int lua_getstack(lua_State L, int level, lua_Debug ar);
565+
public static extern int lua_getstack(lua_State L, int level, ref lua_Debug ar);
566566

567567
[DllImport(DllName, CallingConvention = Convention)]
568-
public static extern int lua_getinfo(lua_State L, string what, lua_Debug ar);
568+
public static extern int lua_getinfo(lua_State L, string what, ref lua_Debug ar);
569569

570570
[DllImport(DllName, CallingConvention = Convention, EntryPoint = "lua_getlocal")]
571571
private static extern nint _lua_getlocal(lua_State L, lua_Debug ar, int n);
@@ -657,10 +657,10 @@ public static double lua_version(lua_State L)
657657
public const int LUA_ERRFILE = LUA_ERRERR + 1;
658658

659659
[DllImport(DllName, CallingConvention = Convention)]
660-
public static extern void luaL_openlib(lua_State L, string libname, luaL_Reg l, int nup);
661-
660+
public static extern void luaL_openlib(lua_State L, string libname, luaL_Reg[] l, int nup);
661+
662662
[DllImport(DllName, CallingConvention = Convention)]
663-
public static extern void luaL_register(lua_State L, string libname, luaL_Reg l);
663+
public static extern void luaL_register(lua_State L, string libname, luaL_Reg[] l);
664664

665665
[DllImport(DllName, CallingConvention = Convention)]
666666
public static extern int luaL_getmetafield(lua_State L, int obj, string e);

0 commit comments

Comments
 (0)