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.56 by root, Thu Jul 26 11:33:35 2007 UTC vs.
Revision 1.57 by root, Mon Aug 13 16:05:42 2007 UTC

57# define inline static 57# define inline static
58#endif 58#endif
59 59
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
63#ifdef USE_ITHREADS
64# define JSON_SLOW 1
65#else
66# define JSON_SLOW 1
67#endif
62 68
63static HV *json_stash, *json_boolean_stash; // JSON::XS:: 69static HV *json_stash, *json_boolean_stash; // JSON::XS::
64static SV *json_true, *json_false; 70static SV *json_true, *json_false;
65 71
66typedef struct { 72typedef struct {
478 SvGETMAGIC (sv); 484 SvGETMAGIC (sv);
479 svt = SvTYPE (sv); 485 svt = SvTYPE (sv);
480 486
481 if (expect_false (SvOBJECT (sv))) 487 if (expect_false (SvOBJECT (sv)))
482 { 488 {
489 HV *stash = !JSON_SLOW || json_boolean_stash
490 ? json_boolean_stash
491 : gv_stashpv ("JSON::XS::Boolean", 1);
492
483 if (SvSTASH (sv) == json_boolean_stash) 493 if (SvSTASH (sv) == stash)
484 { 494 {
485 if (SvIV (sv)) 495 if (SvIV (sv))
486 encode_str (enc, "true", 4, 0); 496 encode_str (enc, "true", 4, 0);
487 else 497 else
488 encode_str (enc, "false", 5, 0); 498 encode_str (enc, "false", 5, 0);
1361 json_false = get_sv ("JSON::XS::false", 1); SvREADONLY_on (json_false); 1371 json_false = get_sv ("JSON::XS::false", 1); SvREADONLY_on (json_false);
1362} 1372}
1363 1373
1364PROTOTYPES: DISABLE 1374PROTOTYPES: DISABLE
1365 1375
1376void CLONE (...)
1377 CODE:
1378 json_stash = 0;
1379 json_boolean_stash = 0;
1380
1366void new (char *klass) 1381void new (char *klass)
1367 PPCODE: 1382 PPCODE:
1368{ 1383{
1384 HV *stash = !JSON_SLOW || json_stash
1385 ? json_stash
1386 : gv_stashpv ("JSON::XS", 1);
1369 SV *pv = NEWSV (0, sizeof (JSON)); 1387 SV *pv = NEWSV (0, sizeof (JSON));
1370 SvPOK_only (pv); 1388 SvPOK_only (pv);
1371 Zero (SvPVX (pv), 1, JSON); 1389 Zero (SvPVX (pv), 1, JSON);
1372 ((JSON *)SvPVX (pv))->flags = F_DEFAULT; 1390 ((JSON *)SvPVX (pv))->flags = F_DEFAULT;
1373 XPUSHs (sv_2mortal (sv_bless (newRV_noinc (pv), json_stash))); 1391 XPUSHs (sv_2mortal (sv_bless (newRV_noinc (pv), stash)));
1374} 1392}
1375 1393
1376void ascii (JSON *self, int enable = 1) 1394void ascii (JSON *self, int enable = 1)
1377 ALIAS: 1395 ALIAS:
1378 ascii = F_ASCII 1396 ascii = F_ASCII

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines