ldo.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. ** $Id: ldo.h,v 2.9 2008/07/03 14:24:36 roberto Exp roberto $
  3. ** Stack and Call structure of Lua
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef ldo_h
  7. #define ldo_h
  8. #include "lobject.h"
  9. #include "lstate.h"
  10. #include "lzio.h"
  11. #define luaD_checkstack(L,n) \
  12. if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
  13. luaD_growstack(L, n); \
  14. else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1));
  15. #define incr_top(L) {L->top++; luaD_checkstack(L,0);}
  16. #define savestack(L,p) ((char *)(p) - (char *)L->stack)
  17. #define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
  18. #define saveci(L,p) ((char *)(p) - (char *)L->base_ci)
  19. #define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n)))
  20. /* type of protected functions, to be ran by `runprotected' */
  21. typedef void (*Pfunc) (lua_State *L, void *ud);
  22. LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name);
  23. LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line);
  24. LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
  25. LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
  26. LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
  27. ptrdiff_t oldtop, ptrdiff_t ef);
  28. LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
  29. LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
  30. LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
  31. LUAI_FUNC void luaD_growstack (lua_State *L, int n);
  32. LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
  33. LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
  34. /* exported for Coco */
  35. LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
  36. #endif