diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-06-30 16:03:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-30 16:03:58 +0200 |
commit | 10a533e9d41ad8917c17e96cf696fcea4b07374f (patch) | |
tree | 69bcc294d1a956856578e9dfb6d87271b6057729 /src/nvim/generators | |
parent | 3b504e7c8d20bb41ef6b6f95e46527766438046a (diff) | |
parent | 99f24dfbed84cea24fc1d8bb80ab10a2dd3eca0b (diff) | |
download | rneovim-10a533e9d41ad8917c17e96cf696fcea4b07374f.tar.gz rneovim-10a533e9d41ad8917c17e96cf696fcea4b07374f.tar.bz2 rneovim-10a533e9d41ad8917c17e96cf696fcea4b07374f.zip |
Merge pull request #10316 from bfredl/cb_safety
luv callbacks: throw error on deferred methods instead of crashing
Diffstat (limited to 'src/nvim/generators')
-rw-r--r-- | src/nvim/generators/c_grammar.lua | 4 | ||||
-rw-r--r-- | src/nvim/generators/gen_api_dispatch.lua | 11 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/nvim/generators/c_grammar.lua b/src/nvim/generators/c_grammar.lua index 40bdc3e30c..8d50290ccc 100644 --- a/src/nvim/generators/c_grammar.lua +++ b/src/nvim/generators/c_grammar.lua @@ -35,11 +35,11 @@ local c_params = Ct(c_void + c_param_list) local c_proto = Ct( Cg(c_type, 'return_type') * Cg(c_id, 'name') * fill * P('(') * fill * Cg(c_params, 'parameters') * fill * P(')') * - Cg(Cc(false), 'async') * + Cg(Cc(false), 'fast') * (fill * Cg((P('FUNC_API_SINCE(') * C(num ^ 1)) * P(')'), 'since') ^ -1) * (fill * Cg((P('FUNC_API_DEPRECATED_SINCE(') * C(num ^ 1)) * P(')'), 'deprecated_since') ^ -1) * - (fill * Cg((P('FUNC_API_ASYNC') * Cc(true)), 'async') ^ -1) * + (fill * Cg((P('FUNC_API_FAST') * Cc(true)), 'fast') ^ -1) * (fill * Cg((P('FUNC_API_NOEXPORT') * Cc(true)), 'noexport') ^ -1) * (fill * Cg((P('FUNC_API_REMOTE_ONLY') * Cc(true)), 'remote_only') ^ -1) * (fill * Cg((P('FUNC_API_REMOTE_IMPL') * Cc(true)), 'remote_impl') ^ -1) * diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index f52d05a4a5..3ebcd2d1c4 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -309,7 +309,7 @@ for i = 1, #functions do '(String) {.data = "'..fn.name..'", '.. '.size = sizeof("'..fn.name..'") - 1}, '.. '(MsgpackRpcRequestHandler) {.fn = handle_'.. (fn.impl_name or fn.name).. - ', .async = '..tostring(fn.async)..'});\n') + ', .fast = '..tostring(fn.fast)..'});\n') end @@ -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 |