libluv: use luv_set_callback to control callback execution

Disable the use of deferred API functions in a fast lua callback
Correctly display error messages from a fast lua callback
This commit is contained in:
Björn Linse
2019-06-23 20:10:28 +02:00
parent 7030d7daf1
commit d33aaa0f5f
8 changed files with 192 additions and 14 deletions

View File

@@ -349,6 +349,7 @@ output:write([[
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/lua/converter.h"
#include "nvim/lua/executor.h"
]])
include_headers(output, headers)
output:write('\n')
@@ -372,6 +373,14 @@ local function process_function(fn)
binding=lua_c_function_name,
api=fn.name
}
if not fn.fast then
write_shifted_output(output, string.format([[
if (!nlua_is_deferred_safe(lstate)) {
return luaL_error(lstate, e_luv_api_disabled, "%s");
}
]], fn.name))
end
local cparams = ''
local free_code = {}
for j = #fn.parameters,1,-1 do