diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-12-20 08:26:33 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-12-20 08:26:33 -0200 |
| commit | 32fd039bb563b24cbe4621dcc9b3cc18d9e078b0 (patch) | |
| tree | 381804f8030b6d1d09b5cc35bd46511d7dc29739 /ltests.c | |
| parent | 75f73172c463af9643bc187eed7f1fd195238078 (diff) | |
| download | lua-32fd039bb563b24cbe4621dcc9b3cc18d9e078b0.tar.gz lua-32fd039bb563b24cbe4621dcc9b3cc18d9e078b0.tar.bz2 lua-32fd039bb563b24cbe4621dcc9b3cc18d9e078b0.zip | |
`openlib' functions return new module
Diffstat (limited to 'ltests.c')
| -rw-r--r-- | ltests.c | 25 |
1 files changed, 17 insertions, 8 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.c,v 1.148 2002/12/04 17:38:31 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.149 2002/12/19 11:11:55 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 | */ |
| @@ -457,13 +457,21 @@ static int newstate (lua_State *L) { | |||
| 457 | return 1; | 457 | return 1; |
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | |||
| 460 | static int loadlib (lua_State *L) { | 461 | static int loadlib (lua_State *L) { |
| 461 | lua_State *L1 = cast(lua_State *, cast(unsigned long, luaL_checknumber(L, 1))); | 462 | static const luaL_reg libs[] = { |
| 462 | lua_register(L1, "mathlibopen", lua_mathlibopen); | 463 | {"mathlibopen", lua_mathlibopen}, |
| 463 | lua_register(L1, "strlibopen", lua_strlibopen); | 464 | {"strlibopen", lua_strlibopen}, |
| 464 | lua_register(L1, "iolibopen", lua_iolibopen); | 465 | {"iolibopen", lua_iolibopen}, |
| 465 | lua_register(L1, "dblibopen", lua_dblibopen); | 466 | {"tablibopen", lua_tablibopen}, |
| 466 | lua_register(L1, "baselibopen", lua_baselibopen); | 467 | {"dblibopen", lua_dblibopen}, |
| 468 | {"baselibopen", lua_baselibopen}, | ||
| 469 | {NULL, NULL} | ||
| 470 | }; | ||
| 471 | lua_State *L1 = cast(lua_State *, | ||
| 472 | cast(unsigned long, luaL_checknumber(L, 1))); | ||
| 473 | lua_pushvalue(L1, LUA_GLOBALSINDEX); | ||
| 474 | luaL_openlib(L1, NULL, libs, 0); | ||
| 467 | return 0; | 475 | return 0; |
| 468 | } | 476 | } |
| 469 | 477 | ||
| @@ -486,7 +494,8 @@ static int doremote (lua_State *L) { | |||
| 486 | if (status != 0) { | 494 | if (status != 0) { |
| 487 | lua_pushnil(L); | 495 | lua_pushnil(L); |
| 488 | lua_pushnumber(L, status); | 496 | lua_pushnumber(L, status); |
| 489 | return 2; | 497 | lua_pushstring(L, lua_tostring(L1, -1)); |
| 498 | return 3; | ||
| 490 | } | 499 | } |
| 491 | else { | 500 | else { |
| 492 | int i = 0; | 501 | int i = 0; |
