From 296da85198a7d5da36dbb2e6f213edb5da511635 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Mon, 23 Jun 2014 11:52:42 -0300 Subject: channel/msgpack_rpc: Refactor API dispatching This is how API dispatching worked before this commit: - The generated `msgpack_rpc_dispatch` function receives a the `msgpack_packer` argument. - The response is incrementally built while validating/calling the API. - Return values/errors are also packed into the `msgpack_packer` while the final response is being calculated. Now the `msgpack_packer` argument is no longer provided, and the `msgpack_rpc_dispatch` function returns `Object`/`Error` values to `msgpack_rpc_call`, which will use those values to build the response in a single pass. This was done because the new `channel_send_call` function created the possibility of having recursive API invocations, and this wasn't possible when sharing a single `msgpack_sbuffer` across call frames(it was shared implicitly through the `msgpack_packer` instance). Since we only start to build the response when the necessary information has been computed, it's now safe to share a single `msgpack_sbuffer` instance across all channels and API invocations. Some other changes also had to be performed: - Handling of the metadata discover was moved to `msgpack_rpc_call` - Expose more types as subtypes of `Object`, this was required to forward the return value from `msgpack_rpc_dispatch` to `msgpack_rpc_call` - Added more helper macros for casting API types to `Object` any --- src/nvim/api/private/helpers.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/api/private/helpers.c') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index d5ebc93f7c..024f0c2405 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -426,6 +426,8 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err) } tv->vval.v_dict->dv_refcount++; break; + default: + abort(); } return true; -- cgit