Commit Graph

23 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
59c88f846d Broadening the use of branch hints
More uses of macros 'likely'/'unlikely' (renamed to
'l_likely'/'l_unlikely'), both in range (extended to the
libraries) and in scope (extended to hooks, stack growth).
2021-02-24 11:14:44 -03:00
Roberto Ierusalimschy
0ceada8da9 Report last error in closing methods
When there are multiple errors around closing methods, report the
last error instead of the original.
2020-12-22 10:54:25 -03:00
Roberto Ierusalimschy
b57574d6fb Keep memory errors as memory errors
Allow memory errors to be raised through the API (throwing the
error with the memory error message); error in external allocations
raises a memory error; memory errors in coroutines are re-raised
as memory errors.
2020-07-06 12:09:44 -03:00
Roberto Ierusalimschy
7bd1e53753 Fixed a warning and other minor issues
Fixed some minor issues from the feedback for 5.4-beta rc1.
2019-10-04 16:17:04 -03:00
Roberto Ierusalimschy
b4d5dff8ec Multiple errors in '__toclose' report the first one
When there are multiple errors when closing objects, the error
reported by the protected call is the first one, for two reasons:
First, other errors may be caused by this one;
second, the first error is handled in the original execution context,
and therefore has the full traceback.
2019-06-05 13:16:25 -03:00
Roberto Ierusalimschy
514d942748 'coroutine.kill' renamed 'coroutine.close' 2019-06-03 13:11:20 -03:00
Roberto Ierusalimschy
3f253f116e Test for dead coroutine moved to 'lua_resume'
The test for dead coroutines done in the 'coro' library was moved
to 'lua_resume', in the kernel, which already does other similar
tests.
2019-05-09 11:32:20 -03:00
Roberto Ierusalimschy
389116d8ab Coroutines do not unwind the stack in case of errors
Back to how it was, a coroutine does not unwind its stack in case of
errors (and therefore do not close its to-be-closed variables). This
allows the stack to be examined after the error. The program can
use 'coroutine.kill' to close the variables.

The function created by 'coroutine.wrap', however, closes the
coroutine's variables in case of errors, as it is impossible to examine
the stack any way.
2019-05-09 11:13:45 -03:00
Roberto Ierusalimschy
a93e014447 Added an optional parameter to 'coroutine.isyieldable' 2019-04-10 13:23:14 -03:00
Roberto Ierusalimschy
fdc25a1ebf New functions 'lua_resetthread' and 'coroutine.kill'
New functions to reset/kill a thread/coroutine, mainly (only?) to
close any pending to-be-closed variable. ('lua_resetthread' also
allows a thread to be reused...)
2018-12-13 13:07:53 -02:00
Roberto Ierusalimschy
46beca5bed Better error messages for some polymorphic functions
New auxiliary functions/macros 'luaL_argexpected'/'luaL_typeerror'
ease the creation of error messages such as

  bad argument #2 to 'setmetatable' (nil or table expected, got boolean)

(The novelty being the "got boolean" part...)
2018-12-10 13:46:03 -02:00
Roberto Ierusalimschy
f99509581e Removed extra information from RCS keyword strings
Version numbers and dates (mostly wrong) from RCS keyword strings
removed from all source files; only the file name are kept.
2018-08-23 14:26:12 -03:00
Roberto Ierusalimschy
ba36180fd7 new API for 'lua_resume' + cleaning the uses of the 'extra' field in
'CallInfo'
2017-11-02 09:28:56 -02:00
Roberto Ierusalimschy
fdd7209688 error handling in 'wrap' does not coerce numbers into string messages 2016-04-11 16:19:55 -03:00
Roberto Ierusalimschy
28fdbcf393 added include for 'lprefix.h', for stuff that must be added before
any other header file
2014-11-02 17:19:04 -02:00
Roberto Ierusalimschy
bdf566a8a3 `name' in comments changed to 'name' 2014-10-25 09:50:46 -02:00
Roberto Ierusalimschy
979a663d2a detail (error message from 'coroutine.status') 2014-09-01 15:00:04 -03:00
Roberto Ierusalimschy
1bd70a8e40 new function 'lua_isyieldable' (and 'coroutine.isyieldable') 2014-05-08 10:52:20 -03:00
Roberto Ierusalimschy
a83ed55f1e added 'return' (when possible) to calls to error functions 2013-02-21 10:44:53 -03:00
Roberto Ierusalimschy
bb1146dc39 wrong error message when 'coroutine.create' or 'coroutine.wrap' are
called with no arguments (new thread is assumed to be the missing
argument).
2012-04-27 15:59:04 -03:00
Roberto Ierusalimschy
3dc5475e23 'nCcalls' should be local to each thread, as each thread may have its
own C stack (with LuaThreads or something similar)
2011-08-23 14:24:34 -03:00
Roberto Ierusalimschy
7192afafee new module policy: C modules do not create globals and do not register
themselves with 'require' (let 'require' do its work); new auxiliary
functions luaL_newlib/luaL_newlibtable/luaL_setfuncs/luaL_requiref.
Old luaL_register will be deprecated.
2010-07-02 08:38:13 -03:00
Roberto Ierusalimschy
bd262d591f 'coroutine' library separated from 'baselib' 2010-06-10 18:30:26 -03:00