diff options
| author | Philipp Janda <siffiejoe@gmx.net> | 2017-08-27 17:21:32 +0200 |
|---|---|---|
| committer | Philipp Janda <siffiejoe@gmx.net> | 2017-08-27 17:21:32 +0200 |
| commit | 7bc1476cb655ea1b3adf0e81178dd852c323839c (patch) | |
| tree | 7eb5bce45391290726fc2d0bffc70348cc21ebce | |
| parent | 818e129043c73930aca0d223db62837ee921bb2a (diff) | |
| download | lua-compat-5.3-7bc1476cb655ea1b3adf0e81178dd852c323839c.tar.gz lua-compat-5.3-7bc1476cb655ea1b3adf0e81178dd852c323839c.tar.bz2 lua-compat-5.3-7bc1476cb655ea1b3adf0e81178dd852c323839c.zip | |
Put parens around L macro parameter as well.
Lua only reserves the right to evaluate L multiples times after all,
*not* that L won't contain commas.
| -rw-r--r-- | c-api/compat-5.3.h | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/c-api/compat-5.3.h b/c-api/compat-5.3.h index 7bd8a56..bee77a1 100644 --- a/c-api/compat-5.3.h +++ b/c-api/compat-5.3.h | |||
| @@ -112,30 +112,30 @@ COMPAT53_API int lua_compare (lua_State *L, int idx1, int idx2, int op); | |||
| 112 | COMPAT53_API void lua_copy (lua_State *L, int from, int to); | 112 | COMPAT53_API void lua_copy (lua_State *L, int from, int to); |
| 113 | 113 | ||
| 114 | #define lua_getuservalue(L, i) \ | 114 | #define lua_getuservalue(L, i) \ |
| 115 | (lua_getfenv(L, (i)), lua_type(L, -1)) | 115 | (lua_getfenv((L), (i)), lua_type((L), -1)) |
| 116 | #define lua_setuservalue(L, i) \ | 116 | #define lua_setuservalue(L, i) \ |
| 117 | (luaL_checktype(L, -1, LUA_TTABLE), lua_setfenv(L, (i))) | 117 | (luaL_checktype((L), -1, LUA_TTABLE), lua_setfenv((L), (i))) |
| 118 | 118 | ||
| 119 | #define lua_len COMPAT53_CONCAT(COMPAT53_PREFIX, _len) | 119 | #define lua_len COMPAT53_CONCAT(COMPAT53_PREFIX, _len) |
| 120 | COMPAT53_API void lua_len (lua_State *L, int i); | 120 | COMPAT53_API void lua_len (lua_State *L, int i); |
| 121 | 121 | ||
| 122 | #define lua_pushstring(L, s) \ | 122 | #define lua_pushstring(L, s) \ |
| 123 | (lua_pushstring(L, (s)), lua_tostring(L, -1)) | 123 | (lua_pushstring((L), (s)), lua_tostring((L), -1)) |
| 124 | 124 | ||
| 125 | #define lua_pushlstring(L, s, len) \ | 125 | #define lua_pushlstring(L, s, len) \ |
| 126 | ((((len) == 0) ? lua_pushlstring(L, "", 0) : lua_pushlstring(L, (s), (len))), lua_tostring(L, -1)) | 126 | ((((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len))), lua_tostring((L), -1)) |
| 127 | 127 | ||
| 128 | #ifndef luaL_newlibtable | 128 | #ifndef luaL_newlibtable |
| 129 | # define luaL_newlibtable(L, l) \ | 129 | # define luaL_newlibtable(L, l) \ |
| 130 | (lua_createtable(L, 0, sizeof((l))/sizeof(*(l))-1)) | 130 | (lua_createtable((L), 0, sizeof((l))/sizeof(*(l))-1)) |
| 131 | #endif | 131 | #endif |
| 132 | #ifndef luaL_newlib | 132 | #ifndef luaL_newlib |
| 133 | # define luaL_newlib(L, l) \ | 133 | # define luaL_newlib(L, l) \ |
| 134 | (luaL_newlibtable(L, (l)), luaL_register(L, NULL, (l))) | 134 | (luaL_newlibtable((L), (l)), luaL_register((L), NULL, (l))) |
| 135 | #endif | 135 | #endif |
| 136 | 136 | ||
| 137 | #define lua_pushglobaltable(L) \ | 137 | #define lua_pushglobaltable(L) \ |
| 138 | lua_pushvalue(L, LUA_GLOBALSINDEX) | 138 | lua_pushvalue((L), LUA_GLOBALSINDEX) |
| 139 | 139 | ||
| 140 | #define lua_rawgetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawgetp) | 140 | #define lua_rawgetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawgetp) |
| 141 | COMPAT53_API int lua_rawgetp (lua_State *L, int i, const void *p); | 141 | COMPAT53_API int lua_rawgetp (lua_State *L, int i, const void *p); |
| @@ -143,7 +143,7 @@ COMPAT53_API int lua_rawgetp (lua_State *L, int i, const void *p); | |||
| 143 | #define lua_rawsetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawsetp) | 143 | #define lua_rawsetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawsetp) |
| 144 | COMPAT53_API void lua_rawsetp(lua_State *L, int i, const void *p); | 144 | COMPAT53_API void lua_rawsetp(lua_State *L, int i, const void *p); |
| 145 | 145 | ||
| 146 | #define lua_rawlen(L, i) lua_objlen(L, (i)) | 146 | #define lua_rawlen(L, i) lua_objlen((L), (i)) |
| 147 | 147 | ||
| 148 | #define lua_tointegerx COMPAT53_CONCAT(COMPAT53_PREFIX, _tointegerx) | 148 | #define lua_tointegerx COMPAT53_CONCAT(COMPAT53_PREFIX, _tointegerx) |
| 149 | COMPAT53_API lua_Integer lua_tointegerx (lua_State *L, int i, int *isnum); | 149 | COMPAT53_API lua_Integer lua_tointegerx (lua_State *L, int i, int *isnum); |
| @@ -182,9 +182,9 @@ COMPAT53_API int luaL_fileresult (lua_State *L, int stat, const char *fname); | |||
| 182 | COMPAT53_API int luaL_execresult (lua_State *L, int stat); | 182 | COMPAT53_API int luaL_execresult (lua_State *L, int stat); |
| 183 | 183 | ||
| 184 | #define lua_callk(L, na, nr, ctx, cont) \ | 184 | #define lua_callk(L, na, nr, ctx, cont) \ |
| 185 | ((void)(ctx), (void)(cont), lua_call(L, (na), (nr))) | 185 | ((void)(ctx), (void)(cont), lua_call((L), (na), (nr))) |
| 186 | #define lua_pcallk(L, na, nr, err, ctx, cont) \ | 186 | #define lua_pcallk(L, na, nr, err, ctx, cont) \ |
| 187 | ((void)(ctx), (void)(cont), lua_pcall(L, (na), (nr), (err))) | 187 | ((void)(ctx), (void)(cont), lua_pcall((L), (na), (nr), (err))) |
| 188 | 188 | ||
| 189 | #define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53) | 189 | #define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53) |
| 190 | COMPAT53_API void luaL_buffinit (lua_State *L, luaL_Buffer_53 *B); | 190 | COMPAT53_API void luaL_buffinit (lua_State *L, luaL_Buffer_53 *B); |
| @@ -203,7 +203,7 @@ COMPAT53_API void luaL_pushresult (luaL_Buffer_53 *B); | |||
| 203 | 203 | ||
| 204 | #undef luaL_buffinitsize | 204 | #undef luaL_buffinitsize |
| 205 | #define luaL_buffinitsize(L, B, s) \ | 205 | #define luaL_buffinitsize(L, B, s) \ |
| 206 | (luaL_buffinit(L, (B)), luaL_prepbuffsize((B), (s))) | 206 | (luaL_buffinit((L), (B)), luaL_prepbuffsize((B), (s))) |
| 207 | 207 | ||
| 208 | #undef luaL_prepbuffer | 208 | #undef luaL_prepbuffer |
| 209 | #define luaL_prepbuffer(B) \ | 209 | #define luaL_prepbuffer(B) \ |
| @@ -228,15 +228,15 @@ COMPAT53_API void luaL_pushresult (luaL_Buffer_53 *B); | |||
| 228 | 228 | ||
| 229 | #if defined(LUA_COMPAT_APIINTCASTS) | 229 | #if defined(LUA_COMPAT_APIINTCASTS) |
| 230 | #define lua_pushunsigned(L, n) \ | 230 | #define lua_pushunsigned(L, n) \ |
| 231 | lua_pushinteger(L, (lua_Integer)(n)) | 231 | lua_pushinteger((L), (lua_Integer)(n)) |
| 232 | #define lua_tounsignedx(L, i, is) \ | 232 | #define lua_tounsignedx(L, i, is) \ |
| 233 | ((lua_Unsigned)lua_tointegerx(L, (i), (is))) | 233 | ((lua_Unsigned)lua_tointegerx((L), (i), (is))) |
| 234 | #define lua_tounsigned(L, i) \ | 234 | #define lua_tounsigned(L, i) \ |
| 235 | lua_tounsignedx(L, (i), NULL) | 235 | lua_tounsignedx((L), (i), NULL) |
| 236 | #define luaL_checkunsigned(L, a) \ | 236 | #define luaL_checkunsigned(L, a) \ |
| 237 | ((lua_Unsigned)luaL_checkinteger(L, (a))) | 237 | ((lua_Unsigned)luaL_checkinteger((L), (a))) |
| 238 | #define luaL_optunsigned(L, a, d) \ | 238 | #define luaL_optunsigned(L, a, d) \ |
| 239 | ((lua_Unsigned)luaL_optinteger(L, (a), (lua_Integer)(d))) | 239 | ((lua_Unsigned)luaL_optinteger((L), (a), (lua_Integer)(d))) |
| 240 | #endif | 240 | #endif |
| 241 | 241 | ||
| 242 | #endif /* Lua 5.1 only */ | 242 | #endif /* Lua 5.1 only */ |
| @@ -251,13 +251,13 @@ typedef int lua_KContext; | |||
| 251 | typedef int (*lua_KFunction)(lua_State *L, int status, lua_KContext ctx); | 251 | typedef int (*lua_KFunction)(lua_State *L, int status, lua_KContext ctx); |
| 252 | 252 | ||
| 253 | #define lua_dump(L, w, d, s) \ | 253 | #define lua_dump(L, w, d, s) \ |
| 254 | ((void)(s), lua_dump(L, (w), (d))) | 254 | ((void)(s), lua_dump((L), (w), (d))) |
| 255 | 255 | ||
| 256 | #define lua_getfield(L, i, k) \ | 256 | #define lua_getfield(L, i, k) \ |
| 257 | (lua_getfield(L, (i), (k)), lua_type(L, -1)) | 257 | (lua_getfield((L), (i), (k)), lua_type((L), -1)) |
| 258 | 258 | ||
| 259 | #define lua_gettable(L, i) \ | 259 | #define lua_gettable(L, i) \ |
| 260 | (lua_gettable(L, (i)), lua_type(L, -1)) | 260 | (lua_gettable((L), (i)), lua_type((L), -1)) |
| 261 | 261 | ||
| 262 | #define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti) | 262 | #define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti) |
| 263 | COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i); | 263 | COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i); |
| @@ -269,10 +269,10 @@ COMPAT53_API int lua_isinteger (lua_State *L, int index); | |||
| 269 | ((*(p) = (lua_Integer)(n)), 1) | 269 | ((*(p) = (lua_Integer)(n)), 1) |
| 270 | 270 | ||
| 271 | #define lua_rawget(L, i) \ | 271 | #define lua_rawget(L, i) \ |
| 272 | (lua_rawget(L, (i)), lua_type(L, -1)) | 272 | (lua_rawget((L), (i)), lua_type((L), -1)) |
| 273 | 273 | ||
| 274 | #define lua_rawgeti(L, i, n) \ | 274 | #define lua_rawgeti(L, i, n) \ |
| 275 | (lua_rawgeti(L, (i), (n)), lua_type(L, -1)) | 275 | (lua_rawgeti((L), (i), (n)), lua_type((L), -1)) |
| 276 | 276 | ||
| 277 | #define lua_rotate COMPAT53_CONCAT(COMPAT53_PREFIX, _rotate) | 277 | #define lua_rotate COMPAT53_CONCAT(COMPAT53_PREFIX, _rotate) |
| 278 | COMPAT53_API void lua_rotate (lua_State *L, int idx, int n); | 278 | COMPAT53_API void lua_rotate (lua_State *L, int idx, int n); |
| @@ -287,10 +287,10 @@ COMPAT53_API size_t lua_stringtonumber (lua_State *L, const char *s); | |||
| 287 | COMPAT53_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len); | 287 | COMPAT53_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len); |
| 288 | 288 | ||
| 289 | #define luaL_getmetafield(L, o, e) \ | 289 | #define luaL_getmetafield(L, o, e) \ |
| 290 | (luaL_getmetafield(L, (o), (e)) ? lua_type(L, -1) : LUA_TNIL) | 290 | (luaL_getmetafield((L), (o), (e)) ? lua_type((L), -1) : LUA_TNIL) |
| 291 | 291 | ||
| 292 | #define luaL_newmetatable(L, tn) \ | 292 | #define luaL_newmetatable(L, tn) \ |
| 293 | (luaL_newmetatable(L, (tn)) ? (lua_pushstring(L, (tn)), lua_setfield(L, -2, "__name"), 1) : 0) | 293 | (luaL_newmetatable((L), (tn)) ? (lua_pushstring((L), (tn)), lua_setfield((L), -2, "__name"), 1) : 0) |
| 294 | 294 | ||
| 295 | #define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53) | 295 | #define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53) |
| 296 | COMPAT53_API void luaL_requiref (lua_State *L, const char *modname, | 296 | COMPAT53_API void luaL_requiref (lua_State *L, const char *modname, |
| @@ -311,16 +311,16 @@ COMPAT53_API void luaL_requiref (lua_State *L, const char *modname, | |||
| 311 | */ | 311 | */ |
| 312 | 312 | ||
| 313 | #define lua_getglobal(L, n) \ | 313 | #define lua_getglobal(L, n) \ |
| 314 | (lua_getglobal(L, (n)), lua_type(L, -1)) | 314 | (lua_getglobal((L), (n)), lua_type((L), -1)) |
| 315 | 315 | ||
| 316 | #define lua_getuservalue(L, i) \ | 316 | #define lua_getuservalue(L, i) \ |
| 317 | (lua_getuservalue(L, (i)), lua_type(L, -1)) | 317 | (lua_getuservalue((L), (i)), lua_type((L), -1)) |
| 318 | 318 | ||
| 319 | #define lua_pushlstring(L, s, len) \ | 319 | #define lua_pushlstring(L, s, len) \ |
| 320 | (((len) == 0) ? lua_pushlstring(L, "", 0) : lua_pushlstring(L, (s), (len))) | 320 | (((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len))) |
| 321 | 321 | ||
| 322 | #define lua_rawgetp(L, i, p) \ | 322 | #define lua_rawgetp(L, i, p) \ |
| 323 | (lua_rawgetp(L, (i), (p)), lua_type(L, -1)) | 323 | (lua_rawgetp((L), (i), (p)), lua_type((L), -1)) |
| 324 | 324 | ||
| 325 | #define LUA_KFUNCTION(_name) \ | 325 | #define LUA_KFUNCTION(_name) \ |
| 326 | static int (_name)(lua_State *L, int status, lua_KContext ctx); \ | 326 | static int (_name)(lua_State *L, int status, lua_KContext ctx); \ |
| @@ -332,30 +332,30 @@ COMPAT53_API void luaL_requiref (lua_State *L, const char *modname, | |||
| 332 | static int (_name)(lua_State *L, int status, lua_KContext ctx) | 332 | static int (_name)(lua_State *L, int status, lua_KContext ctx) |
| 333 | 333 | ||
| 334 | #define lua_pcallk(L, na, nr, err, ctx, cont) \ | 334 | #define lua_pcallk(L, na, nr, err, ctx, cont) \ |
| 335 | lua_pcallk(L, (na), (nr), (err), (ctx), cont ## _52) | 335 | lua_pcallk((L), (na), (nr), (err), (ctx), cont ## _52) |
| 336 | 336 | ||
| 337 | #define lua_callk(L, na, nr, ctx, cont) \ | 337 | #define lua_callk(L, na, nr, ctx, cont) \ |
| 338 | lua_callk(L, (na), (nr), (ctx), cont ## _52) | 338 | lua_callk((L), (na), (nr), (ctx), cont ## _52) |
| 339 | 339 | ||
| 340 | #define lua_yieldk(L, nr, ctx, cont) \ | 340 | #define lua_yieldk(L, nr, ctx, cont) \ |
| 341 | lua_yieldk(L, (nr), (ctx), cont ## _52) | 341 | lua_yieldk((L), (nr), (ctx), cont ## _52) |
| 342 | 342 | ||
| 343 | #ifdef lua_call | 343 | #ifdef lua_call |
| 344 | # undef lua_call | 344 | # undef lua_call |
| 345 | # define lua_call(L, na, nr) \ | 345 | # define lua_call(L, na, nr) \ |
| 346 | (lua_callk)(L, (na), (nr), 0, NULL) | 346 | (lua_callk)((L), (na), (nr), 0, NULL) |
| 347 | #endif | 347 | #endif |
| 348 | 348 | ||
| 349 | #ifdef lua_pcall | 349 | #ifdef lua_pcall |
| 350 | # undef lua_pcall | 350 | # undef lua_pcall |
| 351 | # define lua_pcall(L, na, nr, err) \ | 351 | # define lua_pcall(L, na, nr, err) \ |
| 352 | (lua_pcallk)(L, (na), (nr), (err), 0, NULL) | 352 | (lua_pcallk)((L), (na), (nr), (err), 0, NULL) |
| 353 | #endif | 353 | #endif |
| 354 | 354 | ||
| 355 | #ifdef lua_yield | 355 | #ifdef lua_yield |
| 356 | # undef lua_yield | 356 | # undef lua_yield |
| 357 | # define lua_yield(L, nr) \ | 357 | # define lua_yield(L, nr) \ |
| 358 | (lua_yieldk)(L, (nr), 0, NULL) | 358 | (lua_yieldk)((L), (nr), 0, NULL) |
| 359 | #endif | 359 | #endif |
| 360 | 360 | ||
| 361 | #endif /* Lua 5.2 only */ | 361 | #endif /* Lua 5.2 only */ |
