| 269 | } |
| 270 | |
| 271 | static FfiFuncWrapper *newfuncwrapper (lua_State *L) { |
| 272 | auto fw = new (lua_newuserdata(L, sizeof(FfiFuncWrapper))) FfiFuncWrapper(); |
| 273 | if (luaL_newmetatable(L, "pluto:ffi-funcwrapper")) { |
| 274 | lua_pushliteral(L, "__gc"); |
| 275 | lua_pushcfunction(L, [](lua_State *L) { |
| 276 | pluto_errorifnotgc(L); |
| 277 | std::destroy_at<>(checkfuncwrapper(L, 1)); |
| 278 | return 0; |
| 279 | }); |
| 280 | lua_settable(L, -3); |
| 281 | } |
| 282 | lua_setmetatable(L, -2); |
| 283 | lua_pushcclosure(L, ffi_funcwrapper_call, 1); |
| 284 | return fw; |
| 285 | } |
| 286 | |
| 287 | static int ffi_lib_wrap (lua_State *L) { |
| 288 | auto fw = newfuncwrapper(L); |
no test coverage detected