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.1 by root, Thu Mar 22 16:40:16 2007 UTC vs.
Revision 1.2 by root, Thu Mar 22 17:28:50 2007 UTC

12#define F_CANONICAL 0x00000008 12#define F_CANONICAL 0x00000008
13#define F_SPACE_BEFORE 0x00000010 13#define F_SPACE_BEFORE 0x00000010
14#define F_SPACE_AFTER 0x00000020 14#define F_SPACE_AFTER 0x00000020
15#define F_JSON_RPC 0x00000040 15#define F_JSON_RPC 0x00000040
16 16
17#define F_PRETTY F_INDENT | F_SPACE_BEFORE | F_SPACE_AFTER
17#define F_DEFAULT 0 18#define F_DEFAULT 0
18 19
19#define INIT_SIZE 32 // initial scalar size to be allocated 20#define INIT_SIZE 32 // initial scalar size to be allocated
20 21
21#define SB do { 22#define SB do {
146 for (i_ = enc->indent * 3; i_--; )\ 147 for (i_ = enc->indent * 3; i_--; )\
147 encode_ch (enc, ' '); \ 148 encode_ch (enc, ' '); \
148 } \ 149 } \
149 SE 150 SE
150 151
151#define SPACE SB if (enc->flags & F_INDENT) { need (enc, 1); encode_ch (enc, ' '); } SE 152#define SPACE SB need (enc, 1); encode_ch (enc, ' '); SE
152#define NL SB if (enc->flags & F_INDENT) { need (enc, 1); encode_ch (enc, '\n'); } SE 153#define NL SB if (enc->flags & F_INDENT) { need (enc, 1); encode_ch (enc, '\n'); } SE
153#define COMMA SB \ 154#define COMMA SB \
154 encode_ch (enc, ','); \ 155 encode_ch (enc, ','); \
155 if (enc->flags & F_INDENT) \ 156 if (enc->flags & F_INDENT) \
156 NL; \ 157 NL; \
809 indent = F_INDENT 810 indent = F_INDENT
810 canonical = F_CANONICAL 811 canonical = F_CANONICAL
811 space_before = F_SPACE_BEFORE 812 space_before = F_SPACE_BEFORE
812 space_after = F_SPACE_AFTER 813 space_after = F_SPACE_AFTER
813 json_rpc = F_JSON_RPC 814 json_rpc = F_JSON_RPC
815 pretty = F_PRETTY
814 CODE: 816 CODE:
815{ 817{
816 UV *uv = SvJSON (self); 818 UV *uv = SvJSON (self);
817 if (enable) 819 if (enable)
818 *uv |= ix; 820 *uv |= ix;
826 828
827void encode (SV *self, SV *scalar) 829void encode (SV *self, SV *scalar)
828 PPCODE: 830 PPCODE:
829 XPUSHs (encode_json (scalar, *SvJSON (self))); 831 XPUSHs (encode_json (scalar, *SvJSON (self)));
830 832
831void decode (SV *self, SV *jsondata) 833void decode (SV *self, SV *jsonstr)
832 PPCODE: 834 PPCODE:
833 XPUSHs (decode_json (jsondata, *SvJSON (self))); 835 XPUSHs (decode_json (jsonstr, *SvJSON (self)));
834 836
837void to_json (SV *scalar)
838 PPCODE:
839 XPUSHs (encode_json (scalar, F_UTF8));
840
841void from_json (SV *jsonstr)
842 PPCODE:
843 XPUSHs (decode_json (jsonstr, F_UTF8));
844

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines