aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/msgpack_rpc_helpers.c
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-06-23 11:52:42 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-06-24 13:02:24 -0300
commit296da85198a7d5da36dbb2e6f213edb5da511635 (patch)
tree4fb8f7d5e1d7f4153b508e987f268c0222431152 /src/nvim/os/msgpack_rpc_helpers.c
parentbc0380038e0a4ff4f4bfaa939b0cef26c5e53582 (diff)
downloadrneovim-296da85198a7d5da36dbb2e6f213edb5da511635.tar.gz
rneovim-296da85198a7d5da36dbb2e6f213edb5da511635.tar.bz2
rneovim-296da85198a7d5da36dbb2e6f213edb5da511635.zip
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
Diffstat (limited to 'src/nvim/os/msgpack_rpc_helpers.c')
-rw-r--r--src/nvim/os/msgpack_rpc_helpers.c55
1 files changed, 52 insertions, 3 deletions
diff --git a/src/nvim/os/msgpack_rpc_helpers.c b/src/nvim/os/msgpack_rpc_helpers.c
index 3af6794169..e2c277abe4 100644
--- a/src/nvim/os/msgpack_rpc_helpers.c
+++ b/src/nvim/os/msgpack_rpc_helpers.c
@@ -231,12 +231,41 @@ void msgpack_rpc_from_object(Object result, msgpack_packer *res)
msgpack_rpc_from_array(result.data.array, res);
break;
+ case kObjectTypePosition:
+ msgpack_rpc_from_position(result.data.position, res);
+ break;
+
+ case kObjectTypeBuffer:
+ msgpack_rpc_from_buffer(result.data.buffer, res);
+ break;
+
+ case kObjectTypeWindow:
+ msgpack_rpc_from_window(result.data.window, res);
+ break;
+
+ case kObjectTypeTabpage:
+ msgpack_rpc_from_tabpage(result.data.tabpage, res);
+ break;
+
+ case kObjectTypeStringArray:
+ msgpack_rpc_from_stringarray(result.data.stringarray, res);
+ break;
+
+ case kObjectTypeBufferArray:
+ msgpack_rpc_from_bufferarray(result.data.bufferarray, res);
+ break;
+
+ case kObjectTypeWindowArray:
+ msgpack_rpc_from_windowarray(result.data.windowarray, res);
+ break;
+
+ case kObjectTypeTabpageArray:
+ msgpack_rpc_from_tabpagearray(result.data.tabpagearray, res);
+ break;
+
case kObjectTypeDictionary:
msgpack_rpc_from_dictionary(result.data.dictionary, res);
break;
-
- default:
- abort();
}
}
@@ -282,6 +311,10 @@ void msgpack_rpc_free_object(Object value)
case kObjectTypeBoolean:
case kObjectTypeInteger:
case kObjectTypeFloat:
+ case kObjectTypePosition:
+ case kObjectTypeBuffer:
+ case kObjectTypeWindow:
+ case kObjectTypeTabpage:
break;
case kObjectTypeString:
@@ -292,6 +325,22 @@ void msgpack_rpc_free_object(Object value)
msgpack_rpc_free_array(value.data.array);
break;
+ case kObjectTypeStringArray:
+ msgpack_rpc_free_stringarray(value.data.stringarray);
+ break;
+
+ case kObjectTypeBufferArray:
+ msgpack_rpc_free_bufferarray(value.data.bufferarray);
+ break;
+
+ case kObjectTypeWindowArray:
+ msgpack_rpc_free_windowarray(value.data.windowarray);
+ break;
+
+ case kObjectTypeTabpageArray:
+ msgpack_rpc_free_tabpagearray(value.data.tabpagearray);
+ break;
+
case kObjectTypeDictionary:
msgpack_rpc_free_dictionary(value.data.dictionary);
break;