/*
 * This file was generated automatically by ExtUtils::ParseXS version 3.35 from the
 * contents of Json3.xs. Do not edit this file, edit Json3.xs instead.
 *
 *    ANY CHANGES MADE HERE WILL BE LOST!
 *
 */

#line 1 "Json3.xs"
#include "EXTERN.h"
#include "perl.h"
#include <stdint.h>
#include "XSUB.h"

/* TESTRANDOM should never be defined in the code released to
   CPAN. That this is not defined is tested in
   "xt/testrandom-invalid.t". */

//#define TESTRANDOM

#ifdef TESTRANDOM
#include <setjmp.h>
#endif /* def TESTRANDOM */

/* A structure representing the "null" in JSON. Although we're now
   using PL_sv_yes and PL_sv_no, we don't use PL_sv_undef, because
   perldoc perlguts says it's a bad idea. */

static SV * json_null;

/* Code starts here. */

#include "unicode.h"
#include "unicode.c"
#include "json-common.c"
#define PERLING
#include "json-perl.c"
#undef PERLING
#define TOKENING
#include "json-perl.c"
#undef TOKENING
#include "json-perl.c"
#include "json-entry-points.c"
#ifdef TESTRANDOM
#include "json-random-test.c"
#endif /* def TESTRANDOM */
#include "json-whitespace.c"
#ifdef NOPERL
#error "Cannot define NOPERL error when compiling Perl version"
#endif /* def NOPERL */

typedef json_parse_t * JSON__Parse;
typedef json_token_t * JSON__Tokenize;

#line 56 "Json3.c"
#ifndef PERL_UNUSED_VAR
#  define PERL_UNUSED_VAR(var) if (0) var = var
#endif

#ifndef dVAR
#  define dVAR		dNOOP
#endif


/* This stuff is not part of the API! You have been warned. */
#ifndef PERL_VERSION_DECIMAL
#  define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
#endif
#ifndef PERL_DECIMAL_VERSION
#  define PERL_DECIMAL_VERSION \
	  PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
#endif
#ifndef PERL_VERSION_GE
#  define PERL_VERSION_GE(r,v,s) \
	  (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
#endif
#ifndef PERL_VERSION_LE
#  define PERL_VERSION_LE(r,v,s) \
	  (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
#endif

/* XS_INTERNAL is the explicit static-linkage variant of the default
 * XS macro.
 *
 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
 * "STATIC", ie. it exports XSUB symbols. You probably don't want that
 * for anything but the BOOT XSUB.
 *
 * See XSUB.h in core!
 */


/* TODO: This might be compatible further back than 5.10.0. */
#if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
#  undef XS_EXTERNAL
#  undef XS_INTERNAL
#  if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
#    define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
#    define XS_INTERNAL(name) STATIC XSPROTO(name)
#  endif
#  if defined(__SYMBIAN32__)
#    define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
#    define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
#  endif
#  ifndef XS_EXTERNAL
#    if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
#      define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
#      define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
#    else
#      ifdef __cplusplus
#        define XS_EXTERNAL(name) extern "C" XSPROTO(name)
#        define XS_INTERNAL(name) static XSPROTO(name)
#      else
#        define XS_EXTERNAL(name) XSPROTO(name)
#        define XS_INTERNAL(name) STATIC XSPROTO(name)
#      endif
#    endif
#  endif
#endif

/* perl >= 5.10.0 && perl <= 5.15.1 */


/* The XS_EXTERNAL macro is used for functions that must not be static
 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
 * macro defined, the best we can do is assume XS is the same.
 * Dito for XS_INTERNAL.
 */
#ifndef XS_EXTERNAL
#  define XS_EXTERNAL(name) XS(name)
#endif
#ifndef XS_INTERNAL
#  define XS_INTERNAL(name) XS(name)
#endif

/* Now, finally, after all this mess, we want an ExtUtils::ParseXS
 * internal macro that we're free to redefine for varying linkage due
 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
 */

#undef XS_EUPXS
#if defined(PERL_EUPXS_ALWAYS_EXPORT)
#  define XS_EUPXS(name) XS_EXTERNAL(name)
#else
   /* default to internal */
#  define XS_EUPXS(name) XS_INTERNAL(name)
#endif

#ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
#define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)

/* prototype to pass -Wmissing-prototypes */
STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params);

STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params)
{
    const GV *const gv = CvGV(cv);

    PERL_ARGS_ASSERT_CROAK_XS_USAGE;

    if (gv) {
        const char *const gvname = GvNAME(gv);
        const HV *const stash = GvSTASH(gv);
        const char *const hvname = stash ? HvNAME(stash) : NULL;

        if (hvname)
	    Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
        else
	    Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
    } else {
        /* Pants. I don't think that it should be possible to get here. */
	Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
    }
}
#undef  PERL_ARGS_ASSERT_CROAK_XS_USAGE

#define croak_xs_usage        S_croak_xs_usage

#endif

/* NOTE: the prototype of newXSproto() is different in versions of perls,
 * so we define a portable version of newXSproto()
 */
#ifdef newXS_flags
#define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
#else
#define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
#endif /* !defined(newXS_flags) */

#if PERL_VERSION_LE(5, 21, 5)
#  define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
#else
#  define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
#endif

#line 200 "Json3.c"

XS_EUPXS(XS_JSON__Parse_parse_json); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_parse_json)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "json");
    {
	SV *	json = ST(0)
;
	SV *	RETVAL;
#line 58 "Json3.xs"
	RETVAL = parse (json);
#line 214 "Json3.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_JSON__Parse_parse_json_safer); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_parse_json_safer)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "json");
    {
	SV *	json = ST(0)
;
	SV *	RETVAL;
#line 65 "Json3.xs"
	RETVAL = parse_safe (json);
#line 234 "Json3.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_JSON__Parse_assert_valid_json); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_assert_valid_json)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "json");
    {
	SV *	json = ST(0)
;
#line 72 "Json3.xs"
	validate (json, 0);
#line 253 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_new); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_new)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "class, ...");
    {
	JSON__Parse	RETVAL;
	char *	class = (char *)SvPV_nolen(ST(0))
;
#line 77 "Json3.xs"
	if (! class) {
	    croak ("no class");
	}
	Newxz (RETVAL, 1, json_parse_t);
	json_parse_init (RETVAL);
#line 275 "Json3.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "JSON::Parse", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_JSON__Parse_run_internal); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_run_internal)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "parser, json");
    {
	JSON__Parse	parser;
	SV *	json = ST(1)
;
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::run_internal",
			"parser", "JSON::Parse")
;
#line 89 "Json3.xs"
	RETVAL = json_parse_run (parser, json);
#line 310 "Json3.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_JSON__Parse_check); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_check)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "parser, json");
    {
	JSON__Parse	parser;
	SV *	json = ST(1)
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::check",
			"parser", "JSON::Parse")
;
#line 98 "Json3.xs"
	check (parser, json);
#line 340 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_DESTROY)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "parser");
    {
	JSON__Parse	parser;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not a reference",
			"JSON::Parse::DESTROY",
			"parser")
;
#line 104 "Json3.xs"
	json_parse_free (parser);
#line 366 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_set_true); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_set_true)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "parser, user_true");
    {
	JSON__Parse	parser;
	SV *	user_true = ST(1)
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::set_true",
			"parser", "JSON::Parse")
;
#line 111 "Json3.xs"
	json_parse_set_true (parser, user_true);
#line 394 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_set_false); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_set_false)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "parser, user_false");
    {
	JSON__Parse	parser;
	SV *	user_false = ST(1)
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::set_false",
			"parser", "JSON::Parse")
;
#line 118 "Json3.xs"
	json_parse_set_false (parser, user_false);
#line 422 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_set_null); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_set_null)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "parser, user_null");
    {
	JSON__Parse	parser;
	SV *	user_null = ST(1)
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::set_null",
			"parser", "JSON::Parse")
;
#line 125 "Json3.xs"
	json_parse_set_null (parser, user_null);
#line 450 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_delete_true); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_delete_true)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "parser");
    {
	JSON__Parse	parser;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::delete_true",
			"parser", "JSON::Parse")
;
#line 131 "Json3.xs"
	json_parse_delete_true (parser);
#line 476 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_delete_false); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_delete_false)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "parser");
    {
	JSON__Parse	parser;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::delete_false",
			"parser", "JSON::Parse")
;
#line 137 "Json3.xs"
	json_parse_delete_false (parser);
#line 502 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_delete_null); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_delete_null)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "parser");
    {
	JSON__Parse	parser;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::delete_null",
			"parser", "JSON::Parse")
;
#line 143 "Json3.xs"
	json_parse_delete_null (parser);
#line 528 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_copy_literals); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_copy_literals)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "parser, onoff");
    {
	JSON__Parse	parser;
	SV *	onoff = ST(1)
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::copy_literals",
			"parser", "JSON::Parse")
;
#line 150 "Json3.xs"
	json_parse_copy_literals (parser, onoff);
#line 556 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_no_warn_literals); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_no_warn_literals)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "parser, onoff");
    {
	JSON__Parse	parser;
	SV *	onoff = ST(1)
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::no_warn_literals",
			"parser", "JSON::Parse")
;
#line 157 "Json3.xs"
	parser->no_warn_literals = SvTRUE (onoff) ? 1 : 0;
#line 584 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_diagnostics_hash); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_diagnostics_hash)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "parser, onoff");
    {
	JSON__Parse	parser;
	SV *	onoff = ST(1)
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::diagnostics_hash",
			"parser", "JSON::Parse")
;
#line 164 "Json3.xs"
#if PERL_VERSION > 12
	parser->diagnostics_hash = SvTRUE (onoff) ? 1 : 0;
#else
        warn ("diagnostics_hash () requires Perl 5.14 or later; this is 5.%d",
	      PERL_VERSION);
#endif
#line 617 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_warn_only); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_warn_only)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "parser, onoff");
    {
	JSON__Parse	parser;
	SV *	onoff = ST(1)
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::warn_only",
			"parser", "JSON::Parse")
;
#line 176 "Json3.xs"
	parser->warn_only = SvTRUE (onoff) ? 1 : 0;
#line 645 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_get_warn_only); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_get_warn_only)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "parser");
    {
	JSON__Parse	parser;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::get_warn_only",
			"parser", "JSON::Parse")
;
#line 182 "Json3.xs"
	if (parser->warn_only) {
		RETVAL = 1;
	}
	else {
		RETVAL = 0;
	}
#line 678 "Json3.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_JSON__Parse_detect_collisions); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_detect_collisions)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "parser, onoff");
    {
	JSON__Parse	parser;
	SV *	onoff = ST(1)
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    parser = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::detect_collisions",
			"parser", "JSON::Parse")
;
#line 197 "Json3.xs"
	parser->detect_collisions = SvTRUE (onoff) ? 1 : 0;
#line 707 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_set_max_depth); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_set_max_depth)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "json, max_depth");
    {
	JSON__Parse	json;
	int	max_depth = (int)SvIV(ST(1))
;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    json = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::set_max_depth",
			"json", "JSON::Parse")
;
#line 204 "Json3.xs"
	if (max_depth < 0) {
		croak ("Invalid max depth %d", max_depth);
	}
	json->max_depth = max_depth;
#line 738 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Parse_get_max_depth); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_get_max_depth)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "json");
    {
	JSON__Parse	json;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Parse")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    json = INT2PTR(JSON__Parse,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Parse::get_max_depth",
			"json", "JSON::Parse")
;
#line 213 "Json3.xs"
	RETVAL = json->max_depth;
	if (json->max_depth == 0) {
		RETVAL = JSON_PARSE_DEFAULT_MAX_DEPTH;
	}
#line 769 "Json3.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#ifdef TESTRANDOM
#define XSubPPtmpAAAA 1


XS_EUPXS(XS_JSON__Parse_random_json); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Parse_random_json)
{
    dVAR; dXSARGS;
    if (items != 0)
       croak_xs_usage(cv,  "");
    {
	int	RETVAL;
	dXSTARG;
#line 224 "Json3.xs"
	RETVAL = random_json ();
#line 790 "Json3.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#endif /* def TESTRANDOM */

XS_EUPXS(XS_JSON__Tokenize_tokenize_json); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Tokenize_tokenize_json)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "json");
    {
	SV *	json = ST(0)
;
	JSON__Tokenize	RETVAL;
#line 235 "Json3.xs"
	RETVAL = tokenize (json);
	RETVAL->blessed = 1;
#line 811 "Json3.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "JSON::Tokenize", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_JSON__Tokenize_tokenize_child); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Tokenize_tokenize_child)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "token");
    {
	JSON__Tokenize	token;
	JSON__Tokenize	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Tokenize")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    token = INT2PTR(JSON__Tokenize,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Tokenize::tokenize_child",
			"token", "JSON::Tokenize")
;
#line 243 "Json3.xs"
	RETVAL = token;
	if (token->child) {
		RETVAL = token->child;
		RETVAL->blessed = 1;
	}
#line 848 "Json3.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "JSON::Tokenize", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_JSON__Tokenize_tokenize_next); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Tokenize_tokenize_next)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "token");
    {
	JSON__Tokenize	token;
	JSON__Tokenize	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Tokenize")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    token = INT2PTR(JSON__Tokenize,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Tokenize::tokenize_next",
			"token", "JSON::Tokenize")
;
#line 254 "Json3.xs"
	if (token->next) {
		RETVAL = token->next;
		RETVAL->blessed = 1;
	}
	else {
       		RETVAL = 0;
	}
#line 887 "Json3.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "JSON::Tokenize", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_JSON__Tokenize_tokenize_start); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Tokenize_tokenize_start)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "token");
    {
	JSON__Tokenize	token;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Tokenize")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    token = INT2PTR(JSON__Tokenize,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Tokenize::tokenize_start",
			"token", "JSON::Tokenize")
;
#line 267 "Json3.xs"
	RETVAL = token->start;
#line 921 "Json3.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_JSON__Tokenize_tokenize_end); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Tokenize_tokenize_end)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "token");
    {
	JSON__Tokenize	token;
	int	RETVAL;
	dXSTARG;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Tokenize")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    token = INT2PTR(JSON__Tokenize,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Tokenize::tokenize_end",
			"token", "JSON::Tokenize")
;
#line 274 "Json3.xs"
	RETVAL = token->end;
#line 950 "Json3.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_JSON__Tokenize_tokenize_type); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Tokenize_tokenize_type)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "token");
    {
	JSON__Tokenize	token;
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Tokenize")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    token = INT2PTR(JSON__Tokenize,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Tokenize::tokenize_type",
			"token", "JSON::Tokenize")
;
#line 281 "Json3.xs"
	/* Only set this to the real value if everything is OK. */
	RETVAL = & PL_sv_undef;
	if (token->type > json_token_invalid &&
	    token->type < n_json_tokens) {
		RETVAL = newSVpv (token_names[token->type], 0);
	}
	else {
		warn ("Invalid JSON token type %d", token->type);
	}
#line 986 "Json3.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_JSON__Tokenize_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Tokenize_DESTROY)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "token");
    {
	JSON__Tokenize	token;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    token = INT2PTR(JSON__Tokenize,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not a reference",
			"JSON::Tokenize::DESTROY",
			"token")
;
#line 296 "Json3.xs"
	tokenize_free (token);
#line 1014 "Json3.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_JSON__Whitespace_strip_whitespace); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_JSON__Whitespace_strip_whitespace)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "tokens, json");
    {
	JSON__Tokenize	tokens;
	SV *	json = ST(1)
;
	SV *	RETVAL;

	if (SvROK(ST(0)) && sv_derived_from(ST(0), "JSON::Tokenize")) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    tokens = INT2PTR(JSON__Tokenize,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not of type %s",
			"JSON::Whitespace::strip_whitespace",
			"tokens", "JSON::Tokenize")
;
#line 304 "Json3.xs"
	RETVAL = strip_whitespace (tokens, json);
#line 1043 "Json3.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}

#ifdef __cplusplus
extern "C"
#endif
XS_EXTERNAL(boot_JSON__Parse); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_JSON__Parse)
{
#if PERL_VERSION_LE(5, 21, 5)
    dVAR; dXSARGS;
#else
    dVAR; dXSBOOTARGSXSAPIVERCHK;
#endif
#if (PERL_REVISION == 5 && PERL_VERSION < 9)
    char* file = __FILE__;
#else
    const char* file = __FILE__;
#endif

    PERL_UNUSED_VAR(file);

    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
#if PERL_VERSION_LE(5, 21, 5)
    XS_VERSION_BOOTCHECK;
#  ifdef XS_APIVERSION_BOOTCHECK
    XS_APIVERSION_BOOTCHECK;
#  endif
#endif

        newXS_deffile("JSON::Parse::parse_json", XS_JSON__Parse_parse_json);
        newXS_deffile("JSON::Parse::parse_json_safer", XS_JSON__Parse_parse_json_safer);
        newXS_deffile("JSON::Parse::assert_valid_json", XS_JSON__Parse_assert_valid_json);
        newXS_deffile("JSON::Parse::new", XS_JSON__Parse_new);
        newXS_deffile("JSON::Parse::run_internal", XS_JSON__Parse_run_internal);
        newXS_deffile("JSON::Parse::check", XS_JSON__Parse_check);
        newXS_deffile("JSON::Parse::DESTROY", XS_JSON__Parse_DESTROY);
        newXS_deffile("JSON::Parse::set_true", XS_JSON__Parse_set_true);
        newXS_deffile("JSON::Parse::set_false", XS_JSON__Parse_set_false);
        newXS_deffile("JSON::Parse::set_null", XS_JSON__Parse_set_null);
        newXS_deffile("JSON::Parse::delete_true", XS_JSON__Parse_delete_true);
        newXS_deffile("JSON::Parse::delete_false", XS_JSON__Parse_delete_false);
        newXS_deffile("JSON::Parse::delete_null", XS_JSON__Parse_delete_null);
        newXS_deffile("JSON::Parse::copy_literals", XS_JSON__Parse_copy_literals);
        newXS_deffile("JSON::Parse::no_warn_literals", XS_JSON__Parse_no_warn_literals);
        newXS_deffile("JSON::Parse::diagnostics_hash", XS_JSON__Parse_diagnostics_hash);
        newXS_deffile("JSON::Parse::warn_only", XS_JSON__Parse_warn_only);
        newXS_deffile("JSON::Parse::get_warn_only", XS_JSON__Parse_get_warn_only);
        newXS_deffile("JSON::Parse::detect_collisions", XS_JSON__Parse_detect_collisions);
        newXS_deffile("JSON::Parse::set_max_depth", XS_JSON__Parse_set_max_depth);
        newXS_deffile("JSON::Parse::get_max_depth", XS_JSON__Parse_get_max_depth);
#if XSubPPtmpAAAA
        newXS_deffile("JSON::Parse::random_json", XS_JSON__Parse_random_json);
#endif
        newXS_deffile("JSON::Tokenize::tokenize_json", XS_JSON__Tokenize_tokenize_json);
        newXS_deffile("JSON::Tokenize::tokenize_child", XS_JSON__Tokenize_tokenize_child);
        newXS_deffile("JSON::Tokenize::tokenize_next", XS_JSON__Tokenize_tokenize_next);
        newXS_deffile("JSON::Tokenize::tokenize_start", XS_JSON__Tokenize_tokenize_start);
        newXS_deffile("JSON::Tokenize::tokenize_end", XS_JSON__Tokenize_tokenize_end);
        newXS_deffile("JSON::Tokenize::tokenize_type", XS_JSON__Tokenize_tokenize_type);
        newXS_deffile("JSON::Tokenize::DESTROY", XS_JSON__Tokenize_DESTROY);
        newXS_deffile("JSON::Whitespace::strip_whitespace", XS_JSON__Whitespace_strip_whitespace);

    /* Initialisation Section */

#line 50 "Json3.xs"
{
       json_null = get_sv ("JSON::Parse::null", GV_ADD);
       SvREADONLY_on (json_null);
}

#if XSubPPtmpAAAA
#endif
#line 1121 "Json3.c"

    /* End of Initialisation Section */

#if PERL_VERSION_LE(5, 21, 5)
#  if PERL_VERSION_GE(5, 9, 0)
    if (PL_unitcheckav)
        call_list(PL_scopestack_ix, PL_unitcheckav);
#  endif
    XSRETURN_YES;
#else
    Perl_xs_boot_epilog(aTHX_ ax);
#endif
}

