找到文档看了下,原来lua_tolstring只支持number和string类型,但是对于number类型,在取值后也会转换其在表中的实际内容为string,而我遍历的表是使用默认自增索引作为key的,这样对key调用这个函数会导致key变成字符串,因而遍历有问题。 如果表的key不一定是string,而又要用lua_tolstring获取它的值,那么建议先在栈上复制...
因此,标准 Lua 语言的代码可以不加修改地运行在 LuaJIT 之上。LuaJIT 和标准 Lua 解释器的一大区别是,LuaJIT 的执行速度,即使是其汇编编写的 Lua 解释器,也要比标准 Lua 5.1 解释器快很多,可以说是一个高效的 Lua 实现。另一个区别是,LuaJIT 支持比标准 Lua 5.1 语言更多的基本原语和特性,因此功能上也要更加...
lua_tolstring const char *lua_tolstring (lua_State *L, int index, size_t *len); Converts the Lua value at the given acceptable index to a string (const char*). Iflenis notNULL, it also sets*lenwith the string length. The Lua value must be a string or a number; otherwise, the f...