mirror of
https://github.com/neovim/neovim.git
synced 2025-10-13 21:36:05 +00:00
msgpack-rpc: Remove support for integer ids in methods
There's no need to have integer and string ids, and since we now fully support msgpack-RPC, support for integer ids was removed.
This commit is contained in:
@@ -60,8 +60,7 @@ for i = 1, #arg - 1 do
|
|||||||
local tmp = grammar:match(input:read('*all'))
|
local tmp = grammar:match(input:read('*all'))
|
||||||
for i = 1, #tmp do
|
for i = 1, #tmp do
|
||||||
api.functions[#api.functions + 1] = tmp[i]
|
api.functions[#api.functions + 1] = tmp[i]
|
||||||
local fn_id = #api.functions
|
local fn = tmp[i]
|
||||||
local fn = api.functions[fn_id]
|
|
||||||
if #fn.parameters ~= 0 and fn.parameters[1][2] == 'channel_id' then
|
if #fn.parameters ~= 0 and fn.parameters[1][2] == 'channel_id' then
|
||||||
-- this function should receive the channel id
|
-- this function should receive the channel id
|
||||||
fn.receives_channel_id = true
|
fn.receives_channel_id = true
|
||||||
@@ -75,8 +74,6 @@ for i = 1, #arg - 1 do
|
|||||||
-- for specifying errors
|
-- for specifying errors
|
||||||
fn.parameters[#fn.parameters] = nil
|
fn.parameters[#fn.parameters] = nil
|
||||||
end
|
end
|
||||||
-- assign a unique integer id for each api function
|
|
||||||
fn.id = fn_id
|
|
||||||
end
|
end
|
||||||
input:close()
|
input:close()
|
||||||
end
|
end
|
||||||
@@ -221,17 +218,6 @@ for i = 1, #api.functions do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Generate the table of handler functions indexed by method id
|
|
||||||
output:write([[
|
|
||||||
static const rpc_method_handler_fn rpc_method_handlers[] = {
|
|
||||||
[0] = (rpc_method_handler_fn)NULL]])
|
|
||||||
|
|
||||||
for i = 1, #api.functions do
|
|
||||||
local fn = api.functions[i]
|
|
||||||
output:write(',\n ['..i..'] = handle_'..fn.name..'')
|
|
||||||
end
|
|
||||||
output:write('\n};\n\n')
|
|
||||||
|
|
||||||
-- Generate a function that initializes method names with handler functions
|
-- Generate a function that initializes method names with handler functions
|
||||||
output:write([[
|
output:write([[
|
||||||
static Map(String, rpc_method_handler_fn) *methods = NULL;
|
static Map(String, rpc_method_handler_fn) *methods = NULL;
|
||||||
@@ -279,7 +265,6 @@ Object msgpack_rpc_dispatch(uint64_t channel_id,
|
|||||||
Error *error)
|
Error *error)
|
||||||
{
|
{
|
||||||
msgpack_object method = req->via.array.ptr[2];
|
msgpack_object method = req->via.array.ptr[2];
|
||||||
uint64_t method_id = method.via.u64;
|
|
||||||
rpc_method_handler_fn handler = NULL;
|
rpc_method_handler_fn handler = NULL;
|
||||||
|
|
||||||
if (method.type == MSGPACK_OBJECT_BIN || method.type == MSGPACK_OBJECT_STR) {
|
if (method.type == MSGPACK_OBJECT_BIN || method.type == MSGPACK_OBJECT_STR) {
|
||||||
@@ -288,8 +273,6 @@ output:write(' handler = map_get(String, rpc_method_handler_fn)')
|
|||||||
output:write('(methods, (String){.data=(char *)method.via.bin.ptr,')
|
output:write('(methods, (String){.data=(char *)method.via.bin.ptr,')
|
||||||
output:write('.size=min(method.via.bin.size, '..max_fname_len..')});\n')
|
output:write('.size=min(method.via.bin.size, '..max_fname_len..')});\n')
|
||||||
output:write([[
|
output:write([[
|
||||||
} else if (method_id <= ]]..#api.functions..[[) {
|
|
||||||
handler = rpc_method_handlers[method_id];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!handler) {
|
if (!handler) {
|
||||||
|
@@ -226,10 +226,9 @@ static char *msgpack_rpc_validate(uint64_t *response_id, msgpack_object *req)
|
|||||||
return "Message type must be 0";
|
return "Message type must be 0";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req->via.array.ptr[2].type != MSGPACK_OBJECT_POSITIVE_INTEGER
|
if (req->via.array.ptr[2].type != MSGPACK_OBJECT_BIN
|
||||||
&& req->via.array.ptr[2].type != MSGPACK_OBJECT_BIN
|
&& req->via.array.ptr[2].type != MSGPACK_OBJECT_STR) {
|
||||||
&& req->via.array.ptr[2].type != MSGPACK_OBJECT_STR) {
|
return "Method must be a string";
|
||||||
return "Method must be a positive integer or a string";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req->via.array.ptr[3].type != MSGPACK_OBJECT_ARRAY) {
|
if (req->via.array.ptr[3].type != MSGPACK_OBJECT_ARRAY) {
|
||||||
|
Reference in New Issue
Block a user