api: represent api type String as msgpack type STR. closes #1250

This commit is contained in:
Björn Linse 2015-10-07 13:40:53 +02:00
parent cd6b4af649
commit 57d3a2a52f
3 changed files with 7 additions and 8 deletions

View File

@ -175,7 +175,7 @@ Nil -> msgpack nil
Boolean -> msgpack boolean
Integer (signed 64-bit integer) -> msgpack integer
Float (IEEE 754 double precision) -> msgpack float
String -> msgpack binary
String -> msgpack string
Array -> msgpack array
Dictionary -> msgpack map

View File

@ -225,8 +225,8 @@ void msgpack_rpc_from_float(Float result, msgpack_packer *res)
void msgpack_rpc_from_string(String result, msgpack_packer *res)
FUNC_ATTR_NONNULL_ARG(2)
{
msgpack_pack_bin(res, result.size);
msgpack_pack_bin_body(res, result.data, result.size);
msgpack_pack_str(res, result.size);
msgpack_pack_str_body(res, result.data, result.size);
}
void msgpack_rpc_from_object(Object result, msgpack_packer *res)
@ -332,8 +332,7 @@ void msgpack_rpc_serialize_request(uint64_t request_id,
msgpack_pack_uint64(pac, request_id);
}
msgpack_pack_bin(pac, method.size);
msgpack_pack_bin_body(pac, method.data, method.size);
msgpack_rpc_from_string(method, pac);
msgpack_rpc_from_array(args, pac);
}

View File

@ -452,12 +452,12 @@ describe('msgpackparse() function', function()
end)
it('msgpackparse(systemlist(...)) does not segfault. #3135', function()
local cmd = "msgpackparse(systemlist('"
..helpers.nvim_prog.." --api-info'))['_TYPE']['_VAL'][0][0]"
local cmd = "sort(keys(msgpackparse(systemlist('"
..helpers.nvim_prog.." --api-info'))[0]))"
local api_info = eval(cmd)
api_info = eval(cmd) -- do it again (try to force segfault)
api_info = eval(cmd) -- do it again
eq('functions', api_info)
eq({'error_types', 'functions', 'types'}, api_info)
end)
it('fails when called with no arguments', function()