diff -r 728aafac9682 -r 48a109847dce src/event_callback.c --- a/src/event_callback.c Wed Sep 05 22:49:38 2007 -0400 +++ b/src/event_callback.c Wed Sep 05 23:05:05 2007 -0400 @@ -4,6 +4,8 @@ #include #include +#define EVENT_CALLBACK_ARG_MT "EVENT_CALLBACK_ARG_MT" + void freeCallbackArgs(le_callback* arg, lua_State* L) { if(arg->base) { arg->base = NULL; @@ -45,6 +47,20 @@ return 0; } +le_callback* event_callback_push(lua_State* L, int baseIdx, int callbackIdx) { + le_callback* cb; + le_base *base = event_base_get(L, baseIdx); + luaL_checktype(L, callbackIdx, LUA_TFUNCTION); + cb = lua_newuserdata(L, sizeof(*cb)); + luaL_getmetatable(L, EVENT_CALLBACK_ARG_MT); + lua_setmetatable(L, -2); + + lua_pushvalue(L, callbackIdx); + cb->callbackRef = luaL_ref(L, LUA_REGISTRYINDEX); + cb->base = base; + return cb; +} + int event_callback_register(lua_State* L) { luaL_newmetatable(L, EVENT_CALLBACK_ARG_MT); lua_pushcfunction(L, luaevent_cb_gc);