Browse Source

rename of lua_isnull to lua_isnone

v5-2
Roberto Ierusalimschy 23 years ago
parent
commit
09e15692f3
  1. 4
      lauxlib.c
  2. 10
      lbaselib.c
  3. 6
      liolib.c
  4. 10
      ltests.c
  5. 2
      lua.h

4
lauxlib.c

@ -81,7 +81,7 @@ LUALIB_API const char *luaL_check_lstr (lua_State *L, int narg, size_t *len) {
LUALIB_API const char *luaL_opt_lstr (lua_State *L, int narg, const char *def, size_t *len) { LUALIB_API const char *luaL_opt_lstr (lua_State *L, int narg, const char *def, size_t *len) {
if (lua_isnull(L, narg)) { if (lua_isnone(L, narg)) {
if (len) if (len)
*len = (def ? strlen(def) : 0); *len = (def ? strlen(def) : 0);
return def; return def;
@ -99,7 +99,7 @@ LUALIB_API lua_Number luaL_check_number (lua_State *L, int narg) {
LUALIB_API lua_Number luaL_opt_number (lua_State *L, int narg, lua_Number def) { LUALIB_API lua_Number luaL_opt_number (lua_State *L, int narg, lua_Number def) {
if (lua_isnull(L, narg)) return def; if (lua_isnone(L, narg)) return def;
else return luaL_check_number(L, narg); else return luaL_check_number(L, narg);
} }

10
lbaselib.c

@ -137,7 +137,7 @@ static int luaB_getglobal (lua_State *L) {
static int luaB_eventtable (lua_State *L) { static int luaB_eventtable (lua_State *L) {
luaL_check_type(L, 1, LUA_TTABLE); luaL_check_type(L, 1, LUA_TTABLE);
if (lua_isnull(L, 2)) if (lua_isnone(L, 2))
lua_geteventtable(L, 1); lua_geteventtable(L, 1);
else { else {
lua_settop(L, 2); lua_settop(L, 2);
@ -174,7 +174,7 @@ static int luaB_weakmode (lua_State *L) {
static int luaB_globals (lua_State *L) { static int luaB_globals (lua_State *L) {
lua_getglobals(L); /* value to be returned */ lua_getglobals(L); /* value to be returned */
if (!lua_isnull(L, 1)) { if (!lua_isnone(L, 1)) {
luaL_check_type(L, 1, LUA_TTABLE); luaL_check_type(L, 1, LUA_TTABLE);
lua_pushvalue(L, 1); /* new table of globals */ lua_pushvalue(L, 1); /* new table of globals */
lua_setglobals(L); lua_setglobals(L);
@ -213,7 +213,7 @@ static int luaB_collectgarbage (lua_State *L) {
static int luaB_type (lua_State *L) { static int luaB_type (lua_State *L) {
luaL_check_any(L, 1); luaL_check_any(L, 1);
if (lua_isnull(L, 2)) if (lua_isnone(L, 2))
lua_pushstring(L, lua_typename(L, lua_type(L, 1))); lua_pushstring(L, lua_typename(L, lua_type(L, 1)));
else { else {
lua_pushboolean(L, lua_pushboolean(L,
@ -362,7 +362,7 @@ static int luaB_call (lua_State *L) {
int err = 0; /* index of old error method */ int err = 0; /* index of old error method */
int status; int status;
int n; int n;
if (!lua_isnull(L, 4)) { /* set new error method */ if (!lua_isnone(L, 4)) { /* set new error method */
lua_getglobal(L, LUA_ERRORMESSAGE); lua_getglobal(L, LUA_ERRORMESSAGE);
err = lua_gettop(L); /* get index */ err = lua_gettop(L); /* get index */
lua_pushvalue(L, 4); lua_pushvalue(L, 4);
@ -618,7 +618,7 @@ static int luaB_sort (lua_State *L) {
int n; int n;
luaL_check_type(L, 1, LUA_TTABLE); luaL_check_type(L, 1, LUA_TTABLE);
n = lua_getn(L, 1); n = lua_getn(L, 1);
if (!lua_isnull(L, 2)) /* is there a 2nd argument? */ if (!lua_isnone(L, 2)) /* is there a 2nd argument? */
luaL_check_type(L, 2, LUA_TFUNCTION); luaL_check_type(L, 2, LUA_TFUNCTION);
lua_settop(L, 2); /* make sure there is two arguments */ lua_settop(L, 2); /* make sure there is two arguments */
auxsort(L, 1, n); auxsort(L, 1, n);

6
liolib.c

@ -177,7 +177,7 @@ static int io_tmpfile (lua_State *L) {
static int io_fromto (lua_State *L, int inout, const char *mode) { static int io_fromto (lua_State *L, int inout, const char *mode) {
FILE *current; FILE *current;
if (lua_isnull(L, 1)) { if (lua_isnone(L, 1)) {
getopthandle(L, inout); getopthandle(L, inout);
resetfile(L, inout); resetfile(L, inout);
return io_close(L); return io_close(L);
@ -405,7 +405,7 @@ static int io_seek (lua_State *L) {
static int io_flush (lua_State *L) { static int io_flush (lua_State *L) {
FILE *f = (lua_isnull(L, 1)) ? (FILE *)(NULL) : FILE *f = (lua_isnone(L, 1)) ? (FILE *)(NULL) :
(FILE *)(luaL_check_userdata(L, 1, FILEHANDLE)); (FILE *)(luaL_check_userdata(L, 1, FILEHANDLE));
return pushresult(L, fflush(f) == 0); return pushresult(L, fflush(f) == 0);
} }
@ -525,7 +525,7 @@ static int io_date (lua_State *L) {
static int io_time (lua_State *L) { static int io_time (lua_State *L) {
if (lua_isnull(L, 1)) /* called without args? */ if (lua_isnone(L, 1)) /* called without args? */
lua_pushnumber(L, time(NULL)); /* return current time */ lua_pushnumber(L, time(NULL)); /* return current time */
else { else {
time_t t; time_t t;

10
ltests.c

@ -225,7 +225,7 @@ static int get_limits (lua_State *L) {
static int mem_query (lua_State *L) { static int mem_query (lua_State *L) {
if (lua_isnull(L, 1)) { if (lua_isnone(L, 1)) {
lua_pushnumber(L, memdebug_total); lua_pushnumber(L, memdebug_total);
lua_pushnumber(L, memdebug_numblocks); lua_pushnumber(L, memdebug_numblocks);
lua_pushnumber(L, memdebug_maxmem); lua_pushnumber(L, memdebug_maxmem);
@ -239,7 +239,7 @@ static int mem_query (lua_State *L) {
static int hash_query (lua_State *L) { static int hash_query (lua_State *L) {
if (lua_isnull(L, 2)) { if (lua_isnone(L, 2)) {
luaL_arg_check(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected"); luaL_arg_check(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected");
lua_pushnumber(L, tsvalue(luaA_index(L, 1))->tsv.hash); lua_pushnumber(L, tsvalue(luaA_index(L, 1))->tsv.hash);
} }
@ -335,7 +335,7 @@ static int unref (lua_State *L) {
static int eventtable (lua_State *L) { static int eventtable (lua_State *L) {
luaL_check_any(L, 1); luaL_check_any(L, 1);
if (lua_isnull(L, 2)) if (lua_isnone(L, 2))
lua_geteventtable(L, 1); lua_geteventtable(L, 1);
else { else {
lua_settop(L, 2); lua_settop(L, 2);
@ -429,7 +429,7 @@ static int doremote (lua_State *L) {
} }
else { else {
int i = 0; int i = 0;
while (!lua_isnull(L1, ++i)) while (!lua_isnone(L1, ++i))
lua_pushstring(L, lua_tostring(L1, i)); lua_pushstring(L, lua_tostring(L1, i));
lua_pop(L1, i-1); lua_pop(L1, i-1);
return i-1; return i-1;
@ -518,7 +518,7 @@ static int testC (lua_State *L) {
lua_pushnumber(L, lua_isnil(L, getnum)); lua_pushnumber(L, lua_isnil(L, getnum));
} }
else if EQ("isnull") { else if EQ("isnull") {
lua_pushnumber(L, lua_isnull(L, getnum)); lua_pushnumber(L, lua_isnone(L, getnum));
} }
else if EQ("tonumber") { else if EQ("tonumber") {
lua_pushnumber(L, lua_tonumber(L, getnum)); lua_pushnumber(L, lua_tonumber(L, getnum));

2
lua.h

@ -227,7 +227,7 @@ LUA_API int lua_getweakmode (lua_State *L, int index);
#define lua_isuserdata(L,n) (lua_type(L,n) == LUA_TUSERDATA) #define lua_isuserdata(L,n) (lua_type(L,n) == LUA_TUSERDATA)
#define lua_isnil(L,n) (lua_type(L,n) == LUA_TNIL) #define lua_isnil(L,n) (lua_type(L,n) == LUA_TNIL)
#define lua_isboolean(L,n) (lua_type(L,n) == LUA_TBOOLEAN) #define lua_isboolean(L,n) (lua_type(L,n) == LUA_TBOOLEAN)
#define lua_isnull(L,n) (lua_type(L,n) == LUA_TNONE) #define lua_isnone(L,n) (lua_type(L,n) == LUA_TNONE)
#define lua_pushliteral(L, s) lua_pushlstring(L, "" s, \ #define lua_pushliteral(L, s) lua_pushlstring(L, "" s, \
(sizeof(s)/sizeof(char))-1) (sizeof(s)/sizeof(char))-1)

Loading…
Cancel
Save