浏览代码

Support build for Lua 5.1 (for LuaJIT), Lua 5.2 and Lua 5.3 (Step 4/?)

See #195
bel2125 10 年之前
父节点
当前提交
5197106e0a
共有 3 个文件被更改,包括 9 次插入3 次删除
  1. 7 1
      src/civetweb_private_lua.h
  2. 0 2
      src/mod_lua.inl
  3. 2 0
      src/third_party/civetweb_lua.h

+ 7 - 1
src/civetweb_private_lua.h

@@ -1,5 +1,11 @@
-/* "lua_civet.h" */
+/* "civetweb_private_lua.h" */
 /* Project internal header to allow main.c to call a non-public function in
  * mod_lua.inl */
 
+#ifndef CIVETWEB_PRIVATE_LUA_H
+#define CIVETWEB_PRIVATE_LUA_H
+
 void civetweb_open_lua_libs(lua_State *L);
+
+#endif
+

+ 0 - 2
src/mod_lua.inl

@@ -1145,14 +1145,12 @@ static void prepare_lua_environment(struct mg_context *ctx,
 {
 	civetweb_open_lua_libs(L);
 
-#if LUA_VERSION_NUM != 501
 	luaL_newmetatable(L, LUASOCKET);
 	lua_pushliteral(L, "__index");
 	luaL_newlib(L, luasocket_methods);
 	lua_rawset(L, -3);
 	lua_pop(L, 1);
 	lua_register(L, "connect", lsp_connect);
-#endif
 
 	/* Store context in the registry */
 	if (ctx != NULL) {

+ 2 - 0
src/third_party/civetweb_lua.h

@@ -42,6 +42,8 @@
 #define lua_rawlen lua_objlen
 #define lua_newstate(a, b) luaL_newstate() /* Must use luaL_newstate() for 64 bit target */
 #define lua_pushinteger lua_pushnumber
+#define luaL_newlib(L, t) {luaL_Reg const *r = t; while (r->name) {lua_register(L, r->name, r->func); r++;}}
+
 
 #elif LUA_VERSION_NUM == 502
 /* Lua 5.2 detected */