]> git.vpit.fr Git - perl/modules/re-engine-Plugin.git/blob - Plugin.xs
Introduce ->callbacks to specify the 'exec' callback individually
[perl/modules/re-engine-Plugin.git] / Plugin.xs
1 /* This file is part of the re::engine::Plugin Perl module.
2  * See http://search.cpan.org/dist/re-engine-Plugin/ */
3
4 #define PERL_NO_GET_CONTEXT
5 #include "EXTERN.h"
6 #include "perl.h"
7 #include "XSUB.h"
8
9 #include "Plugin.h"
10
11 #define __PACKAGE__     "re::engine::Plugin"
12 #define __PACKAGE_LEN__ (sizeof(__PACKAGE__)-1)
13
14 #define REP_HAS_PERL(R, V, S) (PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S))))))
15
16 #ifndef REP_WORKAROUND_REQUIRE_PROPAGATION
17 # define REP_WORKAROUND_REQUIRE_PROPAGATION !REP_HAS_PERL(5, 10, 1)
18 #endif
19
20 /* ... Thread safety and multiplicity ...................................... */
21
22 #ifndef REP_MULTIPLICITY
23 # if defined(MULTIPLICITY) || defined(PERL_IMPLICIT_CONTEXT)
24 #  define REP_MULTIPLICITY 1
25 # else
26 #  define REP_MULTIPLICITY 0
27 # endif
28 #endif
29 #if REP_MULTIPLICITY && !defined(tTHX)
30 # define tTHX PerlInterpreter*
31 #endif
32
33 #if REP_MULTIPLICITY && defined(USE_ITHREADS) && defined(dMY_CXT) && defined(MY_CXT) && defined(START_MY_CXT) && defined(MY_CXT_INIT) && (defined(MY_CXT_CLONE) || defined(dMY_CXT_SV))
34 # define REP_THREADSAFE 1
35 # ifndef MY_CXT_CLONE
36 #  define MY_CXT_CLONE \
37     dMY_CXT_SV;                                                      \
38     my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1)); \
39     Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t); \
40     sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
41 # endif
42 #else
43 # define REP_THREADSAFE 0
44 # undef  dMY_CXT
45 # define dMY_CXT      dNOOP
46 # undef  MY_CXT
47 # define MY_CXT       rep_globaldata
48 # undef  START_MY_CXT
49 # define START_MY_CXT STATIC my_cxt_t MY_CXT;
50 # undef  MY_CXT_INIT
51 # define MY_CXT_INIT  NOOP
52 # undef  MY_CXT_CLONE
53 # define MY_CXT_CLONE NOOP
54 #endif
55
56 /* --- Helpers ------------------------------------------------------------- */
57
58 /* ... Thread-safe hints ................................................... */
59
60 typedef struct {
61  SV  *comp;
62  SV  *exec;
63 #if REP_WORKAROUND_REQUIRE_PROPAGATION
64  I32  requires;
65 #endif
66 } rep_hint_t;
67
68 #if REP_THREADSAFE
69
70 #define PTABLE_VAL_FREE(V) { \
71  rep_hint_t *h = (V);        \
72  SvREFCNT_dec(h->comp);      \
73  SvREFCNT_dec(h->exec);      \
74  PerlMemShared_free(h);      \
75 }
76
77 #define pPTBL  pTHX
78 #define pPTBL_ pTHX_
79 #define aPTBL  aTHX
80 #define aPTBL_ aTHX_
81
82 #include "ptable.h"
83
84 #define ptable_store(T, K, V) ptable_store(aTHX_ (T), (K), (V))
85 #define ptable_free(T)        ptable_free(aTHX_ (T))
86
87 #define MY_CXT_KEY __PACKAGE__ "::_guts" XS_VERSION
88
89 typedef struct {
90  ptable *tbl;
91  tTHX    owner;
92 } my_cxt_t;
93
94 START_MY_CXT
95
96 STATIC SV *rep_clone(pTHX_ SV *sv, tTHX owner) {
97 #define rep_clone(S, O) rep_clone(aTHX_ (S), (O))
98  CLONE_PARAMS  param;
99  AV           *stashes = NULL;
100  SV           *dupsv;
101
102  if (SvTYPE(sv) == SVt_PVHV && HvNAME_get(sv))
103   stashes = newAV();
104
105  param.stashes    = stashes;
106  param.flags      = 0;
107  param.proto_perl = owner;
108
109  dupsv = sv_dup(sv, &param);
110
111  if (stashes) {
112   av_undef(stashes);
113   SvREFCNT_dec(stashes);
114  }
115
116  return SvREFCNT_inc(dupsv);
117 }
118
119 STATIC void rep_ptable_clone(pTHX_ ptable_ent *ent, void *ud_) {
120  my_cxt_t   *ud = ud_;
121  rep_hint_t *h1 = ent->val;
122  rep_hint_t *h2;
123
124  if (ud->owner == aTHX)
125   return;
126
127  h2           = PerlMemShared_malloc(sizeof *h2);
128  h2->comp     = rep_clone(h1->comp, ud->owner);
129  SvREFCNT_inc(h2->comp);
130  h2->exec     = rep_clone(h1->exec, ud->owner);
131  SvREFCNT_inc(h2->exec);
132 #if REP_WORKAROUND_REQUIRE_PROPAGATION
133  h2->requires = h1->requires;
134 #endif
135
136  ptable_store(ud->tbl, ent->key, h2);
137 }
138
139 STATIC void rep_thread_cleanup(pTHX_ void *);
140
141 STATIC void rep_thread_cleanup(pTHX_ void *ud) {
142  int *level = ud;
143
144  if (*level) {
145   *level = 0;
146   LEAVE;
147   SAVEDESTRUCTOR_X(rep_thread_cleanup, level);
148   ENTER;
149  } else {
150   dMY_CXT;
151   PerlMemShared_free(level);
152   ptable_free(MY_CXT.tbl);
153  }
154 }
155
156 #endif /* REP_THREADSAFE */
157
158 STATIC SV *rep_validate_callback(SV *code) {
159  if (!SvROK(code))
160   return NULL;
161
162  code = SvRV(code);
163  if (SvTYPE(code) < SVt_PVCV)
164   return NULL;
165
166  return SvREFCNT_inc_simple_NN(code);
167 }
168
169 STATIC SV *rep_tag(pTHX_ SV *comp, SV *exec) {
170 #define rep_tag(C, E) rep_tag(aTHX_ (C), (E))
171  rep_hint_t *h;
172  dMY_CXT;
173
174  h = PerlMemShared_malloc(sizeof *h);
175
176  h->comp = rep_validate_callback(comp);
177  h->exec = rep_validate_callback(exec);
178
179 #if REP_WORKAROUND_REQUIRE_PROPAGATION
180  {
181   const PERL_SI *si;
182   I32            requires = 0;
183
184   for (si = PL_curstackinfo; si; si = si->si_prev) {
185    I32 cxix;
186
187    for (cxix = si->si_cxix; cxix >= 0; --cxix) {
188     const PERL_CONTEXT *cx = si->si_cxstack + cxix;
189
190     if (CxTYPE(cx) == CXt_EVAL && cx->blk_eval.old_op_type == OP_REQUIRE)
191      ++requires;
192    }
193   }
194
195   h->requires = requires;
196  }
197 #endif
198
199 #if REP_THREADSAFE
200  /* We only need for the key to be an unique tag for looking up the value later.
201   * Allocated memory provides convenient unique identifiers, so that's why we
202   * use the hint as the key itself. */
203  ptable_store(MY_CXT.tbl, h, h);
204 #endif /* REP_THREADSAFE */
205
206  return newSViv(PTR2IV(h));
207 }
208
209 STATIC const rep_hint_t *rep_detag(pTHX_ const SV *hint) {
210 #define rep_detag(H) rep_detag(aTHX_ (H))
211  rep_hint_t *h;
212  dMY_CXT;
213
214  if (!(hint && SvIOK(hint)))
215   return NULL;
216
217  h = INT2PTR(rep_hint_t *, SvIVX(hint));
218 #if REP_THREADSAFE
219  h = ptable_fetch(MY_CXT.tbl, h);
220 #endif /* REP_THREADSAFE */
221
222 #if REP_WORKAROUND_REQUIRE_PROPAGATION
223  {
224   const PERL_SI *si;
225   I32            requires = 0;
226
227   for (si = PL_curstackinfo; si; si = si->si_prev) {
228    I32 cxix;
229
230    for (cxix = si->si_cxix; cxix >= 0; --cxix) {
231     const PERL_CONTEXT *cx = si->si_cxstack + cxix;
232
233     if (CxTYPE(cx) == CXt_EVAL && cx->blk_eval.old_op_type == OP_REQUIRE
234                                && ++requires > h->requires)
235      return NULL;
236    }
237   }
238  }
239 #endif
240
241  return h;
242 }
243
244 STATIC U32 rep_hash = 0;
245
246 STATIC const rep_hint_t *rep_hint(pTHX) {
247 #define rep_hint() rep_hint(aTHX)
248  SV *hint;
249
250  /* We already require 5.9.5 for the regexp engine API. */
251  hint = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash,
252                                        NULL,
253                                        __PACKAGE__, __PACKAGE_LEN__,
254                                        0,
255                                        rep_hash);
256
257  return rep_detag(hint);
258 }
259
260 REGEXP *
261 #if PERL_VERSION <= 10
262 Plugin_comp(pTHX_ const SV * const pattern, const U32 flags)
263 #else
264 Plugin_comp(pTHX_ SV * const pattern, U32 flags)
265 #endif
266 {
267     dSP;
268     struct regexp * rx;
269     REGEXP *RX;
270     I32 buffers;
271     re__engine__Plugin re;
272     const rep_hint_t *h;
273
274     h = rep_hint();
275     if (!h) /* This looks like a pragma leak. Apply the default behaviour */
276         return re_compile(pattern, flags);
277
278     /* exp/xend version of the pattern & length */
279     STRLEN plen;
280     char*  exp = SvPV((SV*)pattern, plen);
281
282     /* Our blessed object */
283     SV *obj = newSV(0);
284     SvREFCNT_inc(obj);
285     Newxz(re, 1, struct replug);
286     sv_setref_pv(obj, "re::engine::Plugin", (void*)re);
287
288     newREGEXP(RX);
289     rx = rxREGEXP(RX);
290
291     re->rx = rx;                   /* Make the rx accessible from self->rx */
292     rx->intflags = flags;          /* Flags for internal use */
293     rx->extflags = flags;          /* Flags for perl to use */
294     rx->engine = RE_ENGINE_PLUGIN; /* Compile to use this engine */
295
296 #if PERL_VERSION <= 10
297     rx->refcnt = 1;                /* Refcount so we won't be destroyed */
298
299     /* Precompiled pattern for pp_regcomp to use */
300     rx->prelen = plen;
301     rx->precomp = savepvn(exp, rx->prelen);
302
303     /* Set up qr// stringification to be equivalent to the supplied
304      * pattern, this should be done via overload eventually.
305      */
306     rx->wraplen = rx->prelen;
307     Newx(rx->wrapped, rx->wraplen, char);
308     Copy(rx->precomp, rx->wrapped, rx->wraplen, char);
309 #endif
310
311     /* Store our private object */
312     rx->pprivate = obj;
313
314     /* Store the pattern for ->pattern */
315     re->pattern = (SV*)pattern;
316     SvREFCNT_inc(re->pattern);
317
318     /* If there's an exec callback, store it into the private object so
319      * that it will be the one to be called, even if the engine changes
320      * in between */
321     if (h->exec) {
322         re->cb_exec = h->exec;
323         SvREFCNT_inc_simple_void_NN(h->exec);
324     }
325
326     re->cb_num_capture_buff_FETCH  = NULL;
327     re->cb_num_capture_buff_STORE  = NULL;
328     re->cb_num_capture_buff_LENGTH = NULL;
329
330     /* Call our callback function if one was defined, if not we've
331      * already set up all the stuff we're going to to need for
332      * subsequent exec and other calls */
333     if (h->comp) {
334         ENTER;    
335         SAVETMPS;
336    
337         PUSHMARK(SP);
338         XPUSHs(obj);
339         PUTBACK;
340
341         call_sv(h->comp, G_DISCARD);
342
343         FREETMPS;
344         LEAVE;
345     }
346
347     /* If any of the comp-time accessors were called we'll have to
348      * update the regexp struct with the new info.
349      */
350
351     buffers = rx->nparens;
352
353     Newxz(rx->offs, buffers + 1, regexp_paren_pair);
354
355     return RX;
356 }
357
358 I32
359 Plugin_exec(pTHX_ REGEXP * const RX, char *stringarg, char *strend,
360             char *strbeg, I32 minend, SV *sv, void *data, U32 flags)
361 {
362     dSP;
363     I32 matched;
364     struct regexp *rx = rxREGEXP(RX);
365     GET_SELF_FROM_PPRIVATE(rx->pprivate);
366
367     if (self->cb_exec) {
368         /* Store the current str for ->str */
369         self->str = (SV*)sv;
370         SvREFCNT_inc(self->str);
371
372         ENTER;
373         SAVETMPS;
374    
375         PUSHMARK(SP);
376         XPUSHs(rx->pprivate);
377         XPUSHs(sv);
378         PUTBACK;
379
380         call_sv(self->cb_exec, G_SCALAR);
381  
382         SPAGAIN;
383
384         SV * ret = POPs;
385
386         if (SvTRUE(ret))
387             matched = 1;
388         else
389             matched = 0;
390
391         PUTBACK;
392         FREETMPS;
393         LEAVE;
394     } else {
395         matched = 0;
396     }
397
398     return matched;
399 }
400
401 char *
402 Plugin_intuit(pTHX_ REGEXP * const RX, SV *sv, char *strpos,
403                      char *strend, U32 flags, re_scream_pos_data *data)
404 {
405     PERL_UNUSED_ARG(RX);
406     PERL_UNUSED_ARG(sv);
407     PERL_UNUSED_ARG(strpos);
408     PERL_UNUSED_ARG(strend);
409     PERL_UNUSED_ARG(flags);
410     PERL_UNUSED_ARG(data);
411     return NULL;
412 }
413
414 SV *
415 Plugin_checkstr(pTHX_ REGEXP * const RX)
416 {
417     PERL_UNUSED_ARG(RX);
418     return NULL;
419 }
420
421 void
422 Plugin_free(pTHX_ REGEXP * const RX)
423 {
424     struct regexp *rx = rxREGEXP(RX);
425     GET_SELF_FROM_PPRIVATE(rx->pprivate);
426
427     SvREFCNT_dec(self->pattern);
428     SvREFCNT_dec(self->str);
429
430     SvREFCNT_dec(self->cb_exec);
431
432     SvREFCNT_dec(self->cb_num_capture_buff_FETCH);
433     SvREFCNT_dec(self->cb_num_capture_buff_STORE);
434     SvREFCNT_dec(self->cb_num_capture_buff_LENGTH);
435
436     self->rx = NULL;
437     Safefree(self);
438
439 /*
440     dSP;
441     SV * callback;
442
443     callback = self->cb_free;
444
445     if (callback) {
446         ENTER;
447         SAVETMPS;
448    
449         PUSHMARK(SP);
450         XPUSHs(rx->pprivate);
451         PUTBACK;
452
453         call_sv(callback, G_DISCARD);
454
455         PUTBACK;
456         FREETMPS;
457         LEAVE;
458     }
459     return;
460 */
461 }
462
463 void *
464 Plugin_dupe(pTHX_ REGEXP * const RX, CLONE_PARAMS *param)
465 {
466     struct regexp *rx = rxREGEXP(RX);
467     Perl_croak(aTHX_ "dupe not supported yet");
468     return rx->pprivate;
469 }
470
471
472 void
473 Plugin_numbered_buff_FETCH(pTHX_ REGEXP * const RX, const I32 paren,
474                            SV * const sv)
475 {
476     dSP;
477     I32 items;
478     SV * callback;
479     struct regexp *rx = rxREGEXP(RX);
480     GET_SELF_FROM_PPRIVATE(rx->pprivate);
481
482     callback = self->cb_num_capture_buff_FETCH;
483
484     if (callback) {
485         ENTER;
486         SAVETMPS;
487    
488         PUSHMARK(SP);
489         XPUSHs(rx->pprivate);
490         XPUSHs(sv_2mortal(newSViv(paren)));
491         PUTBACK;
492
493         items = call_sv(callback, G_SCALAR);
494         
495         if (items == 1) {
496             SPAGAIN;
497
498             SV * ret = POPs;
499             sv_setsv(sv, ret);
500         } else {
501             sv_setsv(sv, &PL_sv_undef);
502         }
503
504         PUTBACK;
505         FREETMPS;
506         LEAVE;
507     } else {
508         sv_setsv(sv, &PL_sv_undef);
509     }
510 }
511
512 void
513 Plugin_numbered_buff_STORE(pTHX_ REGEXP * const RX, const I32 paren,
514                            SV const * const value)
515 {
516     dSP;
517     SV * callback;
518     struct regexp *rx = rxREGEXP(RX);
519     GET_SELF_FROM_PPRIVATE(rx->pprivate);
520
521     callback = self->cb_num_capture_buff_STORE;
522
523     if (callback) {
524         ENTER;
525         SAVETMPS;
526    
527         PUSHMARK(SP);
528         XPUSHs(rx->pprivate);
529         XPUSHs(sv_2mortal(newSViv(paren)));
530         XPUSHs(SvREFCNT_inc((SV *) value));
531         PUTBACK;
532
533         call_sv(callback, G_DISCARD);
534
535         PUTBACK;
536         FREETMPS;
537         LEAVE;
538     }
539 }
540
541 I32
542 Plugin_numbered_buff_LENGTH(pTHX_ REGEXP * const RX, const SV * const sv,
543                               const I32 paren)
544 {
545     dSP;
546     SV * callback;
547     struct regexp *rx = rxREGEXP(RX);
548     GET_SELF_FROM_PPRIVATE(rx->pprivate);
549
550     callback = self->cb_num_capture_buff_LENGTH;
551
552     if (callback) {
553         ENTER;
554         SAVETMPS;
555    
556         PUSHMARK(SP);
557         XPUSHs(rx->pprivate);
558         XPUSHs(sv_2mortal(newSViv(paren)));
559         PUTBACK;
560
561         call_sv(callback, G_SCALAR);
562
563         SPAGAIN;
564
565         IV ret = POPi;
566
567         PUTBACK;
568         FREETMPS;
569         LEAVE;
570
571         return (I32)ret;
572     } else {
573         /* TODO: call FETCH and get the length on that value */
574         return 0;
575     }
576 }
577
578
579 SV*
580 Plugin_named_buff (pTHX_ REGEXP * const RX, SV * const key, SV * const value,
581                    const U32 flags)
582 {
583     return NULL;
584 }
585
586 SV*
587 Plugin_named_buff_iter (pTHX_ REGEXP * const RX, const SV * const lastkey,
588                         const U32 flags)
589 {
590     return NULL;
591 }
592
593 SV*
594 Plugin_package(pTHX_ REGEXP * const RX)
595 {
596     PERL_UNUSED_ARG(RX);
597     return newSVpvs("re::engine::Plugin");
598 }
599
600 #if REP_THREADSAFE
601
602 STATIC U32 rep_initialized = 0;
603
604 STATIC void rep_teardown(pTHX_ void *root) {
605  dMY_CXT;
606
607  if (!rep_initialized || aTHX != root)
608   return;
609
610  ptable_free(MY_CXT.tbl);
611
612  rep_initialized = 0;
613 }
614
615 STATIC void rep_setup(pTHX) {
616 #define rep_setup() rep_setup(aTHX)
617  if (rep_initialized)
618   return;
619
620  MY_CXT_INIT;
621  MY_CXT.tbl   = ptable_new();
622  MY_CXT.owner = aTHX;
623
624  call_atexit(rep_teardown, aTHX);
625
626  rep_initialized = 1;
627 }
628
629 #else  /*  REP_THREADSAFE */
630
631 #define rep_setup()
632
633 #endif /* !REP_THREADSAFE */
634
635 STATIC U32 rep_booted = 0;
636
637 /* --- XS ------------------------------------------------------------------ */
638
639 MODULE = re::engine::Plugin     PACKAGE = re::engine::Plugin
640
641 PROTOTYPES: DISABLE
642
643 BOOT:
644 {
645     if (!rep_booted++) {
646         PERL_HASH(rep_hash, __PACKAGE__, __PACKAGE_LEN__);
647     }
648
649     rep_setup();
650 }
651
652 #if REP_THREADSAFE
653
654 void
655 CLONE(...)
656 PREINIT:
657     ptable *t;
658     int    *level;
659 CODE:
660     {
661         my_cxt_t ud;
662         dMY_CXT;
663         ud.tbl   = t = ptable_new();
664         ud.owner = MY_CXT.owner;
665         ptable_walk(MY_CXT.tbl, rep_ptable_clone, &ud);
666     }
667     {
668         MY_CXT_CLONE;
669         MY_CXT.tbl   = t;
670         MY_CXT.owner = aTHX;
671     }
672
673 #endif
674
675 void
676 pattern(re::engine::Plugin self, ...)
677 PPCODE:
678     XPUSHs(self->pattern);
679
680 void
681 str(re::engine::Plugin self, ...)
682 PPCODE:
683     XPUSHs(self->str);
684
685 char*
686 mod(re::engine::Plugin self, ...)
687 PPCODE:
688     /* /i */
689     if (self->rx->intflags & PMf_FOLD) {
690       XPUSHs(sv_2mortal(newSVpvs("i")));
691       XPUSHs(&PL_sv_yes);
692     }
693
694     /* /m */
695     if (self->rx->intflags & PMf_MULTILINE) {
696       XPUSHs(sv_2mortal(newSVpvs("m")));
697       XPUSHs(&PL_sv_yes);
698     }
699
700     /* /s */
701     if (self->rx->intflags & PMf_SINGLELINE) {
702       XPUSHs(sv_2mortal(newSVpvs("s")));
703       XPUSHs(&PL_sv_yes);
704     }
705
706     /* /x */
707     if (self->rx->intflags & PMf_EXTENDED) {
708       XPUSHs(sv_2mortal(newSVpvs("x")));
709       XPUSHs(&PL_sv_yes);
710     }
711
712     /* /p */
713     if (self->rx->intflags & RXf_PMf_KEEPCOPY) {
714       XPUSHs(sv_2mortal(newSVpvs("p")));
715       XPUSHs(&PL_sv_yes);
716     }
717
718 void
719 stash(re::engine::Plugin self, ...)
720 PPCODE:
721     if (items > 1) {
722         self->stash = ST(1);
723         SvREFCNT_inc(self->stash);
724         XSRETURN_EMPTY;
725     } else {
726         XPUSHs(self->stash);
727     }
728
729 void
730 minlen(re::engine::Plugin self, ...)
731 PPCODE:
732     if (items > 1) {
733         self->rx->minlen = (I32)SvIV(ST(1));
734         XSRETURN_EMPTY;
735     } else {
736         if (self->rx->minlen) {
737             XPUSHs(sv_2mortal(newSViv(self->rx->minlen)));
738         } else {
739             XPUSHs(sv_2mortal(&PL_sv_undef));
740         }
741     }
742
743 void
744 gofs(re::engine::Plugin self, ...)
745 PPCODE:
746     if (items > 1) {
747         self->rx->gofs = (U32)SvIV(ST(1));
748         XSRETURN_EMPTY;
749     } else {
750         if (self->rx->gofs) {
751             XPUSHs(sv_2mortal(newSVuv(self->rx->gofs)));
752         } else {
753             XPUSHs(sv_2mortal(&PL_sv_undef));
754         }
755     }
756
757 void
758 nparens(re::engine::Plugin self, ...)
759 PPCODE:
760     if (items > 1) {
761         self->rx->nparens = (U32)SvIV(ST(1));
762         XSRETURN_EMPTY;
763     } else {
764         if (self->rx->nparens) {
765             XPUSHs(sv_2mortal(newSVuv(self->rx->nparens)));
766         } else {
767             XPUSHs(sv_2mortal(&PL_sv_undef));
768         }
769     }
770
771 void
772 _exec(re::engine::Plugin self, ...)
773 PPCODE:
774     if (items > 1) {
775         SvREFCNT_dec(self->cb_exec);
776         self->cb_exec = ST(1);
777         SvREFCNT_inc(self->cb_exec);
778     }
779
780 void
781 _num_capture_buff_FETCH(re::engine::Plugin self, ...)
782 PPCODE:
783     if (items > 1) {
784         SvREFCNT_dec(self->cb_num_capture_buff_FETCH);
785         self->cb_num_capture_buff_FETCH = ST(1);
786         SvREFCNT_inc(self->cb_num_capture_buff_FETCH);
787     }
788
789 void
790 _num_capture_buff_STORE(re::engine::Plugin self, ...)
791 PPCODE:
792     if (items > 1) {
793         SvREFCNT_dec(self->cb_num_capture_buff_STORE);
794         self->cb_num_capture_buff_STORE = ST(1);
795         SvREFCNT_inc(self->cb_num_capture_buff_STORE);
796     }
797
798 void
799 _num_capture_buff_LENGTH(re::engine::Plugin self, ...)
800 PPCODE:
801     if (items > 1) {
802         SvREFCNT_dec(self->cb_num_capture_buff_LENGTH);
803         self->cb_num_capture_buff_LENGTH = ST(1);
804         SvREFCNT_inc(self->cb_num_capture_buff_LENGTH);
805     }
806
807 SV *
808 _tag(SV *comp, SV *exec)
809 CODE:
810     RETVAL = rep_tag(comp, exec);
811 OUTPUT:
812     RETVAL
813
814 void
815 ENGINE()
816 PPCODE:
817     XPUSHs(sv_2mortal(newSViv(PTR2IV(&engine_plugin))));