lua_getfield(L, -1, "x") <== push mytable["x"],作用同下面两行调用 --lua_pushstring(L, "x") <== push key "x" --lua_gettable(L,-2) <== pop key "x", push mytable["x"] lua_setfield必须为字符串键 lua_getglobal(L, "mytable") <== push mytable lua_pushstring(L, "abc") <== push value "abc" lua_set...
在 Lua 中,这个函数可能触发对应 "index" 事件的元方法(参见 §2.8)。 lua_getglobal void lua_getglobal (lua_State *L, const char *name); 1. 把全局变量 name 里的值压入堆栈。这个是用一个宏定义出来的: #define lua_getglobal(L,s) lua_getfield...
void lua_getfield (lua_State *L, int index, const char *k); 把t[k]值压入堆栈,这里的t是指有效索引index指向的值。在 Lua 中,这个函数可能触发对应 "index" 事件的元方法(参见§2.8)。 lua_getglobal void lua_getglobal (lua_State *L, const char *name); 把全局变量name里的值压入堆栈。这...
问lua_getfield的奇怪行为EN我有两个弹簧启动应用程序(1.4.3.RELEASE),它们位于同一台服务器上.应用...
lua_getfield(L, -1, "x"); /* 压入 t.x 的值(第 2 个参数)*/ lua_remove(L, -2); /* 从堆栈中移去 't' */ lua_pushinteger(L, 14); /* 第 3 个参数 */ lua_call(L, 3, 1); /* 调用 'f',传入 3 个参数,并索取 1 个返回值 */ ...
lua_getfield# [-0, +1, e] int lua_getfield (lua_State *L, int index, const char *k); 把t[k] 的值压栈, 这里的 t 是索引指向的值。 在 Lua 中,这个函数可能触发对应 “index” 事件对应的元方法 (参见 §2.4)。 函数将返回压入值的类型。 lua_getextraspace# [-0, +0, –] void...
lua_getfield是用来取出lua中的一个值,一般都是先找到table所在的位置索引index,然后传入key,取出值。 1、lua_getfield(L, LUA_GLOBALSINDEX, key) 等价于 lua_getglobal(L,key) 含义:从全局表中取出key字段的值 2、lua_getfield(L, index, key) 等价于:lua_pushstring(L,key) lua_gettable(L,ind...
lua_getfield(L, LUA_GLOBALSINDEX, "f"); /* function to be called */ lua_pushstring(L, "how"); /* 1st argument */ lua_getfield(L, LUA_GLOBALSINDEX, "t"); /* table to be indexed */ lua_getfield(L, -1, "x"); /* push result of t.x (2nd arg) */ lua_remove(L, -2...
lua_newtable(lua_state); 创建一个新的表并把它压入栈中。 int lua_getfield (lua_State *L, int index, const char *k); 把 t[k] 的值压栈, 这里的 t 是索引指向的表。 在 Lua 中,这个函数可能触发对应 "index" 事件对应的元方法 ,函数将返回压入值的...
void lua_getfield (lua_State *L, int index, const char *k);把t[k]值压⼊堆栈,这⾥的t是指有效索引index指向的值。在 Lua 中,这个函数可能触发对应 "index" 事件的元⽅法(参见)。void lua_getglobal (lua_State *L, const char *name);把全局变量name⾥的值压⼊堆栈。这个是⽤⼀...