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

#line 1 "Litavis.xs"
#include "litavis.h"

/* Store C context pointer inside Perl object */
typedef LitavisCtx* Litavis;

#line 16 "Litavis.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 160 "Litavis.c"

XS_EUPXS(XS_Litavis_new); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis_new)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "class, ...");
    {
	const char *	class = (const char *)SvPV_nolen(ST(0))
;
#line 12 "Litavis.xs"
    LitavisCtx *ctx;
    int i;
#line 174 "Litavis.c"
	Litavis	RETVAL;
#line 15 "Litavis.xs"
    ctx = litavis_ctx_new();
    /* Parse optional hash-style args from Perl stack */
    if (items > 1 && (items - 1) % 2 == 0) {
        for (i = 1; i < items; i += 2) {
            const char *key = SvPV_nolen(ST(i));
            if (strcmp(key, "pretty") == 0) {
                ctx->pretty = SvIV(ST(i + 1));
            } else if (strcmp(key, "dedupe") == 0) {
                ctx->dedupe = SvIV(ST(i + 1));
            } else if (strcmp(key, "indent") == 0) {
                if (ctx->indent) free(ctx->indent);
                ctx->indent = litavis_strdup(SvPV_nolen(ST(i + 1)));
            } else if (strcmp(key, "shorthand_hex") == 0) {
                ctx->shorthand_hex = SvIV(ST(i + 1));
            } else if (strcmp(key, "sort_props") == 0) {
                ctx->sort_props = SvIV(ST(i + 1));
            }
        }
    }
    RETVAL = ctx;
#line 197 "Litavis.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, "Litavis", (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


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

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    self = INT2PTR(Litavis,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not a reference",
			"Litavis::DESTROY",
			"self")
;
#line 42 "Litavis.xs"
    litavis_ctx_free(self);
#line 229 "Litavis.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Litavis_parse); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis_parse)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "self, input");
    {
	Litavis	self;
	const char *	input = (const char *)SvPV_nolen(ST(1))
;
	SV *	RETVAL;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 49 "Litavis.xs"
    litavis_parse_string(self, input);
    /* return self for chaining */
    RETVAL = SvREFCNT_inc(ST(0));
#line 256 "Litavis.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Litavis_parse_file); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis_parse_file)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "self, filename");
    {
	Litavis	self;
	const char *	filename = (const char *)SvPV_nolen(ST(1))
;
	SV *	RETVAL;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 60 "Litavis.xs"
    litavis_parse_file(self, filename);
    RETVAL = SvREFCNT_inc(ST(0));
#line 284 "Litavis.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Litavis_parse_dir); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis_parse_dir)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "self, dirname");
    {
	Litavis	self;
	const char *	dirname = (const char *)SvPV_nolen(ST(1))
;
	SV *	RETVAL;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 70 "Litavis.xs"
    litavis_parse_dir(self, dirname);
    RETVAL = SvREFCNT_inc(ST(0));
#line 312 "Litavis.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


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

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 79 "Litavis.xs"
    char *css = litavis_emit(self);
    RETVAL = newSVpv(css, 0);
    free(css);
#line 339 "Litavis.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Litavis_compile_file); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis_compile_file)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "self, filename");
    {
	Litavis	self;
	const char *	filename = (const char *)SvPV_nolen(ST(1))
;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 90 "Litavis.xs"
    litavis_emit_file(self, filename);
#line 365 "Litavis.c"
    }
    XSRETURN_EMPTY;
}


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

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 96 "Litavis.xs"
    litavis_ctx_reset(self);
#line 387 "Litavis.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Litavis_pretty); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis_pretty)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "self, ...");
    {
	Litavis	self;
	int	RETVAL;
	dXSTARG;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 102 "Litavis.xs"
    if (items > 1)
        self->pretty = SvIV(ST(1));
    RETVAL = self->pretty;
#line 413 "Litavis.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Litavis_dedupe); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis_dedupe)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "self, ...");
    {
	Litavis	self;
	int	RETVAL;
	dXSTARG;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 112 "Litavis.xs"
    if (items > 1)
        self->dedupe = SvIV(ST(1));
    RETVAL = self->dedupe;
#line 440 "Litavis.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Litavis__ast_add_rule); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis__ast_add_rule)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "self, selector");
    {
	Litavis	self;
	const char *	selector = (const char *)SvPV_nolen(ST(1))
;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 125 "Litavis.xs"
    litavis_ast_add_rule(self->ast, selector);
#line 465 "Litavis.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Litavis__ast_has_rule); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis__ast_has_rule)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "self, selector");
    {
	Litavis	self;
	const char *	selector = (const char *)SvPV_nolen(ST(1))
;
	int	RETVAL;
	dXSTARG;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 132 "Litavis.xs"
    RETVAL = litavis_ast_has_rule(self->ast, selector);
#line 491 "Litavis.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


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

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 140 "Litavis.xs"
    RETVAL = self->ast->count;
#line 516 "Litavis.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Litavis__ast_rule_selector); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis__ast_rule_selector)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "self, index");
    {
	Litavis	self;
	int	index = (int)SvIV(ST(1))
;
	SV *	RETVAL;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 149 "Litavis.xs"
    if (index < 0 || index >= self->ast->count)
        XSRETURN_UNDEF;
    RETVAL = newSVpv(self->ast->rules[index].selector, 0);
#line 544 "Litavis.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Litavis__ast_remove_rule); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis__ast_remove_rule)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "self, index");
    {
	Litavis	self;
	int	index = (int)SvIV(ST(1))
;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 160 "Litavis.xs"
    litavis_ast_remove_rule(self->ast, index);
#line 570 "Litavis.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Litavis__ast_rename_rule); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis__ast_rename_rule)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "self, index, new_selector");
    {
	Litavis	self;
	int	index = (int)SvIV(ST(1))
;
	const char *	new_selector = (const char *)SvPV_nolen(ST(2))
;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 168 "Litavis.xs"
    litavis_ast_rename_rule(self->ast, index, new_selector);
#line 596 "Litavis.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Litavis__ast_add_prop); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis__ast_add_prop)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "self, selector, key, value");
    {
	Litavis	self;
	const char *	selector = (const char *)SvPV_nolen(ST(1))
;
	const char *	key = (const char *)SvPV_nolen(ST(2))
;
	const char *	value = (const char *)SvPV_nolen(ST(3))
;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 177 "Litavis.xs"
    LitavisRule *rule = litavis_ast_get_rule(self->ast, selector);
    if (!rule)
        croak("litavis: no rule with selector '%s'", selector);
    litavis_rule_add_prop(rule, key, value);
#line 627 "Litavis.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Litavis__ast_get_prop); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis__ast_get_prop)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "self, selector, key");
    {
	Litavis	self;
	const char *	selector = (const char *)SvPV_nolen(ST(1))
;
	const char *	key = (const char *)SvPV_nolen(ST(2))
;
	SV *	RETVAL;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 188 "Litavis.xs"
    LitavisRule *rule = litavis_ast_get_rule(self->ast, selector);
    if (!rule)
        XSRETURN_UNDEF;
    char *val = litavis_rule_get_prop(rule, key);
    if (!val)
        XSRETURN_UNDEF;
    RETVAL = newSVpv(val, 0);
#line 660 "Litavis.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Litavis__ast_has_prop); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis__ast_has_prop)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "self, selector, key");
    {
	Litavis	self;
	const char *	selector = (const char *)SvPV_nolen(ST(1))
;
	const char *	key = (const char *)SvPV_nolen(ST(2))
;
	int	RETVAL;
	dXSTARG;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 204 "Litavis.xs"
    LitavisRule *rule = litavis_ast_get_rule(self->ast, selector);
    if (!rule)
        RETVAL = 0;
    else
        RETVAL = litavis_rule_has_prop(rule, key);
#line 694 "Litavis.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Litavis__ast_prop_count); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis__ast_prop_count)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "self, selector");
    {
	Litavis	self;
	const char *	selector = (const char *)SvPV_nolen(ST(1))
;
	int	RETVAL;
	dXSTARG;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 217 "Litavis.xs"
    LitavisRule *rule = litavis_ast_get_rule(self->ast, selector);
    if (!rule)
        RETVAL = 0;
    else
        RETVAL = rule->prop_count;
#line 725 "Litavis.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Litavis__ast_rules_props_equal); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis__ast_rules_props_equal)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "self, sel_a, sel_b");
    {
	Litavis	self;
	const char *	sel_a = (const char *)SvPV_nolen(ST(1))
;
	const char *	sel_b = (const char *)SvPV_nolen(ST(2))
;
	int	RETVAL;
	dXSTARG;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 231 "Litavis.xs"
    LitavisRule *a = litavis_ast_get_rule(self->ast, sel_a);
    LitavisRule *b = litavis_ast_get_rule(self->ast, sel_b);
    if (!a || !b)
        RETVAL = 0;
    else
        RETVAL = litavis_rules_props_equal(a, b);
#line 759 "Litavis.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Litavis__ast_merge_props); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis__ast_merge_props)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "self, dst_sel, src_sel");
    {
	Litavis	self;
	const char *	dst_sel = (const char *)SvPV_nolen(ST(1))
;
	const char *	src_sel = (const char *)SvPV_nolen(ST(2))
;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 246 "Litavis.xs"
    LitavisRule *dst = litavis_ast_get_rule(self->ast, dst_sel);
    LitavisRule *src = litavis_ast_get_rule(self->ast, src_sel);
    if (!dst || !src)
        croak("litavis: rule not found for merge");
    litavis_rule_merge_props(dst, src);
#line 790 "Litavis.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Litavis__dedupe); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Litavis__dedupe)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "self, strategy");
    {
	Litavis	self;
	int	strategy = (int)SvIV(ST(1))
;

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 257 "Litavis.xs"
    litavis_dedupe(self->ast, (LitavisDedupeStrategy)strategy);
#line 814 "Litavis.c"
    }
    XSRETURN_EMPTY;
}


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

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 263 "Litavis.xs"
    litavis_resolve_vars(self->ast, self->global_scope, self->mixins, self->maps);
#line 836 "Litavis.c"
    }
    XSRETURN_EMPTY;
}


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

	if (sv_isobject(ST(0)) && sv_derived_from(ST(0), "Litavis"))
	    self = INT2PTR(Litavis, SvIV((SV*)SvRV(ST(0))));
	else
	    croak("self is not of type Litavis")
;
#line 269 "Litavis.xs"
    litavis_resolve_colours(self->ast);
#line 858 "Litavis.c"
    }
    XSRETURN_EMPTY;
}

#ifdef __cplusplus
extern "C"
#endif
XS_EXTERNAL(boot_Litavis); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_Litavis)
{
#if PERL_VERSION_LE(5, 21, 5)
    dVAR; dXSARGS;
#else
    dVAR; dXSBOOTARGSXSAPIVERCHK;
#endif
#if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
    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("Litavis::new", XS_Litavis_new);
        newXS_deffile("Litavis::DESTROY", XS_Litavis_DESTROY);
        newXS_deffile("Litavis::parse", XS_Litavis_parse);
        newXS_deffile("Litavis::parse_file", XS_Litavis_parse_file);
        newXS_deffile("Litavis::parse_dir", XS_Litavis_parse_dir);
        newXS_deffile("Litavis::compile", XS_Litavis_compile);
        newXS_deffile("Litavis::compile_file", XS_Litavis_compile_file);
        newXS_deffile("Litavis::reset", XS_Litavis_reset);
        newXS_deffile("Litavis::pretty", XS_Litavis_pretty);
        newXS_deffile("Litavis::dedupe", XS_Litavis_dedupe);
        newXS_deffile("Litavis::_ast_add_rule", XS_Litavis__ast_add_rule);
        newXS_deffile("Litavis::_ast_has_rule", XS_Litavis__ast_has_rule);
        newXS_deffile("Litavis::_ast_rule_count", XS_Litavis__ast_rule_count);
        newXS_deffile("Litavis::_ast_rule_selector", XS_Litavis__ast_rule_selector);
        newXS_deffile("Litavis::_ast_remove_rule", XS_Litavis__ast_remove_rule);
        newXS_deffile("Litavis::_ast_rename_rule", XS_Litavis__ast_rename_rule);
        newXS_deffile("Litavis::_ast_add_prop", XS_Litavis__ast_add_prop);
        newXS_deffile("Litavis::_ast_get_prop", XS_Litavis__ast_get_prop);
        newXS_deffile("Litavis::_ast_has_prop", XS_Litavis__ast_has_prop);
        newXS_deffile("Litavis::_ast_prop_count", XS_Litavis__ast_prop_count);
        newXS_deffile("Litavis::_ast_rules_props_equal", XS_Litavis__ast_rules_props_equal);
        newXS_deffile("Litavis::_ast_merge_props", XS_Litavis__ast_merge_props);
        newXS_deffile("Litavis::_dedupe", XS_Litavis__dedupe);
        newXS_deffile("Litavis::_resolve_vars", XS_Litavis__resolve_vars);
        newXS_deffile("Litavis::_resolve_colours", XS_Litavis__resolve_colours);
#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
}

