39:a0a7f7ebca3f | 63:1b8cbf640378 |
---|---|
8 #include <lua.h> | 8 #include <lua.h> |
9 #include <lauxlib.h> | 9 #include <lauxlib.h> |
10 #include <assert.h> | 10 #include <assert.h> |
11 | 11 |
12 #define EVENT_BASE_MT "EVENT_BASE_MT" | 12 #define EVENT_BASE_MT "EVENT_BASE_MT" |
13 | |
14 #ifdef _WIN32 | |
15 #include <winsock2.h> | |
16 #endif | |
13 | 17 |
14 le_base* event_base_get(lua_State* L, int idx) { | 18 le_base* event_base_get(lua_State* L, int idx) { |
15 return (le_base*)luaL_checkudata(L, idx, EVENT_BASE_MT); | 19 return (le_base*)luaL_checkudata(L, idx, EVENT_BASE_MT); |
16 } | 20 } |
17 | 21 |
116 } | 120 } |
117 } | 121 } |
118 | 122 |
119 /* Verified ok */ | 123 /* Verified ok */ |
120 int luaopen_luaevent_core(lua_State* L) { | 124 int luaopen_luaevent_core(lua_State* L) { |
125 #ifdef _WIN32 | |
126 WORD wVersionRequested = MAKEWORD(2, 2); | |
127 WSADATA wsaData; | |
128 WSAStartup(wVersionRequested, &wsaData); | |
129 #endif | |
130 event_init( ); | |
121 /* Register external items */ | 131 /* Register external items */ |
122 event_callback_register(L); | 132 event_callback_register(L); |
123 event_buffer_register(L); | 133 event_buffer_register(L); |
124 /* Setup metatable */ | 134 /* Setup metatable */ |
125 luaL_newmetatable(L, EVENT_BASE_MT); | 135 luaL_newmetatable(L, EVENT_BASE_MT); |
132 | 142 |
133 luaL_register(L, "luaevent.core", funcs); | 143 luaL_register(L, "luaevent.core", funcs); |
134 setNamedIntegers(L, consts); | 144 setNamedIntegers(L, consts); |
135 return 1; | 145 return 1; |
136 } | 146 } |
147 |