MCPcopy Create free account
hub / github.com/PlutoLang/Pluto / newfuncwrapper

Function newfuncwrapper

src/lffi.cpp:271–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271static 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
287static int ffi_lib_wrap (lua_State *L) {
288 auto fw = newfuncwrapper(L);

Callers 2

ffi_lib_wrapFunction · 0.85
ffi_lib_cdefFunction · 0.85

Calls 6

luaL_newmetatableFunction · 0.85
pluto_errorifnotgcFunction · 0.85
checkfuncwrapperFunction · 0.85
lua_settableFunction · 0.85
lua_setmetatableFunction · 0.85
lua_pushcclosureFunction · 0.85

Tested by

no test coverage detected