diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-12-04 10:38:10 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-12-08 23:44:23 -0300 |
commit | 8b6cfff6a18d839d11900cd1fade5938dc9a02d5 (patch) | |
tree | e7d6ab153622b3415caf0ea183ded51143dbd549 | |
parent | 8bb7aa329d20cb265d8952c96c84a0e54a5726ab (diff) | |
download | rneovim-8b6cfff6a18d839d11900cd1fade5938dc9a02d5.tar.gz rneovim-8b6cfff6a18d839d11900cd1fade5938dc9a02d5.tar.bz2 rneovim-8b6cfff6a18d839d11900cd1fade5938dc9a02d5.zip |
msgpack-rpc: Allow registration of handlers by other modules
-rw-r--r-- | scripts/msgpack-gen.lua | 7 | ||||
-rw-r--r-- | src/nvim/msgpack_rpc/defs.h | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/scripts/msgpack-gen.lua b/scripts/msgpack-gen.lua index 9645784f00..d31a062a68 100644 --- a/scripts/msgpack-gen.lua +++ b/scripts/msgpack-gen.lua @@ -252,6 +252,11 @@ end output:write([[ static Map(String, MsgpackRpcRequestHandler) *methods = NULL; +void msgpack_rpc_add_method_handler(String method, MsgpackRpcRequestHandler handler) +{ + map_put(String, MsgpackRpcRequestHandler)(methods, method, handler); +} + void msgpack_rpc_init_method_table(void) { methods = map_new(String, MsgpackRpcRequestHandler)(); @@ -263,7 +268,7 @@ void msgpack_rpc_init_method_table(void) local max_fname_len = 0 for i = 1, #functions do local fn = functions[i] - output:write(' map_put(String, MsgpackRpcRequestHandler)(methods, '.. + output:write(' msgpack_rpc_add_method_handler('.. '(String) {.data = "'..fn.name..'", '.. '.size = sizeof("'..fn.name..'") - 1}, '.. '(MsgpackRpcRequestHandler) {.fn = handle_'.. fn.name.. diff --git a/src/nvim/msgpack_rpc/defs.h b/src/nvim/msgpack_rpc/defs.h index 13067fb7b4..0492a65290 100644 --- a/src/nvim/msgpack_rpc/defs.h +++ b/src/nvim/msgpack_rpc/defs.h @@ -19,6 +19,10 @@ typedef struct { /// Initializes the msgpack-rpc method table void msgpack_rpc_init_method_table(void); +// Add a handler to the method table +void msgpack_rpc_add_method_handler(String method, + MsgpackRpcRequestHandler handler); + void msgpack_rpc_init_function_metadata(Dictionary *metadata); /// Dispatches to the actual API function after basic payload validation by |