Lua.NET
Lua.NET copied to clipboard
lua_getinfo and lua_getstack incorrect parameters
In the current implementation these are passed to lua as value while they should actually be ptrs for reading data out. One fix could be to replace the struct with an nint and just let .net deal string cancer like this
[DllImport(DllName, CallingConvention = Convention)]
public static extern int lua_getinfo(lua_State L, string what, nint ar);
public static int lua_getinfo(lua_State L, string what, ref lua_Debug ar)
{
nint ptr = Marshal.AllocHGlobal(Marshal.SizeOf<lua_Debug>());
int v;
try
{
v = lua_getinfo(L, what, ptr);
ar = Marshal.PtrToStructure<lua_Debug>(ptr);
}
finally
{
Marshal.FreeHGlobal(ptr);
}
return v;
}
https://www.lua.org/manual/5.1/manual.html#lua_getinfo https://www.lua.org/manual/5.1/manual.html#lua_getstack