JSON-XS
view release on metacpan or search on metacpan
;
}
interrupt:
self->incr_pos = p - SvPVX (self->incr_text);
//printf ("interrupt<%.*s>\n", self->incr_pos, SvPVX(self->incr_text));//D
//printf ("return pos %d mode %d nest %d\n", self->incr_pos, self->incr_mode, self->incr_nest);//D
}
/////////////////////////////////////////////////////////////////////////////
// XS interface functions
MODULE = JSON::XS PACKAGE = JSON::XS
BOOT:
{
int i;
for (i = 0; i < 256; ++i)
decode_hexdigit [i] =
i >= '0' && i <= '9' ? i - '0'
: i >= 'a' && i <= 'f' ? i - 'a' + 10
: i >= 'A' && i <= 'F' ? i - 'A' + 10
: -1;
json_stash = gv_stashpv ("JSON::XS" , 1);
bool_stash = gv_stashpv ("Types::Serialiser::Boolean", 1);
bool_false = get_bool ("Types::Serialiser::false");
bool_true = get_bool ("Types::Serialiser::true");
sv_json = newSVpv ("JSON", 0);
SvREADONLY_on (sv_json);
CvNODEBUG_on (get_cv ("JSON::XS::incr_text", 0)); /* the debugger completely breaks lvalue subs */
}
PROTOTYPES: DISABLE
void CLONE (...)
CODE:
// as long as these writes are atomic, the race should not matter
// as existing threads either already use 0, or use the old value,
// which is sitll correct for the initial thread.
json_stash = 0;
bool_stash = 0;
bool_false = 0;
bool_true = 0;
void new (char *klass)
PPCODE:
{
SV *pv = NEWSV (0, sizeof (JSON));
SvPOK_only (pv);
json_init ((JSON *)SvPVX (pv));
XPUSHs (sv_2mortal (sv_bless (
newRV_noinc (pv),
strEQ (klass, "JSON::XS") ? JSON_STASH : gv_stashpv (klass, 1)
)));
}
void boolean_values (JSON *self, SV *v_false = 0, SV *v_true = 0)
PPCODE:
self->v_false = newSVsv (v_false);
self->v_true = newSVsv (v_true);
XPUSHs (ST (0));
void get_boolean_values (JSON *self)
PPCODE:
if (self->v_false && self->v_true)
{
EXTEND (SP, 2);
PUSHs (self->v_false);
PUSHs (self->v_true);
}
void ascii (JSON *self, int enable = 1)
ALIAS:
ascii = F_ASCII
latin1 = F_LATIN1
utf8 = F_UTF8
indent = F_INDENT
canonical = F_CANONICAL
space_before = F_SPACE_BEFORE
space_after = F_SPACE_AFTER
pretty = F_PRETTY
allow_nonref = F_ALLOW_NONREF
shrink = F_SHRINK
allow_blessed = F_ALLOW_BLESSED
convert_blessed = F_CONV_BLESSED
relaxed = F_RELAXED
allow_unknown = F_ALLOW_UNKNOWN
allow_tags = F_ALLOW_TAGS
PPCODE:
{
if (enable)
self->flags |= ix;
else
self->flags &= ~ix;
XPUSHs (ST (0));
}
void get_ascii (JSON *self)
ALIAS:
get_ascii = F_ASCII
get_latin1 = F_LATIN1
get_utf8 = F_UTF8
get_indent = F_INDENT
get_canonical = F_CANONICAL
get_space_before = F_SPACE_BEFORE
get_space_after = F_SPACE_AFTER
get_allow_nonref = F_ALLOW_NONREF
get_shrink = F_SHRINK
get_allow_blessed = F_ALLOW_BLESSED
get_convert_blessed = F_CONV_BLESSED
get_relaxed = F_RELAXED
get_allow_unknown = F_ALLOW_UNKNOWN
get_allow_tags = F_ALLOW_TAGS
PPCODE:
XPUSHs (boolSV (self->flags & ix));
void max_depth (JSON *self, U32 max_depth = 0x80000000UL)
PPCODE:
self->max_depth = max_depth;
XPUSHs (ST (0));
U32 get_max_depth (JSON *self)
( run in 0.847 second using v1.01-cache-2.11-cpan-39bf76dae61 )