webmcp
changeset 151:6d2bb696f736
Simplified C macros for Lua registry handling in JSON library (using lua_rawgetp API function)
author | jbe |
---|---|
date | Thu Jul 31 00:44:17 2014 +0200 (2014-07-31) |
parents | 35fb4f92a887 |
children | 7b5c13fdc2ec |
files | libraries/json/json.c |
line diff
1.1 --- a/libraries/json/json.c Wed Jul 30 23:11:38 2014 +0200 1.2 +++ b/libraries/json/json.c Thu Jul 31 00:44:17 2014 +0200 1.3 @@ -16,11 +16,11 @@ 1.4 // macros for usage of Lua registry: 1.5 #define JSON_REGENT char 1.6 #define JSON_REGPOINTER void * 1.7 -#define json_pushlightref(L, x) (lua_pushlightuserdata((L), &json_reference.x)) 1.8 +#define json_pushlightref(L, x) lua_pushlightuserdata((L), &json_reference.x) 1.9 #define json_regpointer(x) (&json_registry.x) 1.10 -#define json_regfetchpointer(L, x) (lua_pushlightuserdata((L), (x)), lua_rawget((L), LUA_REGISTRYINDEX)) 1.11 -#define json_regfetch(L, x) (json_regfetchpointer(L, json_regpointer(x))) 1.12 -#define json_regstore(L, x) (lua_pushlightuserdata(L, json_regpointer(x)), lua_pushvalue(L, -2), lua_rawset(L, LUA_REGISTRYINDEX)); 1.13 +#define json_regfetchpointer(L, x) lua_rawgetp((L), LUA_REGISTRYINDEX, (x)) 1.14 +#define json_regfetch(L, x) json_regfetchpointer(L, json_regpointer(x)) 1.15 +#define json_regstore(L, x) lua_rawsetp(L, LUA_REGISTRYINDEX, json_regpointer(x)) 1.16 1.17 // generate dummy memory addresses that represent non-modifiable lightuserdata (dummy) objects: 1.18 static struct {