@@ -167,8 +167,12 @@ public static int lua_upvalueindex(int i)
167167 public const int LUA_RIDX_GLOBALS = 2 ;
168168 public const int LUA_RIDX_LAST = LUA_RIDX_GLOBALS ;
169169
170- [ DllImport ( DllName , CallingConvention = Convention ) ]
171- public static extern lua_State lua_newstate ( lua_Alloc f , voidp ud ) ;
170+ [ DllImport ( DllName , CallingConvention = Convention , EntryPoint = "lua_newstate" ) ]
171+ public static extern lua_State _lua_newstate ( charp f , voidp ud ) ;
172+ public static lua_State lua_newstate ( lua_Alloc ? f , voidp ud )
173+ {
174+ return _lua_newstate ( f == null ? IntPtr . Zero : Marshal . GetFunctionPointerForDelegate < lua_Alloc > ( f ) , ud ) ;
175+ }
172176
173177 [ DllImport ( DllName , CallingConvention = Convention ) ]
174178 public static extern void lua_close ( lua_State L ) ;
@@ -438,11 +442,19 @@ public static int lua_pcall(lua_State L, int n, int r, int f)
438442 return lua_pcallk ( L , n , r , f , null , null ) ;
439443 }
440444
441- [ DllImport ( DllName , CallingConvention = Convention ) ]
442- public static extern int lua_load ( lua_State L , lua_Reader reader , voidp dt , string chunkname , string ? mode ) ;
445+ [ DllImport ( DllName , CallingConvention = Convention , EntryPoint = "lua_load" ) ]
446+ public static extern int _lua_load ( lua_State L , charp reader , voidp dt , string chunkname , string ? mode ) ;
447+ public static int lua_load ( lua_State L , lua_Reader ? reader , voidp dt , string chunkname , string ? mode )
448+ {
449+ return _lua_load ( L , reader == null ? IntPtr . Zero : Marshal . GetFunctionPointerForDelegate < lua_Reader > ( reader ) , dt , chunkname , mode ) ;
450+ }
443451
444- [ DllImport ( DllName , CallingConvention = Convention ) ]
445- public static extern int lua_dump ( lua_State L , lua_Writer writer , voidp data , int strip ) ;
452+ [ DllImport ( DllName , CallingConvention = Convention , EntryPoint = "lua_dump" ) ]
453+ public static extern int _lua_dump ( lua_State L , charp writer , voidp data , int strip ) ;
454+ public static int lua_dump ( lua_State L , lua_Writer ? writer , voidp data , int strip )
455+ {
456+ return _lua_dump ( L , writer == null ? IntPtr . Zero : Marshal . GetFunctionPointerForDelegate < lua_Writer > ( writer ) , data , strip ) ;
457+ }
446458
447459 [ DllImport ( DllName , CallingConvention = Convention , EntryPoint = "lua_yieldk" ) ]
448460 public static extern int _lua_yieldk ( lua_State L , int nresults , charp ctx , charp k ) ;
@@ -465,8 +477,12 @@ public static int lua_yield(lua_State L, int n)
465477 return lua_yieldk ( L , n , null , null ) ;
466478 }
467479
468- [ DllImport ( DllName , CallingConvention = Convention ) ]
469- public static extern void lua_setwarnf ( lua_State L , lua_WarnFunction f , voidp ud ) ;
480+ [ DllImport ( DllName , CallingConvention = Convention , EntryPoint = "lua_setwarnf" ) ]
481+ public static extern void _lua_setwarnf ( lua_State L , charp f , voidp ud ) ;
482+ public static void lua_setwarnf ( lua_State L , lua_WarnFunction ? f , voidp ud )
483+ {
484+ _lua_setwarnf ( L , f == null ? IntPtr . Zero : Marshal . GetFunctionPointerForDelegate < lua_WarnFunction > ( f ) , ud ) ;
485+ }
470486
471487 [ DllImport ( DllName , CallingConvention = Convention ) ]
472488 public static extern void lua_warning ( lua_State L , string msg , int tocont ) ;
@@ -503,10 +519,14 @@ public static int lua_yield(lua_State L, int n)
503519 public static extern size_t lua_stringtonumber ( lua_State L , string s ) ;
504520
505521 [ DllImport ( DllName , CallingConvention = Convention ) ]
506- public static extern lua_Alloc lua_getallocf ( lua_State L , ref voidp ud ) ;
522+ public static extern lua_Alloc lua_getallocf ( lua_State L , out voidp ud ) ;
507523
508- [ DllImport ( DllName , CallingConvention = Convention ) ]
509- public static extern void lua_setallocf ( lua_State L , lua_Alloc f , voidp ud ) ;
524+ [ DllImport ( DllName , CallingConvention = Convention , EntryPoint = "lua_setallocf" ) ]
525+ public static extern void _lua_setallocf ( lua_State L , charp f , voidp ud ) ;
526+ public static void lua_setallocf ( lua_State L , lua_Alloc ? f , voidp ud )
527+ {
528+ _lua_setallocf ( L , f == null ? IntPtr . Zero : Marshal . GetFunctionPointerForDelegate < lua_Alloc > ( f ) , ud ) ;
529+ }
510530
511531 [ DllImport ( DllName , CallingConvention = Convention ) ]
512532 public static extern void lua_toclose ( lua_State L , int idx ) ;
@@ -693,11 +713,20 @@ public static int lua_setuservalue(lua_State L, int idx)
693713 [ DllImport ( DllName , CallingConvention = Convention ) ]
694714 public static extern void lua_upvaluejoin ( lua_State L , int fidx1 , int n1 , int fidx2 , int n2 ) ;
695715
696- [ DllImport ( DllName , CallingConvention = Convention ) ]
697- public static extern void lua_sethook ( lua_State L , lua_Hook func , int mask , int count ) ;
716+ [ DllImport ( DllName , CallingConvention = Convention , EntryPoint = "lua_sethook" ) ]
717+ public static extern void _lua_sethook ( lua_State L , charp func , int mask , int count ) ;
718+ public static void lua_sethook ( lua_State L , lua_Hook ? func , int mask , int count )
719+ {
720+ _lua_sethook ( L , func == null ? IntPtr . Zero : Marshal . GetFunctionPointerForDelegate < lua_Hook > ( func ) , mask , count ) ;
721+ }
698722
699- [ DllImport ( DllName , CallingConvention = Convention ) ]
700- public static extern lua_Hook lua_gethook ( lua_State L ) ;
723+ [ DllImport ( DllName , CallingConvention = Convention , EntryPoint = "lua_gethook" ) ]
724+ public static extern charp _lua_gethook ( lua_State L ) ;
725+ public static lua_Hook ? lua_gethook ( lua_State L )
726+ {
727+ charp ret = _lua_gethook ( L ) ;
728+ return ret == IntPtr . Zero ? null : Marshal . GetDelegateForFunctionPointer < lua_Hook > ( ret ) ;
729+ }
701730
702731 [ DllImport ( DllName , CallingConvention = Convention ) ]
703732 public static extern int lua_gethookmask ( lua_State L ) ;
@@ -855,7 +884,7 @@ public static int luaL_loadfile(lua_State L, string f)
855884 [ DllImport ( DllName , CallingConvention = Convention ) ]
856885 public static extern void luaL_traceback ( lua_State L , lua_State L1 , string msg , int level ) ;
857886
858- [ DllImport ( DllName , CallingConvention = Convention ) ]
887+ [ DllImport ( DllName , CallingConvention = Convention , EntryPoint = "luaL_requiref" ) ]
859888 public static extern void _luaL_requiref ( lua_State L , string modname , charp openf , int glb ) ;
860889 public static void luaL_requiref ( lua_State L , string modname , lua_CFunction ? openf , int glb )
861890 {
0 commit comments