示例#1
0
文件: Lua.cs 项目: fengqk/Art
		public static void Lua_SetFuncsInTable(IntPtr L, LuaL_Reg[] funcs)
		{
			for (int i = 0; i < funcs.Length; ++i)
			{
				LuaDLL.lua_pushstdcallcfunction(L, funcs[i].func);
				LuaDLL.lua_setfield(L, -2, funcs[i].name);
			}
		}
示例#2
0
文件: Lua.cs 项目: fengqk/Art
		public static void LuaL_SetFuncs(IntPtr L ,string package, LuaL_Reg[] funcs)
		{
			bool exist = true;
			LuaDLL.lua_getglobal(L, package);
			if (LuaDLL.lua_isnil(L, -1))
			{
				exist = false;
				LuaDLL.lua_newtable(L);
			}
			Lua_SetFuncsInTable(L, funcs);
			if (!exist)
				LuaDLL.lua_setglobal(L, package);
			else
				LuaDLL.lua_pop(L, 1);
		}
示例#3
0
        public static void luaL_setfuncs(IntPtr luaState, LuaL_Reg[] funcs, int nup)
        {
            LuaDLL.wlua_getglobal(luaState, "cswrapfunc");             //nup,wrap

            for (int i = 0; i < funcs.Length; ++i)
            {
                LuaDLL.lua_pushvalue(luaState, -1);                  //nup,wrap,wrap
                LuaL_Reg reg = funcs[i];
                for (int j = 0; j < nup; ++j)
                {
                    lua_pushvalue(luaState, -nup);
                }                                              //nup,wrap,wrap,nup
                lua_pushcclosure(luaState, reg.func, nup);     //nup,wrap,wrap,f
                LuaDLL.lua_pcall(luaState, 1, 1, 0);           //nup,wrap,f0
                wlua_setfield(luaState, -(nup + 3), reg.name); //nup,wrap
            }
            lua_pop(luaState, nup + 1);
        }
示例#4
0
文件: Lua.cs 项目: fengqk/Art
		public static void LuaL_SetFuncs(IntPtr L ,string package, LuaL_Reg[] funcs)
		{
			bool exist = true;
			LuaDLL.lua_getglobal(L, package);
			if (LuaDLL.lua_isnil(L, -1))
			{
				exist = false;
				LuaDLL.lua_newtable(L);
			}

			for (int i = 0; i < funcs.Length; ++i)
			{
				LuaDLL.lua_pushstdcallcfunction(L, funcs[i].func);
				LuaDLL.lua_setfield(L, -2, funcs[i].name);
			}

			if (!exist)
				LuaDLL.lua_setglobal(L, package);
			else
				LuaDLL.lua_pop(L, 1);
		}