lua_pushvalue:Pushes a copy of the element at the given valid index onto the stack ,也就是说复制指定索引的值到栈顶,指定索引的值不变,影响栈大小。 lua_remove:Removes the element at the given valid index, shifting down the elements
lua_pushvalue# [-0, +1, –] void lua_pushvalue (lua_State *L, int index); 把栈上给定索引处的元素作一个副本压栈。 lua_pushvfstring# [-0, +1, e] const char *lua_pushvfstring (lua_State *L, const char *fmt, va_list argp); 等价于 lua_pushfstring, 不过是用 va_list 接收参数...
任何时候Lua调用C,都可以保证最少有LUA_MINSTACK个堆栈位置是可用 void lua_settop(lua_State* L,int index)//把堆栈的栈顶索引设置为指定的数值 #define lua_pop(L,n) lua_settop(L,-(n)-1)//用于把从栈顶开始的n个元素删除 void lua_pushvalue(lua_State* L,int index)//将栈上指定索引处的值...
void lua_pushvalue (lua_State *L, int index); Pushes a copy of the element at the given valid index onto the stack 如上所述, lua_pushvalue(L, -4) 并不是往栈顶插入元素-4, 而是把在栈中位置为-4的元素copy之后插入于栈顶中!!!
// 创建一个协程对象 static int luaB_cocreate (lua_State *L) { lua_State *NL; // 第一个参数一定是一个函数对象 luaL_checktype(L, 1, LUA_TFUNCTION); // 新建线程 NL = lua_newthread(L); lua_pushvalue(L, 1); /* move function to top */ // 将函数对象转移到NL lua_xmove(L, NL...
lua_pushvalue(L, -1); /* duplicate it */ lua_replace(L, lua_upvalueindex(1)); return 1; } lua_upvaluesindex(1) ,就是取出upvalues值,其索引为第一个参数。 由于这个参数并不是堆栈中索引,而是仅仅表示参数序位的索引,即,取出 upvalue的当前值。
} // 更新成功,从数组里剔除掉 lua_pushvalue(L, -2); lua_pushnil(L); lu...
lua_pushvalue void lua_pushvalue (lua_State *L, int index); 把堆栈上给定有效处索引处的元素作一个拷贝压栈。 lua_settable void lua_settable (lua_State *L, int index); 作一个等价于t[k] = v的操作, 这里t是一个给定有效索引index处的值,v指栈顶的值, 而k是栈顶之下的那个值。
(void*)&cls);// Stack: cl, "__index", clslua_pushvalue(L,-3);// Stack: cl, "__index", cls, cllua_pushcclosure(L,LuaCFunctions::StaticMemberMetaIndex,2);// Stack: cl, "__index", get_static_funclua_rawset(L,-3);// Stack: cl// Help namelua_pushliteral(L,"__tostring")...
voidlua_pushvalue(lua_State*L,int index);//将指定索引的元素副本压入栈。voidlua_remove(lua_State*L,int index);//删除指定索引上的元素,其上面的元素自动下移。voidlua_insert(lua_State*L,int index);//将栈顶元素插入到该索引值指向的位置。voidlua_replace(lua_State*L,int index);//弹出栈顶...