mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 05:05:00 -07:00
rename: FUNC_API_ASYNC => FUNC_API_FAST
This commit is contained in:
parent
0480e991d2
commit
7030d7daf1
@ -11,8 +11,10 @@ typedef Object (*ApiDispatchWrapper)(uint64_t channel_id,
|
||||
/// functions of this type.
|
||||
typedef struct {
|
||||
ApiDispatchWrapper fn;
|
||||
bool async; // function is always safe to run immediately instead of being
|
||||
// put in a request queue for handling when nvim waits for input.
|
||||
bool fast; // Function is safe to be executed immediately while running the
|
||||
// uv loop (the loop is run very frequently due to breakcheck).
|
||||
// If "fast" is false, the function is deferred, i e the call will
|
||||
// be put in the event queue, for safe handling later.
|
||||
} MsgpackRpcRequestHandler;
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
|
@ -209,7 +209,7 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_csi)
|
||||
/// @return Number of bytes actually written (can be fewer than
|
||||
/// requested if the buffer becomes full).
|
||||
Integer nvim_input(String keys)
|
||||
FUNC_API_SINCE(1) FUNC_API_ASYNC
|
||||
FUNC_API_SINCE(1) FUNC_API_FAST
|
||||
{
|
||||
return (Integer)input_enqueue(keys);
|
||||
}
|
||||
@ -238,7 +238,7 @@ Integer nvim_input(String keys)
|
||||
/// @param[out] err Error details, if any
|
||||
void nvim_input_mouse(String button, String action, String modifier,
|
||||
Integer grid, Integer row, Integer col, Error *err)
|
||||
FUNC_API_SINCE(6) FUNC_API_ASYNC
|
||||
FUNC_API_SINCE(6) FUNC_API_FAST
|
||||
{
|
||||
if (button.data == NULL || action.data == NULL) {
|
||||
goto error;
|
||||
@ -1256,7 +1256,7 @@ Dictionary nvim_get_color_map(void)
|
||||
///
|
||||
/// @returns Dictionary { "mode": String, "blocking": Boolean }
|
||||
Dictionary nvim_get_mode(void)
|
||||
FUNC_API_SINCE(2) FUNC_API_ASYNC
|
||||
FUNC_API_SINCE(2) FUNC_API_FAST
|
||||
{
|
||||
Dictionary rv = ARRAY_DICT_INIT;
|
||||
char *modestr = get_mode();
|
||||
@ -1342,7 +1342,7 @@ Dictionary nvim_get_commands(Dictionary opts, Error *err)
|
||||
///
|
||||
/// @returns 2-tuple [{channel-id}, {api-metadata}]
|
||||
Array nvim_get_api_info(uint64_t channel_id)
|
||||
FUNC_API_SINCE(1) FUNC_API_ASYNC FUNC_API_REMOTE_ONLY
|
||||
FUNC_API_SINCE(1) FUNC_API_FAST FUNC_API_REMOTE_ONLY
|
||||
{
|
||||
Array rv = ARRAY_DICT_INIT;
|
||||
|
||||
@ -1652,7 +1652,7 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack;
|
||||
/// @param[out] err Error details, if any
|
||||
Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight,
|
||||
Error *err)
|
||||
FUNC_API_SINCE(4) FUNC_API_ASYNC
|
||||
FUNC_API_SINCE(4) FUNC_API_FAST
|
||||
{
|
||||
int pflags = 0;
|
||||
for (size_t i = 0 ; i < flags.size ; i++) {
|
||||
|
@ -205,8 +205,8 @@
|
||||
#endif
|
||||
|
||||
#ifdef DEFINE_FUNC_ATTRIBUTES
|
||||
/// Non-deferred API function.
|
||||
# define FUNC_API_ASYNC
|
||||
/// Fast (non-deferred) API function.
|
||||
# define FUNC_API_FAST
|
||||
/// Internal C function not exposed in the RPC API.
|
||||
# define FUNC_API_NOEXPORT
|
||||
/// API function not exposed in VimL/eval.
|
||||
|
@ -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) *
|
||||
|
@ -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
|
||||
|
||||
|
@ -179,7 +179,7 @@ MAP_IMPL(cstr_t, ptr_t, DEFAULT_INITIALIZER)
|
||||
MAP_IMPL(ptr_t, ptr_t, DEFAULT_INITIALIZER)
|
||||
MAP_IMPL(uint64_t, ptr_t, DEFAULT_INITIALIZER)
|
||||
MAP_IMPL(handle_T, ptr_t, DEFAULT_INITIALIZER)
|
||||
#define MSGPACK_HANDLER_INITIALIZER { .fn = NULL, .async = false }
|
||||
#define MSGPACK_HANDLER_INITIALIZER { .fn = NULL, .fast = false }
|
||||
MAP_IMPL(String, MsgpackRpcRequestHandler, MSGPACK_HANDLER_INITIALIZER)
|
||||
#define KVEC_INITIALIZER { .size = 0, .capacity = 0, .items = NULL }
|
||||
MAP_IMPL(HlEntry, int, DEFAULT_INITIALIZER)
|
||||
|
@ -344,7 +344,7 @@ static void handle_request(Channel *channel, msgpack_object *request)
|
||||
evdata->args = args;
|
||||
evdata->request_id = request_id;
|
||||
channel_incref(channel);
|
||||
if (handler.async) {
|
||||
if (handler.fast) {
|
||||
bool is_get_mode = handler.fn == handle_nvim_get_mode;
|
||||
|
||||
if (is_get_mode && !input_blocking()) {
|
||||
|
Loading…
Reference in New Issue
Block a user