diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-12-11 20:48:44 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-12-11 20:48:44 -0200 |
| commit | 9aff171f3bf0125314a29a5ca952470b2d83708e (patch) | |
| tree | 8d1b400e0108198bde554a31731c655113bc4086 /lapi.c | |
| parent | ed9be5e1f0d4b68aa848f85744ad959d7a57c9f4 (diff) | |
| download | lua-9aff171f3bf0125314a29a5ca952470b2d83708e.tar.gz lua-9aff171f3bf0125314a29a5ca952470b2d83708e.tar.bz2 lua-9aff171f3bf0125314a29a5ca952470b2d83708e.zip | |
new type `boolean'
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 23 |
1 files changed, 23 insertions, 0 deletions
| @@ -174,6 +174,12 @@ LUA_API int lua_isnumber (lua_State *L, int index) { | |||
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | 176 | ||
| 177 | LUA_API int lua_istrue (lua_State *L, int index) { | ||
| 178 | TObject *o = luaA_indexAcceptable(L, index); | ||
| 179 | return (o != NULL && !l_isfalse(o)); | ||
| 180 | } | ||
| 181 | |||
| 182 | |||
| 177 | LUA_API int lua_isstring (lua_State *L, int index) { | 183 | LUA_API int lua_isstring (lua_State *L, int index) { |
| 178 | int t = lua_type(L, index); | 184 | int t = lua_type(L, index); |
| 179 | return (t == LUA_TSTRING || t == LUA_TNUMBER); | 185 | return (t == LUA_TSTRING || t == LUA_TNUMBER); |
| @@ -213,6 +219,15 @@ LUA_API lua_Number lua_tonumber (lua_State *L, int index) { | |||
| 213 | } | 219 | } |
| 214 | 220 | ||
| 215 | 221 | ||
| 222 | LUA_API int lua_toboolean (lua_State *L, int index) { | ||
| 223 | const TObject *o = luaA_indexAcceptable(L, index); | ||
| 224 | if (o != NULL && (ttype(o) == LUA_TBOOLEAN)) | ||
| 225 | return bvalue(o); | ||
| 226 | else | ||
| 227 | return -1; | ||
| 228 | } | ||
| 229 | |||
| 230 | |||
| 216 | LUA_API const char *lua_tostring (lua_State *L, int index) { | 231 | LUA_API const char *lua_tostring (lua_State *L, int index) { |
| 217 | StkId o = luaA_indexAcceptable(L, index); | 232 | StkId o = luaA_indexAcceptable(L, index); |
| 218 | if (o == NULL) | 233 | if (o == NULL) |
| @@ -323,6 +338,14 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { | |||
| 323 | } | 338 | } |
| 324 | 339 | ||
| 325 | 340 | ||
| 341 | LUA_API void lua_pushboolean (lua_State *L, int b) { | ||
| 342 | lua_lock(L); | ||
| 343 | setbvalue(L->top, b); | ||
| 344 | api_incr_top(L); | ||
| 345 | lua_unlock(L); | ||
| 346 | } | ||
| 347 | |||
| 348 | |||
| 326 | 349 | ||
| 327 | /* | 350 | /* |
| 328 | ** get functions (Lua -> stack) | 351 | ** get functions (Lua -> stack) |
