Skip to content

Commit 8860a29

Browse files
committed
fix review comments
1 parent 340e002 commit 8860a29

5 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/msgpack.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
[{spec, new|old} |
5353
{allow_atom, none|pack} |
5454
{known_atoms, [atom()]} |
55-
{unpack_str, as_binary|as_list|with_tag} |
55+
{unpack_str, as_binary|as_list|as_tagged_list} |
5656
{validate_string, boolean()} |
57-
{pack_str, from_binary|from_list|with_tag|none} |
57+
{pack_str, from_binary|from_list|from_tagged_list|none} |
5858
{map_format, map|jiffy|jsx} |
5959
{ext, {msgpack:ext_packer(), msgpack:ext_unpacker()} | module()}].
6060

@@ -158,14 +158,14 @@ parse_options([{allow_atom,Type}|T], Opt0) ->
158158
parse_options([{known_atoms, Atoms}|T], Opt0) when is_list(Atoms) ->
159159
parse_options(T, Opt0?OPTION{known_atoms=Atoms});
160160

161-
parse_options([{unpack_str, As}|T], Opt0) when As =:= as_binary orelse As =:= as_list orelse As =:= with_tag ->
161+
parse_options([{unpack_str, As}|T], Opt0) when As =:= as_binary orelse As =:= as_list orelse As =:= as_tagged_list ->
162162
parse_options(T, Opt0?OPTION{unpack_str=As});
163163

164164
parse_options([{validate_string, Bool}|T], Opt) when is_boolean(Bool) ->
165165
parse_options(T, Opt?OPTION{validate_string=Bool});
166166

167167
parse_options([{pack_str, From}|T], Opt)
168-
when From =:= from_binary orelse From =:= from_list orelse From =:= with_tag orelse From =:= none ->
168+
when From =:= from_binary orelse From =:= from_list orelse From =:= from_tagged_list orelse From =:= none ->
169169
parse_options(T, Opt?OPTION{pack_str=From});
170170

171171
parse_options([{map_format,Type}|T], Opt0)

src/msgpack.hrl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
%% Erlang representation of msgpack data.
2828
-type msgpack_term() :: [msgpack_term()] | msgpack_map() |
29-
integer() | float() | boolean() | binary().
29+
integer() | float() | boolean() | binary() | string() | {string, string()}.
3030

3131
-type format_type() :: jsx|jiffy|map.
3232

@@ -37,9 +37,9 @@
3737
spec = new :: new | old,
3838
allow_atom = pack :: none | pack, %% allows atom when packing
3939
known_atoms = [] :: [atom()],
40-
unpack_str = as_list :: as_binary | as_list | with_tag,
40+
unpack_str = as_list :: as_binary | as_list | as_tagged_list,
4141
validate_string = false :: boolean(),
42-
pack_str = from_list :: from_binary | from_list | with_tag | none,
42+
pack_str = from_list :: from_binary | from_list | from_tagged_list | none,
4343
map_format = ?DEFAULT_MAP_FORMAT :: format_type(),
4444
map_unpack_fun = ?DEFAULT_MAP_UNPACKER_FUN :: msgpack_map_unpacker(),
4545
ext_packer = undefined :: msgpack:ext_packer() | undefined,

src/msgpack_packer.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pack(Map, Opt = ?OPTION{map_format=jsx}) when Map =:= [{}]->
6161
pack([{_,_}|_] = Map, Opt = ?OPTION{map_format=jsx}) ->
6262
pack_map(Map, Opt);
6363

64-
pack({string, String}, ?OPTION{spec=new, pack_str=with_tag}=Opt) ->
64+
pack({string, String}, ?OPTION{spec=new, pack_str=from_tagged_list}=Opt) ->
6565
case pack_string(String, Opt) of
6666
{error, _} -> throw({badarg, String});
6767
Bin when is_binary(Bin) -> Bin

src/msgpack_unpacker.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ unpack_str_or_raw(V, ?OPTION{spec=new,
234234
as_binary when ValidateString -> unpack_str(V), maybe_bin(V, Opt);
235235
as_binary -> maybe_bin(V, Opt);
236236
as_list -> unpack_str(V);
237-
with_tag -> {string, unpack_str(V)}
237+
as_tagged_list -> {string, unpack_str(V)}
238238
end, Rest}.
239239

240240
maybe_bin(Bin, _) ->

test/msgpack_tests.erl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -569,15 +569,15 @@ new_spec_pack_test_() ->
569569
msgpack:pack(list_minus_one(65536), [{spec,new},{pack_str,PackStr}]))]
570570
|| PackStr <- [from_list, from_binary, none]]
571571
},
572-
{"pack_str with_tag",
572+
{"pack_str from_tagged_list",
573573
[?_assertEqual(<<2#101:3, 3:5, 97,97,97>>,
574-
msgpack:pack({string, "aaa"}, [{spec,new},{pack_str,with_tag}])),
574+
msgpack:pack({string, "aaa"}, [{spec,new},{pack_str,from_tagged_list}])),
575575
?_assertMatch(<<16#D9, 32, _:32/binary>>,
576-
msgpack:pack({string, list_a(32)}, [{spec,new},{pack_str,with_tag}])),
576+
msgpack:pack({string, list_a(32)}, [{spec,new},{pack_str,from_tagged_list}])),
577577
?_assertMatch(<<16#DA, 1, 0, _:256/binary>>,
578-
msgpack:pack({string, list_a(256)}, [{spec,new},{pack_str,with_tag}])),
578+
msgpack:pack({string, list_a(256)}, [{spec,new},{pack_str,from_tagged_list}])),
579579
?_assertMatch(<<16#DB, 0, 1, 0, 0, _:65536/binary>>,
580-
msgpack:pack({string, list_a(65536)}, [{spec,new},{pack_str,with_tag}]))
580+
msgpack:pack({string, list_a(65536)}, [{spec,new},{pack_str,from_tagged_list}]))
581581
]
582582
}].
583583

@@ -616,7 +616,7 @@ new_spec_unpack_test_() ->
616616
?_assertEqual({ok, list_a(65536)},
617617
msgpack:unpack(<<16#DB, 0,1,0,0, (binary_a(65536))/binary>>, [{spec,new},{unpack_str,as_list}])),
618618
?_assertEqual({ok, {string, "aaa"}},
619-
msgpack:unpack(<<2#101:3, 3:5, 97,97,97>>, [{spec,new},{unpack_str,with_tag}]))
619+
msgpack:unpack(<<2#101:3, 3:5, 97,97,97>>, [{spec,new},{unpack_str,as_tagged_list}]))
620620
]}].
621621

622622
unpack_str_validation_test_() ->

0 commit comments

Comments
 (0)