… | |
… | |
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 | } |