Changes in the warning system

- The warning functions get an extra parameter that tells whether
message is to be continued (instead of using end-of-lines as a signal).

- The user data for the warning function is a regular value, instead
of a writable slot inside the Lua state.
This commit is contained in:
Roberto Ierusalimschy
2019-03-14 15:30:54 -03:00
parent 9eca305e75
commit b56d4e570a
12 changed files with 79 additions and 98 deletions

View File

@@ -18,6 +18,8 @@ assert(collectgarbage("incremental") == "generational")
assert(collectgarbage("incremental") == "incremental")
local function nop () end
local function gcinfo ()
return collectgarbage"count" * 1024
end
@@ -388,7 +390,7 @@ if T then
collectgarbage()
for i = 1, 10 do assert(s[i]) end
getmetatable(u).__gc = false
getmetatable(u).__gc = nil
end
print '+'
@@ -604,8 +606,8 @@ if T then
collectgarbage("stop")
local x = T.newuserdata(0)
local y = T.newuserdata(0)
debug.setmetatable(y, {__gc = true}) -- bless the new udata before...
debug.setmetatable(x, {__gc = true}) -- ...the old one
debug.setmetatable(y, {__gc = nop}) -- bless the new udata before...
debug.setmetatable(x, {__gc = nop}) -- ...the old one
assert(T.gccolor(y) == "white")
T.checkmemory()
collectgarbage("restart")
@@ -631,6 +633,7 @@ if T then
assert(T.totalmem("thread") == t + 1)
end
-- create an object to be collected when state is closed
do
local setmetatable,assert,type,print,getmetatable =
@@ -650,7 +653,7 @@ end
-- create several objects to raise errors when collected while closing state
if T then
local error, assert, warn, find = error, assert, warn, string.find
local error, assert, find = error, assert, string.find
local n = 0
local lastmsg
local mt = {__gc = function (o)