aboutsummaryrefslogtreecommitdiff
path: root/ltests.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltests.c')
-rw-r--r--ltests.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/ltests.c b/ltests.c
index 7f431343..7845716f 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 1.63 2001/02/06 16:01:29 roberto Exp roberto $ 2** $Id: ltests.c,v 1.64 2001/02/06 18:18:58 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -348,11 +348,17 @@ static int unref (lua_State *L) {
348} 348}
349 349
350static int newuserdata (lua_State *L) { 350static int newuserdata (lua_State *L) {
351 if (lua_isnumber(L, 2)) 351 if (lua_isnumber(L, 2)) {
352 lua_pushusertag(L, (void *)luaL_check_int(L, 1), luaL_check_int(L, 2)); 352 int tag = luaL_check_int(L, 2);
353 else 353 int res = lua_pushuserdata(L, (void *)luaL_check_int(L, 1));
354 if (tag) lua_settag(L, tag);
355 lua_pushnumber(L, res);
356 return 2;
357 }
358 else {
354 lua_newuserdata(L, luaL_check_int(L, 1)); 359 lua_newuserdata(L, luaL_check_int(L, 1));
355 return 1; 360 return 1;
361 }
356} 362}
357 363
358static int udataval (lua_State *L) { 364static int udataval (lua_State *L) {
@@ -361,6 +367,10 @@ static int udataval (lua_State *L) {
361 return 1; 367 return 1;
362} 368}
363 369
370static int newtag (lua_State *L) {
371 lua_pushnumber(L, lua_newtype(L, lua_tostring(L, 1), lua_tonumber(L, 2)));
372 return 1;
373}
364 374
365static int doonnewstack (lua_State *L) { 375static int doonnewstack (lua_State *L) {
366 lua_State *L1 = lua_open(L, luaL_check_int(L, 1)); 376 lua_State *L1 = lua_open(L, luaL_check_int(L, 1));
@@ -631,6 +641,7 @@ static const struct luaL_reg tests_funcs[] = {
631 {"unref", unref}, 641 {"unref", unref},
632 {"newuserdata", newuserdata}, 642 {"newuserdata", newuserdata},
633 {"udataval", udataval}, 643 {"udataval", udataval},
644 {"newtag", newtag},
634 {"doonnewstack", doonnewstack}, 645 {"doonnewstack", doonnewstack},
635 {"newstate", newstate}, 646 {"newstate", newstate},
636 {"closestate", closestate}, 647 {"closestate", closestate},