Scope-Escape

 view release on metacpan or  search on metacpan

lib/Scope/Escape.xs  view on Meta::CPAN

	entersubop = ck_entersub_args_proto(entersubop, namegv, ckobj);
	op_free(entersubop);
	return newOP_current_escape_continuation(CvXSUBANY((CV*)ckobj).any_i32);
}

MODULE = Scope::Escape PACKAGE = Scope::Escape

PROTOTYPES: DISABLE

BOOT:
{
	CV *curescfunc_cv, *curesccont_cv;
	null_end_op.op_type = OP_NULL;
	null_end_op.op_ppaddr = PL_ppaddr[OP_NULL];
	stash_esccont = gv_stashpvs("Scope::Escape::Continuation", 1);
	THX_next_peep = PL_peepp;
	PL_peepp = THX_my_peep;
	curescfunc_cv = get_cv("Scope::Escape::current_escape_function", 0);
	curesccont_cv = get_cv("Scope::Escape::current_escape_continuation", 0);
	CvXSUBANY(curescfunc_cv).any_i32 = 0;
	CvXSUBANY(curesccont_cv).any_i32 = 1;
	cv_set_call_checker(curescfunc_cv, THX_ck_entersub_curesc,
		(SV*)curescfunc_cv);
	cv_set_call_checker(curesccont_cv, THX_ck_entersub_curesc,
		(SV*)curesccont_cv);
}

void
current_escape_function(...)
PROTOTYPE:
CODE:
	PERL_UNUSED_VAR(items);
	croak("current_escape_function called as a function");

void
current_escape_continuation(...)
PROTOTYPE:
CODE:
	PERL_UNUSED_VAR(items);
	croak("current_escape_continuation called as a function");

void
_set_sanity_checking(bool new_state)
PROTOTYPE: $
CODE:
	sanity_checking_enabled = new_state;

void
_fake_short_cxstack()
PROTOTYPE:
CODE:
#if CATCHER_USES_GHOST_JMPENV
	cxstack_max = cxstack_ix;
#endif /* CATCHER_USES_GHOST_JMPENV */

MODULE = Scope::Escape PACKAGE = Scope::Escape::Continuation

void
go(SV *contref, ...)
PROTOTYPE: $@
PPCODE:
	PUSHMARK(SP+1);
	/* the modified SP is intentionally lost here */
	THX_xsfunc_go(aTHX_ contsub_from_contref(contref));
	/* does not return */

SV *
wantarray(SV *contref)
PROTOTYPE: $
CODE:
	switch(cont_status(contgut_from_contref(contref), G_WANT) & G_WANT) {
		default:       RETVAL = &PL_sv_undef; break;
		case G_SCALAR: RETVAL = &PL_sv_no;    break;
		case G_ARRAY:  RETVAL = &PL_sv_yes;   break;
	}
OUTPUT:
	RETVAL

bool
is_accessible(SV *contref)
PROTOTYPE: $
CODE:
	RETVAL = !(cont_status(contgut_from_contref(contref),
				CONTSTAT_INACCESSIBLE) &
			CONTSTAT_INACCESSIBLE);
OUTPUT:
	RETVAL

bool
may_be_valid(SV *contref)
PROTOTYPE: $
CODE:
	RETVAL = contgut_from_contref(contref)->may_be_valid;
OUTPUT:
	RETVAL

void
invalidate(SV *contref)
PROTOTYPE: $
CODE:
	contgut_from_contref(contref)->may_be_valid = 0;

SV *
as_function(SV *contref)
PROTOTYPE: $
CODE:
	RETVAL = make_contref_from_contsub(contsub_from_contref(contref), 0);
	SvREFCNT_inc(RETVAL);
OUTPUT:
	RETVAL

SV *
as_continuation(SV *contref)
PROTOTYPE: $
CODE:
	RETVAL = make_contref_from_contsub(contsub_from_contref(contref), 1);
	SvREFCNT_inc(RETVAL);
OUTPUT:
	RETVAL



( run in 2.046 seconds using v1.01-cache-2.11-cpan-5511b514fd6 )