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.65 by root, Sat Oct 13 01:55:31 2007 UTC vs.
Revision 1.69 by root, Wed Dec 5 10:59:28 2007 UTC

1457{ 1457{
1458 SV *pv = NEWSV (0, sizeof (JSON)); 1458 SV *pv = NEWSV (0, sizeof (JSON));
1459 SvPOK_only (pv); 1459 SvPOK_only (pv);
1460 Zero (SvPVX (pv), 1, JSON); 1460 Zero (SvPVX (pv), 1, JSON);
1461 ((JSON *)SvPVX (pv))->flags = F_DEFAULT; 1461 ((JSON *)SvPVX (pv))->flags = F_DEFAULT;
1462 XPUSHs (sv_2mortal (sv_bless (newRV_noinc (pv), JSON_STASH))); 1462 XPUSHs (sv_2mortal (sv_bless (
1463 newRV_noinc (pv),
1464 strEQ (klass, "JSON::XS") ? JSON_STASH : gv_stashpv (klass, 1)
1465 )));
1463} 1466}
1464 1467
1465void ascii (JSON *self, int enable = 1) 1468void ascii (JSON *self, int enable = 1)
1466 ALIAS: 1469 ALIAS:
1467 ascii = F_ASCII 1470 ascii = F_ASCII
1485 self->flags &= ~ix; 1488 self->flags &= ~ix;
1486 1489
1487 XPUSHs (ST (0)); 1490 XPUSHs (ST (0));
1488} 1491}
1489 1492
1493void get_ascii (JSON *self)
1494 ALIAS:
1495 get_ascii = F_ASCII
1496 get_latin1 = F_LATIN1
1497 get_utf8 = F_UTF8
1498 get_indent = F_INDENT
1499 get_canonical = F_CANONICAL
1500 get_space_before = F_SPACE_BEFORE
1501 get_space_after = F_SPACE_AFTER
1502 get_allow_nonref = F_ALLOW_NONREF
1503 get_shrink = F_SHRINK
1504 get_allow_blessed = F_ALLOW_BLESSED
1505 get_convert_blessed = F_CONV_BLESSED
1506 get_relaxed = F_RELAXED
1507 PPCODE:
1508 XPUSHs (boolSV (self->flags & ix));
1509
1490void max_depth (JSON *self, UV max_depth = 0x80000000UL) 1510void max_depth (JSON *self, UV max_depth = 0x80000000UL)
1491 PPCODE: 1511 PPCODE:
1492{ 1512{
1493 UV log2 = 0; 1513 UV log2 = 0;
1494 1514
1500 self->flags = self->flags & ~F_MAXDEPTH | (log2 << S_MAXDEPTH); 1520 self->flags = self->flags & ~F_MAXDEPTH | (log2 << S_MAXDEPTH);
1501 1521
1502 XPUSHs (ST (0)); 1522 XPUSHs (ST (0));
1503} 1523}
1504 1524
1525U32 get_max_depth (JSON *self)
1526 CODE:
1527 RETVAL = DEC_DEPTH (self->flags);
1528 OUTPUT:
1529 RETVAL
1530
1505void max_size (JSON *self, UV max_size = 0) 1531void max_size (JSON *self, UV max_size = 0)
1506 PPCODE: 1532 PPCODE:
1507{ 1533{
1508 UV log2 = 0; 1534 UV log2 = 0;
1509 1535
1515 1541
1516 self->flags = self->flags & ~F_MAXSIZE | (log2 << S_MAXSIZE); 1542 self->flags = self->flags & ~F_MAXSIZE | (log2 << S_MAXSIZE);
1517 1543
1518 XPUSHs (ST (0)); 1544 XPUSHs (ST (0));
1519} 1545}
1546
1547int get_max_size (JSON *self)
1548 CODE:
1549 RETVAL = DEC_SIZE (self->flags);
1550 OUTPUT:
1551 RETVAL
1520 1552
1521void filter_json_object (JSON *self, SV *cb = &PL_sv_undef) 1553void filter_json_object (JSON *self, SV *cb = &PL_sv_undef)
1522 PPCODE: 1554 PPCODE:
1523{ 1555{
1524 SvREFCNT_dec (self->cb_object); 1556 SvREFCNT_dec (self->cb_object);
1571 SvREFCNT_dec (self->cb_sk_object); 1603 SvREFCNT_dec (self->cb_sk_object);
1572 SvREFCNT_dec (self->cb_object); 1604 SvREFCNT_dec (self->cb_object);
1573 1605
1574PROTOTYPES: ENABLE 1606PROTOTYPES: ENABLE
1575 1607
1576void to_json (SV *scalar) 1608void encode_json (SV *scalar)
1577 PPCODE: 1609 PPCODE:
1578{ 1610{
1579 JSON json = { F_DEFAULT | F_UTF8 }; 1611 JSON json = { F_DEFAULT | F_UTF8 };
1580 XPUSHs (encode_json (scalar, &json)); 1612 XPUSHs (encode_json (scalar, &json));
1581} 1613}
1582 1614
1583void from_json (SV *jsonstr) 1615void decode_json (SV *jsonstr)
1584 PPCODE: 1616 PPCODE:
1585{ 1617{
1586 JSON json = { F_DEFAULT | F_UTF8 }; 1618 JSON json = { F_DEFAULT | F_UTF8 };
1587 XPUSHs (decode_json (jsonstr, &json, 0)); 1619 XPUSHs (decode_json (jsonstr, &json, 0));
1588} 1620}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines