diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-18 11:31:44 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-18 11:36:07 -0300 |
commit | 20fda27cda172cd83dc103f7d21178a1875f84ee (patch) | |
tree | 78660388dcb292a8c8d18e09853b75e2dac1b7f3 /src | |
parent | 5aca2a6cd8fba00b34b2d3b64a802397d24cd28d (diff) | |
download | rneovim-20fda27cda172cd83dc103f7d21178a1875f84ee.tar.gz rneovim-20fda27cda172cd83dc103f7d21178a1875f84ee.tar.bz2 rneovim-20fda27cda172cd83dc103f7d21178a1875f84ee.zip |
api: Change type of event data to `Object` from `typval_T`
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 3 | ||||
-rw-r--r-- | src/nvim/os/channel.c | 15 | ||||
-rw-r--r-- | src/nvim/os/channel.h | 2 |
3 files changed, 11 insertions, 9 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d7deb2f322..0df0c1e4f4 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -70,6 +70,7 @@ #include "nvim/os/rstream_defs.h" #include "nvim/os/time.h" #include "nvim/os/channel.h" +#include "nvim/api/private/helpers.h" #define DICT_MAXNEST 100 /* maximum nesting of lists and dicts */ @@ -12555,7 +12556,7 @@ static void f_send_event(typval_T *argvars, typval_T *rettv) if (!channel_send_event((uint64_t)argvars[0].vval.v_number, (char *)argvars[1].vval.v_string, - &argvars[2])) { + vim_to_object(&argvars[2]))) { EMSG2(_(e_invarg2), "Channel doesn't exist"); return; } diff --git a/src/nvim/os/channel.c b/src/nvim/os/channel.c index dc8f26026e..653f09756a 100644 --- a/src/nvim/os/channel.c +++ b/src/nvim/os/channel.c @@ -116,12 +116,13 @@ void channel_from_stream(uv_stream_t *stream) /// @param type The event type, an arbitrary string /// @param obj The event data /// @return True if the data was sent successfully, false otherwise. -bool channel_send_event(uint64_t id, char *type, typval_T *data) +bool channel_send_event(uint64_t id, char *type, Object data) { Channel *channel = NULL; if (id > 0) { if (!(channel = pmap_get(uint64_t)(channels, id))) { + msgpack_rpc_free_object(data); return false; } send_event(channel, type, data); @@ -248,12 +249,12 @@ static void parse_msgpack(RStream *rstream, void *data, bool eof) } } -static void send_event(Channel *channel, char *type, typval_T *data) +static void send_event(Channel *channel, char *type, Object data) { wstream_write(channel->data.streams.write, serialize_event(type, data)); } -static void broadcast_event(char *type, typval_T *data) +static void broadcast_event(char *type, Object data) { kvec_t(Channel *) subscribed; kv_init(subscribed); @@ -266,6 +267,7 @@ static void broadcast_event(char *type, typval_T *data) }); if (!kv_size(subscribed)) { + msgpack_rpc_free_object(data); goto end; } @@ -327,18 +329,17 @@ static void close_cb(uv_handle_t *handle) free(handle); } -static WBuffer *serialize_event(char *type, typval_T *data) +static WBuffer *serialize_event(char *type, Object data) { String event_type = {.size = strnlen(type, EVENT_MAXLEN), .data = type}; - Object event_data = vim_to_object(data); msgpack_packer packer; msgpack_packer_init(&packer, &msgpack_event_buffer, msgpack_sbuffer_write); - msgpack_rpc_notification(event_type, event_data, &packer); + msgpack_rpc_notification(event_type, data, &packer); WBuffer *rv = wstream_new_buffer(xmemdup(msgpack_event_buffer.data, msgpack_event_buffer.size), msgpack_event_buffer.size, free); - msgpack_rpc_free_object(event_data); + msgpack_rpc_free_object(data); msgpack_sbuffer_clear(&msgpack_event_buffer); return rv; diff --git a/src/nvim/os/channel.h b/src/nvim/os/channel.h index 240461d22e..f12d54cede 100644 --- a/src/nvim/os/channel.h +++ b/src/nvim/os/channel.h @@ -2,8 +2,8 @@ #define NVIM_OS_CHANNEL_H #include <uv.h> -#include <msgpack.h> +#include "nvim/api/private/defs.h" #include "nvim/vim.h" #define EVENT_MAXLEN 512 |