aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-06-18 20:04:39 -0300
committerJustin M. Keyes <justinkz@gmail.com>2014-07-04 17:05:24 +0000
commit9a2b2d4a64755bc8c1b30ff212482321b40452ce (patch)
treed94ff6b92de833783502279d8653ed5fcc9482f7 /src
parent11653ce2d7789ad1ccf31b37c12589cf1cb7787f (diff)
downloadrneovim-9a2b2d4a64755bc8c1b30ff212482321b40452ce.tar.gz
rneovim-9a2b2d4a64755bc8c1b30ff212482321b40452ce.tar.bz2
rneovim-9a2b2d4a64755bc8c1b30ff212482321b40452ce.zip
MsgPack-RPC dispatch based on function array lookup #864
This simplifies the generated msgpack_rpc_dispatch() function, separates the code for each RPC method more clearly and allows easy implementation of alternative dispatching methods (e.g. string method id dispatch).
Diffstat (limited to 'src')
-rw-r--r--src/nvim/os/msgpack_rpc.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nvim/os/msgpack_rpc.h b/src/nvim/os/msgpack_rpc.h
index b8b947c0ec..e185db3dc2 100644
--- a/src/nvim/os/msgpack_rpc.h
+++ b/src/nvim/os/msgpack_rpc.h
@@ -16,6 +16,12 @@ typedef enum {
kUnpackResultNeedMore /// Need more data
} UnpackResult;
+/// The rpc_method_handlers table, used in msgpack_rpc_dispatch(), stores
+/// functions of this type.
+typedef Object (*rpc_method_handler_fn)(uint64_t channel_id,
+ msgpack_object *req,
+ Error *error);
+
/// Dispatches to the actual API function after basic payload validation by
/// `msgpack_rpc_call`. It is responsible for validating/converting arguments
/// to C types, and converting the return value back to msgpack types.
@@ -25,12 +31,12 @@ typedef enum {
/// @param channel_id The channel id
/// @param method_id The method id
/// @param req The parsed request object
-/// @param err Pointer to error structure
+/// @param error Pointer to error structure
/// @return Some object
Object msgpack_rpc_dispatch(uint64_t channel_id,
uint64_t method_id,
msgpack_object *req,
- Error *err)
+ Error *error)
FUNC_ATTR_NONNULL_ARG(2) FUNC_ATTR_NONNULL_ARG(3);
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -38,4 +44,3 @@ Object msgpack_rpc_dispatch(uint64_t channel_id,
#endif
#endif // NVIM_OS_MSGPACK_RPC_H
-