diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-25 18:31:28 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-25 18:31:28 -0300 |
| commit | 118e9cd843d2956d64b86bfdd70f89919153e471 (patch) | |
| tree | 1b847891b5d725bd34b9335cd47fb982a904ea8b /lapi.c | |
| parent | de00d0d0add8686917bc28b7fe0f2974c155f22e (diff) | |
| download | lua-118e9cd843d2956d64b86bfdd70f89919153e471.tar.gz lua-118e9cd843d2956d64b86bfdd70f89919153e471.tar.bz2 lua-118e9cd843d2956d64b86bfdd70f89919153e471.zip | |
new facility for dumping chunks
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 20 |
1 files changed, 19 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.213 2002/09/20 17:01:24 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.214 2002/10/25 20:05:28 roberto Exp roberto $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -127,6 +127,7 @@ LUA_API lua_State *lua_newthread (lua_State *L) { | |||
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | 129 | ||
| 130 | |||
| 130 | /* | 131 | /* |
| 131 | ** basic stack manipulation | 132 | ** basic stack manipulation |
| 132 | */ | 133 | */ |
| @@ -681,6 +682,23 @@ LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data, | |||
| 681 | } | 682 | } |
| 682 | 683 | ||
| 683 | 684 | ||
| 685 | LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) { | ||
| 686 | int status; | ||
| 687 | TObject *o; | ||
| 688 | lua_lock(L); | ||
| 689 | api_checknelems(L, 1); | ||
| 690 | o = L->top - 1; | ||
| 691 | if (isLfunction(o) && clvalue(o)->l.nupvalues == 0) { | ||
| 692 | luaU_dump(L, clvalue(o)->l.p, writer, data); | ||
| 693 | status = 1; | ||
| 694 | } | ||
| 695 | else | ||
| 696 | status = 0; | ||
| 697 | lua_unlock(L); | ||
| 698 | return status; | ||
| 699 | } | ||
| 700 | |||
| 701 | |||
| 684 | /* | 702 | /* |
| 685 | ** Garbage-collection functions | 703 | ** Garbage-collection functions |
| 686 | */ | 704 | */ |
