43 int ret; |
43 int ret; |
44 lua_rawgeti(L, LUA_REGISTRYINDEX, arg->callbackRef); |
44 lua_rawgeti(L, LUA_REGISTRYINDEX, arg->callbackRef); |
45 lua_pushinteger(L, event); |
45 lua_pushinteger(L, event); |
46 if(lua_pcall(L, 1, 1, 0) || !lua_isnumber(L, -1)) { |
46 if(lua_pcall(L, 1, 1, 0) || !lua_isnumber(L, -1)) { |
47 printf("ERROR IN CB: %s\n", lua_tostring(L, -1)); |
47 printf("ERROR IN CB: %s\n", lua_tostring(L, -1)); |
|
48 lua_pop(L, 1); |
48 freeCallbackArgs(arg); |
49 freeCallbackArgs(arg); |
49 return; |
50 return; |
50 } |
51 } |
51 ret = lua_tointeger(L, -1); |
52 ret = lua_tointeger(L, -1); |
52 lua_pop(L, 1); |
53 lua_pop(L, 1); |
117 callbackRef = luaL_ref(L, LUA_REGISTRYINDEX); |
118 callbackRef = luaL_ref(L, LUA_REGISTRYINDEX); |
118 |
119 |
119 /* Call the callback with all arguments after it to get the loop primed.. */ |
120 /* Call the callback with all arguments after it to get the loop primed.. */ |
120 if(lua_pcall(L, top - 2, 1, 0) || !lua_isnumber(L, -1)) { |
121 if(lua_pcall(L, top - 2, 1, 0) || !lua_isnumber(L, -1)) { |
121 printf("ERROR IN INIT: %s\n", lua_tostring(L, -1)); |
122 printf("ERROR IN INIT: %s\n", lua_tostring(L, -1)); |
|
123 lua_pop(L, 1); |
122 return 0; |
124 return 0; |
123 } |
125 } |
124 ret = lua_tointeger(L, -1); |
126 ret = lua_tointeger(L, -1); |
125 lua_pop(L, 1); |
127 lua_pop(L, 1); |
126 if(ret == -1) { /* Done, no need to setup event */ |
128 if(ret == -1) { /* Done, no need to setup event */ |