X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Plugin.xs;h=3e9918b7856a0c3d6bd0d0bcf64b2f8b675b2b29;hb=47afe57f6afc7b312d1da725bb38f99ae70b157a;hp=483d294f371cf789fa1daabc5816f935fd07a94f;hpb=990ba6fd714681b2a6d50ac5153d654bfea0ccdd;p=perl%2Fmodules%2Fre-engine-Plugin.git diff --git a/Plugin.xs b/Plugin.xs index 483d294..3e9918b 100644 --- a/Plugin.xs +++ b/Plugin.xs @@ -1,3 +1,7 @@ +/* This file is part of the re::engine::Plugin Perl module. + * See http://search.cpan.org/dist/re-engine-Plugin/ */ + +#define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" @@ -327,6 +331,14 @@ Plugin_comp(pTHX_ SV * const pattern, U32 flags) LEAVE; } + /* If there's an exec callback, store it into the private object so + * that it will be the one to be called, even if the engine changes + * in between */ + if (h && h->exec) { + re->cb_exec = h->exec; + SvREFCNT_inc_simple_void_NN(h->exec); + } + /* If any of the comp-time accessors were called we'll have to * update the regexp struct with the new info. */ @@ -345,11 +357,9 @@ Plugin_exec(pTHX_ REGEXP * const RX, char *stringarg, char *strend, dSP; I32 matched; struct regexp *rx = rxREGEXP(RX); - const rep_hint_t *h; GET_SELF_FROM_PPRIVATE(rx->pprivate); - h = rep_hint(); - if (h && h->exec) { + if (self->cb_exec) { /* Store the current str for ->str */ self->str = (SV*)sv; SvREFCNT_inc(self->str); @@ -362,7 +372,7 @@ Plugin_exec(pTHX_ REGEXP * const RX, char *stringarg, char *strend, XPUSHs(sv); PUTBACK; - call_sv(h->exec, G_SCALAR); + call_sv(self->cb_exec, G_SCALAR); SPAGAIN;