如果我有一个Table
包含 functions getValue()
,setValue()
等的全局表。我可以存储对的引用Table.getValue
还是必须存储对的引用Table
然后调用成员函数?
lua_getglobal(L, "Table");
lua_getfield(L, -1, "getValue");
getValueRef = luaL_ref(L, LUA_REGISTRYINDEX);
lua_getfield(L, -1, "setValue");
setValueRef = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pop(L, 1); // Pop "Table" off of the stack