lua(1)
来源:互联网 发布:我的世界java官方版 编辑:程序博客网 时间:2024/06/14 03:57
重拾lua的学习~
大概的看了一下,小小的lua用的内容可是不少,boost template auto_ptr policy............
对于 匿名对象 和 各种操作符的重载 简直炉火纯青哇
scope& operator,(scope s)
namespace_& operator[](scope s);
void operator[](scope s)
{
using namespace luabind;
module(L)[
def("funName", &funName),
class_<CGuiNpcDialog>("CGuiNpcDialog").def("funName2", CGuiNpcDialog::funName2).def(......)
]
}
module(L)是一个匿名对象,并且重载了[]操作符(void operator[](scope s))
def返回的是scope对象,scope对象又重载了,操作符(scope& operator,(scope s))并且返回当前对象的引用
class_<CGuiNpcDialog>("CGuiNpcDialog").也是一个匿名对象,并且是继承scope 的,所以可以直接转scope,它的成员函数def也是返回的class_& ,所以也可连续的调用
lua的栈的索引可以是 1 2 3 也可以是-1 -2 -3 ,如果是A 是-1 ,push B后 A就下移动变为-2 所以-1是栈顶
width =200;
heigh = 300;
void load(lua_State* L, const char* fname , int* w, int* h)
{
if ( luaL_loadfile(L, fname) || lua_pcall(L, 0, 0 ,0 ) )
error(...)
lua_getglobal( L , "width");
lua_getglobal( L, "height" );
if( ! lua_isnumber(L, -2) )
error( L, "width should be a number");
if( ! lua_isnumber(L , -1) )
error(...);
*w = lua_tointeger( L, -2);
*h = lua_tointerger(L, -1);
}
这是一段很简单的代码
lua_getglobal 的每一次调用,都会将相应的全局变量值压入栈中,如果栈非空,只能用 负数索引 -1 -2
- lua(1)
- Lua - 1
- Lua(1)
- lua(1)
- [Lua-1] Metatable In Lua
- 【Lua】【1】探讨Lua基础知识
- Lua笔记1-lua是什么
- lua(1):lua,luarocks介绍及lua库安装
- Lua学习(1),编译Lua与 HelloWorld
- Lua游戏脚本开发1 -- 初始化Lua
- (1)Lua简介之Lua入门
- Lua教程(1): C++嵌入Lua脚本
- 自学Lua(1)--Lua语法特点
- Lua教程: C++嵌入Lua脚本(1)
- Lua.1 lua的类型与变量
- Lua基础(1)--初识lua
- Lua-1:Sublime Text3配置Lua环境
- 我是Lua初学者【1】
- 在Spring中使用JTA事务管理
- inputStream 数据分段传输问题
- 开发那点事1
- CoroutineScheduler
- 以公司实际应用讲解OpenStack到底是什么
- lua(1)
- IOS基础开发二(iphone计算器)
- 程序编译运行时头文件或动态链接库的查找
- 受限的玻尔兹曼机
- 关于Android XML文件的解析方式DOM,SAX,Pull的具体实现。
- 黑马程序员——String str1="abc";String str2=new String("abc");内部原理剖析
- experiment : test CreateProcessWithLogonW
- spoj 4491. Primes in GCD Table 莫比乌斯反演
- 大型企业为何要用腾讯通RTX?甚至很多政府机关也在用RTX