aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-12-11 20:48:44 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-12-11 20:48:44 -0200
commit9aff171f3bf0125314a29a5ca952470b2d83708e (patch)
tree8d1b400e0108198bde554a31731c655113bc4086 /lapi.c
parented9be5e1f0d4b68aa848f85744ad959d7a57c9f4 (diff)
downloadlua-9aff171f3bf0125314a29a5ca952470b2d83708e.tar.gz
lua-9aff171f3bf0125314a29a5ca952470b2d83708e.tar.bz2
lua-9aff171f3bf0125314a29a5ca952470b2d83708e.zip
new type `boolean'
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lapi.c b/lapi.c
index af151636..50578513 100644
--- a/lapi.c
+++ b/lapi.c
@@ -174,6 +174,12 @@ LUA_API int lua_isnumber (lua_State *L, int index) {
174} 174}
175 175
176 176
177LUA_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
177LUA_API int lua_isstring (lua_State *L, int index) { 183LUA_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
222LUA_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
216LUA_API const char *lua_tostring (lua_State *L, int index) { 231LUA_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
341LUA_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)