diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-02 17:10:55 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-02 17:10:55 -0300 |
| commit | f6834f4393eaa1055c2bbde82ebb33cc58be8371 (patch) | |
| tree | 3583008ef181106d0fc7e130300f12adc70a5854 /lua.h | |
| parent | 78bc8e553d4190fc3b90be5b621fc0f3507586ef (diff) | |
| download | lua-f6834f4393eaa1055c2bbde82ebb33cc58be8371.tar.gz lua-f6834f4393eaa1055c2bbde82ebb33cc58be8371.tar.bz2 lua-f6834f4393eaa1055c2bbde82ebb33cc58be8371.zip | |
new API function `lua_type' + new type lua_Type
Diffstat (limited to 'lua.h')
| -rw-r--r-- | lua.h | 24 |
1 files changed, 16 insertions, 8 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.h,v 1.70 2000/09/18 19:39:18 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.71 2000/10/02 14:47:43 roberto Exp roberto $ |
| 3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
| 4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil | 4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil |
| 5 | ** e-mail: lua@tecgraf.puc-rio.br | 5 | ** e-mail: lua@tecgraf.puc-rio.br |
| @@ -48,6 +48,13 @@ typedef struct lua_State lua_State; | |||
| 48 | typedef int (*lua_CFunction) (lua_State *L); | 48 | typedef int (*lua_CFunction) (lua_State *L); |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | typedef enum lua_Type { | ||
| 52 | LUA_NOVALUE, LUA_TUSERDATA, LUA_TNUMBER, LUA_TSTRING, | ||
| 53 | LUA_TTABLE, LUA_TFUNCTION, LUA_TNIL | ||
| 54 | } lua_Type; | ||
| 55 | |||
| 56 | |||
| 57 | |||
| 51 | /* | 58 | /* |
| 52 | ** state manipulation | 59 | ** state manipulation |
| 53 | */ | 60 | */ |
| @@ -70,8 +77,10 @@ int lua_stackspace (lua_State *L); | |||
| 70 | ** access functions (stack -> C) | 77 | ** access functions (stack -> C) |
| 71 | */ | 78 | */ |
| 72 | 79 | ||
| 73 | const char *lua_type (lua_State *L, int index); | 80 | lua_Type lua_type (lua_State *L, int index); |
| 81 | const char *lua_typename (lua_State *L, lua_Type t); | ||
| 74 | int lua_isnumber (lua_State *L, int index); | 82 | int lua_isnumber (lua_State *L, int index); |
| 83 | int lua_isstring (lua_State *L, int index); | ||
| 75 | int lua_iscfunction (lua_State *L, int index); | 84 | int lua_iscfunction (lua_State *L, int index); |
| 76 | int lua_tag (lua_State *L, int index); | 85 | int lua_tag (lua_State *L, int index); |
| 77 | 86 | ||
| @@ -171,12 +180,11 @@ void lua_concat (lua_State *L, int n); | |||
| 171 | #define lua_pushcfunction(L,f) lua_pushcclosure(L, f, 0) | 180 | #define lua_pushcfunction(L,f) lua_pushcclosure(L, f, 0) |
| 172 | #define lua_clonetag(L,t) lua_copytagmethods(L, lua_newtag(L), (t)) | 181 | #define lua_clonetag(L,t) lua_copytagmethods(L, lua_newtag(L), (t)) |
| 173 | 182 | ||
| 174 | #define lua_isfunction(L,n) (*lua_type(L,n) == 'f') | 183 | #define lua_isfunction(L,n) (lua_type(L,n) == LUA_TFUNCTION) |
| 175 | #define lua_isstring(L,n) (lua_tostring(L,n) != 0) | 184 | #define lua_istable(L,n) (lua_type(L,n) == LUA_TTABLE) |
| 176 | #define lua_istable(L,n) (*lua_type(L,n) == 't') | 185 | #define lua_isuserdata(L,n) (lua_type(L,n) == LUA_TUSERDATA) |
| 177 | #define lua_isuserdata(L,n) (*lua_type(L,n) == 'u') | 186 | #define lua_isnil(L,n) (lua_type(L,n) == LUA_TNIL) |
| 178 | #define lua_isnil(L,n) (lua_type(L,n)[2] == 'l') | 187 | #define lua_isnull(L,n) (lua_type(L,n) == LUA_NOVALUE) |
| 179 | #define lua_isnull(L,n) (*lua_type(L,n) == 'N') | ||
| 180 | 188 | ||
| 181 | #endif | 189 | #endif |
| 182 | 190 | ||
