Plugin_comp(pTHX_ const SV * const pattern, const U32 flags)
#endif
{
- dSP;
- struct regexp *rx;
- REGEXP *RX;
-
- re__engine__Plugin re;
const xsh_hints_user_t *h;
-
+ REGEXP *RX;
+ struct regexp *rx;
+ re__engine__Plugin re;
+ char *pbuf;
STRLEN plen;
- char *pbuf;
-
- SV *obj;
+ SV *obj;
h = rep_hint();
if (!h) /* This looks like a pragma leak. Apply the default behaviour */
/* Our blessed object */
obj = newSV(0);
- Newxz(re, 1, struct replug);
+ XSH_LOCAL_ALLOC(re, 1, struct replug);
sv_setref_pv(obj, XSH_PACKAGE, (void *) re);
newREGEXP(RX);
re->pattern = (SV *) pattern;
SvREFCNT_inc_simple_void(re->pattern);
- /* 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->exec) {
- re->cb_exec = h->exec;
- SvREFCNT_inc_simple_void_NN(h->exec);
- }
+ re->str = NULL;
+ re->stash = NULL;
- /* Same goes for the free callback, if there's one. */
- if (h->free) {
- re->cb_free = h->free;
- SvREFCNT_inc_simple_void_NN(h->free);
- }
+ /* Store the default exec callback (which may be NULL) into the regexp
+ * object. */
+ re->cb_exec = h->exec;
+ SvREFCNT_inc_simple_void(h->exec);
+
+ /* Same goes for the free callback. */
+ re->cb_free = h->free;
+ SvREFCNT_inc_simple_void(h->free);
re->cb_num_capture_buff_FETCH = NULL;
re->cb_num_capture_buff_STORE = NULL;
/* Call our callback function if one was defined, if not we've already set up
* all the stuff we're going to to need for subsequent exec and other calls */
if (h->comp) {
+ dSP;
+
ENTER;
SAVETMPS;
char *strbeg, REP_ENG_EXEC_MINEND_TYPE minend,
SV *sv, void *data, U32 flags)
{
- struct regexp *rx;
+ struct regexp *rx;
re__engine__Plugin self;
I32 matched;
void
Plugin_free(pTHX_ REGEXP * const RX)
{
- struct regexp *rx;
+ struct regexp *rx;
re__engine__Plugin self;
SV *callback;
- dSP;
if (PL_dirty)
return;
callback = self->cb_free;
if (callback) {
+ dSP;
+
ENTER;
SAVETMPS;
self->rx = NULL;
- Safefree(self);
+ XSH_LOCAL_FREE(self, 1, struct replug);
SvREFCNT_dec(rx->pprivate);
Plugin_numbered_buff_FETCH(pTHX_ REGEXP * const RX, const I32 paren,
SV * const sv)
{
- struct regexp *rx;
+ struct regexp *rx;
re__engine__Plugin self;
SV *callback;
PUSHMARK(SP);
XPUSHs(rx->pprivate);
- XPUSHs(sv_2mortal(newSViv(paren)));
+ mXPUSHi(paren);
PUTBACK;
items = call_sv(callback, G_SCALAR);
Plugin_numbered_buff_STORE(pTHX_ REGEXP * const RX, const I32 paren,
SV const * const value)
{
- struct regexp *rx;
+ struct regexp *rx;
re__engine__Plugin self;
SV *callback;
PUSHMARK(SP);
XPUSHs(rx->pprivate);
- XPUSHs(sv_2mortal(newSViv(paren)));
+ mXPUSHi(paren);
XPUSHs((SV *) value);
PUTBACK;
Plugin_numbered_buff_LENGTH(pTHX_ REGEXP * const RX, const SV * const sv,
const I32 paren)
{
- struct regexp *rx;
+ struct regexp *rx;
re__engine__Plugin self;
SV *callback;
PUSHMARK(SP);
XPUSHs(rx->pprivate);
- XPUSHs(sv_2mortal(newSViv(paren)));
+ mXPUSHi(paren);
PUTBACK;
call_sv(callback, G_SCALAR);
if (items > 1) {
self->rx->minlen = (I32)SvIV(ST(1));
XSRETURN_EMPTY;
- } else {
- if (self->rx->minlen) {
- XPUSHs(sv_2mortal(newSViv(self->rx->minlen)));
- } else {
- XPUSHs(sv_2mortal(&PL_sv_undef));
- }
+ } else if (self->rx->minlen) {
+ mXPUSHi(self->rx->minlen);
XSRETURN(1);
+ } else {
+ XSRETURN_UNDEF;
}
void
if (items > 1) {
self->rx->gofs = (U32)SvIV(ST(1));
XSRETURN_EMPTY;
- } else {
- if (self->rx->gofs) {
- XPUSHs(sv_2mortal(newSVuv(self->rx->gofs)));
- } else {
- XPUSHs(sv_2mortal(&PL_sv_undef));
- }
+ } else if (self->rx->gofs) {
+ mXPUSHu(self->rx->gofs);
XSRETURN(1);
+ } else {
+ XSRETURN_UNDEF;
}
void
if (items > 1) {
self->rx->nparens = (U32)SvIV(ST(1));
XSRETURN_EMPTY;
- } else {
- if (self->rx->nparens) {
- XPUSHs(sv_2mortal(newSVuv(self->rx->nparens)));
- } else {
- XPUSHs(sv_2mortal(&PL_sv_undef));
- }
+ } else if (self->rx->nparens) {
+ mXPUSHu(self->rx->nparens);
XSRETURN(1);
+ } else {
+ XSRETURN_UNDEF;
}
void
void
ENGINE()
PPCODE:
- XPUSHs(sv_2mortal(newSViv(PTR2IV(&engine_plugin))));
+ mXPUSHi(PTR2IV(&engine_plugin));
XSRETURN(1);