Lua学习---c和lua的交互之表的操作
来源:互联网 发布:php 文件缓存 编辑:程序博客网 时间:2024/06/02 04:31
lua_gettablelua_getglobal(L, "mytable") <== push mytable
lua_pushnumber(L, 1) <== push key 1
lua_gettable(L, -2) <== pop key 1, push mytable[1]
lua_settable
lua_getglobal(L, "mytable") <== push mytable
lua_pushnumber(L, 1) <== push key 1
lua_pushstring(L, "abc") <== push value "abc"
lua_settable(L, -3) <== mytable[1] = "abc", pop key & value
lua_rawget:
用法同lua_gettable,但更快(因为当key不存在时不用访问元方法__index)
lua_rawset:
用法同lua_settable,但更快(因为当key不存在时不用访问元方法__newindex)
lua_rawgeti必须为数值键
lua_getglobal(L, "mytable") <== push mytable
lua_rawgeti(L, -1, 1) <== push mytable[1],作用同下面两行调用
--lua_pushnumber(L, 1) <== push key 1
--lua_rawget(L,-2) <== pop key 1, push mytable[1]
lua_rawseti必须为数值键
lua_getglobal(L, "mytable") <== push mytable
lua_pushstring(L, "abc") <== push value "abc"
lua_rawseti(L, -2, 1) <== mytable[1] = "abc", pop value "abc"
lua_getfield必须为字符串键
lua_getglobal(L, "mytable") <== push mytable
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_setfield(L, -2, "x") <== mytable["x"] = "abc", pop value "abc"
0 0
- Lua学习---c和lua的交互之表的操作
- lua和c的交互
- lua和c的交互
- lua和c的交互
- lua和c的交互
- lua和c的交互
- lua和c的交互
- lua和c的交互
- lua和c的交互
- lua和c的交互
- lua和c的交互
- lua和c的交互
- lua 与的C api交互操作
- 通过例子学习Lua(5)--Lua与C的交互
- [C#/Lua]C#和Lua交互的Demo
- Lua学习之路_C#与Lua的交互001
- C/C++和Lua的交互
- Lua和C/C++的交互
- Android数据类型互换
- NSObject class和NSObject protocol的关系(抽象基类与协议)
- 非常详细的/etc/passwd解释
- Rotate Image
- linux下的C语言开发(进程等待)
- Lua学习---c和lua的交互之表的操作
- linux下的C语言开发(信号处理)
- jquery与其它js文件冲突解决办法
- Cocos2d-android中常用类及其方法的功能
- JRE System Library [jdk1.7]和Server Library [Apache Tomcat v6.0]为绑定错误解决方案
- php全局变量漏洞 $GLOBALS
- linux下的C语言开发(管道通信)
- OpenCV之图像基本操作
- PHP全局变量与SESSION 漏洞(global 与 session)