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

Comparing JSON-XS/XS.xs (file contents):
Revision 1.83 by root, Wed Mar 26 22:54:38 2008 UTC vs.
Revision 1.84 by root, Thu Mar 27 06:37:35 2008 UTC

31#define F_ALLOW_NONREF 0x00000100UL 31#define F_ALLOW_NONREF 0x00000100UL
32#define F_SHRINK 0x00000200UL 32#define F_SHRINK 0x00000200UL
33#define F_ALLOW_BLESSED 0x00000400UL 33#define F_ALLOW_BLESSED 0x00000400UL
34#define F_CONV_BLESSED 0x00000800UL 34#define F_CONV_BLESSED 0x00000800UL
35#define F_RELAXED 0x00001000UL 35#define F_RELAXED 0x00001000UL
36#define F_ALLOW_UNKNOWN 0x00002000UL
36 37
37#define F_MAXDEPTH 0xf8000000UL 38#define F_MAXDEPTH 0xf8000000UL
38#define S_MAXDEPTH 27 39#define S_MAXDEPTH 27
39#define F_MAXSIZE 0x01f00000UL 40#define F_MAXSIZE 0x01f00000UL
40#define S_MAXSIZE 20 41#define S_MAXSIZE 20
642 643
643 if (len == 1 && *pv == '1') 644 if (len == 1 && *pv == '1')
644 encode_str (enc, "true", 4, 0); 645 encode_str (enc, "true", 4, 0);
645 else if (len == 1 && *pv == '0') 646 else if (len == 1 && *pv == '0')
646 encode_str (enc, "false", 5, 0); 647 encode_str (enc, "false", 5, 0);
648 else if (enc->json.flags & F_ALLOW_UNKNOWN)
649 encode_str (enc, "null", 4, 0);
647 else 650 else
648 croak ("cannot encode reference to scalar '%s' unless the scalar is 0 or 1", 651 croak ("cannot encode reference to scalar '%s' unless the scalar is 0 or 1",
649 SvPV_nolen (sv_2mortal (newRV_inc (sv)))); 652 SvPV_nolen (sv_2mortal (newRV_inc (sv))));
650 } 653 }
654 else if (enc->json.flags & F_ALLOW_UNKNOWN)
655 encode_str (enc, "null", 4, 0);
651 else 656 else
652 croak ("encountered %s, but JSON can only represent references to arrays or hashes", 657 croak ("encountered %s, but JSON can only represent references to arrays or hashes",
653 SvPV_nolen (sv_2mortal (newRV_inc (sv)))); 658 SvPV_nolen (sv_2mortal (newRV_inc (sv))));
654} 659}
655 660
717 : snprintf (enc->cur, IVUV_MAXCHARS, "%"IVdf, (IV)SvIVX (sv)); 722 : snprintf (enc->cur, IVUV_MAXCHARS, "%"IVdf, (IV)SvIVX (sv));
718 } 723 }
719 } 724 }
720 else if (SvROK (sv)) 725 else if (SvROK (sv))
721 encode_rv (enc, SvRV (sv)); 726 encode_rv (enc, SvRV (sv));
722 else if (!SvOK (sv)) 727 else if (!SvOK (sv) || enc->json.flags & F_ALLOW_UNKNOWN)
723 encode_str (enc, "null", 4, 0); 728 encode_str (enc, "null", 4, 0);
724 else 729 else
725 croak ("encountered perl type (%s,0x%x) that JSON cannot handle, you might want to report this", 730 croak ("encountered perl type (%s,0x%x) that JSON cannot handle, you might want to report this",
726 SvPV_nolen (sv), SvFLAGS (sv)); 731 SvPV_nolen (sv), SvFLAGS (sv));
727} 732}
1657 allow_nonref = F_ALLOW_NONREF 1662 allow_nonref = F_ALLOW_NONREF
1658 shrink = F_SHRINK 1663 shrink = F_SHRINK
1659 allow_blessed = F_ALLOW_BLESSED 1664 allow_blessed = F_ALLOW_BLESSED
1660 convert_blessed = F_CONV_BLESSED 1665 convert_blessed = F_CONV_BLESSED
1661 relaxed = F_RELAXED 1666 relaxed = F_RELAXED
1667 allow_unknown = F_ALLOW_UNKNOWN
1662 PPCODE: 1668 PPCODE:
1663{ 1669{
1664 if (enable) 1670 if (enable)
1665 self->flags |= ix; 1671 self->flags |= ix;
1666 else 1672 else
1681 get_allow_nonref = F_ALLOW_NONREF 1687 get_allow_nonref = F_ALLOW_NONREF
1682 get_shrink = F_SHRINK 1688 get_shrink = F_SHRINK
1683 get_allow_blessed = F_ALLOW_BLESSED 1689 get_allow_blessed = F_ALLOW_BLESSED
1684 get_convert_blessed = F_CONV_BLESSED 1690 get_convert_blessed = F_CONV_BLESSED
1685 get_relaxed = F_RELAXED 1691 get_relaxed = F_RELAXED
1692 get_allow_unknown = F_ALLOW_UNKNOWN
1686 PPCODE: 1693 PPCODE:
1687 XPUSHs (boolSV (self->flags & ix)); 1694 XPUSHs (boolSV (self->flags & ix));
1688 1695
1689void max_depth (JSON *self, UV max_depth = 0x80000000UL) 1696void max_depth (JSON *self, UV max_depth = 0x80000000UL)
1690 PPCODE: 1697 PPCODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines