3rdparty
lua-5.4.3
src
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
15
/* Increments 'L->top', checking for stack overflows */
16
#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \
17
"stack overflow");}
18
19
20
/*
21
** If a call returns too many multiple returns, the callee may not have
22
** stack space to accommodate all results. In this case, this macro
23
** increases its stack space ('L->ci->top').
24
*/
25
#define adjustresults(L,nres) \
26
{ if ((nres) <= LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
27
28
29
/* Ensure the stack has at least 'n' elements */
30
#define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \
31
"not enough elements in the stack")
32
33
34
/*
35
** To reduce the overhead of returning from C functions, the presence of
36
** to-be-closed variables in these functions is coded in the CallInfo's
37
** field 'nresults', in a way that functions with no to-be-closed variables
38
** with zero, one, or "all" wanted results have no overhead. Functions
39
** with other number of wanted results, as well as functions with
40
** variables to be closed, have an extra check.
41
*/
42
43
#define hastocloseCfunc(n) ((n) < LUA_MULTRET)
44
45
/* Map [-1, inf) (range of 'nresults') into (-inf, -2] */
46
#define codeNresults(n) (-(n) - 3)
47
#define decodeNresults(n) (-(n) - 3)
48
49
#endif
lstate.h
llimits.h
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:44