Skip to content

Commit

Permalink
perlapi: Fold in gv_autoload4 to gv_autoload_pv group
Browse files Browse the repository at this point in the history
And correct some of the misleading documentation previously there
  • Loading branch information
khwilliamson committed Jul 11, 2024
1 parent 1b7e058 commit f651c04
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
4 changes: 0 additions & 4 deletions embed.fnc
Original file line number Diff line number Diff line change
Expand Up @@ -1291,10 +1291,6 @@ Adp |GV * |gv_add_by_type |NULLOK GV *gv \
|svtype type
Adp |int |Gv_AMupdate |NN HV *stash \
|bool destructing
ARdm |GV * |gv_autoload4 |NULLOK HV *stash \
|NN const char *name \
|STRLEN len \
|I32 method
ARdp |GV * |gv_autoload_pv |NULLOK HV *stash \
|NN const char *namepv \
|U32 flags
Expand Down
31 changes: 24 additions & 7 deletions gv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1296,34 +1296,51 @@ Perl_gv_fetchmethod_pvn_flags(pTHX_ HV *stash, const char *name, const STRLEN le
return gv;
}


/*
=for apidoc gv_autoload_pv
=for apidoc_item gv_autoload_pvn
=for apidoc_item gv_autoload_sv
=for apidoc_item gv_autoload4
These each search for an C<AUTOLOAD> method, returning NULL if not found, or
else returning a pointer to its GV, while setting the package
L<C<$AUTOLOAD>|perlobj/AUTOLOAD> variable to C<name> (fully qualified). Also,
if found and the GV's CV is an XSUB, the CV's PV will be set to C<name>, and
L<C<$AUTOLOAD>|perlobj/AUTOLOAD> variable to the name (fully qualified). Also,
if found and the GV's CV is an XSUB, the CV's PV will be set to the name, and
its stash will be set to the stash of the GV.
Searching is done in L<C<MRO> order|perlmroapi>, as specified in
L</C<gv_fetchmeth>>, beginning with C<stash> if it isn't NULL.
The forms differ only in how C<name> is specified.
C<gv_autoload4>) has a C<method> parameter; the others a C<flags> one (both
types explained below). Otherwise, the forms differ only in how the name is
specified.
In C<gv_autoload_pv>, C<namepv> is a C language NUL-terminated string.
In C<gv_autoload_pvn>, C<name> points to the first byte of the name, and an
additional parameter, C<len>, specifies its length in bytes. Hence, C<*name>
may contain embedded-NUL characters.
In C<gv_autoload_pvn> and C<gv_autoload4>), C<name> points to the first byte of
the name, and an additional parameter, C<len>, specifies its length in bytes.
Hence, C<*name> may contain embedded-NUL characters.
In C<gv_autoload_sv>, C<*namesv> is an SV, and the name is the PV extracted
from that using L</C<SvPV>>. If the SV is marked as being in UTF-8, the
extracted PV will also be.
The other way to indicate that the name is encoded as UTF-8 is to set the
C<SVf_UTF8> bit in C<flags> for the forms that have that parameter.
The name is never considered to be UTF-8 in C<gv_autoload4>.
The C<method> parameter in C<gv_autoload4> is used only to indicate that the
name is for a method (non-zero), or not (zero). The other forms use the
C<GV_AUTOLOAD_ISMETHOD> bit in C<flags> to indicate this.
The only other significant value in C<flags> currently is C<GV_SUPER>
to indicate, if set, to skip searching for the name in C<stash>.
=cut
=for apidoc Amnh||GV_AUTOLOAD_ISMETHOD
=for apidoc Amnh||SVf_UTF8
=for apidoc Amnh||GV_SUPER
*/

GV*
Expand Down
8 changes: 4 additions & 4 deletions gv.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ Return the CV from the GV.
#define GV_NOUNIVERSAL 0x2000 /* Skip UNIVERSAL lookup */

/* Flags for gv_autoload_*/
#define GV_AUTOLOAD_ISMETHOD 1 /* autoloading a method? */
#define GV_AUTOLOAD_ISMETHOD 1 /* autoloading a method? gv_autoload4 will
break if this is changed from being 1 */

/* SVf_UTF8 (more accurately the return value from SvUTF8) is also valid
as a flag to various gv_* functions, so ensure it lies
Expand All @@ -289,10 +290,9 @@ Return the CV from the GV.
#define gv_fetchmethod_flags(stash,name,flags) gv_fetchmethod_pv_flags(stash, name, flags)

/*
=for apidoc gv_autoload4
Equivalent to C<L</gv_autoload_pvn>>.
=for apidoc_defn ARdp|GV *|gv_autoload4|NULLOK HV *stash|NN const char *name|STRLEN len|I32 method
=cut
*/
#define gv_autoload4(stash, name, len, autoload) \
gv_autoload_pvn(stash, name, len, cBOOL(autoload))
Expand Down
4 changes: 0 additions & 4 deletions proto.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f651c04

Please sign in to comment.