MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / luaopen_array

Function luaopen_array

src/vm/luavm/luavm.cpp:110–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108 {NULL,NULL}
109};
110static 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

Callers

nothing calls this directly

Calls 5

luaL_newmetatableFunction · 0.85
luaL_openlibFunction · 0.85
lua_pushstringFunction · 0.85
lua_gettableFunction · 0.85
lua_settableFunction · 0.85

Tested by

no test coverage detected