| 24 | } |
| 25 | |
| 26 | void push_function_metatable(lua_State* L) |
| 27 | { |
| 28 | lua_rawgetp(L, LUA_REGISTRYINDEX, &function_tag); |
| 29 | |
| 30 | if (lua_istable(L, -1)) |
| 31 | return; |
| 32 | |
| 33 | lua_pop(L, 1); |
| 34 | |
| 35 | lua_createtable(L, 0, 1); // One non-sequence entry for __gc. |
| 36 | |
| 37 | lua_pushliteral(L, "__gc"); |
| 38 | lua_pushcfunction(L, &function_destroy); |
| 39 | lua_rawset(L, -3); |
| 40 | |
| 41 | lua_pushvalue(L, -1); |
| 42 | lua_rawsetp(L, LUA_REGISTRYINDEX, &function_tag); |
| 43 | } |
| 44 | |
| 45 | } // namespace unnamed |
| 46 |
no test coverage detected