native Lua  0.5.0-devel
Lua on the platform you use with the compiler you choose
lapi.h
Go to the documentation of this file.
1 /*
2 ** $Id: lapi.h $
3 ** Auxiliary functions from Lua API
4 ** See Copyright Notice in lua.h
5 */
6 
7 #ifndef lapi_h
8 #define lapi_h
9 
10 
11 #include "llimits.h"
12 #include "lstate.h"
13 
14 #include "_native_lua_config.h" /* native Lua */
15 
16 
17 /* Increments 'L->top', checking for stack overflows */
18 #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \
19  "stack overflow");}
20 
21 
22 /*
23 ** If a call returns too many multiple returns, the callee may not have
24 ** stack space to accommodate all results. In this case, this macro
25 ** increases its stack space ('L->ci->top').
26 */
27 #define adjustresults(L,nres) \
28  { if ((nres) <= LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
29 
30 
31 /* Ensure the stack has at least 'n' elements */
32 #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \
33  "not enough elements in the stack")
34 
35 
36 /*
37 ** To reduce the overhead of returning from C functions, the presence of
38 ** to-be-closed variables in these functions is coded in the CallInfo's
39 ** field 'nresults', in a way that functions with no to-be-closed variables
40 ** with zero, one, or "all" wanted results have no overhead. Functions
41 ** with other number of wanted results, as well as functions with
42 ** variables to be closed, have an extra check.
43 */
44 
45 #define hastocloseCfunc(n) ((n) < LUA_MULTRET)
46 
47 #define codeNresults(n) (-(n) - 3)
48 
49 #endif
lstate.h
_native_lua_config.h
native Lua configuration file
llimits.h