src/luaevent.c

changeset 69
da7e8688a2b5
parent 68
9e119bf833ae
child 72
adb5fa9ea85a
equal deleted inserted replaced
68:9e119bf833ae 69:da7e8688a2b5
24 le_base *base = (le_base*)lua_newuserdata(L, sizeof(le_base)); 24 le_base *base = (le_base*)lua_newuserdata(L, sizeof(le_base));
25 base->loop_L = NULL; /* No running loop */ 25 base->loop_L = NULL; /* No running loop */
26 base->base = event_init(); 26 base->base = event_init();
27 luaL_getmetatable(L, EVENT_BASE_MT); 27 luaL_getmetatable(L, EVENT_BASE_MT);
28 lua_setmetatable(L, -2); 28 lua_setmetatable(L, -2);
29 return 1;
30 }
31
32 int luaevent_libevent_version(lua_State* L) {
33 lua_pushstring(L, event_get_version());
29 return 1; 34 return 1;
30 } 35 }
31 36
32 static int luaevent_base_gc(lua_State* L) { 37 static int luaevent_base_gc(lua_State* L) {
33 le_base *base = event_base_get(L, 1); 38 le_base *base = event_base_get(L, 1);
113 { NULL, NULL } 118 { NULL, NULL }
114 }; 119 };
115 120
116 static luaL_Reg funcs[] = { 121 static luaL_Reg funcs[] = {
117 { "new", luaevent_newbase }, 122 { "new", luaevent_newbase },
123 { "libevent_version", luaevent_libevent_version },
118 { NULL, NULL } 124 { NULL, NULL }
119 }; 125 };
120 126
121 typedef struct { 127 typedef struct {
122 const char* name; 128 const char* name;

mercurial