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.23 by root, Wed Nov 20 16:19:47 2013 UTC vs.
Revision 1.24 by root, Wed Nov 20 16:29:02 2013 UTC

54 CBOR_TAG_MIME = 36, // mime message rfc2045, utf-8 54 CBOR_TAG_MIME = 36, // mime message rfc2045, utf-8
55 55
56 CBOR_TAG_MAGIC = 55799 // self-describe cbor 56 CBOR_TAG_MAGIC = 55799 // self-describe cbor
57}; 57};
58 58
59#define F_SHRINK 0x00000001UL 59#define F_SHRINK 0x00000001UL
60#define F_ALLOW_UNKNOWN 0x00000002UL 60#define F_ALLOW_UNKNOWN 0x00000002UL
61#define F_ALLOW_SHARING 0x00000004UL //TODO 61#define F_ALLOW_SHARING 0x00000004UL //TODO
62#define F_DEDUP_STRINGS 0x00000008UL //TODO 62#define F_ALLOW_STRINGREF 0x00000008UL //TODO
63 63
64#define INIT_SIZE 32 // initial scalar size to be allocated 64#define INIT_SIZE 32 // initial scalar size to be allocated
65 65
66#define SB do { 66#define SB do {
67#define SE } while (0) 67#define SE } while (0)
223} 223}
224 224
225static void 225static void
226encode_str (enc_t *enc, int utf8, char *str, STRLEN len) 226encode_str (enc_t *enc, int utf8, char *str, STRLEN len)
227{ 227{
228 if (ecb_expect_false (enc->cbor.flags & F_DEDUP_STRINGS)) 228 if (ecb_expect_false (enc->cbor.flags & F_ALLOW_STRINGREF))
229 { 229 {
230 SV **svp = hv_fetch (enc->stringref[!!utf8], str, len, 1); 230 SV **svp = hv_fetch (enc->stringref[!!utf8], str, len, 1);
231 231
232 if (SvOK (*svp)) 232 if (SvOK (*svp))
233 { 233 {
515 enc.cur = SvPVX (enc.sv); 515 enc.cur = SvPVX (enc.sv);
516 enc.end = SvEND (enc.sv); 516 enc.end = SvEND (enc.sv);
517 517
518 SvPOK_only (enc.sv); 518 SvPOK_only (enc.sv);
519 519
520 if (cbor->flags & F_DEDUP_STRINGS) 520 if (cbor->flags & F_ALLOW_STRINGREF)
521 { 521 {
522 encode_tag (&enc, CBOR_TAG_STRINGREF_NAMESPACE); 522 encode_tag (&enc, CBOR_TAG_STRINGREF_NAMESPACE);
523 enc.stringref[0]= (HV *)sv_2mortal ((SV *)newHV ()); 523 enc.stringref[0]= (HV *)sv_2mortal ((SV *)newHV ());
524 enc.stringref[1]= (HV *)sv_2mortal ((SV *)newHV ()); 524 enc.stringref[1]= (HV *)sv_2mortal ((SV *)newHV ());
525 } 525 }
1104void shrink (CBOR *self, int enable = 1) 1104void shrink (CBOR *self, int enable = 1)
1105 ALIAS: 1105 ALIAS:
1106 shrink = F_SHRINK 1106 shrink = F_SHRINK
1107 allow_unknown = F_ALLOW_UNKNOWN 1107 allow_unknown = F_ALLOW_UNKNOWN
1108 allow_sharing = F_ALLOW_SHARING 1108 allow_sharing = F_ALLOW_SHARING
1109 dedup_strings = F_DEDUP_STRINGS 1109 allow_stringref = F_ALLOW_STRINGREF
1110 PPCODE: 1110 PPCODE:
1111{ 1111{
1112 if (enable) 1112 if (enable)
1113 self->flags |= ix; 1113 self->flags |= ix;
1114 else 1114 else
1120void get_shrink (CBOR *self) 1120void get_shrink (CBOR *self)
1121 ALIAS: 1121 ALIAS:
1122 get_shrink = F_SHRINK 1122 get_shrink = F_SHRINK
1123 get_allow_unknown = F_ALLOW_UNKNOWN 1123 get_allow_unknown = F_ALLOW_UNKNOWN
1124 get_allow_sharing = F_ALLOW_SHARING 1124 get_allow_sharing = F_ALLOW_SHARING
1125 get_dedup_strings = F_DEDUP_STRINGS 1125 get_allow_stringref = F_ALLOW_STRINGREF
1126 PPCODE: 1126 PPCODE:
1127 XPUSHs (boolSV (self->flags & ix)); 1127 XPUSHs (boolSV (self->flags & ix));
1128 1128
1129void max_depth (CBOR *self, U32 max_depth = 0x80000000UL) 1129void max_depth (CBOR *self, U32 max_depth = 0x80000000UL)
1130 PPCODE: 1130 PPCODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines