diff options
Diffstat (limited to 'lib/supple/capi.c')
-rw-r--r-- | lib/supple/capi.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/supple/capi.c b/lib/supple/capi.c index 34e6169..e12521d 100644 --- a/lib/supple/capi.c +++ b/lib/supple/capi.c @@ -106,6 +106,13 @@ supple_capi_proxy_type(lua_State *L) } static int +supple_capi_fake_gc(lua_State *L) +{ + (void)L; + return 0; +} + +static int supple_capi_new_proxy(lua_State *L) { void *proxy_ptr; @@ -128,6 +135,9 @@ supple_capi_new_proxy(lua_State *L) lua_pushvalue(L, 1); lua_pushcclosure(L, supple_capi_proxy_type, 1); lua_setfield(L, -2, "__type"); + /* put a dummy __gc so that the fasttm stuff doesn't bite us later */ + lua_pushcclosure(L, supple_capi_fake_gc, 0); + lua_setfield(L, -2, "__gc"); /* And now prevent anything poking in us later */ lua_pushboolean(L, 1); lua_setfield(L, -2, "__metatable"); @@ -438,7 +448,11 @@ supple_capi_functions[] = { int luaopen_supple_capi(lua_State *L) { +#if (LUA_VERSION_NUM > 501) + luaL_newlib(L, supple_capi_functions); +#else luaL_register(L, "supple.capi", supple_capi_functions); +#endif lua_pushnumber(L, CAPI_API); lua_setfield(L, -2, "_API"); lua_pushnumber(L, CAPI_ABI); |