diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-06-26 15:38:28 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-06-26 15:38:28 -0300 |
| commit | a77d263e86feea55529800028f960d7124c1385f (patch) | |
| tree | 88bc21289c5ef341a7f3509c067524fea7003049 | |
| parent | 7cc40851e1d1a18a4c45fca31dbccd4206050b11 (diff) | |
| download | lua-a77d263e86feea55529800028f960d7124c1385f.tar.gz lua-a77d263e86feea55529800028f960d7124c1385f.tar.bz2 lua-a77d263e86feea55529800028f960d7124c1385f.zip | |
unsigned-manipulation functions (lua_puhsunsigned, lua_tounsigned, etc.)
deprecated
| -rw-r--r-- | lauxlib.c | 17 | ||||
| -rw-r--r-- | lauxlib.h | 21 | ||||
| -rw-r--r-- | lmathlib.c | 4 | ||||
| -rw-r--r-- | ltests.c | 5 | ||||
| -rw-r--r-- | lua.h | 23 | ||||
| -rw-r--r-- | luaconf.h | 8 |
6 files changed, 46 insertions, 32 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.262 2014/04/15 18:25:49 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.263 2014/05/12 21:44:17 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -413,26 +413,11 @@ LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int arg) { | |||
| 413 | } | 413 | } |
| 414 | 414 | ||
| 415 | 415 | ||
| 416 | LUALIB_API lua_Unsigned luaL_checkunsigned (lua_State *L, int arg) { | ||
| 417 | int isnum; | ||
| 418 | lua_Unsigned d = lua_tounsignedx(L, arg, &isnum); | ||
| 419 | if (!isnum) | ||
| 420 | interror(L, arg); | ||
| 421 | return d; | ||
| 422 | } | ||
| 423 | |||
| 424 | |||
| 425 | LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int arg, | 416 | LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int arg, |
| 426 | lua_Integer def) { | 417 | lua_Integer def) { |
| 427 | return luaL_opt(L, luaL_checkinteger, arg, def); | 418 | return luaL_opt(L, luaL_checkinteger, arg, def); |
| 428 | } | 419 | } |
| 429 | 420 | ||
| 430 | |||
| 431 | LUALIB_API lua_Unsigned luaL_optunsigned (lua_State *L, int arg, | ||
| 432 | lua_Unsigned def) { | ||
| 433 | return luaL_opt(L, luaL_checkunsigned, arg, def); | ||
| 434 | } | ||
| 435 | |||
| 436 | /* }====================================================== */ | 421 | /* }====================================================== */ |
| 437 | 422 | ||
| 438 | 423 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.h,v 1.123 2014/01/05 14:04:46 roberto Exp roberto $ | 2 | ** $Id: lauxlib.h,v 1.124 2014/04/15 18:25:49 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -46,9 +46,6 @@ LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def); | |||
| 46 | LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg); | 46 | LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg); |
| 47 | LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg, | 47 | LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg, |
| 48 | lua_Integer def); | 48 | lua_Integer def); |
| 49 | LUALIB_API lua_Unsigned (luaL_checkunsigned) (lua_State *L, int arg); | ||
| 50 | LUALIB_API lua_Unsigned (luaL_optunsigned) (lua_State *L, int arg, | ||
| 51 | lua_Unsigned def); | ||
| 52 | 49 | ||
| 53 | LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); | 50 | LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); |
| 54 | LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t); | 51 | LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t); |
| @@ -211,6 +208,22 @@ LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, | |||
| 211 | #endif | 208 | #endif |
| 212 | 209 | ||
| 213 | 210 | ||
| 211 | /* | ||
| 212 | ** {============================================================ | ||
| 213 | ** Compatibility with deprecated unsigned conversions | ||
| 214 | ** ============================================================= | ||
| 215 | */ | ||
| 216 | #if defined(LUA_COMPAT_APIUNSIGNED) | ||
| 217 | |||
| 218 | #define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a)) | ||
| 219 | #define luaL_optunsigned(L,a,d) \ | ||
| 220 | ((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d))) | ||
| 221 | |||
| 222 | #endif | ||
| 223 | /* }============================================================ */ | ||
| 224 | |||
| 225 | |||
| 226 | |||
| 214 | #endif | 227 | #endif |
| 215 | 228 | ||
| 216 | 229 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmathlib.c,v 1.102 2014/06/02 23:09:28 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.103 2014/06/18 12:35:53 roberto Exp roberto $ |
| 3 | ** Standard mathematical library | 3 | ** Standard mathematical library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -257,7 +257,7 @@ static int math_random (lua_State *L) { | |||
| 257 | 257 | ||
| 258 | 258 | ||
| 259 | static int math_randomseed (lua_State *L) { | 259 | static int math_randomseed (lua_State *L) { |
| 260 | l_srand((unsigned int)luaL_checkunsigned(L, 1)); | 260 | l_srand((unsigned int)(lua_Integer)luaL_checknumber(L, 1)); |
| 261 | (void)rand(); /* discard first value to avoid undesirable correlations */ | 261 | (void)rand(); /* discard first value to avoid undesirable correlations */ |
| 262 | return 0; | 262 | return 0; |
| 263 | } | 263 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.c,v 2.172 2014/06/17 17:13:29 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.173 2014/06/19 18:29:30 roberto Exp roberto $ |
| 3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -1263,9 +1263,6 @@ static struct X { int x; } x; | |||
| 1263 | const char *s1 = lua_pushstring(L1, s); | 1263 | const char *s1 = lua_pushstring(L1, s); |
| 1264 | lua_assert((s == NULL && s1 == NULL) || (strcmp)(s, s1) == 0); | 1264 | lua_assert((s == NULL && s1 == NULL) || (strcmp)(s, s1) == 0); |
| 1265 | } | 1265 | } |
| 1266 | else if EQ("tounsigned") { | ||
| 1267 | lua_pushinteger(L1, (lua_Integer)lua_tounsigned(L1, getindex)); | ||
| 1268 | } | ||
| 1269 | else if EQ("type") { | 1266 | else if EQ("type") { |
| 1270 | lua_pushstring(L1, luaL_typename(L1, getnum)); | 1267 | lua_pushstring(L1, luaL_typename(L1, getnum)); |
| 1271 | } | 1268 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.h,v 1.306 2014/05/13 19:40:28 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.307 2014/06/10 17:41:38 roberto Exp roberto $ |
| 3 | ** Lua - A Scripting Language | 3 | ** Lua - A Scripting Language |
| 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) | 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) |
| 5 | ** See Copyright Notice at the end of this file | 5 | ** See Copyright Notice at the end of this file |
| @@ -175,7 +175,6 @@ LUA_API const char *(lua_typename) (lua_State *L, int tp); | |||
| 175 | 175 | ||
| 176 | LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum); | 176 | LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum); |
| 177 | LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum); | 177 | LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum); |
| 178 | LUA_API lua_Unsigned (lua_tounsignedx) (lua_State *L, int idx, int *isnum); | ||
| 179 | LUA_API int (lua_toboolean) (lua_State *L, int idx); | 178 | LUA_API int (lua_toboolean) (lua_State *L, int idx); |
| 180 | LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); | 179 | LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); |
| 181 | LUA_API size_t (lua_rawlen) (lua_State *L, int idx); | 180 | LUA_API size_t (lua_rawlen) (lua_State *L, int idx); |
| @@ -220,7 +219,6 @@ LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op); | |||
| 220 | LUA_API void (lua_pushnil) (lua_State *L); | 219 | LUA_API void (lua_pushnil) (lua_State *L); |
| 221 | LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); | 220 | LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); |
| 222 | LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); | 221 | LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); |
| 223 | LUA_API void (lua_pushunsigned) (lua_State *L, lua_Unsigned n); | ||
| 224 | LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l); | 222 | LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l); |
| 225 | LUA_API const char *(lua_pushstring) (lua_State *L, const char *s); | 223 | LUA_API const char *(lua_pushstring) (lua_State *L, const char *s); |
| 226 | LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, | 224 | LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, |
| @@ -326,14 +324,13 @@ LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); | |||
| 326 | 324 | ||
| 327 | 325 | ||
| 328 | /* | 326 | /* |
| 329 | ** =============================================================== | 327 | ** {============================================================== |
| 330 | ** some useful macros | 328 | ** some useful macros |
| 331 | ** =============================================================== | 329 | ** =============================================================== |
| 332 | */ | 330 | */ |
| 333 | 331 | ||
| 334 | #define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL) | 332 | #define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL) |
| 335 | #define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL) | 333 | #define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL) |
| 336 | #define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL) | ||
| 337 | 334 | ||
| 338 | #define lua_pop(L,n) lua_settop(L, -(n)-1) | 335 | #define lua_pop(L,n) lua_settop(L, -(n)-1) |
| 339 | 336 | ||
| @@ -365,6 +362,22 @@ LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); | |||
| 365 | 362 | ||
| 366 | #define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1)) | 363 | #define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1)) |
| 367 | 364 | ||
| 365 | /* }============================================================== */ | ||
| 366 | |||
| 367 | |||
| 368 | /* | ||
| 369 | ** {============================================================== | ||
| 370 | ** compatibility macros for unsigned conversions | ||
| 371 | ** =============================================================== | ||
| 372 | */ | ||
| 373 | #if defined(LUA_COMPAT_APIUNSIGNED) | ||
| 374 | |||
| 375 | #define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) | ||
| 376 | #define lua_tounsignedx(L,i,is) ((lua_Integer)lua_tointegerx(L,i,is)) | ||
| 377 | #define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL) | ||
| 378 | |||
| 379 | #endif | ||
| 380 | /* }============================================================== */ | ||
| 368 | 381 | ||
| 369 | /* | 382 | /* |
| 370 | ** {====================================================================== | 383 | ** {====================================================================== |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: luaconf.h,v 1.207 2014/06/10 19:21:20 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.208 2014/06/24 17:02:00 roberto Exp roberto $ |
| 3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -280,6 +280,12 @@ | |||
| 280 | */ | 280 | */ |
| 281 | #define LUA_COMPAT_BITLIB | 281 | #define LUA_COMPAT_BITLIB |
| 282 | 282 | ||
| 283 | /* | ||
| 284 | @@ LUA_COMPAT_APIUNSIGNED controls the presence of macros for | ||
| 285 | ** manipulating unsigned integers (lua_pushunsigned, lua_tounsigned, etc.) | ||
| 286 | */ | ||
| 287 | #define LUA_COMPAT_APIUNSIGNED | ||
| 288 | |||
| 283 | 289 | ||
| 284 | /* | 290 | /* |
| 285 | @@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a | 291 | @@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a |
