mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
msgpack-rpc: Allow registration of handlers by other modules
This commit is contained in:
parent
8bb7aa329d
commit
8b6cfff6a1
@ -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..
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user