summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-14 14:09:15 +0100
committerNicholas Clark <nick@ccl4.org>2010-10-14 14:34:29 +0100
commit610f23459d57294735f494ba0a95e50f62231358 (patch)
treee93ada7831864b91b8ce84ae3b92e232560467b0
parent8cf6f931c54936a38eedd3d17d5fa1d5af1b9009 (diff)
downloadperl-610f23459d57294735f494ba0a95e50f62231358.tar.gz
Move Tie::Hash::NamedCapture::{FIRST,NEXT}KEY to NamedCapture.xs
-rw-r--r--ext/Tie-Hash-NamedCapture/NamedCapture.xs27
-rw-r--r--universal.c42
2 files changed, 27 insertions, 42 deletions
diff --git a/ext/Tie-Hash-NamedCapture/NamedCapture.xs b/ext/Tie-Hash-NamedCapture/NamedCapture.xs
index b51dedae78..248efea5bf 100644
--- a/ext/Tie-Hash-NamedCapture/NamedCapture.xs
+++ b/ext/Tie-Hash-NamedCapture/NamedCapture.xs
@@ -6,6 +6,33 @@ MODULE = Tie::Hash::NamedCapture PACKAGE = Tie::Hash::NamedCapture
PROTOTYPES: DISABLE
void
+FIRSTKEY(...)
+ ALIAS:
+ Tie::Hash::NamedCapture::NEXTKEY = 1
+ PREINIT:
+ REGEXP *const rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
+ U32 flags;
+ SV *ret;
+ const int expect = ix ? 2 : 1;
+ const U32 action = ix ? RXapif_NEXTKEY : RXapif_FIRSTKEY;
+ PPCODE:
+ if (items != expect)
+ croak_xs_usage(cv, expect == 2 ? "$lastkey" : "");
+
+ if (!rx || !SvROK(ST(0)))
+ XSRETURN_UNDEF;
+
+ flags = (U32)SvUV(SvRV(MUTABLE_SV(ST(0))));
+
+ PUTBACK;
+ ret = RX_ENGINE(rx)->named_buff_iter(aTHX_ (rx),
+ expect >= 2 ? ST(1) : NULL,
+ flags | action);
+ SPAGAIN;
+
+ PUSHs(ret ? sv_2mortal(ret) : &PL_sv_undef);
+
+void
flags(...)
PPCODE:
EXTEND(SP, 2);
diff --git a/universal.c b/universal.c
index 2cfb241bcb..194631830e 100644
--- a/universal.c
+++ b/universal.c
@@ -1321,46 +1321,6 @@ XS(XS_Tie_Hash_NamedCapture_EXISTS)
S_named_capture_common(aTHX_ cv, FALSE, 2, FALSE, RXapif_EXISTS);
}
-static void
-S_named_capture_iter_common(pTHX_ CV *const cv, const int expect,
- const U32 action)
-{
- dVAR;
- dXSARGS;
- REGEXP * rx;
- U32 flags;
- SV * ret;
-
- if (items != expect)
- croak_xs_usage(cv, expect == 2 ? "$lastkey" : "");
-
- rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
-
- if (!rx || !SvROK(ST(0)))
- XSRETURN_UNDEF;
-
- SP -= items;
- PUTBACK;
-
- flags = (U32)SvUV(SvRV(MUTABLE_SV(ST(0))));
- ret = RX_ENGINE(rx)->named_buff_iter(aTHX_ (rx), expect >= 2 ? ST(1) : NULL,
- flags | action);
-
- SPAGAIN;
- PUSHs(ret ? sv_2mortal(ret) : &PL_sv_undef);
- XSRETURN(1);
-}
-
-XS(XS_Tie_Hash_NamedCapture_FIRSTK)
-{
- S_named_capture_iter_common(aTHX_ cv, 1, RXapif_FIRSTKEY);
-}
-
-XS(XS_Tie_Hash_NamedCapture_NEXTK)
-{
- S_named_capture_iter_common(aTHX_ cv, 2, RXapif_NEXTKEY);
-}
-
XS(XS_Tie_Hash_NamedCapture_SCALAR)
{
S_named_capture_common(aTHX_ cv, FALSE, 1, FALSE, RXapif_SCALAR);
@@ -1421,8 +1381,6 @@ struct xsub_details details[] = {
{"Tie::Hash::NamedCapture::DELETE", XS_Tie_Hash_NamedCapture_DELETE, NULL},
{"Tie::Hash::NamedCapture::CLEAR", XS_Tie_Hash_NamedCapture_CLEAR, NULL},
{"Tie::Hash::NamedCapture::EXISTS", XS_Tie_Hash_NamedCapture_EXISTS, NULL},
- {"Tie::Hash::NamedCapture::FIRSTKEY", XS_Tie_Hash_NamedCapture_FIRSTK, NULL},
- {"Tie::Hash::NamedCapture::NEXTKEY", XS_Tie_Hash_NamedCapture_NEXTK, NULL},
{"Tie::Hash::NamedCapture::SCALAR", XS_Tie_Hash_NamedCapture_SCALAR, NULL},
};