Blame fallback/constants.xs

Packit Service 4a2782
void
Packit Service 4a2782
constant(sv)
Packit Service 4a2782
    PREINIT:
Packit Service 4a2782
#ifdef dXSTARG
Packit Service 4a2782
	dXSTARG; /* Faster if we have it.  */
Packit Service 4a2782
#else
Packit Service 4a2782
	dTARGET;
Packit Service 4a2782
#endif
Packit Service 4a2782
	STRLEN		len;
Packit Service 4a2782
        int		type;
Packit Service 4a2782
	IV		iv;
Packit Service 4a2782
	/* NV		nv;	Uncomment this if you need to return NVs */
Packit Service 4a2782
	const char	*pv;
Packit Service 4a2782
    INPUT:
Packit Service 4a2782
	SV *		sv;
Packit Service 4a2782
        const char *	s = SvPV(sv, len);
Packit Service 4a2782
    PPCODE:
Packit Service 4a2782
        /* Change this to constant(aTHX_ s, len, &iv, &nv);
Packit Service 4a2782
           if you need to return both NVs and IVs */
Packit Service 4a2782
	type = constant(aTHX_ s, len, &iv, &pv;;
Packit Service 4a2782
      /* Return 1 or 2 items. First is error message, or undef if no error.
Packit Service 4a2782
           Second, if present, is found value */
Packit Service 4a2782
        switch (type) {
Packit Service 4a2782
        case PERL_constant_NOTFOUND:
Packit Service 4a2782
          sv =
Packit Service 4a2782
	    sv_2mortal(newSVpvf("%s is not a valid Zlib macro", s));
Packit Service 4a2782
          PUSHs(sv);
Packit Service 4a2782
          break;
Packit Service 4a2782
        case PERL_constant_NOTDEF:
Packit Service 4a2782
          sv = sv_2mortal(newSVpvf(
Packit Service 4a2782
	    "Your vendor has not defined Zlib macro %s, used",
Packit Service 4a2782
				   s));
Packit Service 4a2782
          PUSHs(sv);
Packit Service 4a2782
          break;
Packit Service 4a2782
        case PERL_constant_ISIV:
Packit Service 4a2782
          EXTEND(SP, 1);
Packit Service 4a2782
          PUSHs(&PL_sv_undef);
Packit Service 4a2782
          PUSHi(iv);
Packit Service 4a2782
          break;
Packit Service 4a2782
	/* Uncomment this if you need to return NOs
Packit Service 4a2782
        case PERL_constant_ISNO:
Packit Service 4a2782
          EXTEND(SP, 1);
Packit Service 4a2782
          PUSHs(&PL_sv_undef);
Packit Service 4a2782
          PUSHs(&PL_sv_no);
Packit Service 4a2782
          break; */
Packit Service 4a2782
	/* Uncomment this if you need to return NVs
Packit Service 4a2782
        case PERL_constant_ISNV:
Packit Service 4a2782
          EXTEND(SP, 1);
Packit Service 4a2782
          PUSHs(&PL_sv_undef);
Packit Service 4a2782
          PUSHn(nv);
Packit Service 4a2782
          break; */
Packit Service 4a2782
        case PERL_constant_ISPV:
Packit Service 4a2782
          EXTEND(SP, 1);
Packit Service 4a2782
          PUSHs(&PL_sv_undef);
Packit Service 4a2782
          PUSHp(pv, strlen(pv));
Packit Service 4a2782
          break;
Packit Service 4a2782
	/* Uncomment this if you need to return PVNs
Packit Service 4a2782
        case PERL_constant_ISPVN:
Packit Service 4a2782
          EXTEND(SP, 1);
Packit Service 4a2782
          PUSHs(&PL_sv_undef);
Packit Service 4a2782
          PUSHp(pv, iv);
Packit Service 4a2782
          break; */
Packit Service 4a2782
	/* Uncomment this if you need to return SVs
Packit Service 4a2782
        case PERL_constant_ISSV:
Packit Service 4a2782
          EXTEND(SP, 1);
Packit Service 4a2782
          PUSHs(&PL_sv_undef);
Packit Service 4a2782
          PUSHs(sv);
Packit Service 4a2782
          break; */
Packit Service 4a2782
	/* Uncomment this if you need to return UNDEFs
Packit Service 4a2782
        case PERL_constant_ISUNDEF:
Packit Service 4a2782
          break; */
Packit Service 4a2782
	/* Uncomment this if you need to return UVs
Packit Service 4a2782
        case PERL_constant_ISUV:
Packit Service 4a2782
          EXTEND(SP, 1);
Packit Service 4a2782
          PUSHs(&PL_sv_undef);
Packit Service 4a2782
          PUSHu((UV)iv);
Packit Service 4a2782
          break; */
Packit Service 4a2782
	/* Uncomment this if you need to return YESs
Packit Service 4a2782
        case PERL_constant_ISYES:
Packit Service 4a2782
          EXTEND(SP, 1);
Packit Service 4a2782
          PUSHs(&PL_sv_undef);
Packit Service 4a2782
          PUSHs(&PL_sv_yes);
Packit Service 4a2782
          break; */
Packit Service 4a2782
        default:
Packit Service 4a2782
          sv = sv_2mortal(newSVpvf(
Packit Service 4a2782
	    "Unexpected return type %d while processing Zlib macro %s, used",
Packit Service 4a2782
               type, s));
Packit Service 4a2782
          PUSHs(sv);
Packit Service 4a2782
        }