better names for type-related functions

This commit is contained in:
Roberto Ierusalimschy 2001-07-12 15:11:58 -03:00
parent a264fd089e
commit ae1cf64348
8 changed files with 74 additions and 75 deletions

30
lapi.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lapi.c,v 1.146 2001/06/15 20:36:57 roberto Exp roberto $ ** $Id: lapi.c,v 1.147 2001/06/26 13:20:45 roberto Exp roberto $
** Lua API ** Lua API
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -134,22 +134,13 @@ LUA_API void lua_pushvalue (lua_State *L, int index) {
*/ */
LUA_API int lua_type (lua_State *L, int index) { LUA_API int lua_rawtag (lua_State *L, int index) {
StkId o = luaA_indexAcceptable(L, index); StkId o = luaA_indexAcceptable(L, index);
return (o == NULL) ? LUA_TNONE : ttype(o); return (o == NULL) ? LUA_TNONE : ttype(o);
} }
LUA_API const l_char *lua_tag2name (lua_State *L, int tag) { LUA_API const l_char *lua_type (lua_State *L, int index) {
const l_char *s;
lua_lock(L);
s = (tag == LUA_TNONE) ? l_s("no value") : basictypename(G(L), tag);
lua_unlock(L);
return s;
}
LUA_API const l_char *lua_xtypename (lua_State *L, int index) {
StkId o; StkId o;
const l_char *type; const l_char *type;
lua_lock(L); lua_lock(L);
@ -174,7 +165,7 @@ LUA_API int lua_isnumber (lua_State *L, int index) {
LUA_API int lua_isstring (lua_State *L, int index) { LUA_API int lua_isstring (lua_State *L, int index) {
int t = lua_type(L, index); int t = lua_rawtag(L, index);
return (t == LUA_TSTRING || t == LUA_TNUMBER); return (t == LUA_TSTRING || t == LUA_TNUMBER);
} }
@ -587,7 +578,7 @@ LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) {
** miscellaneous functions ** miscellaneous functions
*/ */
LUA_API int lua_newxtype (lua_State *L, const l_char *name, int basictype) { LUA_API int lua_newtype (lua_State *L, const l_char *name, int basictype) {
int tag; int tag;
lua_lock(L); lua_lock(L);
if (basictype != LUA_TNONE && if (basictype != LUA_TNONE &&
@ -618,6 +609,15 @@ LUA_API int lua_name2tag (lua_State *L, const l_char *name) {
} }
LUA_API const l_char *lua_tag2name (lua_State *L, int tag) {
const l_char *s;
lua_lock(L);
s = (tag == LUA_TNONE) ? l_s("no value") : typenamebytag(G(L), tag);
lua_unlock(L);
return s;
}
LUA_API void lua_settag (lua_State *L, int tag) { LUA_API void lua_settag (lua_State *L, int tag) {
int basictype; int basictype;
lua_lock(L); lua_lock(L);
@ -627,7 +627,7 @@ LUA_API void lua_settag (lua_State *L, int tag) {
basictype = G(L)->TMtable[tag].basictype; basictype = G(L)->TMtable[tag].basictype;
if (basictype != LUA_TNONE && basictype != ttype(L->top-1)) if (basictype != LUA_TNONE && basictype != ttype(L->top-1))
luaO_verror(L, l_s("tag %d can only be used for type '%.20s'"), tag, luaO_verror(L, l_s("tag %d can only be used for type '%.20s'"), tag,
basictypename(G(L), basictype)); typenamebytag(G(L), basictype));
switch (ttype(L->top-1)) { switch (ttype(L->top-1)) {
case LUA_TTABLE: case LUA_TTABLE:
hvalue(L->top-1)->htag = tag; hvalue(L->top-1)->htag = tag;

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lauxlib.c,v 1.49 2001/03/26 14:31:49 roberto Exp roberto $ ** $Id: lauxlib.c,v 1.50 2001/04/23 16:35:45 roberto Exp roberto $
** Auxiliary functions for building Lua libraries ** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -44,7 +44,7 @@ LUALIB_API void luaL_argerror (lua_State *L, int narg, const l_char *extramsg) {
static void type_error (lua_State *L, int narg, const l_char *tname) { static void type_error (lua_State *L, int narg, const l_char *tname) {
l_char buff[80]; l_char buff[80];
sprintf(buff, l_s("%.25s expected, got %.25s"), tname, lua_xtypename(L,narg)); sprintf(buff, l_s("%.25s expected, got %.25s"), tname, lua_type(L,narg));
luaL_argerror(L, narg, buff); luaL_argerror(L, narg, buff);
} }
@ -61,20 +61,20 @@ LUALIB_API void luaL_checkstack (lua_State *L, int space, const l_char *mes) {
LUALIB_API void luaL_checktype(lua_State *L, int narg, int t) { LUALIB_API void luaL_checktype(lua_State *L, int narg, int t) {
if (lua_type(L, narg) != t) if (lua_rawtag(L, narg) != t)
tag_error(L, narg, t); tag_error(L, narg, t);
} }
LUALIB_API void luaL_checkany (lua_State *L, int narg) { LUALIB_API void luaL_checkany (lua_State *L, int narg) {
if (lua_type(L, narg) == LUA_TNONE) if (lua_rawtag(L, narg) == LUA_TNONE)
luaL_argerror(L, narg, l_s("value expected")); luaL_argerror(L, narg, l_s("value expected"));
} }
LUALIB_API void *luaL_check_userdata (lua_State *L, int narg, LUALIB_API void *luaL_check_userdata (lua_State *L, int narg,
const l_char *name) { const l_char *name) {
if (strcmp(lua_xtypename(L, narg), name) != 0) if (strcmp(lua_type(L, narg), name) != 0)
type_error(L, narg, name); type_error(L, narg, name);
return lua_touserdata(L, narg); return lua_touserdata(L, narg);
} }

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lbaselib.c,v 1.37 2001/06/06 18:00:19 roberto Exp roberto $ ** $Id: lbaselib.c,v 1.38 2001/06/20 17:25:30 roberto Exp roberto $
** Basic library ** Basic library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -139,7 +139,7 @@ static int luaB_getglobal (lua_State *L) {
/* auxiliary function to get `tags' */ /* auxiliary function to get `tags' */
static int gettag (lua_State *L, int narg) { static int gettag (lua_State *L, int narg) {
switch (lua_type(L, narg)) { switch (lua_rawtag(L, narg)) {
case LUA_TNUMBER: case LUA_TNUMBER:
return (int)lua_tonumber(L, narg); return (int)lua_tonumber(L, narg);
case LUA_TSTRING: { case LUA_TSTRING: {
@ -162,7 +162,7 @@ static int luaB_tag (lua_State *L) {
return 1; return 1;
} }
static int luaB_settag (lua_State *L) { static int luaB_settype (lua_State *L) {
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
lua_pushvalue(L, 1); /* push table */ lua_pushvalue(L, 1); /* push table */
lua_settag(L, gettag(L, 2)); lua_settag(L, gettag(L, 2));
@ -194,7 +194,7 @@ static int luaB_weakmode (lua_State *L) {
static int luaB_newtype (lua_State *L) { static int luaB_newtype (lua_State *L) {
const l_char *name = luaL_opt_string(L, 1, NULL); const l_char *name = luaL_opt_string(L, 1, NULL);
lua_pushnumber(L, lua_newxtype(L, name, LUA_TTABLE)); lua_pushnumber(L, lua_newtype(L, name, LUA_TTABLE));
return 1; return 1;
} }
@ -267,14 +267,14 @@ static int luaB_collectgarbage (lua_State *L) {
static int luaB_type (lua_State *L) { static int luaB_type (lua_State *L) {
luaL_checkany(L, 1); luaL_checkany(L, 1);
lua_pushstring(L, lua_tag2name(L, lua_type(L, 1))); lua_pushstring(L, lua_type(L, 1));
return 1; return 1;
} }
static int luaB_xtype (lua_State *L) { static int luaB_rawtype (lua_State *L) {
luaL_checkany(L, 1); luaL_checkany(L, 1);
lua_pushstring(L, lua_xtypename(L, 1)); lua_pushstring(L, lua_tag2name(L, lua_rawtag(L, 1)));
return 1; return 1;
} }
@ -458,7 +458,7 @@ static int luaB_call (lua_State *L) {
static int luaB_tostring (lua_State *L) { static int luaB_tostring (lua_State *L) {
l_char buff[64]; l_char buff[64];
switch (lua_type(L, 1)) { switch (lua_rawtag(L, 1)) {
case LUA_TNUMBER: case LUA_TNUMBER:
lua_pushstring(L, lua_tostring(L, 1)); lua_pushstring(L, lua_tostring(L, 1));
return 1; return 1;
@ -466,13 +466,13 @@ static int luaB_tostring (lua_State *L) {
lua_pushvalue(L, 1); lua_pushvalue(L, 1);
return 1; return 1;
case LUA_TTABLE: case LUA_TTABLE:
sprintf(buff, l_s("%.40s: %p"), lua_xtypename(L, 1), lua_topointer(L, 1)); sprintf(buff, l_s("%.40s: %p"), lua_type(L, 1), lua_topointer(L, 1));
break; break;
case LUA_TFUNCTION: case LUA_TFUNCTION:
sprintf(buff, l_s("function: %p"), lua_topointer(L, 1)); sprintf(buff, l_s("function: %p"), lua_topointer(L, 1));
break; break;
case LUA_TUSERDATA: { case LUA_TUSERDATA: {
const l_char *t = lua_xtypename(L, 1); const l_char *t = lua_type(L, 1);
if (strcmp(t, l_s("userdata")) == 0) if (strcmp(t, l_s("userdata")) == 0)
sprintf(buff, l_s("userdata(%d): %p"), lua_tag(L, 1), sprintf(buff, l_s("userdata(%d): %p"), lua_tag(L, 1),
lua_touserdata(L, 1)); lua_touserdata(L, 1));
@ -715,9 +715,11 @@ static const luaL_reg base_funcs[] = {
{l_s("rawset"), luaB_rawset}, {l_s("rawset"), luaB_rawset},
{l_s("rawgettable"), luaB_rawget}, /* for compatibility 3.2 */ {l_s("rawgettable"), luaB_rawget}, /* for compatibility 3.2 */
{l_s("rawsettable"), luaB_rawset}, /* for compatibility 3.2 */ {l_s("rawsettable"), luaB_rawset}, /* for compatibility 3.2 */
{l_s("rawtype"), luaB_rawtype},
{l_s("require"), luaB_require}, {l_s("require"), luaB_require},
{l_s("setglobal"), luaB_setglobal}, {l_s("setglobal"), luaB_setglobal},
{l_s("settag"), luaB_settag}, {l_s("settag"), luaB_settype}, /* for compatibility 4.0 */
{l_s("settype"), luaB_settype},
{l_s("settagmethod"), luaB_settagmethod}, {l_s("settagmethod"), luaB_settagmethod},
{l_s("tag"), luaB_tag}, {l_s("tag"), luaB_tag},
{l_s("tonumber"), luaB_tonumber}, {l_s("tonumber"), luaB_tonumber},
@ -729,7 +731,6 @@ static const luaL_reg base_funcs[] = {
{l_s("tinsert"), luaB_tinsert}, {l_s("tinsert"), luaB_tinsert},
{l_s("tremove"), luaB_tremove}, {l_s("tremove"), luaB_tremove},
{l_s("unpack"), luaB_unpack}, {l_s("unpack"), luaB_unpack},
{l_s("xtype"), luaB_xtype},
{l_s("weakmode"), luaB_weakmode} {l_s("weakmode"), luaB_weakmode}
}; };

View File

@ -1,5 +1,5 @@
/* /*
** $Id: liolib.c,v 1.117 2001/06/28 14:45:44 roberto Exp roberto $ ** $Id: liolib.c,v 1.118 2001/07/12 14:59:14 roberto Exp roberto $
** Standard I/O (and system) library ** Standard I/O (and system) library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -77,14 +77,14 @@ static int pushresult (lua_State *L, int i) {
*/ */
#define checkfile(L,f) (strcmp(lua_xtypename(L,(f)), FILEHANDLE) == 0) #define checkfile(L,f) (strcmp(lua_type(L,(f)), FILEHANDLE) == 0)
static FILE *getopthandle (lua_State *L, int inout) { static FILE *getopthandle (lua_State *L, int inout) {
FILE *p = (FILE *)lua_touserdata(L, 1); FILE *p = (FILE *)lua_touserdata(L, 1);
if (p != NULL) { /* is it a userdata ? */ if (p != NULL) { /* is it a userdata ? */
if (!checkfile(L, 1)) { /* not a valid file handle? */ if (!checkfile(L, 1)) { /* not a valid file handle? */
if (strcmp(lua_xtypename(L, 1), CLOSEDFILEHANDLE) == 0) if (strcmp(lua_type(L, 1), CLOSEDFILEHANDLE) == 0)
luaL_argerror(L, 1, l_s("file is closed")); luaL_argerror(L, 1, l_s("file is closed"));
else else
luaL_argerror(L, 1, l_s("(invalid value)")); luaL_argerror(L, 1, l_s("(invalid value)"));
@ -310,7 +310,7 @@ static int io_read (lua_State *L) {
luaL_checkstack(L, nargs+LUA_MINSTACK, l_s("too many arguments")); luaL_checkstack(L, nargs+LUA_MINSTACK, l_s("too many arguments"));
success = 1; success = 1;
for (n = 1; n<=nargs && success; n++) { for (n = 1; n<=nargs && success; n++) {
if (lua_type(L, n) == LUA_TNUMBER) { if (lua_rawtag(L, n) == LUA_TNUMBER) {
size_t l = (size_t)lua_tonumber(L, n); size_t l = (size_t)lua_tonumber(L, n);
success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
} }
@ -362,7 +362,7 @@ static int io_write (lua_State *L) {
int arg; int arg;
int status = 1; int status = 1;
for (arg=1; arg<=nargs; arg++) { for (arg=1; arg<=nargs; arg++) {
if (lua_type(L, arg) == LUA_TNUMBER) { if (lua_rawtag(L, arg) == LUA_TNUMBER) {
/* optimization: could be done exactly as for strings */ /* optimization: could be done exactly as for strings */
status = status && status = status &&
fprintf(f, l_s(LUA_NUMBER_FMT), lua_tonumber(L, arg)) > 0; fprintf(f, l_s(LUA_NUMBER_FMT), lua_tonumber(L, arg)) > 0;
@ -686,8 +686,8 @@ static const luaL_reg iolib[] = {
LUALIB_API int lua_iolibopen (lua_State *L) { LUALIB_API int lua_iolibopen (lua_State *L) {
int iotag = lua_newxtype(L, FILEHANDLE, LUA_TUSERDATA); int iotag = lua_newtype(L, FILEHANDLE, LUA_TUSERDATA);
lua_newxtype(L, CLOSEDFILEHANDLE, LUA_TUSERDATA); lua_newtype(L, CLOSEDFILEHANDLE, LUA_TUSERDATA);
luaL_openl(L, iolib); luaL_openl(L, iolib);
/* predefined file handles */ /* predefined file handles */
newfilewithname(L, stdin, basicfiles[INFILE]); newfilewithname(L, stdin, basicfiles[INFILE]);

View File

@ -1,5 +1,5 @@
/* /*
** $Id: ltests.c,v 1.86 2001/06/28 19:58:57 roberto Exp roberto $ ** $Id: ltests.c,v 1.87 2001/07/05 20:31:14 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation ** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -367,8 +367,8 @@ static int udataval (lua_State *L) {
} }
static int newtag (lua_State *L) { static int newtag (lua_State *L) {
lua_pushnumber(L, lua_newxtype(L, lua_tostring(L, 1), lua_pushnumber(L, lua_newtype(L, lua_tostring(L, 1),
(int)lua_tonumber(L, 2))); (int)lua_tonumber(L, 2)));
return 1; return 1;
} }
@ -619,7 +619,7 @@ static int testC (lua_State *L) {
lua_gettagmethod(L, tag, event); lua_gettagmethod(L, tag, event);
} }
else if EQ(l_s("type")) { else if EQ(l_s("type")) {
lua_pushstring(L, lua_typename(L, lua_type(L, getnum))); lua_pushstring(L, lua_type(L, getnum));
} }
else luaL_verror(L, l_s("unknown instruction %.30s"), buff); else luaL_verror(L, l_s("unknown instruction %.30s"), buff);
} }

7
ltm.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: ltm.c,v 1.72 2001/06/06 18:00:19 roberto Exp roberto $ ** $Id: ltm.c,v 1.73 2001/06/15 20:36:57 roberto Exp roberto $
** Tag methods ** Tag methods
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -70,7 +70,8 @@ int luaT_validevent (int t, int e) { /* ORDER LUA_T */
void luaT_init (lua_State *L) { void luaT_init (lua_State *L) {
static const l_char *const typenames[NUM_TAGS] = { static const l_char *const typenames[NUM_TAGS] = {
l_s("userdata"), l_s("nil"), l_s("number"), l_s("string"), l_s("table"), l_s("function") l_s("userdata"), l_s("nil"), l_s("number"), l_s("string"),
l_s("table"), l_s("function")
}; };
int i; int i;
for (i=0; i<NUM_TAGS; i++) for (i=0; i<NUM_TAGS; i++)
@ -177,7 +178,7 @@ LUA_API void lua_settagmethod (lua_State *L, int t, const l_char *event) {
checktag(L, t); checktag(L, t);
if (!luaT_validevent(t, e)) if (!luaT_validevent(t, e))
luaO_verror(L, l_s("cannot change `%.20s' tag method for type `%.20s'%.20s"), luaO_verror(L, l_s("cannot change `%.20s' tag method for type `%.20s'%.20s"),
luaT_eventname[e], basictypename(G(L), t), luaT_eventname[e], typenamebytag(G(L), t),
(t == LUA_TTABLE || t == LUA_TUSERDATA) ? (t == LUA_TTABLE || t == LUA_TUSERDATA) ?
l_s(" with default tag") : l_s("")); l_s(" with default tag") : l_s(""));
switch (ttype(L->top - 1)) { switch (ttype(L->top - 1)) {

4
ltm.h
View File

@ -1,5 +1,5 @@
/* /*
** $Id: ltm.h,v 1.24 2001/02/23 17:17:25 roberto Exp roberto $ ** $Id: ltm.h,v 1.25 2001/06/06 18:00:19 roberto Exp roberto $
** Tag methods ** Tag methods
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -62,7 +62,7 @@ struct TM {
#define luaT_gettm(G,tag,event) (G->TMtable[tag].method[event]) #define luaT_gettm(G,tag,event) (G->TMtable[tag].method[event])
#define luaT_gettmbyObj(G,o,e) (luaT_gettm((G),luaT_tag(o),(e))) #define luaT_gettmbyObj(G,o,e) (luaT_gettm((G),luaT_tag(o),(e)))
#define basictypename(G, t) getstr(G->TMtable[t].name) #define typenamebytag(G, t) getstr(G->TMtable[t].name)
#define validtag(G,t) (NUM_TAGS <= (t) && (t) < G->ntag) #define validtag(G,t) (NUM_TAGS <= (t) && (t) < G->ntag)

51
lua.h
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lua.h,v 1.99 2001/06/28 14:45:44 roberto Exp roberto $ ** $Id: lua.h,v 1.100 2001/07/05 19:32:42 roberto Exp roberto $
** Lua - An Extensible Extension Language ** Lua - An Extensible Extension Language
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
** e-mail: info@lua.org ** e-mail: info@lua.org
@ -51,10 +51,16 @@ typedef struct lua_State lua_State;
typedef int (*lua_CFunction) (lua_State *L); typedef int (*lua_CFunction) (lua_State *L);
/* /*
** types returned by `lua_type' ** an invalid `tag'
*/ */
#define LUA_TNONE (-1) #define LUA_NOTAG (-1)
/*
** tags for basic types
*/
#define LUA_TNONE LUA_NOTAG
#define LUA_TUSERDATA 0 #define LUA_TUSERDATA 0
#define LUA_TNIL 1 #define LUA_TNIL 1
@ -63,11 +69,6 @@ typedef int (*lua_CFunction) (lua_State *L);
#define LUA_TTABLE 4 #define LUA_TTABLE 4
#define LUA_TFUNCTION 5 #define LUA_TFUNCTION 5
/*
** an invalid `tag'
*/
#define LUA_NOTAG (-2)
/* minimum Lua stack available to a C function */ /* minimum Lua stack available to a C function */
#define LUA_MINSTACK 20 #define LUA_MINSTACK 20
@ -122,13 +123,12 @@ LUA_API int lua_stackspace (lua_State *L);
** access functions (stack -> C) ** access functions (stack -> C)
*/ */
LUA_API int lua_type (lua_State *L, int index); LUA_API const lua_char *lua_type (lua_State *L, int index);
LUA_API const lua_char *lua_tag2name (lua_State *L, int tag);
LUA_API const lua_char *lua_xtypename (lua_State *L, int index);
LUA_API int lua_isnumber (lua_State *L, int index); LUA_API int lua_isnumber (lua_State *L, int index);
LUA_API int lua_isstring (lua_State *L, int index); LUA_API int lua_isstring (lua_State *L, int index);
LUA_API int lua_iscfunction (lua_State *L, int index); LUA_API int lua_iscfunction (lua_State *L, int index);
LUA_API int lua_tag (lua_State *L, int index); LUA_API int lua_tag (lua_State *L, int index);
LUA_API int lua_rawtag (lua_State *L, int index);
LUA_API int lua_equal (lua_State *L, int index1, int index2); LUA_API int lua_equal (lua_State *L, int index1, int index2);
LUA_API int lua_lessthan (lua_State *L, int index1, int index2); 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);
/* /*
** miscellaneous functions ** miscellaneous functions
*/ */
LUA_API int lua_newxtype (lua_State *L, const lua_char *name, int basictype); LUA_API int lua_newtype (lua_State *L, const lua_char *name, int basictype);
LUA_API int lua_name2tag (lua_State *L, const lua_char *name);
LUA_API int lua_copytagmethods (lua_State *L, int tagto, int tagfrom); LUA_API int lua_copytagmethods (lua_State *L, int tagto, int tagfrom);
LUA_API void lua_settag (lua_State *L, int tag); LUA_API void lua_settag (lua_State *L, int tag);
LUA_API int lua_name2tag (lua_State *L, const lua_char *name);
LUA_API const lua_char *lua_tag2name (lua_State *L, int tag);
LUA_API void lua_error (lua_State *L, const lua_char *s); LUA_API void lua_error (lua_State *L, const lua_char *s);
LUA_API void lua_unref (lua_State *L, int ref); 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);
LUA_API void lua_newuserdatabox (lua_State *L, void *u); LUA_API void lua_newuserdatabox (lua_State *L, void *u);
LUA_API void lua_setweakmode (lua_State *L, int mode); LUA_API void lua_setweakmode (lua_State *L, int mode);
LUA_API int lua_getweakmode (lua_State *L, int index); LUA_API int lua_getweakmode (lua_State *L, int index);
/*
** deprecated function
*/
LUA_API void lua_pushusertag (lua_State *L, void *u, int tag);
/* /*
** =============================================================== ** ===============================================================
@ -242,11 +239,11 @@ LUA_API void lua_pushusertag (lua_State *L, void *u, int tag);
#define lua_pushcfunction(L,f) lua_pushcclosure(L, f, 0) #define lua_pushcfunction(L,f) lua_pushcclosure(L, f, 0)
#define lua_clonetag(L,t) lua_copytagmethods(L, lua_newtag(L), (t)) #define lua_clonetag(L,t) lua_copytagmethods(L, lua_newtag(L), (t))
#define lua_isfunction(L,n) (lua_type(L,n) == LUA_TFUNCTION) #define lua_isfunction(L,n) (lua_rawtag(L,n) == LUA_TFUNCTION)
#define lua_istable(L,n) (lua_type(L,n) == LUA_TTABLE) #define lua_istable(L,n) (lua_rawtag(L,n) == LUA_TTABLE)
#define lua_isuserdata(L,n) (lua_type(L,n) == LUA_TUSERDATA) #define lua_isuserdata(L,n) (lua_rawtag(L,n) == LUA_TUSERDATA)
#define lua_isnil(L,n) (lua_type(L,n) == LUA_TNIL) #define lua_isnil(L,n) (lua_rawtag(L,n) == LUA_TNIL)
#define lua_isnull(L,n) (lua_type(L,n) == LUA_TNONE) #define lua_isnull(L,n) (lua_rawtag(L,n) == LUA_TNONE)
#define lua_pushliteral(L, s) lua_pushlstring(L, s, \ #define lua_pushliteral(L, s) lua_pushlstring(L, s, \
(sizeof(s)/sizeof(lua_char))-1) (sizeof(s)/sizeof(lua_char))-1)
@ -256,7 +253,7 @@ LUA_API void lua_pushusertag (lua_State *L, void *u, int tag);
/* /*
** compatibility macros ** compatibility macros
*/ */
#define lua_newtag(L) lua_newxtype(L, NULL, LUA_TNONE) #define lua_newtag(L) lua_newtype(L, NULL, LUA_TNONE)
#define lua_typename lua_tag2name #define lua_typename lua_tag2name
#endif #endif
@ -294,8 +291,8 @@ LUA_API void lua_pushusertag (lua_State *L, void *u, int tag);
/* /*
** formats for Lua numbers ** formats for Lua numbers
*/ */
#ifndef LUA_SCAN_NUMBER #ifndef LUA_NUMBER_SCAN
#define LUA_SCAN_NUMBER "%lf" #define LUA_NUMBER_SCAN "%lf"
#endif #endif
#ifndef LUA_NUMBER_FMT #ifndef LUA_NUMBER_FMT
#define LUA_NUMBER_FMT "%.16g" #define LUA_NUMBER_FMT "%.16g"