@@ -3,7 +3,7 @@ namespace Lua54;
33using System ;
44using System . Diagnostics ;
55using System . Runtime . InteropServices ;
6-
6+
77
88public static class Lua
99{
@@ -155,10 +155,10 @@ public struct luaL_Buffer {
155155 public delegate int lua_CFunction ( IntPtr L ) ;
156156 public delegate int lua_KFunction ( IntPtr L , int status , IntPtr ctx ) ;
157157 public delegate void lua_WarnFunction ( IntPtr ud , string msg , int tocont ) ;
158- public delegate int lua_Writer ( IntPtr L , IntPtr p , ulong sz , IntPtr ud ) ;
158+ public delegate int lua_Writer ( IntPtr L , IntPtr p , ulong sz , ref ulong ud ) ;
159159 public delegate IntPtr lua_Reader ( IntPtr L , IntPtr ud , ulong sz ) ;
160160 public delegate IntPtr lua_Alloc ( IntPtr ud , IntPtr ptr , ulong osize , ulong nsize ) ;
161- public delegate void lua_Hook ( IntPtr L , IntPtr ar ) ;
161+ public delegate void lua_Hook ( IntPtr L , lua_Debug ar ) ;
162162
163163 [ DllImport ( DllName , CallingConvention = CallingConvention . StdCall ) ]
164164 public static extern IntPtr lua_newstate ( lua_Alloc f , IntPtr ud ) ;
@@ -495,7 +495,7 @@ public static int lua_yield(IntPtr L, int n)
495495 public static extern int lua_getstack ( IntPtr L , int level , lua_Debug ar ) ;
496496
497497 [ DllImport ( DllName , CallingConvention = CallingConvention . StdCall ) ]
498- public static extern int lua_getinfo ( IntPtr L , string what , ref lua_Debug ar ) ;
498+ public static extern int lua_getinfo ( IntPtr L , string what , lua_Debug ar ) ;
499499
500500 [ DllImport ( DllName , CallingConvention = CallingConvention . StdCall , EntryPoint = "lua_getlocal" ) ]
501501 public static extern IntPtr _lua_getlocal ( IntPtr L , lua_Debug ar , int n ) ;
@@ -728,17 +728,17 @@ public static void luaL_checkversion(IntPtr L)
728728 public static extern int luaL_typeerror ( IntPtr L , int arg , string tname ) ;
729729
730730 [ DllImport ( DllName , CallingConvention = CallingConvention . StdCall , EntryPoint = "luaL_checklstring" ) ]
731- public static extern IntPtr _luaL_checklstring ( IntPtr L , int arg , IntPtr l ) ;
732- public static string ? luaL_checklstring ( IntPtr L , int arg , IntPtr l )
731+ public static extern IntPtr _luaL_checklstring ( IntPtr L , int arg , ref ulong l ) ;
732+ public static string ? luaL_checklstring ( IntPtr L , int arg , ref ulong l )
733733 {
734- return Marshal . PtrToStringAnsi ( _luaL_checklstring ( L , arg , l ) ) ;
734+ return Marshal . PtrToStringAnsi ( _luaL_checklstring ( L , arg , ref l ) ) ;
735735 }
736736
737737 [ DllImport ( DllName , CallingConvention = CallingConvention . StdCall , EntryPoint = "luaL_optlstring" ) ]
738- public static extern IntPtr _luaL_optlstring ( IntPtr L , int arg , string def , IntPtr l ) ;
739- public static string ? luaL_optlstring ( IntPtr L , int arg , string def , IntPtr l )
738+ public static extern IntPtr _luaL_optlstring ( IntPtr L , int arg , string def , ref ulong l ) ;
739+ public static string ? luaL_optlstring ( IntPtr L , int arg , string def , ref ulong l )
740740 {
741- return Marshal . PtrToStringAnsi ( _luaL_optlstring ( L , arg , def , l ) ) ;
741+ return Marshal . PtrToStringAnsi ( _luaL_optlstring ( L , arg , def , ref l ) ) ;
742742 }
743743
744744 [ DllImport ( DllName , CallingConvention = CallingConvention . StdCall ) ]
@@ -820,7 +820,7 @@ public static int luaL_loadfile(IntPtr L, string f)
820820 public static extern long luaL_len ( IntPtr L , int idx ) ;
821821
822822 [ DllImport ( DllName , CallingConvention = CallingConvention . StdCall ) ]
823- public static extern void luaL_addgsub ( IntPtr b , string s , string p , string r ) ;
823+ public static extern void luaL_addgsub ( luaL_Buffer b , string s , string p , string r ) ;
824824
825825 [ DllImport ( DllName , CallingConvention = CallingConvention . StdCall , EntryPoint = "luaL_gsub" ) ]
826826 public static extern IntPtr _luaL_gsub ( IntPtr L , string s , string p , string r ) ;
@@ -843,7 +843,7 @@ public static int luaL_loadfile(IntPtr L, string f)
843843
844844 public static void luaL_newlibtable ( IntPtr L , luaL_Reg [ ] l )
845845 {
846- lua_createtable ( L , 0 , l . Length ) ;
846+ lua_createtable ( L , 0 , l . Length - 1 ) ;
847847 }
848848
849849 public static void luaL_newlib ( IntPtr L , luaL_Reg [ ] l )
@@ -867,12 +867,14 @@ public static void luaL_argexpected(IntPtr L, bool cond, int arg, string tname)
867867
868868 public static string ? luaL_checkstring ( IntPtr L , int n )
869869 {
870- return luaL_checklstring ( L , n , IntPtr . Zero ) ;
870+ ulong temp = 0 ; // NOP
871+ return luaL_checklstring ( L , n , ref temp ) ;
871872 }
872873
873874 public static string ? luaL_optstring ( IntPtr L , int n , string d )
874875 {
875- return luaL_optlstring ( L , n , d , IntPtr . Zero ) ;
876+ ulong temp = 0 ; // NOP
877+ return luaL_optlstring ( L , n , d , ref temp ) ;
876878 }
877879
878880 public static string ? luaL_typename ( IntPtr L , int i )
@@ -945,14 +947,14 @@ public static void luaL_addchar(luaL_Buffer B, sbyte c)
945947 B . init [ B . n ++ ] = c ;
946948 }
947949
948- public static void luaL_addsize ( luaL_Buffer B , ulong s )
950+ public static void luaL_addsize ( luaL_Buffer B , long s )
949951 {
950- B . n += s ;
952+ B . n = ( ulong ) ( ( long ) B . n + s ) ;
951953 }
952954
953- public static void luaL_buffsub ( luaL_Buffer B , ulong s )
955+ public static void luaL_buffsub ( luaL_Buffer B , long s )
954956 {
955- B . n -= s ;
957+ B . n = ( ulong ) ( ( long ) B . n - s ) ;
956958 }
957959
958960 [ DllImport ( DllName , CallingConvention = CallingConvention . StdCall ) ]
@@ -980,12 +982,8 @@ public static void luaL_buffsub(luaL_Buffer B, ulong s)
980982 [ DllImport ( DllName , CallingConvention = CallingConvention . StdCall ) ]
981983 public static extern void luaL_pushresultsize ( IntPtr B , ulong sz ) ;
982984
983- [ DllImport ( DllName , CallingConvention = CallingConvention . StdCall , EntryPoint = "luaL_buffinitsize" ) ]
984- public static extern IntPtr _luaL_buffinitsize ( IntPtr L , IntPtr B , ulong sz ) ;
985- public static string ? luaL_buffinitsize ( IntPtr L , IntPtr B , ulong sz )
986- {
987- return Marshal . PtrToStringAnsi ( _luaL_buffinitsize ( L , B , sz ) ) ;
988- }
985+ [ DllImport ( DllName , CallingConvention = CallingConvention . StdCall ) ]
986+ public static extern IntPtr luaL_buffinitsize ( IntPtr L , IntPtr B , ulong sz ) ;
989987
990988 public static void lua_writestring ( string s )
991989 {
0 commit comments