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 /lua.h | |
| parent | a264fd089e1814bc13d6de924b928959af2e38d9 (diff) | |
| download | lua-ae1cf64348ca7bcb6d3abb19a0b97918e343914c.tar.gz lua-ae1cf64348ca7bcb6d3abb19a0b97918e343914c.tar.bz2 lua-ae1cf64348ca7bcb6d3abb19a0b97918e343914c.zip | |
better names for type-related functions
Diffstat (limited to 'lua.h')
| -rw-r--r-- | lua.h | 51 |
1 files changed, 24 insertions, 27 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.h,v 1.99 2001/06/28 14:45:44 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.100 2001/07/05 19:32:42 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: info@lua.org | 5 | ** e-mail: info@lua.org |
| @@ -51,10 +51,16 @@ typedef struct lua_State lua_State; | |||
| 51 | 51 | ||
| 52 | typedef int (*lua_CFunction) (lua_State *L); | 52 | typedef int (*lua_CFunction) (lua_State *L); |
| 53 | 53 | ||
| 54 | |||
| 55 | /* | ||
| 56 | ** an invalid `tag' | ||
| 57 | */ | ||
| 58 | #define LUA_NOTAG (-1) | ||
| 59 | |||
| 54 | /* | 60 | /* |
| 55 | ** types returned by `lua_type' | 61 | ** tags for basic types |
| 56 | */ | 62 | */ |
| 57 | #define LUA_TNONE (-1) | 63 | #define LUA_TNONE LUA_NOTAG |
| 58 | 64 | ||
| 59 | #define LUA_TUSERDATA 0 | 65 | #define LUA_TUSERDATA 0 |
| 60 | #define LUA_TNIL 1 | 66 | #define LUA_TNIL 1 |
| @@ -63,11 +69,6 @@ typedef int (*lua_CFunction) (lua_State *L); | |||
| 63 | #define LUA_TTABLE 4 | 69 | #define LUA_TTABLE 4 |
| 64 | #define LUA_TFUNCTION 5 | 70 | #define LUA_TFUNCTION 5 |
| 65 | 71 | ||
| 66 | /* | ||
| 67 | ** an invalid `tag' | ||
| 68 | */ | ||
| 69 | #define LUA_NOTAG (-2) | ||
| 70 | |||
| 71 | 72 | ||
| 72 | /* minimum Lua stack available to a C function */ | 73 | /* minimum Lua stack available to a C function */ |
| 73 | #define LUA_MINSTACK 20 | 74 | #define LUA_MINSTACK 20 |
| @@ -122,13 +123,12 @@ LUA_API int lua_stackspace (lua_State *L); | |||
| 122 | ** access functions (stack -> C) | 123 | ** access functions (stack -> C) |
| 123 | */ | 124 | */ |
| 124 | 125 | ||
| 125 | LUA_API int lua_type (lua_State *L, int index); | 126 | LUA_API const lua_char *lua_type (lua_State *L, int index); |
| 126 | LUA_API const lua_char *lua_tag2name (lua_State *L, int tag); | ||
| 127 | LUA_API const lua_char *lua_xtypename (lua_State *L, int index); | ||
| 128 | LUA_API int lua_isnumber (lua_State *L, int index); | 127 | LUA_API int lua_isnumber (lua_State *L, int index); |
| 129 | LUA_API int lua_isstring (lua_State *L, int index); | 128 | LUA_API int lua_isstring (lua_State *L, int index); |
| 130 | LUA_API int lua_iscfunction (lua_State *L, int index); | 129 | LUA_API int lua_iscfunction (lua_State *L, int index); |
| 131 | LUA_API int lua_tag (lua_State *L, int index); | 130 | LUA_API int lua_tag (lua_State *L, int index); |
| 131 | LUA_API int lua_rawtag (lua_State *L, int index); | ||
| 132 | 132 | ||
| 133 | LUA_API int lua_equal (lua_State *L, int index1, int index2); | 133 | LUA_API int lua_equal (lua_State *L, int index1, int index2); |
| 134 | LUA_API int lua_lessthan (lua_State *L, int index1, int index2); | 134 | LUA_API int lua_lessthan (lua_State *L, int index1, int index2); |
| @@ -201,11 +201,13 @@ LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold); | |||
| 201 | /* | 201 | /* |
| 202 | ** miscellaneous functions | 202 | ** miscellaneous functions |
| 203 | */ | 203 | */ |
| 204 | LUA_API int lua_newxtype (lua_State *L, const lua_char *name, int basictype); | 204 | LUA_API int lua_newtype (lua_State *L, const lua_char *name, int basictype); |
| 205 | LUA_API int lua_name2tag (lua_State *L, const lua_char *name); | ||
| 206 | LUA_API int lua_copytagmethods (lua_State *L, int tagto, int tagfrom); | 205 | LUA_API int lua_copytagmethods (lua_State *L, int tagto, int tagfrom); |
| 207 | LUA_API void lua_settag (lua_State *L, int tag); | 206 | LUA_API void lua_settag (lua_State *L, int tag); |
| 208 | 207 | ||
| 208 | LUA_API int lua_name2tag (lua_State *L, const lua_char *name); | ||
| 209 | LUA_API const lua_char *lua_tag2name (lua_State *L, int tag); | ||
| 210 | |||
| 209 | LUA_API void lua_error (lua_State *L, const lua_char *s); | 211 | LUA_API void lua_error (lua_State *L, const lua_char *s); |
| 210 | 212 | ||
| 211 | LUA_API void lua_unref (lua_State *L, int ref); | 213 | LUA_API void lua_unref (lua_State *L, int ref); |
| @@ -219,14 +221,9 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size); | |||
| 219 | LUA_API void lua_newuserdatabox (lua_State *L, void *u); | 221 | LUA_API void lua_newuserdatabox (lua_State *L, void *u); |
| 220 | 222 | ||
| 221 | LUA_API void lua_setweakmode (lua_State *L, int mode); | 223 | LUA_API void lua_setweakmode (lua_State *L, int mode); |
| 222 | LUA_API int lua_getweakmode (lua_State *L, int index); | 224 | LUA_API int lua_getweakmode (lua_State *L, int index); |
| 223 | 225 | ||
| 224 | 226 | ||
| 225 | /* | ||
| 226 | ** deprecated function | ||
| 227 | */ | ||
| 228 | LUA_API void lua_pushusertag (lua_State *L, void *u, int tag); | ||
| 229 | |||
| 230 | 227 | ||
| 231 | /* | 228 | /* |
| 232 | ** =============================================================== | 229 | ** =============================================================== |
| @@ -242,11 +239,11 @@ LUA_API void lua_pushusertag (lua_State *L, void *u, int tag); | |||
| 242 | #define lua_pushcfunction(L,f) lua_pushcclosure(L, f, 0) | 239 | #define lua_pushcfunction(L,f) lua_pushcclosure(L, f, 0) |
| 243 | #define lua_clonetag(L,t) lua_copytagmethods(L, lua_newtag(L), (t)) | 240 | #define lua_clonetag(L,t) lua_copytagmethods(L, lua_newtag(L), (t)) |
| 244 | 241 | ||
| 245 | #define lua_isfunction(L,n) (lua_type(L,n) == LUA_TFUNCTION) | 242 | #define lua_isfunction(L,n) (lua_rawtag(L,n) == LUA_TFUNCTION) |
| 246 | #define lua_istable(L,n) (lua_type(L,n) == LUA_TTABLE) | 243 | #define lua_istable(L,n) (lua_rawtag(L,n) == LUA_TTABLE) |
| 247 | #define lua_isuserdata(L,n) (lua_type(L,n) == LUA_TUSERDATA) | 244 | #define lua_isuserdata(L,n) (lua_rawtag(L,n) == LUA_TUSERDATA) |
| 248 | #define lua_isnil(L,n) (lua_type(L,n) == LUA_TNIL) | 245 | #define lua_isnil(L,n) (lua_rawtag(L,n) == LUA_TNIL) |
| 249 | #define lua_isnull(L,n) (lua_type(L,n) == LUA_TNONE) | 246 | #define lua_isnull(L,n) (lua_rawtag(L,n) == LUA_TNONE) |
| 250 | 247 | ||
| 251 | #define lua_pushliteral(L, s) lua_pushlstring(L, s, \ | 248 | #define lua_pushliteral(L, s) lua_pushlstring(L, s, \ |
| 252 | (sizeof(s)/sizeof(lua_char))-1) | 249 | (sizeof(s)/sizeof(lua_char))-1) |
| @@ -256,7 +253,7 @@ LUA_API void lua_pushusertag (lua_State *L, void *u, int tag); | |||
| 256 | /* | 253 | /* |
| 257 | ** compatibility macros | 254 | ** compatibility macros |
| 258 | */ | 255 | */ |
| 259 | #define lua_newtag(L) lua_newxtype(L, NULL, LUA_TNONE) | 256 | #define lua_newtag(L) lua_newtype(L, NULL, LUA_TNONE) |
| 260 | #define lua_typename lua_tag2name | 257 | #define lua_typename lua_tag2name |
| 261 | 258 | ||
| 262 | #endif | 259 | #endif |
| @@ -294,8 +291,8 @@ LUA_API void lua_pushusertag (lua_State *L, void *u, int tag); | |||
| 294 | /* | 291 | /* |
| 295 | ** formats for Lua numbers | 292 | ** formats for Lua numbers |
| 296 | */ | 293 | */ |
| 297 | #ifndef LUA_SCAN_NUMBER | 294 | #ifndef LUA_NUMBER_SCAN |
| 298 | #define LUA_SCAN_NUMBER "%lf" | 295 | #define LUA_NUMBER_SCAN "%lf" |
| 299 | #endif | 296 | #endif |
| 300 | #ifndef LUA_NUMBER_FMT | 297 | #ifndef LUA_NUMBER_FMT |
| 301 | #define LUA_NUMBER_FMT "%.16g" | 298 | #define LUA_NUMBER_FMT "%.16g" |
