aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c6
-rw-r--r--lbaselib.c6
-rw-r--r--ldo.c5
-rw-r--r--lstate.h4
-rw-r--r--ltests.c6
-rw-r--r--lua.h60
-rw-r--r--luaconf.h18
7 files changed, 63 insertions, 42 deletions
diff --git a/lapi.c b/lapi.c
index eeba6867..be6955a1 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.224 2014/07/15 21:14:49 roberto Exp roberto $ 2** $Id: lapi.c,v 2.225 2014/07/15 21:26:50 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*/
@@ -859,7 +859,7 @@ LUA_API void lua_setuservalue (lua_State *L, int idx) {
859 "results from function overflow current stack size") 859 "results from function overflow current stack size")
860 860
861 861
862LUA_API void lua_callk (lua_State *L, int nargs, int nresults, int ctx, 862LUA_API void lua_callk (lua_State *L, int nargs, int nresults, lua_Ctx ctx,
863 lua_KFunction k) { 863 lua_KFunction k) {
864 StkId func; 864 StkId func;
865 lua_lock(L); 865 lua_lock(L);
@@ -899,7 +899,7 @@ static void f_call (lua_State *L, void *ud) {
899 899
900 900
901LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, 901LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc,
902 int ctx, lua_KFunction k) { 902 lua_Ctx ctx, lua_KFunction k) {
903 struct CallS c; 903 struct CallS c;
904 int status; 904 int status;
905 ptrdiff_t func; 905 ptrdiff_t func;
diff --git a/lbaselib.c b/lbaselib.c
index ea71660b..47d6793a 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.290 2014/06/30 19:48:08 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.291 2014/07/16 13:56:59 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*/
@@ -344,7 +344,7 @@ static int luaB_load (lua_State *L) {
344/* }====================================================== */ 344/* }====================================================== */
345 345
346 346
347static int dofilecont (lua_State *L, int d1, int d2) { 347static int dofilecont (lua_State *L, int d1, lua_Ctx d2) {
348 (void)d1; (void)d2; /* only to match 'lua_Kfunction' prototype */ 348 (void)d1; (void)d2; /* only to match 'lua_Kfunction' prototype */
349 return lua_gettop(L) - 1; 349 return lua_gettop(L) - 1;
350} 350}
@@ -395,7 +395,7 @@ static int luaB_select (lua_State *L) {
395** 'extra' values (where 'extra' is exactly the number of items to be 395** 'extra' values (where 'extra' is exactly the number of items to be
396** ignored). 396** ignored).
397*/ 397*/
398static int finishpcall (lua_State *L, int status, int extra) { 398static int finishpcall (lua_State *L, int status, lua_Ctx extra) {
399 if (status != LUA_OK && status != LUA_YIELD) { /* error? */ 399 if (status != LUA_OK && status != LUA_YIELD) { /* error? */
400 lua_pushboolean(L, 0); /* first result (false) */ 400 lua_pushboolean(L, 0); /* first result (false) */
401 lua_pushvalue(L, -2); /* error message */ 401 lua_pushvalue(L, -2); /* error message */
diff --git a/ldo.c b/ldo.c
index 1a49ceda..a9daeadb 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 2.124 2014/06/30 19:48:08 roberto Exp roberto $ 2** $Id: ldo.c,v 2.125 2014/07/15 21:26:50 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -593,7 +593,8 @@ LUA_API int lua_isyieldable (lua_State *L) {
593} 593}
594 594
595 595
596LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_KFunction k) { 596LUA_API int lua_yieldk (lua_State *L, int nresults, lua_Ctx ctx,
597 lua_KFunction k) {
597 CallInfo *ci = L->ci; 598 CallInfo *ci = L->ci;
598 luai_userstateyield(L, nresults); 599 luai_userstateyield(L, nresults);
599 lua_lock(L); 600 lua_lock(L);
diff --git a/lstate.h b/lstate.h
index 47dddcec..8b7031f8 100644
--- a/lstate.h
+++ b/lstate.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.h,v 2.106 2014/06/10 19:18:50 roberto Exp roberto $ 2** $Id: lstate.h,v 2.107 2014/06/12 19:07:30 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -71,7 +71,7 @@ typedef struct CallInfo {
71 struct { /* only for C functions */ 71 struct { /* only for C functions */
72 lua_KFunction k; /* continuation in case of yields */ 72 lua_KFunction k; /* continuation in case of yields */
73 ptrdiff_t old_errfunc; 73 ptrdiff_t old_errfunc;
74 int ctx; /* context info. in case of yields */ 74 lua_Ctx ctx; /* context info. in case of yields */
75 } c; 75 } c;
76 } u; 76 } u;
77} CallInfo; 77} CallInfo;
diff --git a/ltests.c b/ltests.c
index d6474335..803b3be2 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.174 2014/06/26 17:25:11 roberto Exp roberto $ 2** $Id: ltests.c,v 2.175 2014/07/16 14:51:36 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*/
@@ -981,7 +981,7 @@ static void pushcode (lua_State *L, int code) {
981 981
982 982
983static int testC (lua_State *L); 983static int testC (lua_State *L);
984static int Cfunck (lua_State *L, int status, int ctx); 984static int Cfunck (lua_State *L, int status, lua_Ctx ctx);
985 985
986/* 986/*
987** arithmetic operation encoding for 'arith' instruction 987** arithmetic operation encoding for 'arith' instruction
@@ -1318,7 +1318,7 @@ static int Cfunc (lua_State *L) {
1318} 1318}
1319 1319
1320 1320
1321static int Cfunck (lua_State *L, int status, int ctx) { 1321static int Cfunck (lua_State *L, int status, lua_Ctx ctx) {
1322 pushcode(L, status); 1322 pushcode(L, status);
1323 lua_setglobal(L, "status"); 1323 lua_setglobal(L, "status");
1324 lua_pushinteger(L, ctx); 1324 lua_pushinteger(L, ctx);
diff --git a/lua.h b/lua.h
index 812df98f..f79da4bc 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.h,v 1.307 2014/06/10 17:41:38 roberto Exp roberto $ 2** $Id: lua.h,v 1.308 2014/06/26 17:25:11 roberto Exp roberto $
3** Lua - A Scripting Language 3** Lua - A Scripting Language
4** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 4** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
5** See Copyright Notice at the end of this file 5** See Copyright Notice at the end of this file
@@ -53,30 +53,6 @@
53 53
54typedef struct lua_State lua_State; 54typedef struct lua_State lua_State;
55 55
56/*
57** Type for C functions registered with Lua
58*/
59typedef int (*lua_CFunction) (lua_State *L);
60
61/*
62** Type for continuation functions
63*/
64typedef int (*lua_KFunction) (lua_State *L, int status, int ctx);
65
66
67/*
68** functions that read/write blocks when loading/dumping Lua chunks
69*/
70typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
71
72typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud);
73
74
75/*
76** prototype for memory-allocation functions
77*/
78typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
79
80 56
81/* 57/*
82** basic types 58** basic types
@@ -117,6 +93,34 @@ typedef LUA_INTEGER lua_Integer;
117/* unsigned integer type */ 93/* unsigned integer type */
118typedef LUA_UNSIGNED lua_Unsigned; 94typedef LUA_UNSIGNED lua_Unsigned;
119 95
96/* type for continuation-function contexts */
97typedef LUA_CTXT lua_Ctx;
98
99
100/*
101** Type for C functions registered with Lua
102*/
103typedef int (*lua_CFunction) (lua_State *L);
104
105/*
106** Type for continuation functions
107*/
108typedef int (*lua_KFunction) (lua_State *L, int status, lua_Ctx ctx);
109
110
111/*
112** Type for functions that read/write blocks when loading/dumping Lua chunks
113*/
114typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
115
116typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud);
117
118
119/*
120** Type for memory-allocation functions
121*/
122typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
123
120 124
121 125
122/* 126/*
@@ -262,12 +266,12 @@ LUA_API void (lua_setuservalue) (lua_State *L, int idx);
262/* 266/*
263** 'load' and 'call' functions (load and run Lua code) 267** 'load' and 'call' functions (load and run Lua code)
264*/ 268*/
265LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, int ctx, 269LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, lua_Ctx ctx,
266 lua_KFunction k); 270 lua_KFunction k);
267#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL) 271#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL)
268 272
269LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, 273LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,
270 int ctx, lua_KFunction k); 274 lua_Ctx ctx, lua_KFunction k);
271#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL) 275#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL)
272 276
273LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, 277LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
@@ -280,7 +284,7 @@ LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip);
280/* 284/*
281** coroutine functions 285** coroutine functions
282*/ 286*/
283LUA_API int (lua_yieldk) (lua_State *L, int nresults, int ctx, 287LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_Ctx ctx,
284 lua_KFunction k); 288 lua_KFunction k);
285#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL) 289#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL)
286LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg); 290LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg);
diff --git a/luaconf.h b/luaconf.h
index 65ee1eff..b477319b 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.208 2014/06/24 17:02:00 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.209 2014/06/26 18:30:27 roberto Exp roberto $
3** Configuration file for Lua 3** Configuration file for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -254,6 +254,22 @@
254#define LUAI_MAXSHORTLEN 40 254#define LUAI_MAXSHORTLEN 40
255 255
256 256
257/*
258@@ LUA_CTXT is the type of the context ('ctx') for continuation functions.
259@@ It must be a numerical type; Lua will use 'intptr_t' if available.
260*/
261#if defined (LUA_USE_C99)
262#include <stdint.h>
263#if defined (INTPTR_MAX) /* even in C99 this type is optional */
264#define LUA_CTXT intptr_t
265#endif
266#endif
267
268#if !defined(LUA_CTXT)
269/* default definition (the nearest thing to 'intptr_t' in C89) */
270#define LUA_CTXT ptrdiff_t
271#endif
272
257 273
258/* 274/*
259** {================================================================== 275** {==================================================================