… | |
… | |
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 | |
69 | static HV *json_stash, *json_boolean_stash; // JSON::XS:: |
71 | static HV *json_stash, *json_boolean_stash; // JSON::XS:: |
70 | static SV *json_true, *json_false; |
72 | static SV *json_true, *json_false; |
71 | |
73 | |
… | |
… | |
1378 | json_boolean_stash = 0; |
1380 | json_boolean_stash = 0; |
1379 | |
1381 | |
1380 | void new (char *klass) |
1382 | void new (char *klass) |
1381 | PPCODE: |
1383 | PPCODE: |
1382 | { |
1384 | { |
1383 | HV *stash = !JSON_SLOW || json_stash |
|
|
1384 | ? json_stash |
|
|
1385 | : gv_stashpv ("JSON::XS", 1); |
|
|
1386 | SV *pv = NEWSV (0, sizeof (JSON)); |
1385 | SV *pv = NEWSV (0, sizeof (JSON)); |
1387 | SvPOK_only (pv); |
1386 | SvPOK_only (pv); |
1388 | Zero (SvPVX (pv), 1, JSON); |
1387 | Zero (SvPVX (pv), 1, JSON); |
1389 | ((JSON *)SvPVX (pv))->flags = F_DEFAULT; |
1388 | ((JSON *)SvPVX (pv))->flags = F_DEFAULT; |
1390 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc (pv), stash))); |
1389 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc (pv), JSON_STASH))); |
1391 | } |
1390 | } |
1392 | |
1391 | |
1393 | void ascii (JSON *self, int enable = 1) |
1392 | void ascii (JSON *self, int enable = 1) |
1394 | ALIAS: |
1393 | ALIAS: |
1395 | ascii = F_ASCII |
1394 | ascii = F_ASCII |