webmcp
diff framework/accelerator/webmcp_accelerator.c @ 64:3d43a5cf17c1
Compatibility with Lua 5.2
author | jbe |
---|---|
date | Sun Apr 15 16:04:33 2012 +0200 (2012-04-15) |
parents | 9fdfb27f8e67 |
children | afed1ab1477f |
line diff
1.1 --- a/framework/accelerator/webmcp_accelerator.c Tue Apr 03 00:56:02 2012 +0200 1.2 +++ b/framework/accelerator/webmcp_accelerator.c Sun Apr 15 16:04:33 2012 +0200 1.3 @@ -53,7 +53,11 @@ 1.4 lua_pushvalue(L, 1); 1.5 lua_gettable(L, -2); // get table by reference passed as 1st argument 1.6 lua_getfield(L, -1, "string_fragments"); 1.7 +#ifdef LUA_VERSION_NUM >= 502 1.8 + j = lua_rawlen(L, -1); 1.9 +#else 1.10 j = lua_objlen(L, -1); 1.11 +#endif 1.12 for (i=2; i<=argc; i++) { 1.13 lua_pushvalue(L, i); 1.14 lua_rawseti(L, -2, ++j); 1.15 @@ -71,7 +75,11 @@ 1.16 lua_getfield(L, -2, "_active_slot"); 1.17 lua_gettable(L, -2); 1.18 lua_getfield(L, -1, "string_fragments"); 1.19 +#ifdef LUA_VERSION_NUM >= 502 1.20 + j = lua_rawlen(L, -1); 1.21 +#else 1.22 j = lua_objlen(L, -1); 1.23 +#endif 1.24 for (i=1; i<=argc; i++) { 1.25 lua_pushvalue(L, i); 1.26 lua_rawseti(L, -2, ++j); 1.27 @@ -108,7 +116,11 @@ 1.28 tag_given = 1; 1.29 } 1.30 } 1.31 +#ifdef LUA_VERSION_NUM >= 502 1.32 + j = lua_rawlen(L, 5); 1.33 +#else 1.34 j = lua_objlen(L, 5); 1.35 +#endif 1.36 if (tag_given) { 1.37 lua_pushliteral(L, "<"); 1.38 lua_rawseti(L, 5, ++j); 1.39 @@ -153,7 +165,11 @@ 1.40 lua_call(L, 0, 0); 1.41 // stack is now at position 7, but we don't care 1.42 // we assume that the active slot hasn't been exchanged or resetted 1.43 +#ifdef LUA_VERSION_NUM >= 502 1.44 + j = lua_rawlen(L, 5); // but it may include more elements now 1.45 +#else 1.46 j = lua_objlen(L, 5); // but it may include more elements now 1.47 +#endif 1.48 } else { 1.49 lua_pushcfunction(L, webmcp_encode_html); // 9 1.50 lua_pushvalue(L, 8); // 10