summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorBen Morrow <ben@morrow.me.uk>2010-08-31 07:10:20 +0100
committerRafael Garcia-Suarez <rgs@consttype.org>2010-09-07 12:10:19 +0200
commit8dff4fc578385a16edd29a881d85a0aa5f09595a (patch)
tree631c8a7c8744e44cc7ed9c1acda586ddd965fafd /hv.c
parent134bbc579801d70bf58eb3e84c78e4c2c244899e (diff)
downloadperl-8dff4fc578385a16edd29a881d85a0aa5f09595a.tar.gz
API functions for accessing the runtime hinthash.
Add hinthash_fetch(sv|pv[ns]) as a replacement for refcounted_he_fetch, which is not API (and should not be). Also add caller_cx, as the correct XS equivalent to caller(). Lots of modules seem to have copies of this, so a proper API function will be more maintainable in future.
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/hv.c b/hv.c
index 567b4d973d..9d7606a46c 100644
--- a/hv.c
+++ b/hv.c
@@ -2623,6 +2623,57 @@ S_refcounted_he_value(pTHX_ const struct refcounted_he *he)
}
/*
+=for apidoc cop_hints_2hv
+
+Generates and returns a C<HV *> from the hinthash in the provided
+C<COP>. Returns C<NULL> if there isn't one there.
+
+=cut
+*/
+HV *
+Perl_cop_hints_2hv(pTHX_ const COP *cop)
+{
+ PERL_ARGS_ASSERT_COP_HINTS_2HV;
+
+ if (!cop->cop_hints_hash)
+ return NULL;
+
+ return Perl_refcounted_he_chain_2hv(aTHX_ cop->cop_hints_hash);
+}
+
+/*
+=for apidoc cop_hints_fetchsv
+
+Fetches an entry from the hinthash in the provided C<COP>. Returns NULL
+if the entry isn't there.
+
+=for apidoc cop_hints_fetchpvn
+
+See L</cop_hints_fetchsv>. If C<flags> includes C<HVhek_UTF8>, C<key> is
+in UTF-8.
+
+=for apidoc cop_hints_fetchpvs
+
+See L</cop_hints_fetchpvn>. This is a macro that takes a constant string
+for its argument, which is assumed to be ASCII (rather than UTF-8).
+
+=cut
+*/
+SV *
+Perl_cop_hints_fetchpvn(pTHX_ const COP *cop, const char *key, STRLEN klen,
+ int flags, U32 hash)
+{
+ PERL_ARGS_ASSERT_COP_HINTS_FETCHPVN;
+
+ /* refcounted_he_fetch takes more flags than we do. Make sure
+ * noone's depending on being able to pass them here. */
+ flags &= ~HVhek_UTF8;
+
+ return Perl_refcounted_he_fetch(aTHX_ cop->cop_hints_hash, NULL,
+ key, klen, flags, hash);
+}
+
+/*
=for apidoc refcounted_he_chain_2hv
Generates and returns a C<HV *> by walking up the tree starting at the passed