Skip to content

Commit 1ef2039

Browse files
committed
feat: export msgpack_key, map, pair
1 parent e5fe35d commit 1ef2039

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

prolog/msgpackc.pl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
[ msgpack//1, % ?Term
3131

3232
msgpack_object//1, % ?Object
33+
msgpack_key//1, % ?Key
3334
msgpack_objects//1, % ?Objects
3435

3536
msgpack_nil//0,
@@ -60,6 +61,8 @@
6061

6162
% map format family
6263
msgpack_map//2, % :OnPair,?Map
64+
msgpack_map//1, % ?Map
65+
msgpack_pair//3, % :OnKey,:OnValue,KeyValuePair
6366

6467
% ext format family
6568
msgpack_ext//1, % ?Term
@@ -120,7 +123,7 @@
120123
msgpack(str(Str)) --> msgpack_str(Str), !.
121124
msgpack(bin(Bin)) --> msgpack_bin(Bin), !.
122125
msgpack(array(Array)) --> msgpack_array(msgpack, Array), !.
123-
msgpack(map(Map)) --> msgpack_map(msgpack_pair(msgpack, msgpack), Map), !.
126+
msgpack(map(Map)) --> msgpack_map(Map), !.
124127
msgpack(Term) --> msgpack_ext(Term).
125128

126129
%! msgpack_object(?Object)// is semidet.
@@ -620,11 +623,14 @@
620623
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
621624

622625
%! msgpack_map(:OnPair, ?Map:list)// is semidet.
626+
%! msgpack_map(?Map:list)// is semidet.
623627
%
624628
% Unify with Map using OnPair as the pair-wise grammar.
625629

626630
msgpack_map(OnPair, Map) --> msgpack_fixmap(OnPair, Map), !.
627-
msgpack_map(OnPair, Map) --> msgpack_map(OnPair, _, Map), !.
631+
msgpack_map(OnPair, Map) --> msgpack_map(OnPair, _, Map).
632+
633+
msgpack_map(Map) --> msgpack_map(msgpack_pair(msgpack, msgpack), Map).
628634

629635
msgpack_fixmap(OnPair, Map) -->
630636
{ var(Map),
@@ -668,6 +674,8 @@
668674
map_width_format(16, 0xde).
669675
map_width_format(32, 0xdf).
670676

677+
%! msgpack_pair(:OnKey, :OnValue, KeyValuePair)// is semidet.
678+
671679
msgpack_pair(OnKey, OnValue, Key-Value) -->
672680
call(OnKey, Key),
673681
call(OnValue, Value).

0 commit comments

Comments
 (0)