55using lua_Integer = System . Int64 ;
66using lua_Unsigned = System . UInt64 ;
77
8- namespace Lua52 ;
8+ namespace LuaNET . Lua52 ;
99
1010
1111public struct lua_State
@@ -169,7 +169,7 @@ public static int lua_upvalueindex(int i)
169169 public static extern lua_State _lua_newstate ( nint f , nuint ud ) ;
170170 public static lua_State lua_newstate ( lua_Alloc ? f , nuint ud )
171171 {
172- return _lua_newstate ( f == null ? nint . Zero : Marshal . GetFunctionPointerForDelegate < lua_Alloc > ( f ) , ud ) ;
172+ return _lua_newstate ( f == null ? ( ( nint ) 0 ) : Marshal . GetFunctionPointerForDelegate < lua_Alloc > ( f ) , ud ) ;
173173 }
174174
175175 [ DllImport ( DllName , CallingConvention = Convention ) ]
@@ -182,16 +182,16 @@ public static lua_State lua_newstate(lua_Alloc? f, nuint ud)
182182 public static extern nint _lua_atpanic ( lua_State L , nint panicf ) ;
183183 public static lua_CFunction ? lua_atpanic ( lua_State L , lua_CFunction ? panicf )
184184 {
185- nint panic = _lua_atpanic ( L , panicf == null ? nint . Zero : Marshal . GetFunctionPointerForDelegate < lua_CFunction > ( panicf ) ) ;
186- return panic == nint . Zero ? null : Marshal . GetDelegateForFunctionPointer < lua_CFunction > ( panic ) ;
185+ nint panic = _lua_atpanic ( L , panicf == null ? ( ( nint ) 0 ) : Marshal . GetFunctionPointerForDelegate < lua_CFunction > ( panicf ) ) ;
186+ return panic == ( ( nint ) 0 ) ? null : Marshal . GetDelegateForFunctionPointer < lua_CFunction > ( panic ) ;
187187 }
188188
189189 [ DllImport ( DllName , CallingConvention = Convention , EntryPoint = "lua_version" ) ]
190190 public static extern nint _lua_version ( lua_State L ) ;
191191 public static double lua_version ( lua_State L )
192192 {
193193 nint mem = _lua_version ( L ) ;
194- if ( mem == nint . Zero )
194+ if ( mem == ( ( nint ) 0 ) )
195195 return 0 ;
196196 byte [ ] arr = new byte [ 8 ] ;
197197 for ( int i = 0 ; i < arr . Length ; i ++ )
@@ -278,7 +278,7 @@ public static double lua_version(lua_State L)
278278 public static lua_CFunction ? lua_tocfunction ( lua_State L , int idx )
279279 {
280280 nint ret = _lua_tocfunction ( L , idx ) ;
281- return ret == nint . Zero ? null : Marshal . GetDelegateForFunctionPointer < lua_CFunction > ( ret ) ;
281+ return ret == ( ( nint ) 0 ) ? null : Marshal . GetDelegateForFunctionPointer < lua_CFunction > ( ret ) ;
282282 }
283283
284284 [ DllImport ( DllName , CallingConvention = Convention ) ]
@@ -353,7 +353,7 @@ public static double lua_version(lua_State L)
353353 public static extern void _lua_pushcclosure ( lua_State L , nint fn , int n ) ;
354354 public static void lua_pushcclosure ( lua_State L , lua_CFunction ? fn , int n )
355355 {
356- _lua_pushcclosure ( L , fn == null ? nint . Zero : Marshal . GetFunctionPointerForDelegate ( fn ) , n ) ;
356+ _lua_pushcclosure ( L , fn == null ? ( ( nint ) 0 ) : Marshal . GetFunctionPointerForDelegate ( fn ) , n ) ;
357357 }
358358
359359 [ DllImport ( DllName , CallingConvention = Convention ) ]
@@ -423,7 +423,7 @@ public static void lua_pushcclosure(lua_State L, lua_CFunction? fn, int n)
423423 public static extern void _lua_callk ( lua_State L , int nargs , int nresults , int ctx , nint k ) ;
424424 public static void lua_callk ( lua_State L , int nargs , int nresults , int ctx , lua_CFunction ? k )
425425 {
426- _lua_callk ( L , nargs , nresults , ctx , k == null ? nint . Zero : Marshal . GetFunctionPointerForDelegate < lua_CFunction > ( k ) ) ;
426+ _lua_callk ( L , nargs , nresults , ctx , k == null ? ( ( nint ) 0 ) : Marshal . GetFunctionPointerForDelegate < lua_CFunction > ( k ) ) ;
427427 }
428428
429429 public static void lua_call ( lua_State L , int n , int r )
@@ -438,7 +438,7 @@ public static void lua_call(lua_State L, int n, int r)
438438 public static extern int _lua_pcallk ( lua_State L , int nargs , int nresults , int errfunc , int ctx , nint k ) ;
439439 public static int lua_pcallk ( lua_State L , int nargs , int nresults , int errfunc , int ctx , lua_CFunction ? k )
440440 {
441- return _lua_pcallk ( L , nargs , nresults , errfunc , ctx , k == null ? nint . Zero : Marshal . GetFunctionPointerForDelegate < lua_CFunction > ( k ) ) ;
441+ return _lua_pcallk ( L , nargs , nresults , errfunc , ctx , k == null ? ( ( nint ) 0 ) : Marshal . GetFunctionPointerForDelegate < lua_CFunction > ( k ) ) ;
442442 }
443443
444444 public static int lua_pcall ( lua_State L , int n , int r , int f )
@@ -450,21 +450,21 @@ public static int lua_pcall(lua_State L, int n, int r, int f)
450450 public static extern int _lua_load ( lua_State L , nint reader , nuint dt , string chunkname , string ? mode ) ;
451451 public static int lua_load ( lua_State L , lua_Reader ? reader , nuint dt , string chunkname , string ? mode )
452452 {
453- return _lua_load ( L , reader == null ? nint . Zero : Marshal . GetFunctionPointerForDelegate < lua_Reader > ( reader ) , dt , chunkname , mode ) ;
453+ return _lua_load ( L , reader == null ? ( ( nint ) 0 ) : Marshal . GetFunctionPointerForDelegate < lua_Reader > ( reader ) , dt , chunkname , mode ) ;
454454 }
455455
456456 [ DllImport ( DllName , CallingConvention = Convention , EntryPoint = "lua_dump" ) ]
457457 public static extern int _lua_dump ( lua_State L , nint writer , nuint data ) ;
458458 public static int lua_dump ( lua_State L , lua_Writer ? writer , nuint data )
459459 {
460- return _lua_dump ( L , writer == null ? nint . Zero : Marshal . GetFunctionPointerForDelegate < lua_Writer > ( writer ) , data ) ;
460+ return _lua_dump ( L , writer == null ? ( ( nint ) 0 ) : Marshal . GetFunctionPointerForDelegate < lua_Writer > ( writer ) , data ) ;
461461 }
462462
463463 [ DllImport ( DllName , CallingConvention = Convention , EntryPoint = "lua_yieldk" ) ]
464464 public static extern int _lua_yieldk ( lua_State L , int nresults , int ctx , nint k ) ;
465465 public static int lua_yieldk ( lua_State L , int nresults , int ctx , lua_CFunction ? k )
466466 {
467- return _lua_yieldk ( L , nresults , ctx , k == null ? nint . Zero : Marshal . GetFunctionPointerForDelegate < lua_CFunction > ( k ) ) ;
467+ return _lua_yieldk ( L , nresults , ctx , k == null ? ( ( nint ) 0 ) : Marshal . GetFunctionPointerForDelegate < lua_CFunction > ( k ) ) ;
468468 }
469469
470470 public static int lua_yield ( lua_State L , int n )
@@ -513,7 +513,7 @@ public static int lua_yield(lua_State L, int n)
513513 public static extern void _lua_setallocf ( lua_State L , nint f , nuint ud ) ;
514514 public static void lua_setallocf ( lua_State L , lua_Alloc ? f , nuint ud )
515515 {
516- _lua_setallocf ( L , f == null ? nint . Zero : Marshal . GetFunctionPointerForDelegate < lua_Alloc > ( f ) , ud ) ;
516+ _lua_setallocf ( L , f == null ? ( ( nint ) 0 ) : Marshal . GetFunctionPointerForDelegate < lua_Alloc > ( f ) , ud ) ;
517517 }
518518
519519 public static double lua_tonumber ( lua_State L , int i )
@@ -666,15 +666,15 @@ public static void lua_pushglobaltable(lua_State L)
666666 public static extern int _lua_sethook ( lua_State L , nint func , int mask , int count ) ;
667667 public static int lua_sethook ( lua_State L , lua_Hook ? func , int mask , int count )
668668 {
669- return _lua_sethook ( L , func == null ? nint . Zero : Marshal . GetFunctionPointerForDelegate < lua_Hook > ( func ) , mask , count ) ;
669+ return _lua_sethook ( L , func == null ? ( ( nint ) 0 ) : Marshal . GetFunctionPointerForDelegate < lua_Hook > ( func ) , mask , count ) ;
670670 }
671671
672672 [ DllImport ( DllName , CallingConvention = Convention , EntryPoint = "lua_gethook" ) ]
673673 public static extern nint _lua_gethook ( lua_State L ) ;
674674 public static lua_Hook ? lua_gethook ( lua_State L )
675675 {
676676 nint ret = _lua_gethook ( L ) ;
677- return ret == nint . Zero ? null : Marshal . GetDelegateForFunctionPointer < lua_Hook > ( ret ) ;
677+ return ret == ( ( nint ) 0 ) ? null : Marshal . GetDelegateForFunctionPointer < lua_Hook > ( ret ) ;
678678 }
679679
680680 [ DllImport ( DllName , CallingConvention = Convention ) ]
@@ -827,7 +827,7 @@ public static int luaL_loadfile(lua_State L, string f)
827827 public static extern void _luaL_requiref ( lua_State L , string modname , nint openf , int glb ) ;
828828 public static void luaL_requiref ( lua_State L , string modname , lua_CFunction ? openf , int glb )
829829 {
830- _luaL_requiref ( L , modname , openf == null ? nint . Zero : Marshal . GetFunctionPointerForDelegate < lua_CFunction > ( openf ) , glb ) ;
830+ _luaL_requiref ( L , modname , openf == null ? ( ( nint ) 0 ) : Marshal . GetFunctionPointerForDelegate < lua_CFunction > ( openf ) , glb ) ;
831831 }
832832
833833 public static void luaL_newlibtable ( lua_State L , luaL_Reg [ ] l )
@@ -921,7 +921,7 @@ public static void luaL_addchar(luaL_Buffer B, byte c)
921921 {
922922 if ( B . n >= B . size )
923923 luaL_prepbuffsize ( B , 1 ) ;
924- Marshal . WriteByte ( new nint ( B . b . ToInt64 ( ) + ( long ) B . n ) , c ) ;
924+ Marshal . WriteByte ( B . b + ( nint ) B . n , c ) ;
925925 B . n += 1 ;
926926 }
927927
0 commit comments