X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FSub-Op.git;a=blobdiff_plain;f=t%2FSub-Op-LexicalSub%2FLexicalSub.xs;h=62e83f833b485b36adcf21c1ab2266bbe4517d1d;hp=c2b7002d11ac6dd00964461bc7b5d1bb4c302bc7;hb=302bf09fbd4b673e199bdd22b330ebbdbec4e1fe;hpb=c987524f0641ca6a25d5e3072c9d1a2ecef2f57c diff --git a/t/Sub-Op-LexicalSub/LexicalSub.xs b/t/Sub-Op-LexicalSub/LexicalSub.xs index c2b7002..62e83f8 100644 --- a/t/Sub-Op-LexicalSub/LexicalSub.xs +++ b/t/Sub-Op-LexicalSub/LexicalSub.xs @@ -22,6 +22,12 @@ STATIC OP *sols_check(pTHX_ OP *o, void *ud_) { return o; } +STATIC OP *sols_ref(pTHX_ OP *o, void *ud_) { + SV *cb = ud_; + + return newSVOP(OP_ANONCODE, o->op_flags & ~OPf_KIDS, cb); +} + STATIC OP *sols_pp(pTHX) { dSP; SV *cb; @@ -63,11 +69,15 @@ PPCODE: cb = SvRV(cb); if (SvTYPE(cb) >= SVt_PVCV) { sub_op_init(&c); - c.name = SvPV_const(name, c.namelen); - c.check = sols_check; - c.ud = SvREFCNT_inc(cb); - c.pp = sols_pp; - sub_op_register(aTHX_ &c); + c.name = SvPV_const(name, c.namelen); + if (SvPOK(cb)) { /* Sub is prototyped */ + c.proto = SvPV_const(cb, c.protolen); + } + c.check = sols_check; + c.ref = sols_ref; + c.ud = SvREFCNT_inc(cb); + c.pp = sols_pp; + sub_op_register(aTHX_ &c, 0); } } XSRETURN(0);