1.

static int mytest(lua_State *L) {
//获取上值
int upv = (int)lua_tonumber(L, lua_upvalueindex());
printf("%d\n", upv);
upv += ;
lua_pushinteger(L, upv);
lua_replace(L, lua_upvalueindex()); //获取一般参数
printf("%d\n", (int)lua_tonumber(L,)); return ;
} int main(void) {
lua_State *L = luaL_newstate();
luaL_openlibs(L); //设置Cclosure函数的上值
lua_pushinteger(L,);
lua_pushinteger(L,);
lua_pushcclosure(L,mytest,);
 lua_setglobal(L,"upvalue_test");

http://www.cnblogs.com/biyeqingfeng/p/4990101.html

05-11 21:42