mirror of
https://github.com/lua/lua
synced 2026-09-26 16:17:11 +03:00
Details
- Some api_checknelems changed to the more restrict api_checkpop. - Added a class to the html for APIs in the manual. - Comments and manual.
This commit is contained in:
parent
9130ceb19d
commit
d5bbe95584
5 changed files with 18 additions and 9 deletions
6
lapi.c
6
lapi.c
|
|
@ -1210,7 +1210,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
|
||||||
else if (g->GCdebt >= n - MAX_LMEM) /* no overflow? */
|
else if (g->GCdebt >= n - MAX_LMEM) /* no overflow? */
|
||||||
newdebt = g->GCdebt - n;
|
newdebt = g->GCdebt - n;
|
||||||
else /* overflow */
|
else /* overflow */
|
||||||
newdebt = -MAX_LMEM; /* set debt to miminum value */
|
newdebt = -MAX_LMEM; /* set debt to mininum value */
|
||||||
luaE_setdebt(g, newdebt);
|
luaE_setdebt(g, newdebt);
|
||||||
luaC_condGC(L, (void)0, work = 1);
|
luaC_condGC(L, (void)0, work = 1);
|
||||||
if (work && g->gcstate == GCSpause) /* end of cycle? */
|
if (work && g->gcstate == GCSpause) /* end of cycle? */
|
||||||
|
|
@ -1299,8 +1299,8 @@ LUA_API void lua_toclose (lua_State *L, int idx) {
|
||||||
|
|
||||||
LUA_API void lua_concat (lua_State *L, int n) {
|
LUA_API void lua_concat (lua_State *L, int n) {
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
api_checknelems(L, n);
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
|
api_checkpop(L, n);
|
||||||
luaV_concat(L, n);
|
luaV_concat(L, n);
|
||||||
luaC_checkGC(L);
|
luaC_checkGC(L);
|
||||||
}
|
}
|
||||||
|
|
@ -1418,7 +1418,7 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
|
||||||
TValue *fi;
|
TValue *fi;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
fi = index2value(L, funcindex);
|
fi = index2value(L, funcindex);
|
||||||
api_checknelems(L, 1);
|
api_checkpop(L, 1);
|
||||||
name = aux_upvalue(fi, n, &val, &owner);
|
name = aux_upvalue(fi, n, &val, &owner);
|
||||||
if (name) {
|
if (name) {
|
||||||
L->top.p--;
|
L->top.p--;
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@
|
||||||
#if defined(LUA_USE_MACOSX)
|
#if defined(LUA_USE_MACOSX)
|
||||||
#define LUA_USE_POSIX
|
#define LUA_USE_POSIX
|
||||||
#define LUA_USE_DLOPEN /* macOS does not need -ldl */
|
#define LUA_USE_DLOPEN /* macOS does not need -ldl */
|
||||||
#define LUA_USE_READLINE
|
#define LUA_USE_READLINE /* needs an extra library: -lreadline */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
2
lvm.c
2
lvm.c
|
|
@ -925,7 +925,7 @@ void luaV_finishOp (lua_State *L) {
|
||||||
** Macros for arithmetic/bitwise/comparison opcodes in 'luaV_execute'
|
** Macros for arithmetic/bitwise/comparison opcodes in 'luaV_execute'
|
||||||
**
|
**
|
||||||
** All these macros are to be used exclusively inside the main
|
** All these macros are to be used exclusively inside the main
|
||||||
** iterpreter loop (function luaV_execute) and may access directly
|
** interpreter loop (function luaV_execute) and may access directly
|
||||||
** the local variables of that function (L, i, pc, ci, etc.).
|
** the local variables of that function (L, i, pc, ci, etc.).
|
||||||
** ===================================================================
|
** ===================================================================
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ end
|
||||||
|
|
||||||
local function compose (f,g)
|
local function compose (f,g)
|
||||||
assert(f and g)
|
assert(f and g)
|
||||||
return function (s) return g(f(s)) end
|
return function (...) return g(f(...)) end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function concat (f, g)
|
local function concat (f, g)
|
||||||
|
|
@ -395,9 +395,10 @@ APIEntry = function (e)
|
||||||
local apiicmd, ne = string.match(e, "^(.-</span>)(.*)")
|
local apiicmd, ne = string.match(e, "^(.-</span>)(.*)")
|
||||||
--io.stderr:write(e)
|
--io.stderr:write(e)
|
||||||
if not apiicmd then
|
if not apiicmd then
|
||||||
return antipara(Tag.hr() .. Tag.h3(a)) .. Tag.pre(h) .. e
|
return antipara(Tag.hr() .. Tag.h3(a)) .. Tag.pre(h, {class="api"}) .. e
|
||||||
else
|
else
|
||||||
return antipara(Tag.hr() .. Tag.h3(a)) .. apiicmd .. Tag.pre(h) .. ne
|
return antipara(Tag.hr() .. Tag.h3(a)) .. apiicmd ..
|
||||||
|
Tag.pre(h, {class="api"}) .. ne
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1728,7 +1728,7 @@ global X <const>, _G
|
||||||
X = 1 -- ERROR
|
X = 1 -- ERROR
|
||||||
_ENV.X = 1 -- Ok
|
_ENV.X = 1 -- Ok
|
||||||
_G.print(X) -- Ok
|
_G.print(X) -- Ok
|
||||||
foo() -- 'foo' can freely change any global
|
foo() -- 'foo' can freely change any global
|
||||||
}
|
}
|
||||||
|
|
||||||
A chunk is also a block @see{chunks},
|
A chunk is also a block @see{chunks},
|
||||||
|
|
@ -6071,6 +6071,14 @@ In both cases,
|
||||||
the function pushes onto the stack the final value associated
|
the function pushes onto the stack the final value associated
|
||||||
with @id{tname} in the registry.
|
with @id{tname} in the registry.
|
||||||
|
|
||||||
|
Usage note: Beware the use of the return value of this function to
|
||||||
|
conditionally initializes the new metatable
|
||||||
|
(e.g., by adding metamethods to it).
|
||||||
|
If the initialization raises an error,
|
||||||
|
the metatable will not be properly initialized,
|
||||||
|
but a subsequent execution of that code will detect that the
|
||||||
|
metatable already exists and then skip the initialization.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@APIEntry{lua_State *luaL_newstate (void);|
|
@APIEntry{lua_State *luaL_newstate (void);|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue