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.31 by root, Thu Nov 28 11:43:26 2013 UTC vs.
Revision 1.32 by root, Thu Nov 28 12:08:07 2013 UTC

59 CBOR_TAG_MAGIC = 55799 // self-describe cbor 59 CBOR_TAG_MAGIC = 55799 // self-describe cbor
60}; 60};
61 61
62#define F_SHRINK 0x00000001UL 62#define F_SHRINK 0x00000001UL
63#define F_ALLOW_UNKNOWN 0x00000002UL 63#define F_ALLOW_UNKNOWN 0x00000002UL
64#define F_ALLOW_SHARING 0x00000004UL //TODO 64#define F_ALLOW_SHARING 0x00000004UL
65#define F_ALLOW_STRINGREF 0x00000008UL //TODO 65#define F_PACK_STRINGS 0x00000008UL
66 66
67#define INIT_SIZE 32 // initial scalar size to be allocated 67#define INIT_SIZE 32 // initial scalar size to be allocated
68 68
69#define SB do { 69#define SB do {
70#define SE } while (0) 70#define SE } while (0)
242} 242}
243 243
244static void 244static void
245encode_strref (enc_t *enc, int utf8, char *str, STRLEN len) 245encode_strref (enc_t *enc, int utf8, char *str, STRLEN len)
246{ 246{
247 if (ecb_expect_false (enc->cbor.flags & F_ALLOW_STRINGREF)) 247 if (ecb_expect_false (enc->cbor.flags & F_PACK_STRINGS))
248 { 248 {
249 SV **svp = hv_fetch (enc->stringref[!!utf8], str, len, 1); 249 SV **svp = hv_fetch (enc->stringref[!!utf8], str, len, 1);
250 250
251 if (SvOK (*svp)) 251 if (SvOK (*svp))
252 { 252 {
526 enc.cur = SvPVX (enc.sv); 526 enc.cur = SvPVX (enc.sv);
527 enc.end = SvEND (enc.sv); 527 enc.end = SvEND (enc.sv);
528 528
529 SvPOK_only (enc.sv); 529 SvPOK_only (enc.sv);
530 530
531 if (cbor->flags & F_ALLOW_STRINGREF) 531 if (cbor->flags & F_PACK_STRINGS)
532 { 532 {
533 encode_tag (&enc, CBOR_TAG_STRINGREF_NAMESPACE); 533 encode_tag (&enc, CBOR_TAG_STRINGREF_NAMESPACE);
534 enc.stringref[0]= (HV *)sv_2mortal ((SV *)newHV ()); 534 enc.stringref[0]= (HV *)sv_2mortal ((SV *)newHV ());
535 enc.stringref[1]= (HV *)sv_2mortal ((SV *)newHV ()); 535 enc.stringref[1]= (HV *)sv_2mortal ((SV *)newHV ());
536 } 536 }
1145void shrink (CBOR *self, int enable = 1) 1145void shrink (CBOR *self, int enable = 1)
1146 ALIAS: 1146 ALIAS:
1147 shrink = F_SHRINK 1147 shrink = F_SHRINK
1148 allow_unknown = F_ALLOW_UNKNOWN 1148 allow_unknown = F_ALLOW_UNKNOWN
1149 allow_sharing = F_ALLOW_SHARING 1149 allow_sharing = F_ALLOW_SHARING
1150 allow_stringref = F_ALLOW_STRINGREF 1150 pack_strings = F_PACK_STRINGS
1151 PPCODE: 1151 PPCODE:
1152{ 1152{
1153 if (enable) 1153 if (enable)
1154 self->flags |= ix; 1154 self->flags |= ix;
1155 else 1155 else
1161void get_shrink (CBOR *self) 1161void get_shrink (CBOR *self)
1162 ALIAS: 1162 ALIAS:
1163 get_shrink = F_SHRINK 1163 get_shrink = F_SHRINK
1164 get_allow_unknown = F_ALLOW_UNKNOWN 1164 get_allow_unknown = F_ALLOW_UNKNOWN
1165 get_allow_sharing = F_ALLOW_SHARING 1165 get_allow_sharing = F_ALLOW_SHARING
1166 get_allow_stringref = F_ALLOW_STRINGREF 1166 get_pack_strings = F_PACK_STRINGS
1167 PPCODE: 1167 PPCODE:
1168 XPUSHs (boolSV (self->flags & ix)); 1168 XPUSHs (boolSV (self->flags & ix));
1169 1169
1170void max_depth (CBOR *self, U32 max_depth = 0x80000000UL) 1170void max_depth (CBOR *self, U32 max_depth = 0x80000000UL)
1171 PPCODE: 1171 PPCODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines