diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2016-10-19 15:16:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-19 15:16:05 +0200 |
commit | 2d961403baf3ed702982ca946ba41a6602ec8608 (patch) | |
tree | 6f240f1f8a473be4b11a0526af6c229cb28a9973 /src/nvim/api/private/dispatch.c | |
parent | 9d4fcec7c6b65ef04fd4416b014e96f33b1f708a (diff) | |
parent | caf85b80ae46a921389ee4954b9a38d10dcde3dc (diff) | |
download | rneovim-2d961403baf3ed702982ca946ba41a6602ec8608.tar.gz rneovim-2d961403baf3ed702982ca946ba41a6602ec8608.tar.bz2 rneovim-2d961403baf3ed702982ca946ba41a6602ec8608.zip |
Merge pull request #5393 from bfredl/dispatchfix
refactor gendispatch.lua to move verbatim c code to .c files
Diffstat (limited to 'src/nvim/api/private/dispatch.c')
-rw-r--r-- | src/nvim/api/private/dispatch.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/nvim/api/private/dispatch.c b/src/nvim/api/private/dispatch.c new file mode 100644 index 0000000000..9b3bcc380a --- /dev/null +++ b/src/nvim/api/private/dispatch.c @@ -0,0 +1,45 @@ +#include <inttypes.h> +#include <stdbool.h> +#include <stdint.h> +#include <assert.h> +#include <msgpack.h> + +#include "nvim/map.h" +#include "nvim/log.h" +#include "nvim/vim.h" +#include "nvim/msgpack_rpc/helpers.h" +#include "nvim/api/private/dispatch.h" +#include "nvim/api/private/helpers.h" +#include "nvim/api/private/defs.h" + +#include "nvim/api/buffer.h" +#include "nvim/api/tabpage.h" +#include "nvim/api/ui.h" +#include "nvim/api/vim.h" +#include "nvim/api/window.h" + +static Map(String, MsgpackRpcRequestHandler) *methods = NULL; + +static void msgpack_rpc_add_method_handler(String method, + MsgpackRpcRequestHandler handler) +{ + map_put(String, MsgpackRpcRequestHandler)(methods, method, handler); +} + +MsgpackRpcRequestHandler msgpack_rpc_get_handler_for(const char *name, + size_t name_len) +{ + 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; + } + + return rv; +} + +#ifdef INCLUDE_GENERATED_DECLARATIONS +#include "api/private/dispatch_wrappers.generated.h" +#endif |