ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/XS.xs
(Generate patch)

Comparing CBOR-XS/XS.xs (file contents):
Revision 1.66 by root, Sun Nov 29 21:32:01 2020 UTC vs.
Revision 1.67 by root, Sun Nov 29 21:35:06 2020 UTC

105enum 105enum
106{ 106{
107 AS_CBOR = 0, 107 AS_CBOR = 0,
108 AS_BYTES = 1, 108 AS_BYTES = 1,
109 AS_TEXT = 2, 109 AS_TEXT = 2,
110 AS_INT = 3,
110 AS_FLOAT16 = 3, 111 AS_FLOAT16 = 4,
111 AS_FLOAT32 = 4, 112 AS_FLOAT32 = 5,
112 AS_FLOAT64 = 5, 113 AS_FLOAT64 = 6,
113 // possibly future enhancements: float, integer 114 // possibly future enhancements: (generic) float, (generic) string
114}; 115};
115 116
116#define F_SHRINK 0x00000001UL 117#define F_SHRINK 0x00000001UL
117#define F_ALLOW_UNKNOWN 0x00000002UL 118#define F_ALLOW_UNKNOWN 0x00000002UL
118#define F_ALLOW_SHARING 0x00000004UL 119#define F_ALLOW_SHARING 0x00000004UL
287 *enc->cur++ = len; 288 *enc->cur++ = len;
288 } 289 }
289} 290}
290 291
291// encodes a perl value into a CBOR integer 292// encodes a perl value into a CBOR integer
292ecb_inline 293ecb_inline void
293encode_int (enc_t *enc, SV *sv) 294encode_int (enc_t *enc, SV *sv)
294{ 295{
295 if (SvIsUV (sv)) 296 if (SvIsUV (sv))
296 encode_uint (enc, MAJOR_POS_INT, SvUVX (sv)); 297 encode_uint (enc, MAJOR_POS_INT, SvUVX (sv));
297 else if (SvIVX (sv) >= 0) 298 else if (SvIVX (sv) >= 0)
448 char *str = SvPVutf8 (sv, len); 449 char *str = SvPVutf8 (sv, len);
449 encode_strref (enc, 1, 1, str, len); 450 encode_strref (enc, 1, 1, str, len);
450 } 451 }
451 break; 452 break;
452 453
454 case AS_INT: encode_int (enc, sv); break;
453 case AS_FLOAT16: encode_float16 (enc, SvNV (sv)); break; 455 case AS_FLOAT16: encode_float16 (enc, SvNV (sv)); break;
454 case AS_FLOAT32: encode_float32 (enc, SvNV (sv)); break; 456 case AS_FLOAT32: encode_float32 (enc, SvNV (sv)); break;
455 case AS_FLOAT64: encode_float64 (enc, SvNV (sv)); break; 457 case AS_FLOAT64: encode_float64 (enc, SvNV (sv)); break;
456 458
457 default: 459 default:
714 encode_strref (enc, enc->cbor.flags & F_TEXT_STRINGS, SvUTF8 (sv), str, len); 716 encode_strref (enc, enc->cbor.flags & F_TEXT_STRINGS, SvUTF8 (sv), str, len);
715 } 717 }
716 else if (SvNOKp (sv)) 718 else if (SvNOKp (sv))
717 encode_nv (enc, sv); 719 encode_nv (enc, sv);
718 else if (SvIOKp (sv)) 720 else if (SvIOKp (sv))
719 encode_int (e,v sv); 721 encode_int (enc, sv);
720 else if (SvROK (sv)) 722 else if (SvROK (sv))
721 encode_rv (enc, SvRV (sv)); 723 encode_rv (enc, SvRV (sv));
722 else if (!SvOK (sv)) 724 else if (!SvOK (sv))
723 encode_ch (enc, MAJOR_MISC | SIMPLE_NULL); 725 encode_ch (enc, MAJOR_MISC | SIMPLE_NULL);
724 else if (enc->cbor.flags & F_ALLOW_UNKNOWN) 726 else if (enc->cbor.flags & F_ALLOW_UNKNOWN)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines