diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-10-25 15:30:15 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-10-25 15:30:15 -0300 |
commit | 34840301b529686ce8168828b140a478a5d44b53 (patch) | |
tree | daceb3978c3d40fd135fb60e9e60dbff9a47731c /lapi.h | |
parent | 41c800b352149e037bdebd5f20d2f25ed2a0e2a5 (diff) | |
download | lua-34840301b529686ce8168828b140a478a5d44b53.tar.gz lua-34840301b529686ce8168828b140a478a5d44b53.tar.bz2 lua-34840301b529686ce8168828b140a478a5d44b53.zip |
To-be-closed variables in the C API
Diffstat (limited to 'lapi.h')
-rw-r--r-- | lapi.h | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -15,10 +15,23 @@ | |||
15 | "stack overflow");} | 15 | "stack overflow");} |
16 | 16 | ||
17 | #define adjustresults(L,nres) \ | 17 | #define adjustresults(L,nres) \ |
18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } | 18 | { if ((nres) <= LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } |
19 | 19 | ||
20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ |
21 | "not enough elements in the stack") | 21 | "not enough elements in the stack") |
22 | 22 | ||
23 | 23 | ||
24 | /* | ||
25 | ** To reduce the overhead of returning from C functions, the presence of | ||
26 | ** to-be-closed variables in these functions is coded in the CallInfo's | ||
27 | ** field 'nresults', in a way that functions with no to-be-closed variables | ||
28 | ** with zero, one, or "all" wanted results have no overhead. Functions | ||
29 | ** with other number of wanted results, as well as functions with | ||
30 | ** variables to be closed, have an extra check. | ||
31 | */ | ||
32 | |||
33 | #define hastocloseCfunc(n) ((n) < LUA_MULTRET) | ||
34 | |||
35 | #define codeNresults(n) (-(n) - 3) | ||
36 | |||
24 | #endif | 37 | #endif |