mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +00:00
channel.c: refactor spaghetti code
channel.c: WIP remove redundant method check and added FUNC_ATTR_NONNULL_ALL macro channel.c channel_defs.h helpers.c: added Error field to RequestEvent, added no_op handler func channel.c: use const char* instead of string and cleanup channel.c; channel_defs.h; helpers.c: removed error from event again; send errors directly to the channel without using handlers and events channel.c: fixed memory leak and lint errors api/private/dispatch.c; api/vim.c; msgpack_rpc/channel.c msgpack_rpc/helpers.c added Error* field to msgpack_get_handler_for; further refactored channel.c channel.c:323 changed order of evaluation in if statement channel.c: removed superflous whitespace dispatch.c: review comment
This commit is contained in:
@@ -32,16 +32,19 @@ static void msgpack_rpc_add_method_handler(String method,
|
||||
/// @param name API method name
|
||||
/// @param name_len name size (includes terminating NUL)
|
||||
MsgpackRpcRequestHandler msgpack_rpc_get_handler_for(const char *name,
|
||||
size_t name_len)
|
||||
size_t name_len,
|
||||
Error *error)
|
||||
{
|
||||
String m = { .data = (char *)name, .size = name_len };
|
||||
MsgpackRpcRequestHandler rv =
|
||||
map_get(String, MsgpackRpcRequestHandler)(methods, m);
|
||||
|
||||
if (!rv.fn) {
|
||||
rv.fn = msgpack_rpc_handle_missing_method;
|
||||
String method_name = m.size > 0 ?
|
||||
m : cstr_as_string("<empty>");
|
||||
api_set_error(error, kErrorTypeException, "Invalid method: %s",
|
||||
method_name);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user