diff options
author | Karl Williamson <khw@cpan.org> | 2020-08-29 12:51:19 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-09-22 07:10:28 -0600 |
commit | 84ca0d824992e0fdf2afea26fce6bdd9cf2c696f (patch) | |
tree | 025ccef383dc72954bf33fba1b2d2a611141e994 /gv.c | |
parent | 0bfb46833b9c1f0866e761651fb6e9bb9e015174 (diff) | |
download | perl-84ca0d824992e0fdf2afea26fce6bdd9cf2c696f.tar.gz |
Document gv_fetch[ps]v and kin
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 71 |
1 files changed, 69 insertions, 2 deletions
@@ -1604,8 +1604,6 @@ Perl_gv_stashsv(pTHX_ SV *sv, I32 flags) PERL_ARGS_ASSERT_GV_STASHSV; return gv_stashsvpvn_cached(sv, NULL, 0, flags); } - - GV * Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 flags, const svtype sv_type) { PERL_ARGS_ASSERT_GV_FETCHPV; @@ -2368,6 +2366,75 @@ S_maybe_multimagic_gv(pTHX_ GV *gv, const char *name, const svtype sv_type) } } +/* +=for apidoc gv_fetchpv +=for apidoc_item |GV *|gv_fetchpvn|const char * nambeg|STRLEN full_len|I32 flags|const svtype sv_type +=for apidoc_item ||gv_fetchpvn_flags +=for apidoc_item |GV *|gv_fetchpvs|"name"|I32 flags|const svtype sv_type +=for apidoc_item ||gv_fetchsv +=for apidoc_item |GV *|gv_fetchsv_nomg|SV *name|I32 flags|const svtype sv_type + +These all return the GV of type C<sv_type> whose name is given by the inputs, +or NULL if no GV of that name and type could be found. See L<perlguts/Stashes +and Globs>. + +The only differences are how the input name is specified, and if 'get' magic is +normally used in getting that name. + +Don't be fooled by the fact that only one form has C<flags> in its name. They +all have a C<flags> parameter in fact, and all the flag bits have the same +meanings for all + +If any of the flags C<GV_ADD>, C<GV_ADDMG>, C<GV_ADDWARN>, C<GV_ADDMULTI>, or +C<GV_NOINIT> is set, a GV is created if none already exists for the input name +and type. However, C<GV_ADDMG> will only do the creation for magical GV's. +For all of these flags except C<GV_NOINIT>, C<L</gv_init_pvn>> is called after +the addition. C<GV_ADDWARN> is used when the caller expects that adding won't +be necessary because the symbol should already exist; but if not, add it +anyway, with a warning that it was unexpectedly absent. The C<GV_ADDMULTI> +flag means to pretend that the GV has been seen before (I<i.e.>, suppress "Used +once" warnings). + +The flag C<GV_NOADD_NOINIT> causes C<L</gv_init_pvn>> not be to called if the +GV existed but isn't PVGV. + +If the C<SVf_UTF8> bit is set, the name is treated as being encoded in UTF-8; +otherwise the name won't be considered to be UTF-8 in the C<pv>-named forms, +and the UTF-8ness of the underlying SVs will be used in the C<sv> forms. + +If the flag C<GV_NOTQUAL> is set, the caller warrants that the input name is a +plain symbol name, not qualified with a package, otherwise the name is checked +for being a qualified one. + +In C<gv_fetchpv>, C<nambeg> is a C string, NUL-terminated with no intermediate +NULs. + +In C<gv_fetchpvs>, C<name> is a literal C string, hence is enclosed in +double quotes. + +C<gv_fetchpvn> and C<gv_fetchpvn_flags> are identical. In these, <nambeg> is +a Perl string whose byte length is given by C<full_len>, and may contain +embedded NULs. + +In C<gv_fetchsv> and C<gv_fetchsv_nomg>, the name is extracted from the PV of +the input C<name> SV. The only difference between these two forms is that +'get' magic is normally done on C<name> in C<gv_fetchsv>, and always skipped +with C<gv_fetchsv_nomg>. Including C<GV_NO_SVGMAGIC> in the C<flags> parameter +to C<gv_fetchsv> makes it behave identically to C<gv_fetchsv_nomg>. + +=for apidoc Amnh||GV_ADD +=for apidoc Amnh||GV_ADDMG +=for apidoc Amnh||GV_ADDMULTI +=for apidoc Amnh||GV_ADDWARN +=for apidoc Amnh||GV_NOADD_NOINIT +=for apidoc Amnh||GV_NOINIT +=for apidoc Amnh||GV_NOTQUAL +=for apidoc Amnh||GV_NO_SVGMAGIC +=for apidoc Amnh||SVf_UTF8 + +=cut +*/ + GV * Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, const svtype sv_type) |