📄 perlapi.pod
字号:
=head1 NAMEperlapi - autogenerated documentation for the perl public API=head1 DESCRIPTIONThis file contains the documentation of the perl public API generated by embed.pl, specifically a listing of functions, macros, flags, and variables that may be used by extension writers. The interfaces of any functions that are not listed here are subject to change without notice. For this reason,blindly using functions listed in proto.h is to be avoided when writingextensions.Note that all Perl API global variables must be referenced with the C<PL_>prefix. Some macros are provided for compatibility with the older,unadorned names, but this support may be disabled in a future release.The listing is alphabetical, case insensitive.=over 8=item AvFILLSame as C<av_len()>. Deprecated, use C<av_len()> instead. int AvFILL(AV* av)=for hackersFound in file av.h=item av_clearClears an array, making it empty. Does not free the memory used by thearray itself. void av_clear(AV* ar)=for hackersFound in file av.c=item av_deleteDeletes the element indexed by C<key> from the array. Returns thedeleted element. C<flags> is currently ignored. SV* av_delete(AV* ar, I32 key, I32 flags)=for hackersFound in file av.c=item av_existsReturns true if the element indexed by C<key> has been initialized.This relies on the fact that uninitialized array elements are set toC<&PL_sv_undef>. bool av_exists(AV* ar, I32 key)=for hackersFound in file av.c=item av_extendPre-extend an array. The C<key> is the index to which the array should beextended. void av_extend(AV* ar, I32 key)=for hackersFound in file av.c=item av_fetchReturns the SV at the specified index in the array. The C<key> is theindex. If C<lval> is set then the fetch will be part of a store. Checkthat the return value is non-null before dereferencing it to a C<SV*>.See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> formore information on how to use this function on tied arrays. SV** av_fetch(AV* ar, I32 key, I32 lval)=for hackersFound in file av.c=item av_fillEnsure than an array has a given number of elements, equivalent toPerl's C<$#array = $fill;>. void av_fill(AV* ar, I32 fill)=for hackersFound in file av.c=item av_lenReturns the highest index in the array. Returns -1 if the array isempty. I32 av_len(AV* ar)=for hackersFound in file av.c=item av_makeCreates a new AV and populates it with a list of SVs. The SVs are copiedinto the array, so they may be freed after the call to av_make. The new AVwill have a reference count of 1. AV* av_make(I32 size, SV** svp)=for hackersFound in file av.c=item av_popPops an SV off the end of the array. Returns C<&PL_sv_undef> if the arrayis empty. SV* av_pop(AV* ar)=for hackersFound in file av.c=item av_pushPushes an SV onto the end of the array. The array will grow automaticallyto accommodate the addition. void av_push(AV* ar, SV* val)=for hackersFound in file av.c=item av_shiftShifts an SV off the beginning of the array. SV* av_shift(AV* ar)=for hackersFound in file av.c=item av_storeStores an SV in an array. The array index is specified as C<key>. Thereturn value will be NULL if the operation failed or if the value did notneed to be actually stored within the array (as in the case of tiedarrays). Otherwise it can be dereferenced to get the original C<SV*>. Notethat the caller is responsible for suitably incrementing the referencecount of C<val> before the call, and decrementing it if the functionreturned NULL.See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> formore information on how to use this function on tied arrays. SV** av_store(AV* ar, I32 key, SV* val)=for hackersFound in file av.c=item av_undefUndefines the array. Frees the memory used by the array itself. void av_undef(AV* ar)=for hackersFound in file av.c=item av_unshiftUnshift the given number of C<undef> values onto the beginning of thearray. The array will grow automatically to accommodate the addition. Youmust then use C<av_store> to assign values to these new elements. void av_unshift(AV* ar, I32 num)=for hackersFound in file av.c=item bytes_from_utf8Converts a string C<s> of length C<len> from UTF8 into byte encoding.Unlike <utf8_to_bytes> but like C<bytes_to_utf8>, returns a pointer tothe newly-created string, and updates C<len> to contain the newlength. Returns the original string if no conversion occurs, C<len>is unchanged. Do nothing if C<is_utf8> points to 0. Sets C<is_utf8> to0 if C<s> is converted or contains all 7bit characters.NOTE: this function is experimental and may change or beremoved without notice. U8* bytes_from_utf8(U8 *s, STRLEN *len, bool *is_utf8)=for hackersFound in file utf8.c=item bytes_to_utf8Converts a string C<s> of length C<len> from ASCII into UTF8 encoding.Returns a pointer to the newly-created string, and sets C<len> toreflect the new length.NOTE: this function is experimental and may change or beremoved without notice. U8* bytes_to_utf8(U8 *s, STRLEN *len)=for hackersFound in file utf8.c=item call_argvPerforms a callback to the specified Perl sub. See L<perlcall>.NOTE: the perl_ form of this function is deprecated. I32 call_argv(const char* sub_name, I32 flags, char** argv)=for hackersFound in file perl.c=item call_methodPerforms a callback to the specified Perl method. The blessed object mustbe on the stack. See L<perlcall>.NOTE: the perl_ form of this function is deprecated. I32 call_method(const char* methname, I32 flags)=for hackersFound in file perl.c=item call_pvPerforms a callback to the specified Perl sub. See L<perlcall>.NOTE: the perl_ form of this function is deprecated. I32 call_pv(const char* sub_name, I32 flags)=for hackersFound in file perl.c=item call_svPerforms a callback to the Perl sub whose name is in the SV. SeeL<perlcall>.NOTE: the perl_ form of this function is deprecated. I32 call_sv(SV* sv, I32 flags)=for hackersFound in file perl.c=item CLASSVariable which is setup by C<xsubpp> to indicate the class name for a C++ XS constructor. This is always a C<char*>. See C<THIS>. char* CLASS=for hackersFound in file XSUB.h=item CopyThe XSUB-writer's interface to the C C<memcpy> function. The C<src> is thesource, C<dest> is the destination, C<nitems> is the number of items, and C<type> isthe type. May fail on overlapping copies. See also C<Move>. void Copy(void* src, void* dest, int nitems, type)=for hackersFound in file handy.h=item croakThis is the XSUB-writer's interface to Perl's C<die> function.Normally use this function the same way you use the C C<printf>function. See C<warn>.If you want to throw an exception object, assign the object toC<$@> and then pass C<Nullch> to croak(): errsv = get_sv("@", TRUE); sv_setsv(errsv, exception_object); croak(Nullch); void croak(const char* pat, ...)=for hackersFound in file util.c=item CvSTASHReturns the stash of the CV. HV* CvSTASH(CV* cv)=for hackersFound in file cv.h=item dMARKDeclare a stack marker variable, C<mark>, for the XSUB. See C<MARK> andC<dORIGMARK>. dMARK;=for hackersFound in file pp.h=item dORIGMARKSaves the original stack mark for the XSUB. See C<ORIGMARK>. dORIGMARK;=for hackersFound in file pp.h=item dSPDeclares a local copy of perl's stack pointer for the XSUB, available viathe C<SP> macro. See C<SP>. dSP;=for hackersFound in file pp.h=item dXSARGSSets up stack and mark pointers for an XSUB, calling dSP and dMARK. Thisis usually handled automatically by C<xsubpp>. Declares the C<items>variable to indicate the number of items on the stack. dXSARGS;=for hackersFound in file XSUB.h=item dXSI32Sets up the C<ix> variable for an XSUB which has aliases. This is usuallyhandled automatically by C<xsubpp>. dXSI32;=for hackersFound in file XSUB.h=item ENTEROpening bracket on a callback. See C<LEAVE> and L<perlcall>. ENTER;=for hackersFound in file scope.h=item eval_pvTells Perl to C<eval> the given string and return an SV* result.NOTE: the perl_ form of this function is deprecated. SV* eval_pv(const char* p, I32 croak_on_error)=for hackersFound in file perl.c=item eval_svTells Perl to C<eval> the string in the SV.NOTE: the perl_ form of this function is deprecated. I32 eval_sv(SV* sv, I32 flags)=for hackersFound in file perl.c=item EXTENDUsed to extend the argument stack for an XSUB's return values. Onceused, guarantees that there is room for at least C<nitems> to be pushedonto the stack. void EXTEND(SP, int nitems)=for hackersFound in file pp.h=item fbm_compileAnalyses the string in order to make fast searches on it using fbm_instr()-- the Boyer-Moore algorithm. void fbm_compile(SV* sv, U32 flags)=for hackersFound in file util.c=item fbm_instrReturns the location of the SV in the string delimited by C<str> andC<strend>. It returns C<Nullch> if the string can't be found. The C<sv>does not have to be fbm_compiled, but the search will not be as fastthen. char* fbm_instr(unsigned char* big, unsigned char* bigend, SV* littlesv, U32 flags)=for hackersFound in file util.c=item FREETMPSClosing bracket for temporaries on a callback. See C<SAVETMPS> andL<perlcall>. FREETMPS;=for hackersFound in file scope.h=item get_avReturns the AV of the specified Perl array. If C<create> is set and thePerl variable does not exist then it will be created. If C<create> is notset and the variable does not exist then NULL is returned.NOTE: the perl_ form of this function is deprecated. AV* get_av(const char* name, I32 create)=for hackersFound in file perl.c=item get_cvReturns the CV of the specified Perl subroutine. If C<create> is set andthe Perl subroutine does not exist then it will be declared (which has thesame effect as saying C<sub name;>). If C<create> is not set and thesubroutine does not exist then NULL is returned.NOTE: the perl_ form of this function is deprecated. CV* get_cv(const char* name, I32 create)=for hackersFound in file perl.c=item get_hvReturns the HV of the specified Perl hash. If C<create> is set and thePerl variable does not exist then it will be created. If C<create> is notset and the variable does not exist then NULL is returned.NOTE: the perl_ form of this function is deprecated. HV* get_hv(const char* name, I32 create)=for hackersFound in file perl.c=item get_svReturns the SV of the specified Perl scalar. If C<create> is set and thePerl variable does not exist then it will be created. If C<create> is notset and the variable does not exist then NULL is returned.NOTE: the perl_ form of this function is deprecated. SV* get_sv(const char* name, I32 create)=for hackersFound in file perl.c=item GIMMEA backward-compatible version of C<GIMME_V> which can only returnC<G_SCALAR> or C<G_ARRAY>; in a void context, it returns C<G_SCALAR>.Deprecated. Use C<GIMME_V> instead. U32 GIMME=for hackersFound in file op.h=item GIMME_VThe XSUB-writer's equivalent to Perl's C<wantarray>. Returns C<G_VOID>,C<G_SCALAR> or C<G_ARRAY> for void, scalar or list context,respectively. U32 GIMME_V=for hackersFound in file op.h=item GvSVReturn the SV from the GV. SV* GvSV(GV* gv)=for hackersFound in file gv.h=item gv_fetchmethReturns the glob with the given C<name> and a defined subroutine orC<NULL>. The glob lives in the given C<stash>, or in the stashesaccessible via @ISA and @UNIVERSAL.The argument C<level> should be either 0 or -1. If C<level==0>, as aside-effect creates a glob with the given C<name> in the given C<stash>which in the case of success contains an alias for the subroutine, and setsup caching info for this glob. Similarly for all the searched stashes.This function grants C<"SUPER"> token as a postfix of the stash name. TheGV returned from C<gv_fetchmeth> may be a method cache entry, which is notvisible to Perl code. So when calling C<call_sv>, you should not usethe GV directly; instead, you should use the method's CV, which can beobtained from the GV with the C<GvCV> macro. GV* gv_fetchmeth(HV* stash, const char* name, STRLEN len, I32 level)=for hackersFound in file gv.c=item gv_fetchmethodSee L<gv_fetchmethod_autoload>. GV* gv_fetchmethod(HV* stash, const char* name)=for hackersFound in file gv.c=item gv_fetchmethod_autoloadReturns the glob which contains the subroutine to call to invoke the methodon the C<stash>. In fact in the presence of autoloading this may be theglob for "AUTOLOAD". In this case the corresponding variable $AUTOLOAD isalready setup.The third parameter of C<gv_fetchmethod_autoload> determines whetherAUTOLOAD lookup is performed if the given method is not present: non-zeromeans yes, look for AUTOLOAD; zero means no, don't look for AUTOLOAD.Calling C<gv_fetchmethod> is equivalent to calling C<gv_fetchmethod_autoload>with a non-zero C<autoload> parameter.These functions grant C<"SUPER"> token as a prefix of the method name. Notethat if you want to keep the returned glob for a long time, you need tocheck for it being "AUTOLOAD", since at the later time the call may load adifferent subroutine due to $AUTOLOAD changing its value. Use the globcreated via a side effect to do this.These functions have the same side-effects and as C<gv_fetchmeth> withC<level==0>. C<name> should be writable if contains C<':'> or C<'''>. The warning against passing the GV returned by C<gv_fetchmeth> toC<call_sv> apply equally to these functions. GV* gv_fetchmethod_autoload(HV* stash, const char* name, I32 autoload)=for hackersFound in file gv.c=item gv_stashpvReturns a pointer to the stash for a specified package. C<name> shouldbe a valid UTF-8 string. If C<create> is set then the package will becreated if it does not already exist. If C<create> is not set and thepackage does not exist then NULL is returned. HV* gv_stashpv(const char* name, I32 create)=for hackersFound in file gv.c=item gv_stashsvReturns a pointer to the stash for a specified package, which must be avalid UTF-8 string. See C<gv_stashpv>. HV* gv_stashsv(SV* sv, I32 create)=for hackersFound in file gv.c=item G_ARRAYUsed to indicate list context. See C<GIMME_V>, C<GIMME> andL<perlcall>.=for hackersFound in file cop.h=item G_DISCARDIndicates that arguments returned from a callback should be discarded. SeeL<perlcall>.=for hackersFound in file cop.h=item G_EVALUsed to force a Perl C<eval> wrapper around a callback. SeeL<perlcall>.=for hackersFound in file cop.h=item G_NOARGSIndicates that no arguments are being sent to a callback. SeeL<perlcall>.=for hackersFound in file cop.h=item G_SCALARUsed to indicate scalar context. See C<GIMME_V>, C<GIMME>, andL<perlcall>.=for hackersFound in file cop.h=item G_VOIDUsed to indicate void context. See C<GIMME_V> and L<perlcall>.=for hackers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -