PerlX-Maybe-XS

 view release on metacpan or  search on metacpan

XS.xs  view on Meta::CPAN


MODULE = PerlX::Maybe::XS		PACKAGE = PerlX::Maybe::XS		

INCLUDE: const-xs.inc

void
maybe (x, y, ...)
	SV *x
	SV *y
PROTOTYPE: $$@
PPCODE:
{
	int i;
	
	if (sv_defined(x) && sv_defined(y))
	{
		// return ($x, $y, @rest);
		for (i = 0; i <= items; i++)
		{
			PUSHs(ST(i));
		}

XS.xs  view on Meta::CPAN

		XSRETURN(items - 2);
	}
}

void
provided (chk, x, y, ...)
	SV *chk
	SV *x
	SV *y
PROTOTYPE: $$$@
PPCODE:
{
	int i;
	
	if (SvTRUE(chk))
	{
		// return ($x, $y, @rest);
		for (i = 1; i <= items; i++)
		{
			PUSHs(ST(i));
		}

fallback/const-xs.inc  view on Meta::CPAN

	dTARGET;
#endif
	STRLEN		len;
        int		type;
	/* IV		iv;	Uncomment this if you need to return IVs */
	/* NV		nv;	Uncomment this if you need to return NVs */
	/* const char	*pv;	Uncomment this if you need to return PVs */
    INPUT:
	SV *		sv;
        const char *	s = SvPV(sv, len);
    PPCODE:
	type = constant(aTHX_ s, len);
      /* Return 1 or 2 items. First is error message, or undef if no error.
           Second, if present, is found value */
        switch (type) {
        case PERL_constant_NOTFOUND:
          sv =
	    sv_2mortal(newSVpvf("%s is not a valid PerlX::Maybe::XS macro", s));
          PUSHs(sv);
          break;
        case PERL_constant_NOTDEF:



( run in 1.862 second using v1.01-cache-2.11-cpan-5511b514fd6 )