src/event_callback.c

changeset 25
5778073d2903
parent 24
cda8e1a2dfa2
child 65
e65466cee871
equal deleted inserted replaced
24:cda8e1a2dfa2 25:5778073d2903
21 void luaevent_callback(int fd, short event, void* p) { 21 void luaevent_callback(int fd, short event, void* p) {
22 le_callback* cb = p; 22 le_callback* cb = p;
23 lua_State* L; 23 lua_State* L;
24 int ret; 24 int ret;
25 double newTimeout = -1; 25 double newTimeout = -1;
26 assert(cb && cb->base && cb->base->loop_L); 26 assert(cb);
27 if(!cb->base) {
28 /* Callback has been collected... die */
29 /* TODO: What should really be done here... */
30 return;
31 }
32 assert(cb->base->loop_L);
27 L = cb->base->loop_L; 33 L = cb->base->loop_L;
28 lua_rawgeti(L, LUA_REGISTRYINDEX, cb->callbackRef); 34 lua_rawgeti(L, LUA_REGISTRYINDEX, cb->callbackRef);
29 lua_pushinteger(L, event); 35 lua_pushinteger(L, event);
30 lua_call(L, 1, 2); 36 lua_call(L, 1, 2);
31 ret = lua_tointeger(L, -2); 37 ret = lua_tointeger(L, -2);

mercurial