ldo.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. ** $Id: ldo.h,v 1.54 2002/11/21 17:19:11 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. /*
  12. ** macro to control inclusion of some hard tests on stack reallocation
  13. */
  14. #ifndef HARDSTACKTESTS
  15. #define condhardstacktests(x) { /* empty */ }
  16. #else
  17. #define condhardstacktests(x) x
  18. #endif
  19. #define luaD_checkstack(L,n) \
  20. if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TObject)) \
  21. luaD_growstack(L, n); \
  22. else condhardstacktests(luaD_reallocstack(L, L->stacksize));
  23. #define incr_top(L) {luaD_checkstack(L,1); L->top++;}
  24. #define savestack(L,p) ((char *)(p) - (char *)L->stack)
  25. #define restorestack(L,n) ((TObject *)((char *)L->stack + (n)))
  26. #define saveci(L,p) ((char *)(p) - (char *)L->base_ci)
  27. #define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n)))
  28. /* type of protected functions, to be ran by `runprotected' */
  29. typedef void (*Pfunc) (lua_State *L, void *ud);
  30. void luaD_resetprotection (lua_State *L);
  31. int luaD_protectedparser (lua_State *L, ZIO *z, int bin);
  32. void luaD_callhook (lua_State *L, int event, int line);
  33. StkId luaD_precall (lua_State *L, StkId func);
  34. void luaD_call (lua_State *L, StkId func, int nResults);
  35. int luaD_pcall (lua_State *L, int nargs, int nresults, ptrdiff_t errfunc);
  36. void luaD_poscall (lua_State *L, int wanted, StkId firstResult);
  37. void luaD_reallocCI (lua_State *L, int newsize);
  38. void luaD_reallocstack (lua_State *L, int newsize);
  39. void luaD_growstack (lua_State *L, int n);
  40. void luaD_throw (lua_State *L, int errcode);
  41. int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
  42. #endif