void luawtWServer(lua_State* L) { luaL_newmetatable(L, "luawt_WServer"); my_setfuncs(L, WServer_mt); lua_newtable(L); my_setfuncs(L, WServer_methods); lua_setfield(L, -2, "__index"); lua_pop(L, 1); // mt // put make to luawt luaL_getmetatable(L, "luawt"); lua_pushcfunction(L, wrap<luawt_WServer_make>::func); lua_setfield(L, -2, "WServer"); lua_pop(L, 1); // luawt }
// create metatables of types, add them to the registry void register_types(lua_State* L) { // metatable of RoteTerm luaL_newmetatable(L, "rote_RoteTerm"); my_setfuncs(L, RoteTerm_mt); lua_pushvalue(L, -1); lua_setfield(L, -2, "__index"); // mt.__index = mt lua_pop(L, 1); // metatable of RoteSnapshot luaL_newmetatable(L, "rote_RoteSnapshot"); my_setfuncs(L, RoteSnapshot_mt); lua_pushvalue(L, -1); lua_setfield(L, -2, "__index"); // mt.__index = mt lua_pop(L, 1); }