ldo.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. ** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
  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) {luaD_checkstack(L,1); L->top++;}
  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. /* results from luaD_precall */
  21. #define PCRLUA 0 /* initiated a call to a Lua function */
  22. #define PCRC 1 /* did a call to a C function */
  23. #define PCRYIELD 2 /* C funtion yielded */
  24. /* type of protected functions, to be ran by `runprotected' */
  25. typedef void (*Pfunc) (lua_State *L, void *ud);
  26. LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name);
  27. LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line);
  28. LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
  29. LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
  30. LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
  31. ptrdiff_t oldtop, ptrdiff_t ef);
  32. LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
  33. LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
  34. LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
  35. LUAI_FUNC void luaD_growstack (lua_State *L, int n);
  36. LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
  37. LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
  38. LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
  39. #endif