lapi.h 1001 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. ** $Id: lapi.h $
  3. ** Auxiliary functions from Lua API
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef lapi_h
  7. #define lapi_h
  8. #include "llimits.h"
  9. #include "lstate.h"
  10. #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \
  11. "stack overflow");}
  12. #define adjustresults(L,nres) \
  13. { if ((nres) <= LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
  14. #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \
  15. "not enough elements in the stack")
  16. /*
  17. ** To reduce the overhead of returning from C functions, the presence of
  18. ** to-be-closed variables in these functions is coded in the CallInfo's
  19. ** field 'nresults', in a way that functions with no to-be-closed variables
  20. ** with zero, one, or "all" wanted results have no overhead. Functions
  21. ** with other number of wanted results, as well as functions with
  22. ** variables to be closed, have an extra check.
  23. */
  24. #define hastocloseCfunc(n) ((n) < LUA_MULTRET)
  25. #define codeNresults(n) (-(n) - 3)
  26. #endif