webmcp
changeset 141:ca27aae3f1a1
Finished removing all upvalues from JSON library
author | jbe |
---|---|
date | Wed Jul 30 01:47:01 2014 +0200 (2014-07-30) |
parents | 641619d3fcb1 |
children | a686ed2ce967 |
files | libraries/json/json.c |
line diff
1.1 --- a/libraries/json/json.c Wed Jul 30 01:37:57 2014 +0200 1.2 +++ b/libraries/json/json.c Wed Jul 30 01:47:01 2014 +0200 1.3 @@ -3,14 +3,6 @@ 1.4 #include <stdlib.h> 1.5 #include <string.h> 1.6 1.7 -#define JSON_UPVAL_LIBRARY lua_upvalueindex(1) 1.8 -#define JSON_UPVAL_NULLMARK lua_upvalueindex(2) 1.9 -#define JSON_UPVAL_SHADOWTBL lua_upvalueindex(3) 1.10 -#define JSON_UPVAL_TYPES lua_upvalueindex(4) 1.11 -#define JSON_UPVAL_METATABLE lua_upvalueindex(5) 1.12 -#define JSON_UPVAL_PAIRS_ITERFUNC lua_upvalueindex(6) 1.13 -#define JSON_UPVAL_IPAIRS_ITERFUNC lua_upvalueindex(7) 1.14 - 1.15 #define JSON_REGENT static char 1.16 #define JSON_REGREF void * 1.17 1.18 @@ -530,15 +522,19 @@ 1.19 return 1; 1.20 } 1.21 1.22 +#define json_index_nullmark_idx 3 1.23 +#define json_index_shadowtbl_idx 4 1.24 + 1.25 static int json_index(lua_State *L) { 1.26 lua_settop(L, 2); 1.27 + json_regfetch(L, json_nullmark); // on stack position 3 1.28 json_regfetch(L, json_shadowtbl); 1.29 lua_pushvalue(L, 1); 1.30 - lua_rawget(L, -2); 1.31 + lua_rawget(L, json_index_shadowtbl_idx); 1.32 if (lua_isnil(L, -1)) return luaL_error(L, "Shadow table not found"); 1.33 lua_pushvalue(L, 2); 1.34 lua_rawget(L, -2); 1.35 - if (lua_rawequal(L, -1, JSON_UPVAL_NULLMARK)) lua_pushnil(L); 1.36 + if (lua_rawequal(L, -1, json_index_nullmark_idx)) lua_pushnil(L); 1.37 return 1; 1.38 } 1.39