diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-05-28 09:05:13 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-05-28 09:05:13 -0300 |
commit | e4fe2dbd777a59a9a9b386d960eb9dddc459e84e (patch) | |
tree | aa99bd39c8a87c95f93457dcf4456caab45f7310 /scripts/msgpack-gen.lua | |
parent | 1faf546ea286ae324c79cfef3b5613a0004182bb (diff) | |
parent | cd8421537034d0b5cc567d81afc4fa5316da171e (diff) | |
download | rneovim-e4fe2dbd777a59a9a9b386d960eb9dddc459e84e.tar.gz rneovim-e4fe2dbd777a59a9a9b386d960eb9dddc459e84e.tar.bz2 rneovim-e4fe2dbd777a59a9a9b386d960eb9dddc459e84e.zip |
Merge 'Refactor WStream to enable writing the same buffer to multiple targets'
Diffstat (limited to 'scripts/msgpack-gen.lua')
-rw-r--r-- | scripts/msgpack-gen.lua | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/scripts/msgpack-gen.lua b/scripts/msgpack-gen.lua index 3cc1558fd7..fac1b10b45 100644 --- a/scripts/msgpack-gen.lua +++ b/scripts/msgpack-gen.lua @@ -62,6 +62,12 @@ for i = 1, #arg - 1 do api.functions[#api.functions + 1] = tmp[i] local fn_id = #api.functions local fn = api.functions[fn_id] + if #fn.parameters ~= 0 and fn.parameters[1][2] == 'channel_id' then + -- this function should receive the channel id + fn.receives_channel_id = true + -- remove the parameter since it won't be passed by the api client + table.remove(fn.parameters, 1) + end if #fn.parameters ~= 0 and fn.parameters[#fn.parameters][1] == 'error' then -- function can fail if the last parameter type is 'Error' fn.can_fail = true @@ -111,7 +117,7 @@ end output:write([[ }; -void msgpack_rpc_dispatch(uint64_t id, msgpack_object *req, msgpack_packer *res) +void msgpack_rpc_dispatch(uint64_t channel_id, msgpack_object *req, msgpack_packer *res) { Error error = { .set = false }; uint64_t method_id = (uint32_t)req->via.array.ptr[2].via.u64; @@ -121,7 +127,7 @@ void msgpack_rpc_dispatch(uint64_t id, msgpack_object *req, msgpack_packer *res) msgpack_pack_nil(res); // The result is the [channel_id, metadata] array msgpack_pack_array(res, 2); - msgpack_pack_uint64(res, id); + msgpack_pack_uint64(res, channel_id); msgpack_pack_raw(res, sizeof(msgpack_metadata)); msgpack_pack_raw_body(res, msgpack_metadata, sizeof(msgpack_metadata)); return; @@ -169,8 +175,19 @@ for i = 1, #api.functions do output:write(fn.return_type..' rv = ') end - -- write the call without the closing parenthesis - output:write(fn.name..'('..call_args) + -- write the function name and the opening parenthesis + output:write(fn.name..'(') + + if fn.receives_channel_id then + -- if the function receives the channel id, pass it as first argument + if #args > 0 then + output:write('channel_id, '..call_args) + else + output:write('channel_id)') + end + else + output:write(call_args) + end if fn.can_fail then -- if the function can fail, also pass a pointer to the local error object |