| 108 | {NULL,NULL} |
| 109 | }; |
| 110 | static int luaopen_array(lua_State *L){ |
| 111 | /*创建数组userdata将要用到的metatable*/ |
| 112 | luaL_newmetatable(L,"LuaBook.array"); |
| 113 | luaL_openlib(L,"array",arraylib,0); |
| 114 | |
| 115 | /*now the statck has the metatable at index 1 and |
| 116 | * 'array' at index 2*/ |
| 117 | lua_pushstring(L,"__index"); |
| 118 | lua_pushstring(L,"get"); |
| 119 | lua_gettable(L,2); /*get array.get*/ |
| 120 | lua_settable(L,1); /*metatable.__index - array.get*/ |
| 121 | |
| 122 | lua_pushstring(L,"__newindex"); |
| 123 | lua_pushstring(L,"set"); |
| 124 | lua_gettable(L,2); /*get array.get*/ |
| 125 | lua_settable(L,1); /*metatable.__newindex - array.get*/ |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | #endif |
| 130 |
nothing calls this directly
no test coverage detected