3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 * 2005, 2006, 2007 by Larry Wall and others
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
12 * "The roots of those mountains must be roots indeed; there must be
13 * great secrets buried there which have not been discovered since the
14 * beginning." --Gandalf, relating Gollum's story
17 /* This file contains the code that implements the functions in Perl's
18 * UNIVERSAL package, such as UNIVERSAL->can().
20 * It is also used to store XS functions that need to be present in
21 * miniperl for a lack of a better place to put them. It might be
22 * clever to move them to seperate XS files which would then be pulled
23 * in by some to-be-written build process.
27 #define PERL_IN_UNIVERSAL_C
31 #include "perliol.h" /* For the PERLIO_F_XXX */
35 * Contributed by Graham Barr <Graham.Barr@tiuk.ti.com>
36 * The main guts of traverse_isa was actually copied from gv_fetchmeth
40 S_isa_lookup(pTHX_ HV *stash, const char * const name, const HV* const name_stash)
48 /* A stash/class can go by many names (ie. User == main::User), so
49 we compare the stash itself just in case */
50 if (name_stash && ((const HV *)stash == name_stash))
53 hvname = HvNAME_get(stash);
55 if (strEQ(hvname, name))
58 if (strEQ(name, "UNIVERSAL"))
61 stash_linear_isa = mro_get_linear_isa(stash);
62 svp = AvARRAY(stash_linear_isa) + 1;
63 items = AvFILLp(stash_linear_isa);
65 SV* const basename_sv = *svp++;
66 HV* const basestash = gv_stashsv(basename_sv, 0);
68 if (ckWARN(WARN_SYNTAX))
69 Perl_warner(aTHX_ packWARN(WARN_SYNTAX),
70 "Can't locate package %"SVf" for the parents of %s",
71 SVfARG(basename_sv), hvname);
74 if(name_stash == basestash || strEQ(name, SvPVX(basename_sv)))
82 =head1 SV Manipulation Functions
84 =for apidoc sv_derived_from
86 Returns a boolean indicating whether the SV is derived from the specified class
87 I<at the C level>. To check derivation at the Perl level, call C<isa()> as a
94 Perl_sv_derived_from(pTHX_ SV *sv, const char *name)
104 type = sv_reftype(sv,0);
105 if (type && strEQ(type,name))
107 stash = SvOBJECT(sv) ? SvSTASH(sv) : NULL;
110 stash = gv_stashsv(sv, 0);
114 HV * const name_stash = gv_stashpv(name, 0);
115 return isa_lookup(stash, name, name_stash);
125 Returns a boolean indicating whether the SV performs a specific, named role.
126 The SV can be a Perl object or the name of a Perl class.
134 Perl_sv_does(pTHX_ SV *sv, const char *name)
136 const char *classname;
146 if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))
147 || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv))))
150 if (sv_isobject(sv)) {
151 classname = sv_reftype(SvRV(sv),TRUE);
153 classname = SvPV_nolen(sv);
156 if (strEQ(name,classname))
161 XPUSHs(sv_2mortal(newSVpv(name, 0)));
164 methodname = sv_2mortal(newSVpv("isa", 0));
165 /* ugly hack: use the SvSCREAM flag so S_method_common
166 * can figure out we're calling DOES() and not isa(),
167 * and report eventual errors correctly. --rgs */
168 SvSCREAM_on(methodname);
169 call_sv(methodname, G_SCALAR | G_METHOD);
172 does_it = SvTRUE( TOPs );
179 PERL_XS_EXPORT_C void XS_UNIVERSAL_isa(pTHX_ CV *cv);
180 PERL_XS_EXPORT_C void XS_UNIVERSAL_can(pTHX_ CV *cv);
181 PERL_XS_EXPORT_C void XS_UNIVERSAL_DOES(pTHX_ CV *cv);
182 PERL_XS_EXPORT_C void XS_UNIVERSAL_VERSION(pTHX_ CV *cv);
184 XS(XS_version_stringify);
185 XS(XS_version_numify);
186 XS(XS_version_normal);
188 XS(XS_version_boolean);
189 #ifdef HASATTRIBUTE_NORETURN
190 XS(XS_version_noop) __attribute__noreturn__;
194 XS(XS_version_is_alpha);
201 XS(XS_utf8_downgrade);
202 XS(XS_utf8_unicode_to_native);
203 XS(XS_utf8_native_to_unicode);
204 XS(XS_Internals_SvREADONLY);
205 XS(XS_Internals_SvREFCNT);
206 XS(XS_Internals_hv_clear_placehold);
207 XS(XS_PerlIO_get_layers);
208 XS(XS_Regexp_DESTROY);
209 XS(XS_Internals_hash_seed);
210 XS(XS_Internals_rehash_seed);
211 XS(XS_Internals_HvREHASH);
212 XS(XS_Internals_inc_sub_generation);
216 XS(XS_re_regnames_count);
217 XS(XS_Tie_Hash_NamedCapture_FETCH);
218 XS(XS_Tie_Hash_NamedCapture_STORE);
219 XS(XS_Tie_Hash_NamedCapture_DELETE);
220 XS(XS_Tie_Hash_NamedCapture_CLEAR);
221 XS(XS_Tie_Hash_NamedCapture_EXISTS);
222 XS(XS_Tie_Hash_NamedCapture_FIRSTK);
223 XS(XS_Tie_Hash_NamedCapture_NEXTK);
224 XS(XS_Tie_Hash_NamedCapture_SCALAR);
225 XS(XS_Tie_Hash_NamedCapture_flags);
228 Perl_boot_core_UNIVERSAL(pTHX)
231 static const char file[] = __FILE__;
233 newXS("UNIVERSAL::isa", XS_UNIVERSAL_isa, file);
234 newXS("UNIVERSAL::can", XS_UNIVERSAL_can, file);
235 newXS("UNIVERSAL::DOES", XS_UNIVERSAL_DOES, file);
236 newXS("UNIVERSAL::VERSION", XS_UNIVERSAL_VERSION, file);
238 /* register the overloading (type 'A') magic */
239 PL_amagic_generation++;
240 /* Make it findable via fetchmethod */
241 newXS("version::()", XS_version_noop, file);
242 newXS("version::new", XS_version_new, file);
243 newXS("version::(\"\"", XS_version_stringify, file);
244 newXS("version::stringify", XS_version_stringify, file);
245 newXS("version::(0+", XS_version_numify, file);
246 newXS("version::numify", XS_version_numify, file);
247 newXS("version::normal", XS_version_normal, file);
248 newXS("version::(cmp", XS_version_vcmp, file);
249 newXS("version::(<=>", XS_version_vcmp, file);
250 newXS("version::vcmp", XS_version_vcmp, file);
251 newXS("version::(bool", XS_version_boolean, file);
252 newXS("version::boolean", XS_version_boolean, file);
253 newXS("version::(nomethod", XS_version_noop, file);
254 newXS("version::noop", XS_version_noop, file);
255 newXS("version::is_alpha", XS_version_is_alpha, file);
256 newXS("version::qv", XS_version_qv, file);
258 newXS("utf8::is_utf8", XS_utf8_is_utf8, file);
259 newXS("utf8::valid", XS_utf8_valid, file);
260 newXS("utf8::encode", XS_utf8_encode, file);
261 newXS("utf8::decode", XS_utf8_decode, file);
262 newXS("utf8::upgrade", XS_utf8_upgrade, file);
263 newXS("utf8::downgrade", XS_utf8_downgrade, file);
264 newXS("utf8::native_to_unicode", XS_utf8_native_to_unicode, file);
265 newXS("utf8::unicode_to_native", XS_utf8_unicode_to_native, file);
266 newXSproto("Internals::SvREADONLY",XS_Internals_SvREADONLY, file, "\\[$%@];$");
267 newXSproto("Internals::SvREFCNT",XS_Internals_SvREFCNT, file, "\\[$%@];$");
268 newXSproto("Internals::hv_clear_placeholders",
269 XS_Internals_hv_clear_placehold, file, "\\%");
270 newXSproto("PerlIO::get_layers",
271 XS_PerlIO_get_layers, file, "*;@");
272 newXS("Regexp::DESTROY", XS_Regexp_DESTROY, file);
273 newXSproto("Internals::hash_seed",XS_Internals_hash_seed, file, "");
274 newXSproto("Internals::rehash_seed",XS_Internals_rehash_seed, file, "");
275 newXSproto("Internals::HvREHASH", XS_Internals_HvREHASH, file, "\\%");
276 newXSproto("re::is_regexp", XS_re_is_regexp, file, "$");
277 newXSproto("re::regname", XS_re_regname, file, ";$$");
278 newXSproto("re::regnames", XS_re_regnames, file, ";$");
279 newXSproto("re::regnames_count", XS_re_regnames_count, file, "");
280 newXS("Tie::Hash::NamedCapture::FETCH", XS_Tie_Hash_NamedCapture_FETCH, file);
281 newXS("Tie::Hash::NamedCapture::STORE", XS_Tie_Hash_NamedCapture_STORE, file);
282 newXS("Tie::Hash::NamedCapture::DELETE", XS_Tie_Hash_NamedCapture_DELETE, file);
283 newXS("Tie::Hash::NamedCapture::CLEAR", XS_Tie_Hash_NamedCapture_CLEAR, file);
284 newXS("Tie::Hash::NamedCapture::EXISTS", XS_Tie_Hash_NamedCapture_EXISTS, file);
285 newXS("Tie::Hash::NamedCapture::FIRSTKEY", XS_Tie_Hash_NamedCapture_FIRSTK, file);
286 newXS("Tie::Hash::NamedCapture::NEXTKEY", XS_Tie_Hash_NamedCapture_NEXTK, file);
287 newXS("Tie::Hash::NamedCapture::SCALAR", XS_Tie_Hash_NamedCapture_SCALAR, file);
288 newXS("Tie::Hash::NamedCapture::flags", XS_Tie_Hash_NamedCapture_flags, file);
299 Perl_croak(aTHX_ "Usage: UNIVERSAL::isa(reference, kind)");
301 SV * const sv = ST(0);
306 if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))
307 || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv))))
310 name = SvPV_nolen_const(ST(1));
312 ST(0) = boolSV(sv_derived_from(sv, name));
328 Perl_croak(aTHX_ "Usage: UNIVERSAL::can(object-ref, method)");
334 if (!SvOK(sv) || !(SvROK(sv) || (SvPOK(sv) && SvCUR(sv))
335 || (SvGMAGICAL(sv) && SvPOKp(sv) && SvCUR(sv))))
338 name = SvPV_nolen_const(ST(1));
347 pkg = gv_stashsv(sv, 0);
351 GV * const gv = gv_fetchmethod_autoload(pkg, name, FALSE);
353 rv = sv_2mortal(newRV((SV*)GvCV(gv)));
360 XS(XS_UNIVERSAL_DOES)
367 Perl_croak(aTHX_ "Usage: invocant->DOES(kind)");
369 SV * const sv = ST(0);
372 name = SvPV_nolen_const(ST(1));
373 if (sv_does( sv, name ))
380 XS(XS_UNIVERSAL_VERSION)
392 sv = (SV*)SvRV(ST(0));
394 Perl_croak(aTHX_ "Cannot find version of an unblessed reference");
398 pkg = gv_stashsv(ST(0), 0);
401 gvp = pkg ? (GV**)hv_fetchs(pkg, "VERSION", FALSE) : NULL;
403 if (gvp && isGV(gv = *gvp) && (sv = GvSV(gv)) && SvOK(sv)) {
404 SV * const nsv = sv_newmortal();
407 if ( !sv_derived_from(sv, "version"))
408 upg_version(sv, FALSE);
412 sv = (SV*)&PL_sv_undef;
421 const char * const name = HvNAME_get(pkg);
423 "%s does not define $%s::VERSION--version check failed",
427 "%s defines neither package nor VERSION--version check failed",
428 SvPVx_nolen_const(ST(0)) );
432 if ( !sv_derived_from(req, "version")) {
433 /* req may very well be R/O, so create a new object */
434 req = sv_2mortal( new_version(req) );
437 if ( vcmp( req, sv ) > 0 ) {
438 if ( hv_exists((HV*)SvRV(req), "qv", 2 ) ) {
439 Perl_croak(aTHX_ "%s version %"SVf" required--"
440 "this is only version %"SVf"", HvNAME_get(pkg),
441 SVfARG(vnormal(req)),
442 SVfARG(vnormal(sv)));
444 Perl_croak(aTHX_ "%s version %"SVf" required--"
445 "this is only version %"SVf"", HvNAME_get(pkg),
446 SVfARG(vstringify(req)),
447 SVfARG(vstringify(sv)));
453 if ( SvOK(sv) && sv_derived_from(sv, "version") ) {
454 ST(0) = vstringify(sv);
468 Perl_croak(aTHX_ "Usage: version::new(class, version)");
473 const char * const classname =
474 sv_isobject(ST(0)) /* get the class if called as an object method */
475 ? HvNAME(SvSTASH(SvRV(ST(0))))
476 : (char *)SvPV_nolen(ST(0));
478 if ( items == 1 || vs == &PL_sv_undef ) { /* no param or explicit undef */
479 /* create empty object */
483 else if ( items == 3 ) {
485 Perl_sv_setpvf(aTHX_ vs,"v%s",SvPV_nolen_const(ST(2)));
488 rv = new_version(vs);
489 if ( strcmp(classname,"version") != 0 ) /* inherited new() */
490 sv_bless(rv, gv_stashpv(classname, GV_ADD));
492 PUSHs(sv_2mortal(rv));
498 XS(XS_version_stringify)
504 Perl_croak(aTHX_ "Usage: version::stringify(lobj, ...)");
509 if (sv_derived_from(ST(0), "version")) {
513 Perl_croak(aTHX_ "lobj is not of type version");
515 PUSHs(sv_2mortal(vstringify(lobj)));
522 XS(XS_version_numify)
528 Perl_croak(aTHX_ "Usage: version::numify(lobj, ...)");
533 if (sv_derived_from(ST(0), "version")) {
537 Perl_croak(aTHX_ "lobj is not of type version");
539 PUSHs(sv_2mortal(vnumify(lobj)));
546 XS(XS_version_normal)
552 Perl_croak(aTHX_ "Usage: version::normal(lobj, ...)");
557 if (sv_derived_from(ST(0), "version")) {
561 Perl_croak(aTHX_ "lobj is not of type version");
563 PUSHs(sv_2mortal(vnormal(lobj)));
576 Perl_croak(aTHX_ "Usage: version::vcmp(lobj, ...)");
581 if (sv_derived_from(ST(0), "version")) {
585 Perl_croak(aTHX_ "lobj is not of type version");
591 const IV swap = (IV)SvIV(ST(2));
593 if ( ! sv_derived_from(robj, "version") )
595 robj = new_version(robj);
601 rs = newSViv(vcmp(rvs,lobj));
605 rs = newSViv(vcmp(lobj,rvs));
608 PUSHs(sv_2mortal(rs));
616 XS(XS_version_boolean)
622 Perl_croak(aTHX_ "Usage: version::boolean(lobj, ...)");
624 if (sv_derived_from(ST(0), "version")) {
625 SV * const lobj = SvRV(ST(0));
626 SV * const rs = newSViv( vcmp(lobj,new_version(newSVpvs("0"))) );
627 PUSHs(sv_2mortal(rs));
632 Perl_croak(aTHX_ "lobj is not of type version");
641 Perl_croak(aTHX_ "Usage: version::noop(lobj, ...)");
642 if (sv_derived_from(ST(0), "version"))
643 Perl_croak(aTHX_ "operation not supported with version object");
645 Perl_croak(aTHX_ "lobj is not of type version");
646 #ifndef HASATTRIBUTE_NORETURN
651 XS(XS_version_is_alpha)
657 Perl_croak(aTHX_ "Usage: version::is_alpha(lobj)");
659 if (sv_derived_from(ST(0), "version")) {
660 SV * const lobj = ST(0);
661 if ( hv_exists((HV*)SvRV(lobj), "alpha", 5 ) )
669 Perl_croak(aTHX_ "lobj is not of type version");
678 Perl_croak(aTHX_ "Usage: version::qv(ver)");
682 if ( !SvVOK(ver) ) { /* only need to do with if not already v-string */
683 SV * const rv = sv_newmortal();
684 sv_setsv(rv,ver); /* make a duplicate */
685 upg_version(rv, TRUE);
690 PUSHs(sv_2mortal(new_version(ver)));
704 Perl_croak(aTHX_ "Usage: utf8::is_utf8(sv)");
706 const SV * const sv = ST(0);
721 Perl_croak(aTHX_ "Usage: utf8::valid(sv)");
723 SV * const sv = ST(0);
725 const char * const s = SvPV_const(sv,len);
726 if (!SvUTF8(sv) || is_utf8_string((const U8*)s,len))
740 Perl_croak(aTHX_ "Usage: utf8::encode(sv)");
741 sv_utf8_encode(ST(0));
751 Perl_croak(aTHX_ "Usage: utf8::decode(sv)");
753 SV * const sv = ST(0);
754 const bool RETVAL = sv_utf8_decode(sv);
755 ST(0) = boolSV(RETVAL);
767 Perl_croak(aTHX_ "Usage: utf8::upgrade(sv)");
769 SV * const sv = ST(0);
773 RETVAL = sv_utf8_upgrade(sv);
774 XSprePUSH; PUSHi((IV)RETVAL);
779 XS(XS_utf8_downgrade)
784 if (items < 1 || items > 2)
785 Perl_croak(aTHX_ "Usage: utf8::downgrade(sv, failok=0)");
787 SV * const sv = ST(0);
788 const bool failok = (items < 2) ? 0 : (int)SvIV(ST(1));
789 const bool RETVAL = sv_utf8_downgrade(sv, failok);
791 ST(0) = boolSV(RETVAL);
797 XS(XS_utf8_native_to_unicode)
801 const UV uv = SvUV(ST(0));
805 Perl_croak(aTHX_ "Usage: utf8::native_to_unicode(sv)");
807 ST(0) = sv_2mortal(newSViv(NATIVE_TO_UNI(uv)));
811 XS(XS_utf8_unicode_to_native)
815 const UV uv = SvUV(ST(0));
819 Perl_croak(aTHX_ "Usage: utf8::unicode_to_native(sv)");
821 ST(0) = sv_2mortal(newSViv(UNI_TO_NATIVE(uv)));
825 XS(XS_Internals_SvREADONLY) /* This is dangerous stuff. */
829 SV * const sv = SvRV(ST(0));
838 else if (items == 2) {
844 /* I hope you really know what you are doing. */
849 XSRETURN_UNDEF; /* Can't happen. */
852 XS(XS_Internals_SvREFCNT) /* This is dangerous stuff. */
856 SV * const sv = SvRV(ST(0));
860 XSRETURN_IV(SvREFCNT(sv) - 1); /* Minus the ref created for us. */
861 else if (items == 2) {
862 /* I hope you really know what you are doing. */
863 SvREFCNT(sv) = SvIV(ST(1));
864 XSRETURN_IV(SvREFCNT(sv));
866 XSRETURN_UNDEF; /* Can't happen. */
869 XS(XS_Internals_hv_clear_placehold)
876 Perl_croak(aTHX_ "Usage: UNIVERSAL::hv_clear_placeholders(hv)");
878 HV * const hv = (HV *) SvRV(ST(0));
879 hv_clear_placeholders(hv);
884 XS(XS_Regexp_DESTROY)
890 XS(XS_PerlIO_get_layers)
895 if (items < 1 || items % 2 == 0)
896 Perl_croak(aTHX_ "Usage: PerlIO_get_layers(filehandle[,args])");
903 bool details = FALSE;
907 for (svp = MARK + 2; svp <= SP; svp += 2) {
908 SV * const * const varp = svp;
909 SV * const * const valp = svp + 1;
911 const char * const key = SvPV_const(*varp, klen);
915 if (klen == 5 && memEQ(key, "input", 5)) {
916 input = SvTRUE(*valp);
921 if (klen == 6 && memEQ(key, "output", 6)) {
922 input = !SvTRUE(*valp);
927 if (klen == 7 && memEQ(key, "details", 7)) {
928 details = SvTRUE(*valp);
935 "get_layers: unknown argument '%s'",
947 if (SvROK(sv) && isGV(SvRV(sv)))
950 gv = gv_fetchsv(sv, 0, SVt_PVIO);
953 if (gv && (io = GvIO(gv))) {
955 AV* const av = PerlIO_get_layers(aTHX_ input ?
956 IoIFP(io) : IoOFP(io));
958 const I32 last = av_len(av);
961 for (i = last; i >= 0; i -= 3) {
962 SV * const * const namsvp = av_fetch(av, i - 2, FALSE);
963 SV * const * const argsvp = av_fetch(av, i - 1, FALSE);
964 SV * const * const flgsvp = av_fetch(av, i, FALSE);
966 const bool namok = namsvp && *namsvp && SvPOK(*namsvp);
967 const bool argok = argsvp && *argsvp && SvPOK(*argsvp);
968 const bool flgok = flgsvp && *flgsvp && SvIOK(*flgsvp);
972 ? newSVpvn(SvPVX_const(*namsvp), SvCUR(*namsvp))
975 ? newSVpvn(SvPVX_const(*argsvp), SvCUR(*argsvp))
978 XPUSHi(SvIVX(*flgsvp));
980 XPUSHs(&PL_sv_undef);
985 XPUSHs(Perl_newSVpvf(aTHX_ "%"SVf"(%"SVf")",
989 XPUSHs(Perl_newSVpvf(aTHX_ "%"SVf,
992 XPUSHs(&PL_sv_undef);
995 const IV flags = SvIVX(*flgsvp);
997 if (flags & PERLIO_F_UTF8) {
998 XPUSHs(newSVpvs("utf8"));
1015 XS(XS_Internals_hash_seed)
1018 /* Using dXSARGS would also have dITEM and dSP,
1019 * which define 2 unused local variables. */
1021 PERL_UNUSED_ARG(cv);
1022 PERL_UNUSED_VAR(mark);
1023 XSRETURN_UV(PERL_HASH_SEED);
1026 XS(XS_Internals_rehash_seed)
1029 /* Using dXSARGS would also have dITEM and dSP,
1030 * which define 2 unused local variables. */
1032 PERL_UNUSED_ARG(cv);
1033 PERL_UNUSED_VAR(mark);
1034 XSRETURN_UV(PL_rehash_seed);
1037 XS(XS_Internals_HvREHASH) /* Subject to change */
1041 PERL_UNUSED_ARG(cv);
1043 const HV * const hv = (HV *) SvRV(ST(0));
1044 if (items == 1 && SvTYPE(hv) == SVt_PVHV) {
1051 Perl_croak(aTHX_ "Internals::HvREHASH $hashref");
1058 PERL_UNUSED_VAR(cv);
1061 Perl_croak(aTHX_ "Usage: %s(%s)", "re::is_regexp", "sv");
1065 if (SvRXOK(ST(0))) {
1072 XS(XS_re_regnames_count)
1074 REGEXP *rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
1078 PERL_UNUSED_ARG(cv);
1081 Perl_croak(aTHX_ "Usage: %s(%s)", "re::regnames_count", "");
1088 ret = CALLREG_NAMED_BUFF_COUNT(rx);
1108 PERL_UNUSED_ARG(cv);
1110 if (items < 1 || items > 2)
1111 Perl_croak(aTHX_ "Usage: %s(%s)", "re::regname", "name[, all ]");
1115 rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
1120 if (items == 2 && SvTRUE(ST(1))) {
1125 ret = CALLREG_NAMED_BUFF_FETCH(rx, ST(0), (flags | RXapif_REGNAME));
1131 XPUSHs(SvREFCNT_inc(ret));
1149 PERL_UNUSED_ARG(cv);
1152 Perl_croak(aTHX_ "Usage: %s(%s)", "re::regnames", "[all]");
1154 rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
1159 if (items == 1 && SvTRUE(ST(0))) {
1167 ret = CALLREG_NAMED_BUFF_ALL(rx, (flags | RXapif_REGNAMES));
1176 av = (AV*)SvRV(ret);
1177 length = av_len(av);
1179 for (i = 0; i <= length; i++) {
1180 entry = av_fetch(av, i, FALSE);
1183 Perl_croak(aTHX_ "NULL array element in re::regnames()");
1191 XS(XS_Tie_Hash_NamedCapture_FETCH)
1198 PERL_UNUSED_ARG(cv);
1201 Perl_croak(aTHX_ "Usage: Tie::Hash::NamedCapture::STORE($key, $flags)");
1203 rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
1210 flags = (U32)INT2PTR(IV,SvIV(SvRV((SV*)ST(0))));
1211 ret = CALLREG_NAMED_BUFF_FETCH(rx, ST(1), flags);
1219 XPUSHs(SvREFCNT_inc(ret));
1226 XS(XS_Tie_Hash_NamedCapture_STORE)
1232 PERL_UNUSED_ARG(cv);
1235 Perl_croak(aTHX_ "Usage: Tie::Hash::NamedCapture::STORE($key, $value, $flags)");
1237 rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
1241 Perl_croak(aTHX_ PL_no_modify);
1248 flags = (U32)INT2PTR(IV,SvIV(SvRV((SV*)ST(0))));
1249 CALLREG_NAMED_BUFF_STORE(rx,ST(1), ST(2), flags);
1252 XS(XS_Tie_Hash_NamedCapture_DELETE)
1256 REGEXP * rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
1258 PERL_UNUSED_ARG(cv);
1261 Perl_croak(aTHX_ "Usage: Tie::Hash::NamedCapture::DELETE($key, $flags)");
1264 Perl_croak(aTHX_ PL_no_modify);
1268 flags = (U32)INT2PTR(IV,SvIV(SvRV((SV*)ST(0))));
1269 CALLREG_NAMED_BUFF_DELETE(rx, ST(1), flags);
1272 XS(XS_Tie_Hash_NamedCapture_CLEAR)
1278 PERL_UNUSED_ARG(cv);
1281 Perl_croak(aTHX_ "Usage: Tie::Hash::NamedCapture::CLEAR($flags)");
1283 rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
1286 Perl_croak(aTHX_ PL_no_modify);
1290 flags = (U32)INT2PTR(IV,SvIV(SvRV((SV*)ST(0))));
1291 CALLREG_NAMED_BUFF_CLEAR(rx, flags);
1294 XS(XS_Tie_Hash_NamedCapture_EXISTS)
1301 PERL_UNUSED_ARG(cv);
1304 Perl_croak(aTHX_ "Usage: Tie::Hash::NamedCapture::EXISTS($key, $flags)");
1306 rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
1313 flags = (U32)INT2PTR(IV,SvIV(SvRV((SV*)ST(0))));
1314 ret = CALLREG_NAMED_BUFF_EXISTS(rx, ST(1), flags);
1323 XS(XS_Tie_Hash_NamedCapture_FIRSTK)
1330 PERL_UNUSED_ARG(cv);
1333 Perl_croak(aTHX_ "Usage: Tie::Hash::NamedCapture::FIRSTKEY()");
1335 rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
1342 flags = (U32)INT2PTR(IV,SvIV(SvRV((SV*)ST(0))));
1343 ret = CALLREG_NAMED_BUFF_FIRSTKEY(rx, flags);
1348 XPUSHs(SvREFCNT_inc(ret));
1356 XS(XS_Tie_Hash_NamedCapture_NEXTK)
1363 PERL_UNUSED_ARG(cv);
1366 Perl_croak(aTHX_ "Usage: Tie::Hash::NamedCapture::NEXTKEY($lastkey)");
1368 rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
1375 flags = (U32)INT2PTR(IV,SvIV(SvRV((SV*)ST(0))));
1376 ret = CALLREG_NAMED_BUFF_NEXTKEY(rx, ST(1), flags);
1388 XS(XS_Tie_Hash_NamedCapture_SCALAR)
1395 PERL_UNUSED_ARG(cv);
1398 Perl_croak(aTHX_ "Usage: Tie::Hash::NamedCapture::SCALAR()");
1400 rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
1407 flags = (U32)INT2PTR(IV,SvIV(SvRV((SV*)ST(0))));
1408 ret = CALLREG_NAMED_BUFF_SCALAR(rx, flags);
1421 XS(XS_Tie_Hash_NamedCapture_flags)
1425 PERL_UNUSED_ARG(cv);
1428 Perl_croak(aTHX_ "Usage: Tie::Hash::NamedCapture::flags()");
1430 XPUSHs(sv_2mortal(newSVuv(RXapif_ONE)));
1431 XPUSHs(sv_2mortal(newSVuv(RXapif_ALL)));
1439 * c-indentation-style: bsd
1441 * indent-tabs-mode: t
1444 * ex: set ts=8 sts=4 sw=4 noet: