aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-12-17 13:14:58 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-12-17 13:14:58 -0200
commitd51743b0c77f7e6a12d06bb139b0a135eb0138dc (patch)
tree5def9b4ac08ba8d4184c183e00e352e638fad72e
parent1a92c2b354bd08031a744cb39125a8c5d04349c3 (diff)
downloadlua-d51743b0c77f7e6a12d06bb139b0a135eb0138dc.tar.gz
lua-d51743b0c77f7e6a12d06bb139b0a135eb0138dc.tar.bz2
lua-d51743b0c77f7e6a12d06bb139b0a135eb0138dc.zip
removed 'newproxy'
-rw-r--r--lbaselib.c38
1 files changed, 1 insertions, 37 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 137ffe71..c71a670f 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.254 2010/12/08 12:58:04 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.255 2010/12/13 16:38:00 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*/
@@ -425,34 +425,6 @@ static int luaB_tostring (lua_State *L) {
425} 425}
426 426
427 427
428static int luaB_newproxy (lua_State *L) {
429 lua_settop(L, 1);
430 lua_newuserdata(L, 0); /* create proxy */
431 if (lua_toboolean(L, 1) == 0)
432 return 1; /* no metatable */
433 else if (lua_isboolean(L, 1)) {
434 lua_createtable(L, 0, 1); /* create a new metatable `m' ... */
435 lua_pushboolean(L, 1);
436 lua_setfield(L, -2, "__gc"); /* ... m.__gc = true (HACK!!)... */
437 lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */
438 lua_pushboolean(L, 1);
439 lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */
440 }
441 else {
442 int validproxy = 0; /* to check if weaktable[metatable(u)] == true */
443 if (lua_getmetatable(L, 1)) {
444 lua_rawget(L, lua_upvalueindex(1));
445 validproxy = lua_toboolean(L, -1);
446 lua_pop(L, 1); /* remove value */
447 }
448 luaL_argcheck(L, validproxy, 1, "boolean or proxy expected");
449 lua_getmetatable(L, 1); /* metatable is valid; get it */
450 }
451 lua_setmetatable(L, 2);
452 return 1;
453}
454
455
456static const luaL_Reg base_funcs[] = { 428static const luaL_Reg base_funcs[] = {
457 {"assert", luaB_assert}, 429 {"assert", luaB_assert},
458 {"collectgarbage", luaB_collectgarbage}, 430 {"collectgarbage", luaB_collectgarbage},
@@ -491,14 +463,6 @@ LUAMOD_API int luaopen_base (lua_State *L) {
491 luaL_setfuncs(L, base_funcs, 0); 463 luaL_setfuncs(L, base_funcs, 0);
492 lua_pushliteral(L, LUA_VERSION); 464 lua_pushliteral(L, LUA_VERSION);
493 lua_setfield(L, -2, "_VERSION"); /* set global _VERSION */ 465 lua_setfield(L, -2, "_VERSION"); /* set global _VERSION */
494 /* `newproxy' needs a weaktable as upvalue */
495 lua_createtable(L, 0, 1); /* new table `w' */
496 lua_pushvalue(L, -1); /* `w' will be its own metatable */
497 lua_setmetatable(L, -2);
498 lua_pushliteral(L, "kv");
499 lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */
500 lua_pushcclosure(L, luaB_newproxy, 1);
501 lua_setfield(L, -2, "newproxy"); /* set global `newproxy' */
502 return 1; 466 return 1;
503} 467}
504 468