| 1850 | |
| 1851 | |
| 1852 | static void createmetatable (lua_State *L) { |
| 1853 | /* table to be metatable for strings */ |
| 1854 | luaL_newlibtable(L, stringmetamethods); |
| 1855 | luaL_setfuncs(L, stringmetamethods, 0); |
| 1856 | lua_pushliteral(L, ""); /* dummy string */ |
| 1857 | lua_pushvalue(L, -2); /* copy table */ |
| 1858 | lua_setmetatable(L, -2); /* set table as metatable for strings */ |
| 1859 | lua_pop(L, 1); /* pop dummy string */ |
| 1860 | lua_pushvalue(L, -2); /* get string library */ |
| 1861 | lua_setfield(L, -2, "__index"); /* metatable.__index = string */ |
| 1862 | lua_pop(L, 1); /* pop metatable */ |
| 1863 | } |
| 1864 | |
| 1865 | |
| 1866 | /* |
no test coverage detected