public static void OpenLibs(IntPtr L) { LuaDLL.lua_getglobal(L, "tolua"); LuaDLL.lua_pushstring(L, "findtype"); LuaDLL.lua_pushcfunction(L, FindType); LuaDLL.lua_rawset(L, -3); LuaDLL.lua_pushstring(L, "loadassembly"); LuaDLL.tolua_pushcsfunction(L, LoadAssembly); LuaDLL.lua_rawset(L, -3); LuaDLL.lua_pushstring(L, "getmethod"); LuaDLL.tolua_pushcsfunction(L, GetMethod); LuaDLL.lua_rawset(L, -3); LuaDLL.lua_pushstring(L, "getconstructor"); LuaDLL.tolua_pushcsfunction(L, GetConstructor); LuaDLL.lua_rawset(L, -3); LuaDLL.lua_pushstring(L, "gettypemethod"); LuaDLL.tolua_pushcsfunction(L, GetTypeMethod); LuaDLL.lua_rawset(L, -3); LuaDLL.lua_pushstring(L, "getfield"); LuaDLL.tolua_pushcsfunction(L, GetField); LuaDLL.lua_rawset(L, -3); LuaDLL.lua_pushstring(L, "getproperty"); LuaDLL.tolua_pushcsfunction(L, GetProperty); LuaDLL.lua_rawset(L, -3); LuaDLL.lua_pushstring(L, "createinstance"); LuaDLL.tolua_pushcsfunction(L, CreateInstance); LuaDLL.lua_rawset(L, -3); LuaDLL.lua_pop(L, 1); GLuaState state = GLuaState.Get(L); state.BeginPreLoad(); state.AddPreLoad("tolua.reflection", OpenReflectionLibs); state.EndPreLoad(); }