From e2fdd53d8c015913e8be4ff708fc3488558c8906 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sun, 14 May 2023 18:45:56 +0200 Subject: refactor(map): avoid duplicated khash_t types for values This reduces the total number of khash_t instantiations from 22 to 8. Make the khash internal functions take the size of values as a runtime parameter. This is abstracted with typesafe Map containers which are still specialized for both key, value type. Introduce `Set(key)` type for when there is no value. Refactor shada.c to use Map/Set instead of khash directly. This requires `map_ref` operation to be more flexible. Return pointers to both key and value, plus an indicator for new_item. As a bonus, `map_key` is now redundant. Instead of Map(cstr_t, FileMarks), use a pointer map as the FileMarks struct is humongous. Make `event_strings` actually work like an intern pool instead of wtf it was doing before. --- src/nvim/msgpack_rpc/channel_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/msgpack_rpc/channel_defs.h') diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h index 404e68329a..1b5f0bb298 100644 --- a/src/nvim/msgpack_rpc/channel_defs.h +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -31,7 +31,7 @@ typedef struct { } RequestEvent; typedef struct { - PMap(cstr_t) subscribed_events[1]; + Set(cstr_t) subscribed_events[1]; bool closed; Unpacker *unpacker; uint32_t next_request_id; -- cgit From 01fe6b9e6a84338d4752c93a286262d79120f163 Mon Sep 17 00:00:00 2001 From: Alisue Date: Sun, 6 Aug 2023 23:19:29 +0900 Subject: feat(msgpack_rpc): support out-of-order responses on `msgpack-rpc` Added to support MessagePack-RPC fully compliant clients that do not return responses in request order. Although it is currently not an efficient implementation for full compliance and full compliance cannot be guaranteed, the addition of the new client type `msgpack-rpc` creates a situation where "if the client type is `msgpack-rpc`, then backward compatibility is ignored and full compliance with MessagePack- RPC compliance is justified even if backward compatibility is ignored if the client type is `msgpack-rpc`. --- src/nvim/msgpack_rpc/channel_defs.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/nvim/msgpack_rpc/channel_defs.h') diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h index 1b5f0bb298..79aa8c1b13 100644 --- a/src/nvim/msgpack_rpc/channel_defs.h +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -14,6 +14,16 @@ typedef struct Channel Channel; typedef struct Unpacker Unpacker; +typedef enum { + kClientTypeUnknown = -1, + kClientTypeRemote = 0, + kClientTypeMsgpackRpc = 5, + kClientTypeUi = 1, + kClientTypeEmbedder = 2, + kClientTypeHost = 3, + kClientTypePlugin = 4, +} ClientType; + typedef struct { uint32_t request_id; bool returned, errored; @@ -37,6 +47,7 @@ typedef struct { uint32_t next_request_id; kvec_t(ChannelCallFrame *) call_stack; Dictionary info; + ClientType client_type; } RpcState; #endif // NVIM_MSGPACK_RPC_CHANNEL_DEFS_H -- cgit From 4f8941c1a5f1ef6caa410feeb52e343db22763ce Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 10 Nov 2023 12:23:42 +0100 Subject: refactor: replace manual header guards with #pragma once It is less error-prone than manually defining header guards. Pretty much all compilers support it even if it's not part of the C standard. --- src/nvim/msgpack_rpc/channel_defs.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/nvim/msgpack_rpc/channel_defs.h') diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h index 79aa8c1b13..0bbffb8beb 100644 --- a/src/nvim/msgpack_rpc/channel_defs.h +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -1,5 +1,4 @@ -#ifndef NVIM_MSGPACK_RPC_CHANNEL_DEFS_H -#define NVIM_MSGPACK_RPC_CHANNEL_DEFS_H +#pragma once #include #include @@ -49,5 +48,3 @@ typedef struct { Dictionary info; ClientType client_type; } RpcState; - -#endif // NVIM_MSGPACK_RPC_CHANNEL_DEFS_H -- cgit From 574d25642fc9ca65b396633aeab6e2d32778b642 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Nov 2023 17:21:58 +0800 Subject: refactor: move Arena and ArenaMem to memory_defs.h (#26240) --- src/nvim/msgpack_rpc/channel_defs.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/msgpack_rpc/channel_defs.h') diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h index 0bbffb8beb..1e3f8a72c1 100644 --- a/src/nvim/msgpack_rpc/channel_defs.h +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -4,10 +4,12 @@ #include #include +#include "klib/kvec.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/dispatch.h" #include "nvim/event/process.h" #include "nvim/event/socket.h" +#include "nvim/map.h" #include "nvim/vim.h" typedef struct Channel Channel; -- cgit From acf525287950277e7b83794184e3df5dcfdecc48 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Nov 2023 18:37:35 +0800 Subject: refactor: remove vim.h from more headers (#26244) --- src/nvim/msgpack_rpc/channel_defs.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/msgpack_rpc/channel_defs.h') diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h index 1e3f8a72c1..1eb57ec4dc 100644 --- a/src/nvim/msgpack_rpc/channel_defs.h +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -10,7 +10,6 @@ #include "nvim/event/process.h" #include "nvim/event/socket.h" #include "nvim/map.h" -#include "nvim/vim.h" typedef struct Channel Channel; typedef struct Unpacker Unpacker; -- cgit From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/nvim/msgpack_rpc/channel_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/msgpack_rpc/channel_defs.h') diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h index 1eb57ec4dc..20b8a89afb 100644 --- a/src/nvim/msgpack_rpc/channel_defs.h +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -9,7 +9,7 @@ #include "nvim/api/private/dispatch.h" #include "nvim/event/process.h" #include "nvim/event/socket.h" -#include "nvim/map.h" +#include "nvim/map_defs.h" typedef struct Channel Channel; typedef struct Unpacker Unpacker; -- cgit