diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-07-12 15:11:58 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-07-12 15:11:58 -0300 |
| commit | ae1cf64348ca7bcb6d3abb19a0b97918e343914c (patch) | |
| tree | 23bd25ec0cc4d29ad62a64fad039495fbbee8bb5 /lapi.c | |
| parent | a264fd089e1814bc13d6de924b928959af2e38d9 (diff) | |
| download | lua-ae1cf64348ca7bcb6d3abb19a0b97918e343914c.tar.gz lua-ae1cf64348ca7bcb6d3abb19a0b97918e343914c.tar.bz2 lua-ae1cf64348ca7bcb6d3abb19a0b97918e343914c.zip | |
better names for type-related functions
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 30 |
1 files changed, 15 insertions, 15 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.146 2001/06/15 20:36:57 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.147 2001/06/26 13:20:45 roberto Exp roberto $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -134,22 +134,13 @@ LUA_API void lua_pushvalue (lua_State *L, int index) { | |||
| 134 | */ | 134 | */ |
| 135 | 135 | ||
| 136 | 136 | ||
| 137 | LUA_API int lua_type (lua_State *L, int index) { | 137 | LUA_API int lua_rawtag (lua_State *L, int index) { |
| 138 | StkId o = luaA_indexAcceptable(L, index); | 138 | StkId o = luaA_indexAcceptable(L, index); |
| 139 | return (o == NULL) ? LUA_TNONE : ttype(o); | 139 | return (o == NULL) ? LUA_TNONE : ttype(o); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | 142 | ||
| 143 | LUA_API const l_char *lua_tag2name (lua_State *L, int tag) { | 143 | LUA_API const l_char *lua_type (lua_State *L, int index) { |
| 144 | const l_char *s; | ||
| 145 | lua_lock(L); | ||
| 146 | s = (tag == LUA_TNONE) ? l_s("no value") : basictypename(G(L), tag); | ||
| 147 | lua_unlock(L); | ||
| 148 | return s; | ||
| 149 | } | ||
| 150 | |||
| 151 | |||
| 152 | LUA_API const l_char *lua_xtypename (lua_State *L, int index) { | ||
| 153 | StkId o; | 144 | StkId o; |
| 154 | const l_char *type; | 145 | const l_char *type; |
| 155 | lua_lock(L); | 146 | lua_lock(L); |
| @@ -174,7 +165,7 @@ LUA_API int lua_isnumber (lua_State *L, int index) { | |||
| 174 | 165 | ||
| 175 | 166 | ||
| 176 | LUA_API int lua_isstring (lua_State *L, int index) { | 167 | LUA_API int lua_isstring (lua_State *L, int index) { |
| 177 | int t = lua_type(L, index); | 168 | int t = lua_rawtag(L, index); |
| 178 | return (t == LUA_TSTRING || t == LUA_TNUMBER); | 169 | return (t == LUA_TSTRING || t == LUA_TNUMBER); |
| 179 | } | 170 | } |
| 180 | 171 | ||
| @@ -587,7 +578,7 @@ LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) { | |||
| 587 | ** miscellaneous functions | 578 | ** miscellaneous functions |
| 588 | */ | 579 | */ |
| 589 | 580 | ||
| 590 | LUA_API int lua_newxtype (lua_State *L, const l_char *name, int basictype) { | 581 | LUA_API int lua_newtype (lua_State *L, const l_char *name, int basictype) { |
| 591 | int tag; | 582 | int tag; |
| 592 | lua_lock(L); | 583 | lua_lock(L); |
| 593 | if (basictype != LUA_TNONE && | 584 | if (basictype != LUA_TNONE && |
| @@ -618,6 +609,15 @@ LUA_API int lua_name2tag (lua_State *L, const l_char *name) { | |||
| 618 | } | 609 | } |
| 619 | 610 | ||
| 620 | 611 | ||
| 612 | LUA_API const l_char *lua_tag2name (lua_State *L, int tag) { | ||
| 613 | const l_char *s; | ||
| 614 | lua_lock(L); | ||
| 615 | s = (tag == LUA_TNONE) ? l_s("no value") : typenamebytag(G(L), tag); | ||
| 616 | lua_unlock(L); | ||
| 617 | return s; | ||
| 618 | } | ||
| 619 | |||
| 620 | |||
| 621 | LUA_API void lua_settag (lua_State *L, int tag) { | 621 | LUA_API void lua_settag (lua_State *L, int tag) { |
| 622 | int basictype; | 622 | int basictype; |
| 623 | lua_lock(L); | 623 | lua_lock(L); |
| @@ -627,7 +627,7 @@ LUA_API void lua_settag (lua_State *L, int tag) { | |||
| 627 | basictype = G(L)->TMtable[tag].basictype; | 627 | basictype = G(L)->TMtable[tag].basictype; |
| 628 | if (basictype != LUA_TNONE && basictype != ttype(L->top-1)) | 628 | if (basictype != LUA_TNONE && basictype != ttype(L->top-1)) |
| 629 | luaO_verror(L, l_s("tag %d can only be used for type '%.20s'"), tag, | 629 | luaO_verror(L, l_s("tag %d can only be used for type '%.20s'"), tag, |
| 630 | basictypename(G(L), basictype)); | 630 | typenamebytag(G(L), basictype)); |
| 631 | switch (ttype(L->top-1)) { | 631 | switch (ttype(L->top-1)) { |
| 632 | case LUA_TTABLE: | 632 | case LUA_TTABLE: |
| 633 | hvalue(L->top-1)->htag = tag; | 633 | hvalue(L->top-1)->htag = tag; |
