summaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-04-05 15:54:31 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-04-05 15:54:31 -0300
commit237969724f54eeefee057ae382237c8db54af44e (patch)
treefc4abd54f7cac0749023f1c021e7d86e3ee4f273 /lbaselib.c
parentf438d00ef31e3aea54023602f529b68834ffb80a (diff)
downloadlua-237969724f54eeefee057ae382237c8db54af44e.tar.gz
lua-237969724f54eeefee057ae382237c8db54af44e.tar.bz2
lua-237969724f54eeefee057ae382237c8db54af44e.zip
support for `light' userdata + simpler support for `boxed' udata
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lbaselib.c b/lbaselib.c
index dae741b3..b8d0bacb 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.62 2002/03/27 15:30:41 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.63 2002/04/02 20:42:20 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*/
@@ -206,7 +206,7 @@ static int passresults (lua_State *L, int status, int oldtop) {
206 if (nresults > 0) 206 if (nresults > 0)
207 return nresults; /* results are already on the stack */ 207 return nresults; /* results are already on the stack */
208 else { 208 else {
209 lua_newuserdatabox(L, NULL); /* at least one result to signal no errors */ 209 lua_pushboolean(L, 1); /* at least one result to signal no errors */
210 return 1; 210 return 1;
211 } 211 }
212 } 212 }
@@ -383,6 +383,7 @@ static int luaB_tostring (lua_State *L) {
383 sprintf(buff, "function: %p", lua_topointer(L, 1)); 383 sprintf(buff, "function: %p", lua_topointer(L, 1));
384 break; 384 break;
385 case LUA_TUSERDATA: 385 case LUA_TUSERDATA:
386 case LUA_TUDATAVAL:
386 sprintf(buff, "userdata: %p", lua_touserdata(L, 1)); 387 sprintf(buff, "userdata: %p", lua_touserdata(L, 1));
387 break; 388 break;
388 case LUA_TNIL: 389 case LUA_TNIL:
@@ -439,7 +440,7 @@ static void base_open (lua_State *L) {
439 440
440 441
441static int luaB_resume (lua_State *L) { 442static int luaB_resume (lua_State *L) {
442 lua_State *co = (lua_State *)lua_touserdata(L, lua_upvalueindex(1)); 443 lua_State *co = (lua_State *)lua_getfrombox(L, lua_upvalueindex(1));
443 if (lua_resume(L, co) != 0) 444 if (lua_resume(L, co) != 0)
444 lua_error(L, "error running co-routine"); 445 lua_error(L, "error running co-routine");
445 return lua_gettop(L); 446 return lua_gettop(L);
@@ -448,7 +449,7 @@ static int luaB_resume (lua_State *L) {
448 449
449 450
450static int gc_coroutine (lua_State *L) { 451static int gc_coroutine (lua_State *L) {
451 lua_State *co = (lua_State *)lua_touserdata(L, 1); 452 lua_State *co = (lua_State *)lua_getfrombox(L, 1);
452 lua_closethread(L, co); 453 lua_closethread(L, co);
453 return 0; 454 return 0;
454} 455}
@@ -471,7 +472,7 @@ static int luaB_coroutine (lua_State *L) {
471 lua_unref(L, ref); 472 lua_unref(L, ref);
472 } 473 }
473 lua_cobegin(NL, n-1); 474 lua_cobegin(NL, n-1);
474 lua_newuserdatabox(L, NL); 475 lua_newpointerbox(L, NL);
475 lua_pushliteral(L, "Coroutine"); 476 lua_pushliteral(L, "Coroutine");
476 lua_rawget(L, LUA_REGISTRYINDEX); 477 lua_rawget(L, LUA_REGISTRYINDEX);
477 lua_setmetatable(L, -2); 478 lua_setmetatable(L, -2);