summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c8
-rw-r--r--lua.c4
-rw-r--r--lua.h25
-rw-r--r--lzio.c10
-rw-r--r--lzio.h8
5 files changed, 27 insertions, 28 deletions
diff --git a/lapi.c b/lapi.c
index 680ce9e1..3a58fbc0 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.194 2002/06/03 17:46:34 roberto Exp roberto $ 2** $Id: lapi.c,v 1.195 2002/06/03 20:11:07 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*/
@@ -100,7 +100,7 @@ LUA_API int lua_checkstack (lua_State *L, int size) {
100} 100}
101 101
102 102
103LUA_API lua_CFunction lua_setpanicf (lua_State *L, lua_CFunction panicf) { 103LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
104 lua_CFunction old; 104 lua_CFunction old;
105 lua_lock(L); 105 lua_lock(L);
106 old = G(L)->panic; 106 old = G(L)->panic;
@@ -563,14 +563,14 @@ LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errf) {
563} 563}
564 564
565 565
566LUA_API int lua_load (lua_State *L, lua_Getblock getblock, void *ud, 566LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data,
567 const char *chunkname) { 567 const char *chunkname) {
568 ZIO z; 568 ZIO z;
569 int status; 569 int status;
570 int c; 570 int c;
571 lua_lock(L); 571 lua_lock(L);
572 if (!chunkname) chunkname = "?"; 572 if (!chunkname) chunkname = "?";
573 luaZ_init(&z, getblock, ud, chunkname); 573 luaZ_init(&z, reader, data, chunkname);
574 c = luaZ_lookahead(&z); 574 c = luaZ_lookahead(&z);
575 status = luaD_protectedparser(L, &z, (c == LUA_SIGNATURE[0])); 575 status = luaD_protectedparser(L, &z, (c == LUA_SIGNATURE[0]));
576 lua_unlock(L); 576 lua_unlock(L);
diff --git a/lua.c b/lua.c
index 5e1f4d5a..27ef515b 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.c,v 1.88 2002/05/23 19:43:04 roberto Exp roberto $ 2** $Id: lua.c,v 1.89 2002/06/03 20:11:41 roberto Exp roberto $
3** Lua stand-alone interpreter 3** Lua stand-alone interpreter
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -370,7 +370,7 @@ int main (int argc, char *argv[]) {
370 int toclose = 0; 370 int toclose = 0;
371 (void)argc; /* to avoid warnings */ 371 (void)argc; /* to avoid warnings */
372 L = lua_open(); /* create state */ 372 L = lua_open(); /* create state */
373 lua_setpanicf(L, l_panic); 373 lua_atpanic(L, l_panic);
374 LUA_USERINIT(L); /* open libraries */ 374 LUA_USERINIT(L); /* open libraries */
375 register_own(argv); /* create own function */ 375 register_own(argv); /* create own function */
376 status = handle_luainit(); 376 status = handle_luainit();
diff --git a/lua.h b/lua.h
index 38888730..2b2082a4 100644
--- a/lua.h
+++ b/lua.h
@@ -1,9 +1,8 @@
1/* 1/*
2** $Id: lua.h,v 1.136 2002/06/03 20:11:07 roberto Exp roberto $ 2** $Id: lua.h,v 1.137 2002/06/05 12:34:19 roberto Exp roberto $
3** Lua - An Extensible Extension Language 3** Lua - An Extensible Extension Language
4** Tecgraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil 4** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
5** e-mail: info@lua.org 5** http://www.lua.org mailto:info@lua.org
6** www: http://www.lua.org
7** See Copyright Notice at the end of this file 6** See Copyright Notice at the end of this file
8*/ 7*/
9 8
@@ -26,7 +25,7 @@
26 25
27 26
28 27
29/* option for multiple returns in `lua_call' */ 28/* option for multiple returns in `lua_pcall' and `lua_rawcall' */
30#define LUA_MULTRET (-1) 29#define LUA_MULTRET (-1)
31 30
32 31
@@ -38,7 +37,7 @@
38#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) 37#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i))
39 38
40 39
41/* error codes for `lua_load*' and `lua_pcall' */ 40/* error codes for `lua_load' and `lua_pcall' */
42#define LUA_ERRRUN 1 41#define LUA_ERRRUN 1
43#define LUA_ERRFILE 2 42#define LUA_ERRFILE 2
44#define LUA_ERRSYNTAX 3 43#define LUA_ERRSYNTAX 3
@@ -52,9 +51,9 @@ typedef int (*lua_CFunction) (lua_State *L);
52 51
53 52
54/* 53/*
55** function for loading Lua code 54** functions that read blocks when loading Lua chunk
56*/ 55*/
57typedef const char * (*lua_Getblock) (void *ud, size_t *size); 56typedef const char * (*lua_Chunkreader) (void *ud, size_t *size);
58 57
59 58
60/* 59/*
@@ -84,7 +83,7 @@ typedef const char * (*lua_Getblock) (void *ud, size_t *size);
84#endif 83#endif
85 84
86 85
87/* Lua numerical type */ 86/* type of Numbers in Lua */
88#ifndef LUA_NUMBER 87#ifndef LUA_NUMBER
89#define LUA_NUMBER double 88#define LUA_NUMBER double
90#endif 89#endif
@@ -105,7 +104,7 @@ LUA_API void lua_close (lua_State *L);
105LUA_API lua_State *lua_newthread (lua_State *L); 104LUA_API lua_State *lua_newthread (lua_State *L);
106LUA_API void lua_closethread (lua_State *L, lua_State *thread); 105LUA_API void lua_closethread (lua_State *L, lua_State *thread);
107 106
108LUA_API lua_CFunction lua_setpanicf (lua_State *L, lua_CFunction panicf); 107LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf);
109 108
110 109
111/* 110/*
@@ -181,7 +180,7 @@ LUA_API void lua_setmetatable (lua_State *L, int objindex);
181*/ 180*/
182LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults); 181LUA_API void lua_rawcall (lua_State *L, int nargs, int nresults);
183LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errf); 182LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errf);
184LUA_API int lua_load (lua_State *L, lua_Getblock getblock, void *ud, 183LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data,
185 const char *chunkname); 184 const char *chunkname);
186 185
187 186
@@ -244,8 +243,8 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size);
244#define lua_isnone(L,n) (lua_type(L,n) == LUA_TNONE) 243#define lua_isnone(L,n) (lua_type(L,n) == LUA_TNONE)
245#define lua_isnoneornil(L, n) (lua_type(L,n) <= 0) 244#define lua_isnoneornil(L, n) (lua_type(L,n) <= 0)
246 245
247#define lua_pushliteral(L, s) lua_pushlstring(L, "" s, \ 246#define lua_pushliteral(L, s) \
248 (sizeof(s)/sizeof(char))-1) 247 lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
249 248
250 249
251 250
diff --git a/lzio.c b/lzio.c
index fe0e18cd..b693f636 100644
--- a/lzio.c
+++ b/lzio.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lzio.c,v 1.17 2002/06/03 17:46:34 roberto Exp roberto $ 2** $Id: lzio.c,v 1.18 2002/06/03 20:11:07 roberto Exp roberto $
3** a generic input stream interface 3** a generic input stream interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -16,7 +16,7 @@
16 16
17int luaZ_fill (ZIO *z) { 17int luaZ_fill (ZIO *z) {
18 size_t size; 18 size_t size;
19 const char *buff = z->getblock(z->ud, &size); 19 const char *buff = z->reader(z->data, &size);
20 if (buff == NULL || size == 0) return EOZ; 20 if (buff == NULL || size == 0) return EOZ;
21 z->n = size - 1; 21 z->n = size - 1;
22 z->p = buff; 22 z->p = buff;
@@ -35,9 +35,9 @@ int luaZ_lookahead (ZIO *z) {
35} 35}
36 36
37 37
38void luaZ_init (ZIO *z, lua_Getblock getblock, void *ud, const char *name) { 38void luaZ_init (ZIO *z, lua_Chunkreader reader, void *data, const char *name) {
39 z->getblock = getblock; 39 z->reader = reader;
40 z->ud = ud; 40 z->data = data;
41 z->name = name; 41 z->name = name;
42 z->n = 0; 42 z->n = 0;
43 z->p = NULL; 43 z->p = NULL;
diff --git a/lzio.h b/lzio.h
index e24c4f0e..a0dfa091 100644
--- a/lzio.h
+++ b/lzio.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lzio.h,v 1.10 2002/06/03 17:46:34 roberto Exp roberto $ 2** $Id: lzio.h,v 1.11 2002/06/03 20:11:07 roberto Exp roberto $
3** Buffered streams 3** Buffered streams
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -24,7 +24,7 @@ typedef struct zio ZIO;
24 24
25#define zname(z) ((z)->name) 25#define zname(z) ((z)->name)
26 26
27void luaZ_init (ZIO *z, lua_Getblock getblock, void *ud, const char *name); 27void luaZ_init (ZIO *z, lua_Chunkreader reader, void *data, const char *name);
28size_t luaZ_zread (ZIO* z, void* b, size_t n); /* read next n bytes */ 28size_t luaZ_zread (ZIO* z, void* b, size_t n); /* read next n bytes */
29int luaZ_lookahead (ZIO *z); 29int luaZ_lookahead (ZIO *z);
30 30
@@ -34,8 +34,8 @@ int luaZ_lookahead (ZIO *z);
34struct zio { 34struct zio {
35 size_t n; /* bytes still unread */ 35 size_t n; /* bytes still unread */
36 const char *p; /* current position in buffer */ 36 const char *p; /* current position in buffer */
37 lua_Getblock getblock; 37 lua_Chunkreader reader;
38 void* ud; /* additional data */ 38 void* data; /* additional data */
39 const char *name; 39 const char *name;
40}; 40};
41 41