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.58 by root, Mon Aug 13 16:06:25 2007 UTC vs.
Revision 1.60 by root, Mon Aug 13 16:19:13 2007 UTC

60#define expect_false(expr) expect ((expr) != 0, 0) 60#define expect_false(expr) expect ((expr) != 0, 0)
61#define expect_true(expr) expect ((expr) != 0, 1) 61#define expect_true(expr) expect ((expr) != 0, 1)
62 62
63#ifdef USE_ITHREADS 63#ifdef USE_ITHREADS
64# define JSON_SLOW 1 64# define JSON_SLOW 1
65# define JSON_STASH (json_stash ? json_stash : gv_stashpv ("JSON::XS", 1))
65#else 66#else
66# define JSON_SLOW 0 67# define JSON_SLOW 0
68# define JSON_STASH json_stash
67#endif 69#endif
68 70
69static HV *json_stash, *json_boolean_stash; // JSON::XS:: 71static HV *json_stash, *json_boolean_stash; // JSON::XS::
70static SV *json_true, *json_false; 72static SV *json_true, *json_false;
71 73
1223 1225
1224 case 't': 1226 case 't':
1225 if (dec->end - dec->cur >= 4 && !memcmp (dec->cur, "true", 4)) 1227 if (dec->end - dec->cur >= 4 && !memcmp (dec->cur, "true", 4))
1226 { 1228 {
1227 dec->cur += 4; 1229 dec->cur += 4;
1230#if JSON_SLOW
1231 json_true = get_sv ("JSON::XS::true", 1); SvREADONLY_on (json_true);
1232#endif
1228 return SvREFCNT_inc (json_true); 1233 return SvREFCNT_inc (json_true);
1229 } 1234 }
1230 else 1235 else
1231 ERR ("'true' expected"); 1236 ERR ("'true' expected");
1232 1237
1234 1239
1235 case 'f': 1240 case 'f':
1236 if (dec->end - dec->cur >= 5 && !memcmp (dec->cur, "false", 5)) 1241 if (dec->end - dec->cur >= 5 && !memcmp (dec->cur, "false", 5))
1237 { 1242 {
1238 dec->cur += 5; 1243 dec->cur += 5;
1244#if JSON_SLOW
1245 json_false = get_sv ("JSON::XS::false", 1); SvREADONLY_on (json_false);
1246#endif
1239 return SvREFCNT_inc (json_false); 1247 return SvREFCNT_inc (json_false);
1240 } 1248 }
1241 else 1249 else
1242 ERR ("'false' expected"); 1250 ERR ("'false' expected");
1243 1251
1378 json_boolean_stash = 0; 1386 json_boolean_stash = 0;
1379 1387
1380void new (char *klass) 1388void new (char *klass)
1381 PPCODE: 1389 PPCODE:
1382{ 1390{
1383 HV *stash = !JSON_SLOW || json_stash
1384 ? json_stash
1385 : gv_stashpv ("JSON::XS", 1);
1386 SV *pv = NEWSV (0, sizeof (JSON)); 1391 SV *pv = NEWSV (0, sizeof (JSON));
1387 SvPOK_only (pv); 1392 SvPOK_only (pv);
1388 Zero (SvPVX (pv), 1, JSON); 1393 Zero (SvPVX (pv), 1, JSON);
1389 ((JSON *)SvPVX (pv))->flags = F_DEFAULT; 1394 ((JSON *)SvPVX (pv))->flags = F_DEFAULT;
1390 XPUSHs (sv_2mortal (sv_bless (newRV_noinc (pv), stash))); 1395 XPUSHs (sv_2mortal (sv_bless (newRV_noinc (pv), JSON_STASH)));
1391} 1396}
1392 1397
1393void ascii (JSON *self, int enable = 1) 1398void ascii (JSON *self, int enable = 1)
1394 ALIAS: 1399 ALIAS:
1395 ascii = F_ASCII 1400 ascii = F_ASCII

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines