aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-04-11 15:39:37 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-04-11 15:39:37 -0300
commit6473f965ca699719b3b9908008f15da48cc2e6f1 (patch)
treebe13733e390e62f168995c82f9485a994b2e9464 /lapi.c
parent0e0e4a480e6d9b0125a96ca982a3e9571578a037 (diff)
downloadlua-6473f965ca699719b3b9908008f15da48cc2e6f1.tar.gz
lua-6473f965ca699719b3b9908008f15da48cc2e6f1.tar.bz2
lua-6473f965ca699719b3b9908008f15da48cc2e6f1.zip
new API functions to load (parse?) a chunk without running it.
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/lapi.c b/lapi.c
index f146bf8a..243087fe 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.137 2001/03/26 14:31:49 roberto Exp roberto $ 2** $Id: lapi.c,v 1.138 2001/04/11 14:42:41 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*/
@@ -533,7 +533,6 @@ LUA_API int lua_ref (lua_State *L, int lock) {
533 533
534/* 534/*
535** `do' functions (run Lua code) 535** `do' functions (run Lua code)
536** (most of them are in ldo.c)
537*/ 536*/
538 537
539LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) { 538LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) {
@@ -544,6 +543,31 @@ LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults) {
544} 543}
545 544
546 545
546LUA_API int lua_dofile (lua_State *L, const l_char *filename) {
547 int status;
548 status = lua_loadfile(L, filename);
549 if (status == 0) /* parse OK? */
550 status = lua_call(L, 0, LUA_MULTRET); /* call main */
551 return status;
552}
553
554
555LUA_API int lua_dobuffer (lua_State *L, const l_char *buff, size_t size,
556 const l_char *name) {
557 int status;
558 status = lua_loadbuffer(L, buff, size, name);
559 if (status == 0) /* parse OK? */
560 status = lua_call(L, 0, LUA_MULTRET); /* call main */
561 return status;
562}
563
564
565LUA_API int lua_dostring (lua_State *L, const l_char *str) {
566 return lua_dobuffer(L, str, strlen(str), str);
567}
568
569
570
547/* 571/*
548** Garbage-collection functions 572** Garbage-collection functions
549*/ 573*/