git clone https://gitcode.com/funsion/CLua.git
在src文件夹下的ltm.c 表格操作函数,此模块是C语言编写的,是Lua语言中的一个库文件,主要用来提供元表操作的功能。
该库提供了许多函数,可以用来执行诸如__索引,__新索引,__加等Lua中的元表操作。
因技术问题,只保留中文版等的luaT_eventname[]数组列表。
- void luaT_init (lua_State *L) {
- static const char *const luaT_eventname[] = { /* ORDER TM */
- "__index", "__newindex",
- "__gc", "__mode", "__len", "__eq",
- "__add", "__sub", "__mul", "__mod", "__pow",
- "__div", "__idiv",
- "__band", "__bor", "__bxor", "__shl", "__shr",
- "__unm", "__bnot", "__lt", "__le",
- "__concat", "__call", "__close"
- };
- int i;
- for (i=0; i<TM_N; i++) {
- G(L)->tmname[i] = luaS_new(L, luaT_eventname[i]);
- luaC_fix(L, obj2gco(G(L)->tmname[i])); /* never collect these names */
- }
- }
- /* 初始化操作符和事件名称 */
- void luaT_init (lua_State *L) {
- /* 定义操作符和事件名称的数组。注:该数组必须按照特定的顺序排列。包括了Lua中各种特殊方法的名称。 */
- static const char *const luaT_eventname[] = {
- /* "__index", "__newindex",
- "__gc", "__mode", "__len", "__eq",
- "__add", "__sub", "__mul", "__mod", "__pow",
- "__div", "__idiv",
- "__band", "__bor", "__bxor", "__shl", "__shr",
- "__unm", "__bnot", "__lt", "__le",
- "__concat", "__call", "__close", 中文关键字 */
- "__索引","__新索引",
- "__垃圾回收", "__模式", "__长度", "__等于",
- "__加", "__减", "__乘", "__模", "__幂",
- "__除", "__整除",
- "__位与", "__位或", "__位异或", "__左移", "__右移",
- "__负", "__位非", "__小于", "__小于等于",
- "__连接", "__调用", "__关闭"
- };
- int i;
注意,在Window系统下编译Lua, 最好将所有Lua的源码,重新保存成ANSI格式的文件,刚下载的默认的源码会是UTF-8格式的。
这个事情说三遍,
1,不然就会出现,Window下的UTF-8源码可编译,但Shell里的中文输出会乱码。
2,要不然就是Window的ANSI源码不可编译(假如你没做以上步骤),
3,如果是用ANSI格式的源码编译的Lua.exe,对应的,你在Window下写的Lua程序也是需要保存成ANSI格式的。这样就可以在Shell里输出正确的中文显示