diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-10-22 07:30:32 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-10-22 07:30:32 -0300 |
commit | 5cd9b6474287650790e97187058c81b176fbc7c9 (patch) | |
tree | 57a419ce9104adf84bd1152a01f9c1f75f4bef85 /src/nvim/msgpack_rpc/defs.h | |
parent | 6e268cd0d40a3652a68b486bdbb421d39295ab48 (diff) | |
parent | f7fab4af863839a064a941a555b237b6eb789870 (diff) | |
download | rneovim-5cd9b6474287650790e97187058c81b176fbc7c9.tar.gz rneovim-5cd9b6474287650790e97187058c81b176fbc7c9.tar.bz2 rneovim-5cd9b6474287650790e97187058c81b176fbc7c9.zip |
Merge PR #1316 'Refactor event deferral'
Diffstat (limited to 'src/nvim/msgpack_rpc/defs.h')
-rw-r--r-- | src/nvim/msgpack_rpc/defs.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/nvim/msgpack_rpc/defs.h b/src/nvim/msgpack_rpc/defs.h new file mode 100644 index 0000000000..13067fb7b4 --- /dev/null +++ b/src/nvim/msgpack_rpc/defs.h @@ -0,0 +1,43 @@ +#ifndef NVIM_MSGPACK_RPC_DEFS_H +#define NVIM_MSGPACK_RPC_DEFS_H + +#include <msgpack.h> + + +/// The rpc_method_handlers table, used in msgpack_rpc_dispatch(), stores +/// functions of this type. +typedef struct { + Object (*fn)(uint64_t channel_id, + uint64_t request_id, + Array args, + Error *error); + bool defer; // Should the call be deferred to the main loop? This should + // be true if the function mutates editor data structures such + // as buffers, windows, tabs, or if it executes vimscript code. +} MsgpackRpcRequestHandler; + +/// Initializes the msgpack-rpc method table +void msgpack_rpc_init_method_table(void); + +void msgpack_rpc_init_function_metadata(Dictionary *metadata); + +/// 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. +/// The implementation is generated at compile time with metadata extracted +/// from the api/*.h headers, +/// +/// @param channel_id The channel id +/// @param method_id The method id +/// @param req The parsed request object +/// @param error Pointer to error structure +/// @return Some object +Object msgpack_rpc_dispatch(uint64_t channel_id, + msgpack_object *req, + Error *error) + FUNC_ATTR_NONNULL_ARG(2) FUNC_ATTR_NONNULL_ARG(3); + +MsgpackRpcRequestHandler msgpack_rpc_get_handler_for(const char *name, + size_t name_len) + FUNC_ATTR_NONNULL_ARG(1); +#endif // NVIM_MSGPACK_RPC_DEFS_H |