mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
msgpack-rpc: Refactor API metadata discovery method
A new method is now exposed via msgpack-rpc: "get_api_metadata". This method has the same job as the old method '0', it returns an object with API metadata for use by generators. There's one difference in the return value though: instead of returning a string containing another serialized msgpack document, the metadata object is returned directly(a separate deserialization step by clients is not required).
This commit is contained in:
@@ -123,6 +123,7 @@ end
|
||||
output:write([[
|
||||
};
|
||||
const unsigned int msgpack_metadata_size = sizeof(msgpack_metadata);
|
||||
msgpack_unpacked msgpack_unpacked_metadata;
|
||||
|
||||
]])
|
||||
|
||||
@@ -237,6 +238,14 @@ static Map(String, rpc_method_handler_fn) *methods = NULL;
|
||||
|
||||
void msgpack_rpc_init(void)
|
||||
{
|
||||
msgpack_unpacked_init(&msgpack_unpacked_metadata);
|
||||
if (msgpack_unpack_next(&msgpack_unpacked_metadata,
|
||||
(const char *)msgpack_metadata,
|
||||
msgpack_metadata_size,
|
||||
NULL) != MSGPACK_UNPACK_SUCCESS) {
|
||||
abort();
|
||||
}
|
||||
|
||||
methods = map_new(String, rpc_method_handler_fn)();
|
||||
|
||||
]])
|
||||
@@ -256,6 +265,12 @@ for i = 1, #api.functions do
|
||||
end
|
||||
end
|
||||
|
||||
local metadata_fn = 'get_api_metadata'
|
||||
output:write(' map_put(String, rpc_method_handler_fn)(methods, '..
|
||||
'(String) {.data = "'..metadata_fn..'", '..
|
||||
'.size = sizeof("'..metadata_fn..'") - 1}, msgpack_rpc_handle_'..
|
||||
metadata_fn..');\n')
|
||||
|
||||
output:write('\n}\n\n')
|
||||
|
||||
output:write([[
|
||||
|
||||
Reference in New Issue
Block a user