aboutsummaryrefslogtreecommitdiff
path: root/scripts/msgpack-gen.lua
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-09-03 16:22:05 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-09-12 13:25:28 -0300
commitcd70b9c0152f79887ed548e6cf8992ae2121fedb (patch)
treea57bca6386d4156382b14a54f5d5b343bc16b7d9 /scripts/msgpack-gen.lua
parent19bc29ee834516ff76944741b25fe158d2282b15 (diff)
downloadrneovim-cd70b9c0152f79887ed548e6cf8992ae2121fedb.tar.gz
rneovim-cd70b9c0152f79887ed548e6cf8992ae2121fedb.tar.bz2
rneovim-cd70b9c0152f79887ed548e6cf8992ae2121fedb.zip
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).
Diffstat (limited to 'scripts/msgpack-gen.lua')
-rw-r--r--scripts/msgpack-gen.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/scripts/msgpack-gen.lua b/scripts/msgpack-gen.lua
index 946cff1d11..1516271973 100644
--- a/scripts/msgpack-gen.lua
+++ b/scripts/msgpack-gen.lua
@@ -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([[