mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 23:08:16 +00:00
api: add textlock check
This commit is contained in:
@@ -329,6 +329,7 @@ void nvim_buf_set_lines(uint64_t channel_id,
|
|||||||
ArrayOf(String) replacement,
|
ArrayOf(String) replacement,
|
||||||
Error *err)
|
Error *err)
|
||||||
FUNC_API_SINCE(1)
|
FUNC_API_SINCE(1)
|
||||||
|
FUNC_API_CHECK_TEXTLOCK
|
||||||
{
|
{
|
||||||
buf_T *buf = find_buffer_by_handle(buffer, err);
|
buf_T *buf = find_buffer_by_handle(buffer, err);
|
||||||
|
|
||||||
@@ -779,6 +780,7 @@ Boolean nvim_buf_is_loaded(Buffer buffer)
|
|||||||
/// - unload: Unloaded only, do not delete. See |:bunload|
|
/// - unload: Unloaded only, do not delete. See |:bunload|
|
||||||
void nvim_buf_delete(Buffer buffer, Dictionary opts, Error *err)
|
void nvim_buf_delete(Buffer buffer, Dictionary opts, Error *err)
|
||||||
FUNC_API_SINCE(7)
|
FUNC_API_SINCE(7)
|
||||||
|
FUNC_API_CHECK_TEXTLOCK
|
||||||
{
|
{
|
||||||
buf_T *buf = find_buffer_by_handle(buffer, err);
|
buf_T *buf = find_buffer_by_handle(buffer, err);
|
||||||
|
|
||||||
|
@@ -857,6 +857,7 @@ String nvim_get_current_line(Error *err)
|
|||||||
/// @param[out] err Error details, if any
|
/// @param[out] err Error details, if any
|
||||||
void nvim_set_current_line(String line, Error *err)
|
void nvim_set_current_line(String line, Error *err)
|
||||||
FUNC_API_SINCE(1)
|
FUNC_API_SINCE(1)
|
||||||
|
FUNC_API_CHECK_TEXTLOCK
|
||||||
{
|
{
|
||||||
buffer_set_line(curbuf->handle, curwin->w_cursor.lnum - 1, line, err);
|
buffer_set_line(curbuf->handle, curwin->w_cursor.lnum - 1, line, err);
|
||||||
}
|
}
|
||||||
@@ -866,6 +867,7 @@ void nvim_set_current_line(String line, Error *err)
|
|||||||
/// @param[out] err Error details, if any
|
/// @param[out] err Error details, if any
|
||||||
void nvim_del_current_line(Error *err)
|
void nvim_del_current_line(Error *err)
|
||||||
FUNC_API_SINCE(1)
|
FUNC_API_SINCE(1)
|
||||||
|
FUNC_API_CHECK_TEXTLOCK
|
||||||
{
|
{
|
||||||
buffer_del_line(curbuf->handle, curwin->w_cursor.lnum - 1, err);
|
buffer_del_line(curbuf->handle, curwin->w_cursor.lnum - 1, err);
|
||||||
}
|
}
|
||||||
@@ -1060,6 +1062,7 @@ Buffer nvim_get_current_buf(void)
|
|||||||
/// @param[out] err Error details, if any
|
/// @param[out] err Error details, if any
|
||||||
void nvim_set_current_buf(Buffer buffer, Error *err)
|
void nvim_set_current_buf(Buffer buffer, Error *err)
|
||||||
FUNC_API_SINCE(1)
|
FUNC_API_SINCE(1)
|
||||||
|
FUNC_API_CHECK_TEXTLOCK
|
||||||
{
|
{
|
||||||
buf_T *buf = find_buffer_by_handle(buffer, err);
|
buf_T *buf = find_buffer_by_handle(buffer, err);
|
||||||
|
|
||||||
@@ -1114,6 +1117,7 @@ Window nvim_get_current_win(void)
|
|||||||
/// @param[out] err Error details, if any
|
/// @param[out] err Error details, if any
|
||||||
void nvim_set_current_win(Window window, Error *err)
|
void nvim_set_current_win(Window window, Error *err)
|
||||||
FUNC_API_SINCE(1)
|
FUNC_API_SINCE(1)
|
||||||
|
FUNC_API_CHECK_TEXTLOCK
|
||||||
{
|
{
|
||||||
win_T *win = find_window_by_handle(window, err);
|
win_T *win = find_window_by_handle(window, err);
|
||||||
|
|
||||||
@@ -1263,6 +1267,7 @@ fail:
|
|||||||
Window nvim_open_win(Buffer buffer, Boolean enter, Dictionary config,
|
Window nvim_open_win(Buffer buffer, Boolean enter, Dictionary config,
|
||||||
Error *err)
|
Error *err)
|
||||||
FUNC_API_SINCE(6)
|
FUNC_API_SINCE(6)
|
||||||
|
FUNC_API_CHECK_TEXTLOCK
|
||||||
{
|
{
|
||||||
FloatConfig fconfig = FLOAT_CONFIG_INIT;
|
FloatConfig fconfig = FLOAT_CONFIG_INIT;
|
||||||
if (!parse_float_config(config, &fconfig, false, err)) {
|
if (!parse_float_config(config, &fconfig, false, err)) {
|
||||||
@@ -1327,6 +1332,7 @@ Tabpage nvim_get_current_tabpage(void)
|
|||||||
/// @param[out] err Error details, if any
|
/// @param[out] err Error details, if any
|
||||||
void nvim_set_current_tabpage(Tabpage tabpage, Error *err)
|
void nvim_set_current_tabpage(Tabpage tabpage, Error *err)
|
||||||
FUNC_API_SINCE(1)
|
FUNC_API_SINCE(1)
|
||||||
|
FUNC_API_CHECK_TEXTLOCK
|
||||||
{
|
{
|
||||||
tabpage_T *tp = find_tab_by_handle(tabpage, err);
|
tabpage_T *tp = find_tab_by_handle(tabpage, err);
|
||||||
|
|
||||||
@@ -1411,6 +1417,7 @@ Dictionary nvim_get_namespaces(void)
|
|||||||
/// - false: Client must cancel the paste.
|
/// - false: Client must cancel the paste.
|
||||||
Boolean nvim_paste(String data, Boolean crlf, Integer phase, Error *err)
|
Boolean nvim_paste(String data, Boolean crlf, Integer phase, Error *err)
|
||||||
FUNC_API_SINCE(6)
|
FUNC_API_SINCE(6)
|
||||||
|
FUNC_API_CHECK_TEXTLOCK
|
||||||
{
|
{
|
||||||
static bool draining = false;
|
static bool draining = false;
|
||||||
bool cancel = false;
|
bool cancel = false;
|
||||||
@@ -1483,6 +1490,7 @@ theend:
|
|||||||
void nvim_put(ArrayOf(String) lines, String type, Boolean after,
|
void nvim_put(ArrayOf(String) lines, String type, Boolean after,
|
||||||
Boolean follow, Error *err)
|
Boolean follow, Error *err)
|
||||||
FUNC_API_SINCE(6)
|
FUNC_API_SINCE(6)
|
||||||
|
FUNC_API_CHECK_TEXTLOCK
|
||||||
{
|
{
|
||||||
yankreg_T *reg = xcalloc(sizeof(yankreg_T), 1);
|
yankreg_T *reg = xcalloc(sizeof(yankreg_T), 1);
|
||||||
if (!prepare_yankreg_from_object(reg, type, lines.size)) {
|
if (!prepare_yankreg_from_object(reg, type, lines.size)) {
|
||||||
|
@@ -44,6 +44,7 @@ Buffer nvim_win_get_buf(Window window, Error *err)
|
|||||||
/// @param[out] err Error details, if any
|
/// @param[out] err Error details, if any
|
||||||
void nvim_win_set_buf(Window window, Buffer buffer, Error *err)
|
void nvim_win_set_buf(Window window, Buffer buffer, Error *err)
|
||||||
FUNC_API_SINCE(5)
|
FUNC_API_SINCE(5)
|
||||||
|
FUNC_API_CHECK_TEXTLOCK
|
||||||
{
|
{
|
||||||
win_T *win = find_window_by_handle(window, err), *save_curwin = curwin;
|
win_T *win = find_window_by_handle(window, err), *save_curwin = curwin;
|
||||||
buf_T *buf = find_buffer_by_handle(buffer, err);
|
buf_T *buf = find_buffer_by_handle(buffer, err);
|
||||||
@@ -500,6 +501,7 @@ Dictionary nvim_win_get_config(Window window, Error *err)
|
|||||||
/// @param[out] err Error details, if any
|
/// @param[out] err Error details, if any
|
||||||
void nvim_win_close(Window window, Boolean force, Error *err)
|
void nvim_win_close(Window window, Boolean force, Error *err)
|
||||||
FUNC_API_SINCE(6)
|
FUNC_API_SINCE(6)
|
||||||
|
FUNC_API_CHECK_TEXTLOCK
|
||||||
{
|
{
|
||||||
win_T *win = find_window_by_handle(window, err);
|
win_T *win = find_window_by_handle(window, err);
|
||||||
if (!win) {
|
if (!win) {
|
||||||
|
@@ -213,6 +213,8 @@
|
|||||||
# define FUNC_API_REMOTE_ONLY
|
# define FUNC_API_REMOTE_ONLY
|
||||||
/// API function not exposed in VimL/remote.
|
/// API function not exposed in VimL/remote.
|
||||||
# define FUNC_API_LUA_ONLY
|
# define FUNC_API_LUA_ONLY
|
||||||
|
/// API function checked textlock.
|
||||||
|
# define FUNC_API_CHECK_TEXTLOCK
|
||||||
/// API function introduced at the given API level.
|
/// API function introduced at the given API level.
|
||||||
# define FUNC_API_SINCE(X)
|
# define FUNC_API_SINCE(X)
|
||||||
/// API function deprecated since the given API level.
|
/// API function deprecated since the given API level.
|
||||||
|
@@ -43,6 +43,7 @@ local c_proto = Ct(
|
|||||||
(fill * Cg((P('FUNC_API_NOEXPORT') * Cc(true)), 'noexport') ^ -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_ONLY') * Cc(true)), 'remote_only') ^ -1) *
|
||||||
(fill * Cg((P('FUNC_API_LUA_ONLY') * Cc(true)), 'lua_only') ^ -1) *
|
(fill * Cg((P('FUNC_API_LUA_ONLY') * Cc(true)), 'lua_only') ^ -1) *
|
||||||
|
(fill * Cg((P('FUNC_API_CHECK_TEXTLOCK') * Cc(true)), 'check_textlock') ^ -1) *
|
||||||
(fill * Cg((P('FUNC_API_REMOTE_IMPL') * Cc(true)), 'remote_impl') ^ -1) *
|
(fill * Cg((P('FUNC_API_REMOTE_IMPL') * Cc(true)), 'remote_impl') ^ -1) *
|
||||||
(fill * Cg((P('FUNC_API_BRIDGE_IMPL') * Cc(true)), 'bridge_impl') ^ -1) *
|
(fill * Cg((P('FUNC_API_BRIDGE_IMPL') * Cc(true)), 'bridge_impl') ^ -1) *
|
||||||
(fill * Cg((P('FUNC_API_COMPOSITOR_IMPL') * Cc(true)), 'compositor_impl') ^ -1) *
|
(fill * Cg((P('FUNC_API_COMPOSITOR_IMPL') * Cc(true)), 'compositor_impl') ^ -1) *
|
||||||
|
@@ -260,6 +260,13 @@ for i = 1, #functions do
|
|||||||
args[#args + 1] = converted
|
args[#args + 1] = converted
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if fn.check_textlock then
|
||||||
|
output:write('\n if (textlock != 0) {')
|
||||||
|
output:write('\n api_set_error(error, kErrorTypeException, "%s", e_secure);')
|
||||||
|
output:write('\n goto cleanup;')
|
||||||
|
output:write('\n }\n')
|
||||||
|
end
|
||||||
|
|
||||||
-- function call
|
-- function call
|
||||||
local call_args = table.concat(args, ', ')
|
local call_args = table.concat(args, ', ')
|
||||||
output:write('\n ')
|
output:write('\n ')
|
||||||
@@ -393,6 +400,16 @@ local function process_function(fn)
|
|||||||
}
|
}
|
||||||
]], fn.name))
|
]], fn.name))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if fn.check_textlock then
|
||||||
|
write_shifted_output(output, [[
|
||||||
|
if (textlock != 0) {
|
||||||
|
api_set_error(&err, kErrorTypeException, "%s", e_secure);
|
||||||
|
goto exit_0;
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
end
|
||||||
|
|
||||||
local cparams = ''
|
local cparams = ''
|
||||||
local free_code = {}
|
local free_code = {}
|
||||||
for j = #fn.parameters,1,-1 do
|
for j = #fn.parameters,1,-1 do
|
||||||
|
Reference in New Issue
Block a user