… | |
… | |
64 | |
64 | |
65 | package CBOR::XS; |
65 | package CBOR::XS; |
66 | |
66 | |
67 | use common::sense; |
67 | use common::sense; |
68 | |
68 | |
69 | our $VERSION = 1.5; |
69 | our $VERSION = 1.51; |
70 | our @ISA = qw(Exporter); |
70 | our @ISA = qw(Exporter); |
71 | |
71 | |
72 | our @EXPORT = qw(encode_cbor decode_cbor); |
72 | our @EXPORT = qw(encode_cbor decode_cbor); |
73 | |
73 | |
74 | use Exporter; |
74 | use Exporter; |
… | |
… | |
180 | reference to the earlier value. |
180 | reference to the earlier value. |
181 | |
181 | |
182 | This means that such values will only be encoded once, and will not result |
182 | This means that such values will only be encoded once, and will not result |
183 | in a deep cloning of the value on decode, in decoders supporting the value |
183 | in a deep cloning of the value on decode, in decoders supporting the value |
184 | sharing extension. This also makes it possible to encode cyclic data |
184 | sharing extension. This also makes it possible to encode cyclic data |
185 | structures (which need C<allow_cycles> to ne enabled to be decoded by this |
185 | structures (which need C<allow_cycles> to be enabled to be decoded by this |
186 | module). |
186 | module). |
187 | |
187 | |
188 | It is recommended to leave it off unless you know your |
188 | It is recommended to leave it off unless you know your |
189 | communication partner supports the value sharing extensions to CBOR |
189 | communication partner supports the value sharing extensions to CBOR |
190 | (L<http://cbor.schmorp.de/value-sharing>), as without decoder support, the |
190 | (L<http://cbor.schmorp.de/value-sharing>), as without decoder support, the |
… | |
… | |
440 | |
440 | |
441 | Resets the incremental decoder. This throws away any saved state, so that |
441 | Resets the incremental decoder. This throws away any saved state, so that |
442 | subsequent calls to C<incr_parse> or C<incr_parse_multiple> start to parse |
442 | subsequent calls to C<incr_parse> or C<incr_parse_multiple> start to parse |
443 | a new CBOR value from the beginning of the C<$buffer> again. |
443 | a new CBOR value from the beginning of the C<$buffer> again. |
444 | |
444 | |
445 | This method can be caled at any time, but it I<must> be called if you want |
445 | This method can be called at any time, but it I<must> be called if you want |
446 | to change your C<$buffer> or there was a decoding error and you want to |
446 | to change your C<$buffer> or there was a decoding error and you want to |
447 | reuse the C<$cbor> object for future incremental parsings. |
447 | reuse the C<$cbor> object for future incremental parsings. |
448 | |
448 | |
449 | =back |
449 | =back |
450 | |
450 | |
… | |
… | |
1206 | } |
1206 | } |
1207 | |
1207 | |
1208 | sub Math::BigRat::TO_CBOR { |
1208 | sub Math::BigRat::TO_CBOR { |
1209 | my ($n, $d) = $_[0]->parts; |
1209 | my ($n, $d) = $_[0]->parts; |
1210 | |
1210 | |
|
|
1211 | # older versions of BigRat need *1, as they not always return numbers |
|
|
1212 | |
1211 | $d == 1 |
1213 | $d*1 == 1 |
1212 | ? $n |
1214 | ? $n*1 |
1213 | : tag 30, [$n, $d] |
1215 | : tag 30, [$n*1, $d*1] |
1214 | } |
1216 | } |
1215 | |
1217 | |
1216 | sub Time::Piece::TO_CBOR { |
1218 | sub Time::Piece::TO_CBOR { |
1217 | tag 1, 0 + $_[0]->epoch |
1219 | tag 1, 0 + $_[0]->epoch |
1218 | } |
1220 | } |