The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

newCONSTSUB

NEED_newCONSTSUB /* Because we define this weirdly */

/* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */ #if { VERSION < 5.004_63 } && { VERSION != 5.004_05 }

/* And before that, we need to make sure this gets compiled for the functions * that rely on it */ #define NEED_newCONSTSUB

#if { NEED newCONSTSUB }

/* This is just a trick to avoid a dependency of newCONSTSUB on PL_parser */ /* (There's no PL_parser in perl < 5.005, so this is completely safe) */ #define D_PPP_PL_copline PL_copline

CV * newCONSTSUB(HV *stash, const char *name, SV *sv) { CV *cv; U32 oldhints = PL_hints; HV *old_cop_stash = PL_curcop->cop_stash; HV *old_curstash = PL_curstash; line_t oldline = PL_curcop->cop_line; PL_curcop->cop_line = D_PPP_PL_copline;

        PL_hints &= ~HINT_BLOCK_SCOPE;
        if (stash)
                PL_curstash = PL_curcop->cop_stash = stash;

        cv = newSUB(

                start_subparse(FALSE, 0),

                newSVOP(OP_CONST, 0, newSVpv((char *) name, 0)),
                newSVOP(OP_CONST, 0, &PL_sv_no),   /* SvPV(&PL_sv_no) == "" -- GMB */
                newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
        );

        PL_hints = oldhints;
        PL_curcop->cop_stash = old_cop_stash;
        PL_curstash = old_curstash;
        PL_curcop->cop_line = oldline;

        return cv;
}
#endif
#endif

#define NEED_newCONSTSUB

void call_newCONSTSUB_1(void) { #ifdef PERL_NO_GET_CONTEXT dTHX; #endif newCONSTSUB(gv_stashpv("Devel::PPPort", FALSE), "test_value_1", newSViv(1)); }

extern void call_newCONSTSUB_2(void); extern void call_newCONSTSUB_3(void);

void call_newCONSTSUB_1()

void call_newCONSTSUB_2()

void call_newCONSTSUB_3()

&Devel::PPPort::call_newCONSTSUB_1(); is(&Devel::PPPort::test_value_1(), 1);

&Devel::PPPort::call_newCONSTSUB_2(); is(&Devel::PPPort::test_value_2(), 2);

&Devel::PPPort::call_newCONSTSUB_3(); is(&Devel::PPPort::test_value_3(), 3);

7 POD Errors

The following errors were encountered while parsing the POD:

Around line 12:

Unknown directive: =provides

Around line 16:

Unknown directive: =dontwarn

Around line 20:

Unknown directive: =implementation

Around line 68:

Unknown directive: =xsinit

Around line 72:

Unknown directive: =xsmisc

Around line 85:

Unknown directive: =xsubs

Around line 96:

Unknown directive: =tests