aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 7865e62f..1710f4d5 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.37 2001/06/06 18:00:19 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.38 2001/06/20 17:25:30 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -139,7 +139,7 @@ static int luaB_getglobal (lua_State *L) {
139 139
140/* auxiliary function to get `tags' */ 140/* auxiliary function to get `tags' */
141static int gettag (lua_State *L, int narg) { 141static int gettag (lua_State *L, int narg) {
142 switch (lua_type(L, narg)) { 142 switch (lua_rawtag(L, narg)) {
143 case LUA_TNUMBER: 143 case LUA_TNUMBER:
144 return (int)lua_tonumber(L, narg); 144 return (int)lua_tonumber(L, narg);
145 case LUA_TSTRING: { 145 case LUA_TSTRING: {
@@ -162,7 +162,7 @@ static int luaB_tag (lua_State *L) {
162 return 1; 162 return 1;
163} 163}
164 164
165static int luaB_settag (lua_State *L) { 165static int luaB_settype (lua_State *L) {
166 luaL_checktype(L, 1, LUA_TTABLE); 166 luaL_checktype(L, 1, LUA_TTABLE);
167 lua_pushvalue(L, 1); /* push table */ 167 lua_pushvalue(L, 1); /* push table */
168 lua_settag(L, gettag(L, 2)); 168 lua_settag(L, gettag(L, 2));
@@ -194,7 +194,7 @@ static int luaB_weakmode (lua_State *L) {
194 194
195static int luaB_newtype (lua_State *L) { 195static int luaB_newtype (lua_State *L) {
196 const l_char *name = luaL_opt_string(L, 1, NULL); 196 const l_char *name = luaL_opt_string(L, 1, NULL);
197 lua_pushnumber(L, lua_newxtype(L, name, LUA_TTABLE)); 197 lua_pushnumber(L, lua_newtype(L, name, LUA_TTABLE));
198 return 1; 198 return 1;
199} 199}
200 200
@@ -267,14 +267,14 @@ static int luaB_collectgarbage (lua_State *L) {
267 267
268static int luaB_type (lua_State *L) { 268static int luaB_type (lua_State *L) {
269 luaL_checkany(L, 1); 269 luaL_checkany(L, 1);
270 lua_pushstring(L, lua_tag2name(L, lua_type(L, 1))); 270 lua_pushstring(L, lua_type(L, 1));
271 return 1; 271 return 1;
272} 272}
273 273
274 274
275static int luaB_xtype (lua_State *L) { 275static int luaB_rawtype (lua_State *L) {
276 luaL_checkany(L, 1); 276 luaL_checkany(L, 1);
277 lua_pushstring(L, lua_xtypename(L, 1)); 277 lua_pushstring(L, lua_tag2name(L, lua_rawtag(L, 1)));
278 return 1; 278 return 1;
279} 279}
280 280
@@ -458,7 +458,7 @@ static int luaB_call (lua_State *L) {
458 458
459static int luaB_tostring (lua_State *L) { 459static int luaB_tostring (lua_State *L) {
460 l_char buff[64]; 460 l_char buff[64];
461 switch (lua_type(L, 1)) { 461 switch (lua_rawtag(L, 1)) {
462 case LUA_TNUMBER: 462 case LUA_TNUMBER:
463 lua_pushstring(L, lua_tostring(L, 1)); 463 lua_pushstring(L, lua_tostring(L, 1));
464 return 1; 464 return 1;
@@ -466,13 +466,13 @@ static int luaB_tostring (lua_State *L) {
466 lua_pushvalue(L, 1); 466 lua_pushvalue(L, 1);
467 return 1; 467 return 1;
468 case LUA_TTABLE: 468 case LUA_TTABLE:
469 sprintf(buff, l_s("%.40s: %p"), lua_xtypename(L, 1), lua_topointer(L, 1)); 469 sprintf(buff, l_s("%.40s: %p"), lua_type(L, 1), lua_topointer(L, 1));
470 break; 470 break;
471 case LUA_TFUNCTION: 471 case LUA_TFUNCTION:
472 sprintf(buff, l_s("function: %p"), lua_topointer(L, 1)); 472 sprintf(buff, l_s("function: %p"), lua_topointer(L, 1));
473 break; 473 break;
474 case LUA_TUSERDATA: { 474 case LUA_TUSERDATA: {
475 const l_char *t = lua_xtypename(L, 1); 475 const l_char *t = lua_type(L, 1);
476 if (strcmp(t, l_s("userdata")) == 0) 476 if (strcmp(t, l_s("userdata")) == 0)
477 sprintf(buff, l_s("userdata(%d): %p"), lua_tag(L, 1), 477 sprintf(buff, l_s("userdata(%d): %p"), lua_tag(L, 1),
478 lua_touserdata(L, 1)); 478 lua_touserdata(L, 1));
@@ -715,9 +715,11 @@ static const luaL_reg base_funcs[] = {
715 {l_s("rawset"), luaB_rawset}, 715 {l_s("rawset"), luaB_rawset},
716 {l_s("rawgettable"), luaB_rawget}, /* for compatibility 3.2 */ 716 {l_s("rawgettable"), luaB_rawget}, /* for compatibility 3.2 */
717 {l_s("rawsettable"), luaB_rawset}, /* for compatibility 3.2 */ 717 {l_s("rawsettable"), luaB_rawset}, /* for compatibility 3.2 */
718 {l_s("rawtype"), luaB_rawtype},
718 {l_s("require"), luaB_require}, 719 {l_s("require"), luaB_require},
719 {l_s("setglobal"), luaB_setglobal}, 720 {l_s("setglobal"), luaB_setglobal},
720 {l_s("settag"), luaB_settag}, 721 {l_s("settag"), luaB_settype}, /* for compatibility 4.0 */
722 {l_s("settype"), luaB_settype},
721 {l_s("settagmethod"), luaB_settagmethod}, 723 {l_s("settagmethod"), luaB_settagmethod},
722 {l_s("tag"), luaB_tag}, 724 {l_s("tag"), luaB_tag},
723 {l_s("tonumber"), luaB_tonumber}, 725 {l_s("tonumber"), luaB_tonumber},
@@ -729,7 +731,6 @@ static const luaL_reg base_funcs[] = {
729 {l_s("tinsert"), luaB_tinsert}, 731 {l_s("tinsert"), luaB_tinsert},
730 {l_s("tremove"), luaB_tremove}, 732 {l_s("tremove"), luaB_tremove},
731 {l_s("unpack"), luaB_unpack}, 733 {l_s("unpack"), luaB_unpack},
732 {l_s("xtype"), luaB_xtype},
733 {l_s("weakmode"), luaB_weakmode} 734 {l_s("weakmode"), luaB_weakmode}
734}; 735};
735 736