From 8f0b3fcc4329e278204a58fd52feabdf9e4c5681 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Tue, 25 Oct 2022 15:37:00 +0100 Subject: Add sv_derived_from_hv() helper function --- universal.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'universal.c') diff --git a/universal.c b/universal.c index fe221dcedd..119117e818 100644 --- a/universal.c +++ b/universal.c @@ -188,6 +188,27 @@ Perl_sv_derived_from_pvn(pTHX_ SV *sv, const char *const name, const STRLEN len, return sv_derived_from_svpvn(sv, NULL, name, len, flags); } +/* +=for apidoc sv_derived_from_hv + +Exactly like L, but takes the name string as the +C of the given HV (which would presumably represent a stash). + +=cut +*/ + +bool +Perl_sv_derived_from_hv(pTHX_ SV *sv, HV *hv) +{ + PERL_ARGS_ASSERT_SV_DERIVED_FROM_HV; + + const char *hvname = HvNAME(hv); + if(!hvname) + return FALSE; + + return sv_derived_from_svpvn(sv, NULL, hvname, HvNAMELEN(hv), HvNAMEUTF8(hv) ? SVf_UTF8 : 0); +} + /* =for apidoc sv_isa_sv -- cgit v1.2.1