Table 按照 lua 语言的定义,需要具有四种基本操作:读,写,迭代和获取长度。lua中没有删除操作,而是将对应 key 的值置为 nil。 写操作被实现为查询已有 key,若不存在则创建新 key。得到key 后,写入操作就是一次赋值。所以,在table 模块中,实际实现的基本操作为:创建,查询,迭代和获取长度。 创建操作的 api 为lu...
gc是一个指针, 它可以指向的类型由联合体GCObject定义, 从图中可以看出, 有string, userdata, closure, table, proto, upvalue, thread lua中, number, boolean, nil, light userdata四种类型的值是直接存在栈上元素里的, 和垃圾回收无关. lua中, string, table, closure, userdata, thread存在栈上元素里的只...
** Union of all Lua values */typedef union Value{struct GCObject*gc;/* collectable objects */void*p;/* light userdata */lua_CFunction f;/* light C functions */lua_Integer i;/* integer numbers */lua_Number n;/* float numbers */}Value;/* ** Tagged Values. This is the basic rep...
** Common Header for all collectable objects (in macro form, to be ** included in other objects) */ #define CommonHeader GCObject *next; lu_byte tt; lu_byte marked ... typedef struct Table { CommonHeader; lu_byte flags; /* 1<<p means tagmethod(p) is not present */ lu_byte ls...
typedef union Value { GCObject *gc; /* collectable objects */ void *p; /* light userdata */ int b; /* booleans */ lua_CFunction f; /* light C functions */ lua_Integer i; /* integer numbers */ lua_Number n; /* float numbers */ } Value; struct lua_TValue { Value val...
最近新项目重新评估了一下protobuf的C/C++ -> Lua binding 方案。之前,使用最广泛的 Lua binding 方案应该是 云风 的 pbc 。但是这个库已经是作者弃坑好多年的状态了。我之前使用 pbc 的时候刚碰上 protobuf 3.0 刚出来,当时打了patch来适配 protobuf 3...
table是lua中唯一的聚合类型,不像c++的STL那样,拥有vector、map、set等多种容器,在lua中,只有table。 这8种类型以union的形式定义在TValue中 代码语言:txt AI代码解释 typedef union Value { GCObject *gc; /* collectable objects */ void *p; /* light userdata */ ...
所以,需要引入第三态:触碰过的对象(The Touched Objects)。 当back barrier 需要解决old对象指向young对象的问题时,old对象被标记为触碰过,并放入一个特别的集合。 被触碰的对象在minor过程中也会参与遍历,但是不会被清理。被触碰的对象如果不再被触碰,那么在活过两次后,它会回到old集合。
Objects(对象/物体) 对象是真实存在于桌游模拟器中的任何物体。对于我们的例子来说,就是两个立方体和一个标记(真的是搞了个麻烦的游戏)我们可以用脚本来控制游戏中的物体进行移动,为他们增加按钮或者执行其他各种操作。我们将重新开始编写Global.lua,清空里面所有的文字。
table是lua中唯一的聚合类型,不像c++的STL那样,拥有vector、map、set等多种容器,在lua中,只有table。 这8种类型以union的形式定义在TValue中 typedef union Value{GCObject*gc;/* collectable objects */void*p;/* light userdata */int b;/* booleans */lua_CFunction f;/* light C functions */lua_In...