mirror of
https://github.com/neovim/neovim.git
synced 2025-11-16 15:21:20 +00:00
eval/decode: Make msgpackparse() function use new v: vars
This commit is contained in:
@@ -4907,9 +4907,13 @@ msgpackparse({list}) {Nvim} *msgpackparse()*
|
|||||||
contains name of the key from |v:msgpack_types|):
|
contains name of the key from |v:msgpack_types|):
|
||||||
|
|
||||||
Key Value ~
|
Key Value ~
|
||||||
nil Zero, ignored when dumping.
|
nil Zero, ignored when dumping. This value cannot
|
||||||
boolean One or zero. When dumping it is only checked that
|
possibly appear in |msgpackparse()| output in Neovim
|
||||||
value is a |Number|.
|
versions which have |v:null|.
|
||||||
|
boolean One or zero. When dumping it is only checked that
|
||||||
|
value is a |Number|. This value cannot possibly
|
||||||
|
appear in |msgpackparse()| output in Neovim versions
|
||||||
|
which have |v:true| and |v:false|.
|
||||||
integer |List| with four numbers: sign (-1 or 1), highest two
|
integer |List| with four numbers: sign (-1 or 1), highest two
|
||||||
bits, number with bits from 62nd to 31st, lowest 31
|
bits, number with bits from 62nd to 31st, lowest 31
|
||||||
bits. I.e. to get actual number one will need to use
|
bits. I.e. to get actual number one will need to use
|
||||||
|
|||||||
@@ -551,21 +551,11 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv)
|
|||||||
{
|
{
|
||||||
switch (mobj.type) {
|
switch (mobj.type) {
|
||||||
case MSGPACK_OBJECT_NIL: {
|
case MSGPACK_OBJECT_NIL: {
|
||||||
create_special_dict(rettv, kMPNil, ((typval_T) {
|
*rettv = get_vim_var_tv(VV_NULL);
|
||||||
.v_type = VAR_NUMBER,
|
|
||||||
.v_lock = 0,
|
|
||||||
.vval = { .v_number = 0 },
|
|
||||||
}));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSGPACK_OBJECT_BOOLEAN: {
|
case MSGPACK_OBJECT_BOOLEAN: {
|
||||||
create_special_dict(rettv, kMPBoolean, ((typval_T) {
|
*rettv = get_vim_var_tv(mobj.via.boolean ? VV_TRUE : VV_FALSE);
|
||||||
.v_type = VAR_NUMBER,
|
|
||||||
.v_lock = 0,
|
|
||||||
.vval = {
|
|
||||||
.v_number = (varnumber_T) mobj.via.boolean,
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSGPACK_OBJECT_POSITIVE_INTEGER: {
|
case MSGPACK_OBJECT_POSITIVE_INTEGER: {
|
||||||
|
|||||||
@@ -393,25 +393,22 @@ end)
|
|||||||
describe('msgpackparse() function', function()
|
describe('msgpackparse() function', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
it('restores nil as special dict', function()
|
it('restores nil as v:null', function()
|
||||||
execute('let dumped = ["\\xC0"]')
|
execute('let dumped = ["\\xC0"]')
|
||||||
execute('let parsed = msgpackparse(dumped)')
|
execute('let parsed = msgpackparse(dumped)')
|
||||||
eq({{_TYPE={}, _VAL=0}}, eval('parsed'))
|
eq('[v:null]', eval('string(parsed)'))
|
||||||
eq(1, eval('g:parsed[0]._TYPE is v:msgpack_types.nil'))
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('restores boolean false as zero', function()
|
it('restores boolean false as v:false', function()
|
||||||
execute('let dumped = ["\\xC2"]')
|
execute('let dumped = ["\\xC2"]')
|
||||||
execute('let parsed = msgpackparse(dumped)')
|
execute('let parsed = msgpackparse(dumped)')
|
||||||
eq({{_TYPE={}, _VAL=0}}, eval('parsed'))
|
eq({false}, eval('parsed'))
|
||||||
eq(1, eval('g:parsed[0]._TYPE is v:msgpack_types.boolean'))
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('restores boolean true as one', function()
|
it('restores boolean true as v:true', function()
|
||||||
execute('let dumped = ["\\xC3"]')
|
execute('let dumped = ["\\xC3"]')
|
||||||
execute('let parsed = msgpackparse(dumped)')
|
execute('let parsed = msgpackparse(dumped)')
|
||||||
eq({{_TYPE={}, _VAL=1}}, eval('parsed'))
|
eq({true}, eval('parsed'))
|
||||||
eq(1, eval('g:parsed[0]._TYPE is v:msgpack_types.boolean'))
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('restores FIXSTR as special dict', function()
|
it('restores FIXSTR as special dict', function()
|
||||||
|
|||||||
Reference in New Issue
Block a user