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

#line 1 "SMOP.xs"
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "ppport.h"

#include <smop/base.h>
#include <smop/native.h>
#include <smop/s1p.h>
#include <smop/s0native.h>
#include <smop/mold.h>
#include <smop/p5.h>
#include <smop/capture.h>

SMOP__Object* SMOP__ID__goto;
SMOP__Object* SMOP__ID__setr;
#line 27 "SMOP.c"
#ifndef PERL_UNUSED_VAR
#  define PERL_UNUSED_VAR(var) if (0) var = var
#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(pTHX_ const CV *const cv, const char *const params);

STATIC void
S_croak_xs_usage(pTHX_ 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(aTHX_ "Usage: %s::%s(%s)", hvname, gvname, params);
        else
            Perl_croak(aTHX_ "Usage: %s(%s)", gvname, params);
    } else {
        /* Pants. I don't think that it should be possible to get here. */
        Perl_croak(aTHX_ "Usage: CODE(0x%"UVxf")(%s)", PTR2UV(cv), params);
    }
}
#undef  PERL_ARGS_ASSERT_CROAK_XS_USAGE

#ifdef PERL_IMPLICIT_CONTEXT
#define croak_xs_usage(a,b)	S_croak_xs_usage(aTHX_ a,b)
#else
#define croak_xs_usage		S_croak_xs_usage
#endif

#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) */

#line 79 "SMOP.c"

XS(XS_SMOP_goto_back); /* prototype to pass -Wmissing-prototypes */
XS(XS_SMOP_goto_back)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       croak_xs_usage(cv,  "ret");
    {
	SV*	ret = ST(0);
#line 26 "SMOP.xs"
    SMOP__Object* interpreter = SMOP__P5__smop_interpreter;


    SMOP_DISPATCH(interpreter,SMOP_RI(SMOP__P5__current_back),SMOP__ID__setr,
      SMOP__NATIVE__capture_create(interpreter,
        (SMOP__Object*[]) {
          SMOP_REFERENCE(interpreter,SMOP__P5__current_back),
          SMOP__P5__SV_create(SMOP__P5__smop_interpreter,SMOP_REFERENCE(interpreter,SMOP__P5__smop_p5interpreter),ret),NULL
        },
        (SMOP__Object*[]) { NULL }
    ));

  SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), SMOP__ID__goto,SMOP__NATIVE__capture_create(interpreter,(SMOP__Object*[]) {SMOP_REFERENCE(interpreter,interpreter),SMOP_REFERENCE(interpreter,SMOP__P5__current_back) , NULL}, (SMOP__Object*[]) {NULL}));


    SMOP__P5__transfer_to_main_coro(interpreter,my_perl);
#line 110 "SMOP.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_SMOP__Object_AUTOLOAD); /* prototype to pass -Wmissing-prototypes */
XS(XS_SMOP__Object_AUTOLOAD)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items < 1)
       croak_xs_usage(cv,  "self, ...");
    {
	SV *	RETVAL;
	SV*	self = ST(0);
#line 48 "SMOP.xs"
    SV* value = SvRV(self);
    SMOP__Object* object = (SMOP__Object*)SvIV(value);    

    int len = SvCUR(cv);
    char* identifier = SvPVX(cv);

    SMOP__Object* interpreter = SMOP__P5__smop_interpreter;

    SMOP__Object* ret = SMOP_DISPATCH(interpreter,SMOP_RI(object),SMOP__NATIVE__idconst_createn(identifier,len),SMOP__NATIVE__capture_create(interpreter,(SMOP__Object*[]) {SMOP_REFERENCE(interpreter,object),NULL},(SMOP__Object*[]) {NULL}));


    RETVAL = SMOP__Object2SV(interpreter,my_perl,ret);
    SMOP__P5__result_sv = RETVAL;

    SMOP__P5__transfer_to_main_coro(interpreter,my_perl);

#line 146 "SMOP.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_SMOP__Object_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_SMOP__Object_DESTROY)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       croak_xs_usage(cv,  "self");
    {
	SV *	self = ST(0);
#line 70 "SMOP.xs"
    SV* value = SvRV(self);
    SMOP__Object* object = (SMOP__Object*)SvIV(value);    
    SMOP__Object* interpreter = SMOP__P5__smop_interpreter;
    SMOP_RELEASE(interpreter,object);
    SMOP__P5__transfer_to_main_coro(interpreter,my_perl);
#line 172 "SMOP.c"
    }
    XSRETURN_EMPTY;
}


XS(XS_SMOP__NATIVE__bool_true); /* prototype to pass -Wmissing-prototypes */
XS(XS_SMOP__NATIVE__bool_true)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    PERL_UNUSED_VAR(cv); /* -W */
    {
	SV *	RETVAL;
#line 82 "SMOP.xs"
    SV* pointer = newSViv(PTR2IV(SMOP__NATIVE__bool_true));
    SV* object = newRV_noinc(pointer);
    HV* class = gv_stashpv("SMOP::Object", 0);
    RETVAL = sv_bless(object, class);
#line 194 "SMOP.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_SMOP__NATIVE__bool_false); /* prototype to pass -Wmissing-prototypes */
XS(XS_SMOP__NATIVE__bool_false)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    PERL_UNUSED_VAR(cv); /* -W */
    {
	SV *	RETVAL;
#line 92 "SMOP.xs"
    SV* pointer = newSViv(PTR2IV(SMOP__NATIVE__bool_false));
    SV* object = newRV_noinc(pointer);
    HV* class = gv_stashpv("SMOP::Object", 0);
    RETVAL = sv_bless(object, class);
#line 218 "SMOP.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_SMOP__NATIVE__bool_fetch); /* prototype to pass -Wmissing-prototypes */
XS(XS_SMOP__NATIVE__bool_fetch)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       croak_xs_usage(cv,  "self");
    {
	int	RETVAL;
	dXSTARG;
	SV *	self = ST(0);
#line 101 "SMOP.xs"
    SV* value = SvRV(self);
    SMOP__Object* object = INT2PTR(SMOP__Object*,SvIV(value));
    RETVAL = (object != SMOP__NATIVE__bool_false);
#line 244 "SMOP.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_SMOP__NATIVE__int_create); /* prototype to pass -Wmissing-prototypes */
XS(XS_SMOP__NATIVE__int_create)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       croak_xs_usage(cv,  "p5class, i");
    {
	SV *	RETVAL;
	SV*	p5class = ST(0);
	int	i = (int)SvIV(ST(1));
#line 112 "SMOP.xs"
    SV* pointer = newSViv(PTR2IV(SMOP__NATIVE__int_create(i)));
    SV* object = newRV_noinc(pointer);
    HV* class = gv_stashpv("SMOP::Object", 0);
    RETVAL = sv_bless(object, class);
#line 270 "SMOP.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_SMOP__NATIVE__int_fetch); /* prototype to pass -Wmissing-prototypes */
XS(XS_SMOP__NATIVE__int_fetch)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       croak_xs_usage(cv,  "self");
    {
	int	RETVAL;
	dXSTARG;
	SV*	self = ST(0);
#line 122 "SMOP.xs"
    SV* value = SvRV(self);
    SMOP__Object* object = (SMOP__Object*)SvIV(value);
    int foo = SMOP__NATIVE__int_fetch(object);
    RETVAL = foo;
#line 297 "SMOP.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS(XS_SMOP__NATIVE__idconst_create); /* prototype to pass -Wmissing-prototypes */
XS(XS_SMOP__NATIVE__idconst_create)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 2)
       croak_xs_usage(cv,  "p5class, val");
    {
	SV *	RETVAL;
	SV*	p5class = ST(0);
	char*	val = (char *)SvPV_nolen(ST(1));
#line 134 "SMOP.xs"
    SV* pointer = newSViv(PTR2IV(SMOP__NATIVE__idconst_create(val)));
    SV* object = newRV_noinc(pointer);
    HV* class = gv_stashpv("SMOP::Object", 0);
    RETVAL = sv_bless(object, class);
#line 323 "SMOP.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}


XS(XS_SMOP__NATIVE__idconst_fetch); /* prototype to pass -Wmissing-prototypes */
XS(XS_SMOP__NATIVE__idconst_fetch)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
       croak_xs_usage(cv,  "self");
    {
	char *	RETVAL;
	dXSTARG;
	SV*	self = ST(0);
#line 144 "SMOP.xs"
    SV* value = SvRV(self);
    SMOP__Object* object = INT2PTR(SMOP__Object*,SvIV(value));
    if (SMOP_RI(object) == SMOP_RI(SMOP__ID__goto)) {
        int retsize;
        RETVAL = SMOP__NATIVE__idconst_fetch_with_null(object, &retsize);
    } else {
        printf("Calling SMOP::NATIVE::idconst::fetch on a non idconst.\n");
        RETVAL = 0;
    }
#line 355 "SMOP.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

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

    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
    XS_VERSION_BOOTCHECK ;

        newXS("SMOP::goto_back", XS_SMOP_goto_back, file);
        newXS("SMOP::Object::AUTOLOAD", XS_SMOP__Object_AUTOLOAD, file);
        newXS("SMOP::Object::DESTROY", XS_SMOP__Object_DESTROY, file);
        newXS("SMOP::NATIVE::bool::true", XS_SMOP__NATIVE__bool_true, file);
        newXS("SMOP::NATIVE::bool::false", XS_SMOP__NATIVE__bool_false, file);
        newXS("SMOP::NATIVE::bool::fetch", XS_SMOP__NATIVE__bool_fetch, file);
        newXS("SMOP::NATIVE::int::create", XS_SMOP__NATIVE__int_create, file);
        newXS("SMOP::NATIVE::int::fetch", XS_SMOP__NATIVE__int_fetch, file);
        newXS("SMOP::NATIVE::idconst::create", XS_SMOP__NATIVE__idconst_create, file);
        newXS("SMOP::NATIVE::idconst::fetch", XS_SMOP__NATIVE__idconst_fetch, file);

    /* Initialisation Section */

#line 20 "SMOP.xs"
    SMOP__ID__goto = SMOP__NATIVE__idconst_create("goto");
    SMOP__ID__setr = SMOP__NATIVE__idconst_create("setr");

#line 399 "SMOP.c"

    /* End of Initialisation Section */

#if (PERL_REVISION == 5 && PERL_VERSION >= 9)
  if (PL_unitcheckav)
       call_list(PL_scopestack_ix, PL_unitcheckav);
#endif
    XSRETURN_YES;
}

