rlm@1: /* rlm@1: ** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ rlm@1: ** Stack and Call structure of Lua rlm@1: ** See Copyright Notice in lua.h rlm@1: */ rlm@1: rlm@1: #ifndef ldo_h rlm@1: #define ldo_h rlm@1: rlm@1: rlm@1: #include "lobject.h" rlm@1: #include "lstate.h" rlm@1: #include "lzio.h" rlm@1: rlm@1: rlm@1: #define luaD_checkstack(L,n) \ rlm@1: if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ rlm@1: luaD_growstack(L, n); \ rlm@1: else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); rlm@1: rlm@1: rlm@1: #define incr_top(L) {luaD_checkstack(L,1); L->top++;} rlm@1: rlm@1: #define savestack(L,p) ((char *)(p) - (char *)L->stack) rlm@1: #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) rlm@1: rlm@1: #define saveci(L,p) ((char *)(p) - (char *)L->base_ci) rlm@1: #define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) rlm@1: rlm@1: rlm@1: /* results from luaD_precall */ rlm@1: #define PCRLUA 0 /* initiated a call to a Lua function */ rlm@1: #define PCRC 1 /* did a call to a C function */ rlm@1: #define PCRYIELD 2 /* C funtion yielded */ rlm@1: rlm@1: rlm@1: /* type of protected functions, to be ran by `runprotected' */ rlm@1: typedef void (*Pfunc) (lua_State *L, void *ud); rlm@1: rlm@1: LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); rlm@1: LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); rlm@1: LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); rlm@1: LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); rlm@1: LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, rlm@1: ptrdiff_t oldtop, ptrdiff_t ef); rlm@1: LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); rlm@1: LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); rlm@1: LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); rlm@1: LUAI_FUNC void luaD_growstack (lua_State *L, int n); rlm@1: rlm@1: LUAI_FUNC void luaD_throw (lua_State *L, int errcode); rlm@1: LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); rlm@1: rlm@1: LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); rlm@1: rlm@1: #endif rlm@1: