perlapi - autogenerated documentation for the perl public API
Note that all Perl API global variables must be referenced with the "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.
U32 GIMME
U32 GIMME_V
int AvFILL(AV* av)
void av_clear(AV* ar)
SV* av_delete(AV* ar, I32 key, I32 flags)
This relies on the fact that uninitialized array elements are set to &PL_sv_undef.
bool av_exists(AV* ar, I32 key)
void av_extend(AV* ar, I32 key)
See ``Understanding the Magic of Tied Hashes and Arrays'' in perlguts for more information on how to use this function on tied arrays.
SV** av_fetch(AV* ar, I32 key, I32 lval)
void av_fill(AV* ar, I32 fill)
I32 av_len(AV* ar)
AV* av_make(I32 size, SV** svp)
SV* av_pop(AV* ar)
void av_push(AV* ar, SV* val)
SV* av_shift(AV* ar)
See ``Understanding the Magic of Tied Hashes and Arrays'' in perlguts for more information on how to use this function on tied arrays.
SV** av_store(AV* ar, I32 key, SV* val)
void av_undef(AV* ar)
void av_unshift(AV* ar, I32 num)
NOTE: the perl_ form of this function is deprecated.
AV* get_av(const char* name, I32 create)
AV* newAV()
sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale);
See lib/sort.pm for details about controlling the sorting algorithm.
void sortsv(SV** array, size_t num_elts, SVCOMPARE_t cmp)
NOTE: the perl_ form of this function is deprecated.
I32 call_argv(const char* sub_name, I32 flags, char** argv)
NOTE: the perl_ form of this function is deprecated.
I32 call_method(const char* methname, I32 flags)
NOTE: the perl_ form of this function is deprecated.
I32 call_pv(const char* sub_name, I32 flags)
NOTE: the perl_ form of this function is deprecated.
I32 call_sv(SV* sv, I32 flags)
ENTER;
NOTE: the perl_ form of this function is deprecated.
SV* eval_pv(const char* p, I32 croak_on_error)
NOTE: the perl_ form of this function is deprecated.
I32 eval_sv(SV* sv, I32 flags)
FREETMPS;
LEAVE;
SAVETMPS;
bool isALNUM(char ch)
bool isALPHA(char ch)
bool isDIGIT(char ch)
bool isLOWER(char ch)
bool isSPACE(char ch)
bool isUPPER(char ch)
char toLOWER(char ch)
char toUPPER(char ch)
perl_clone takes these flags as parameters:
CLONEf_COPY_STACKS - is used to, well, copy the stacks also, without it we only clone the data and zero the stacks, with it we copy the stacks and the new perl interpreter is ready to run at the exact same point as the previous one. The pseudo-fork code uses COPY_STACKS while the threads->new doesn't.
CLONEf_KEEP_PTR_TABLE perl_clone keeps a ptr_table with the pointer of the old variable as a key and the new variable as a value, this allows it to check if something has been cloned and not clone it again but rather just use the value and increase the refcount. If KEEP_PTR_TABLE is not set then perl_clone will kill the ptr_table using the function "ptr_table_free(PL_ptr_table); PL_ptr_table = NULL;", reason to keep it around is if you want to dup some of your own variable who are outside the graph perl scans, example of this code is in threads.xs create
CLONEf_CLONE_HOST This is a win32 thing, it is ignored on unix, it tells perls win32host code (which is c++) to clone itself, this is needed on win32 if you want to run two threads at the same time, if you just want to do some stuff in a separate perl interpreter and then throw it away and return to the original one, you don't need to do anything.
PerlInterpreter* perl_clone(PerlInterpreter* interp, UV flags)
HV* CvSTASH(CV* cv)
NOTE: the perl_ form of this function is deprecated.
CV* get_cv(const char* name, I32 create)
void cv_undef(CV* cv)
void load_module(U32 flags, SV* name, SV* ver, ...)
int nothreadhook()
PerlInterpreter* perl_alloc()
void perl_construct(PerlInterpreter* interp)
int perl_destruct(PerlInterpreter* interp)
void perl_free(PerlInterpreter* interp)
int perl_parse(PerlInterpreter* interp, XSINIT_t xsinit, int argc, char** argv, char** env)
int perl_run(PerlInterpreter* interp)
NOTE: the perl_ form of this function is deprecated.
void require_pv(const char* pv)
void packlist(SV *cat, char *pat, char *patend, SV **beglist, SV **endlist)
void pack_cat(SV *cat, char *pat, char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
I32 unpackstring(char *pat, char *patend, char *s, char *strend, U32 flags)
I32 unpack_str(char *pat, char *patend, char *s, char *strbeg, char *strend, char **new_s, I32 ocnt, U32 flags)
HV* PL_modglobal
STRLEN PL_na
SV PL_sv_no
SV PL_sv_undef
SV PL_sv_yes
SV* GvSV(GV* gv)
The argument "level" should be either 0 or -1. If "level==0", as a side-effect creates a glob with the given "name" in the given "stash" which in the case of success contains an alias for the subroutine, and sets up caching info for this glob. Similarly for all the searched stashes.
This function grants "SUPER" token as a postfix of the stash name. The GV returned from "gv_fetchmeth" may be a method cache entry, which is not visible to Perl code. So when calling "call_sv", you should not use the GV directly; instead, you should use the method's CV, which can be obtained from the GV with the "GvCV" macro.
GV* gv_fetchmeth(HV* stash, const char* name, STRLEN len, I32 level)
GV* gv_fetchmethod(HV* stash, const char* name)
The third parameter of "gv_fetchmethod_autoload" determines whether AUTOLOAD lookup is performed if the given method is not present: non-zero means yes, look for AUTOLOAD; zero means no, don't look for AUTOLOAD. Calling "gv_fetchmethod" is equivalent to calling "gv_fetchmethod_autoload" with a non-zero "autoload" parameter.
These functions grant "SUPER" token as a prefix of the method name. Note that if you want to keep the returned glob for a long time, you need to check for it being ``AUTOLOAD'', since at the later time the call may load a different subroutine due to $AUTOLOAD changing its value. Use the glob created via a side effect to do this.
These functions have the same side-effects and as "gv_fetchmeth" with "level==0". "name" should be writable if contains ':' or "' ''". The warning against passing the GV returned by "gv_fetchmeth" to "call_sv" apply equally to these functions.
GV* gv_fetchmethod_autoload(HV* stash, const char* name, I32 autoload)
For an autoloaded subroutine without a GV, will create a GV even if "level < 0". For an autoloaded subroutine without a stub, GvCV() of the result may be zero.
GV* gv_fetchmeth_autoload(HV* stash, const char* name, STRLEN len, I32 level)
HV* gv_stashpv(const char* name, I32 create)
HV* gv_stashpvn(const char* name, U32 namelen, I32 create)
HV* gv_stashsv(SV* sv, I32 create)
NOTE: the perl_ form of this function is deprecated.
HV* get_hv(const char* name, I32 create)
U32 HeHASH(HE* he)
void* HeKEY(HE* he)
STRLEN HeKLEN(HE* he)
char* HePV(HE* he, STRLEN len)
SV* HeSVKEY(HE* he)
SV* HeSVKEY_force(HE* he)
SV* HeSVKEY_set(HE* he, SV* sv)
SV* HeVAL(HE* he)
char* HvNAME(HV* stash)
void hv_clear(HV* tb)
void hv_clear_placeholders(HV* hb)
SV* hv_delete(HV* tb, const char* key, I32 klen, I32 flags)
SV* hv_delete_ent(HV* tb, SV* key, I32 flags, U32 hash)
bool hv_exists(HV* tb, const char* key, I32 klen)
bool hv_exists_ent(HV* tb, SV* key, U32 hash)
See ``Understanding the Magic of Tied Hashes and Arrays'' in perlguts for more information on how to use this function on tied hashes.
SV** hv_fetch(HV* tb, const char* key, I32 klen, I32 lval)
See ``Understanding the Magic of Tied Hashes and Arrays'' in perlguts for more information on how to use this function on tied hashes.
HE* hv_fetch_ent(HV* tb, SV* key, I32 lval, U32 hash)
NOTE: Before version 5.004_65, "hv_iterinit" used to return the number of hash buckets that happen to be in use. If you still need that esoteric value, you can get it through the macro "HvFILL(tb)".
I32 hv_iterinit(HV* tb)
char* hv_iterkey(HE* entry, I32* retlen)
SV* hv_iterkeysv(HE* entry)
You may call "hv_delete" or "hv_delete_ent" on the hash entry that the iterator currently points to, without losing your place or invalidating your iterator. Note that in this case the current entry is deleted from the hash with your iterator holding the last reference to it. Your iterator is flagged to free the entry on the next call to "hv_iternext", so you must not discard your iterator immediately else the entry will leak - call "hv_iternext" to trigger the resource deallocation.
HE* hv_iternext(HV* tb)
SV* hv_iternextsv(HV* hv, char** key, I32* retlen)
NOTE: this function is experimental and may change or be removed without notice.
HE* hv_iternext_flags(HV* tb, I32 flags)
SV* hv_iterval(HV* tb, HE* entry)
void hv_magic(HV* hv, GV* gv, int how)
SV* hv_scalar(HV* hv)
See ``Understanding the Magic of Tied Hashes and Arrays'' in perlguts for more information on how to use this function on tied hashes.
SV** hv_store(HV* tb, const char* key, I32 klen, SV* val, U32 hash)
See ``Understanding the Magic of Tied Hashes and Arrays'' in perlguts for more information on how to use this function on tied hashes.
HE* hv_store_ent(HV* tb, SV* key, SV* val, U32 hash)
void hv_undef(HV* tb)
HV* newHV()
int mg_clear(SV* sv)
int mg_copy(SV* sv, SV* nsv, const char* key, I32 klen)
MAGIC* mg_find(SV* sv, int type)
int mg_free(SV* sv)
int mg_get(SV* sv)
U32 mg_length(SV* sv)
void mg_magical(SV* sv)
int mg_set(SV* sv)
void SvGETMAGIC(SV* sv)
void SvLOCK(SV* sv)
void SvSETMAGIC(SV* sv)
void SvSetMagicSV(SV* dsb, SV* ssv)
void SvSetMagicSV_nosteal(SV* dsv, SV* ssv)
void SvSetSV(SV* dsb, SV* ssv)
void SvSetSV_nosteal(SV* dsv, SV* ssv)
void SvSHARE(SV* sv)
void SvUNLOCK(SV* sv)
void Copy(void* src, void* dest, int nitems, type)
void * CopyD(void* src, void* dest, int nitems, type)
void Move(void* src, void* dest, int nitems, type)
void * MoveD(void* src, void* dest, int nitems, type)
void Newx(void* ptr, int nitems, type)
void Newxc(void* ptr, int nitems, type, cast)
In 5.9.3, we removed the 1st parameter, a debug aid, from the api. It was used to uniquely identify each usage of these allocation functions, but was deemed unnecessary with the availability of better memory tracking tools, valgrind for example.
void Newxz(void* ptr, int nitems, type)
void Poison(void* dest, int nitems, type)
void Renew(void* ptr, int nitems, type)
void Renewc(void* ptr, int nitems, type, cast)
void Safefree(void* ptr)
char* savepv(const char* pv)
char* savepvn(const char* pv, I32 len)
char* savesharedpv(const char* pv)
char* savesvpv(SV* sv)
void StructCopy(type src, type dest, type)
void Zero(void* dest, int nitems, type)
void * ZeroD(void* dest, int nitems, type)
void fbm_compile(SV* sv, U32 flags)
char* fbm_instr(unsigned char* big, unsigned char* bigend, SV* littlesv, U32 flags)
(char *) Perl_form(pTHX_ const char* pat, ...)
can be used any place a string (char *) is required:
char * s = Perl_form("%d.%d",major,minor);
Uses a single private buffer so if you want to format several strings you must explicitly copy the earlier strings away (and free the copies when you are done).
char* form(const char* pat, ...)
int getcwd_sv(SV* sv)
bool strEQ(char* s1, char* s2)
bool strGE(char* s1, char* s2)
bool strGT(char* s1, char* s2)
bool strLE(char* s1, char* s2)
bool strLT(char* s1, char* s2)
bool strNE(char* s1, char* s2)
bool strnEQ(char* s1, char* s2, STRLEN len)
bool strnNE(char* s1, char* s2, STRLEN len)
void sv_nolocking(SV *)
void sv_nosharing(SV *)
void sv_nounlocking(SV *)
On entry start and *len give the string to scan, *flags gives conversion flags, and result should be NULL or a pointer to an NV. The scan stops at the end of the string, or the first invalid character. Unless "PERL_SCAN_SILENT_ILLDIGIT" is set in *flags, encountering an invalid character will also trigger a warning. On return *len is set to the length of the scanned string, and *flags gives output flags.
If the value is <= "UV_MAX" it is returned as a UV, the output flags are clear, and nothing is written to *result. If the value is > UV_MAX "grok_bin" returns UV_MAX, sets "PERL_SCAN_GREATER_THAN_UV_MAX" in the output flags, and writes the value to *result (or the value is discarded if result is NULL).
The binary number may optionally be prefixed with ``0b'' or ``b'' unless "PERL_SCAN_DISALLOW_PREFIX" is set in *flags on entry. If "PERL_SCAN_ALLOW_UNDERSCORES" is set in *flags then the binary number may use '_' characters to separate digits.
UV grok_bin(char* start, STRLEN* len, I32* flags, NV *result)
On entry start and *len give the string to scan, *flags gives conversion flags, and result should be NULL or a pointer to an NV. The scan stops at the end of the string, or the first invalid character. Unless "PERL_SCAN_SILENT_ILLDIGIT" is set in *flags, encountering an invalid character will also trigger a warning. On return *len is set to the length of the scanned string, and *flags gives output flags.
If the value is <= UV_MAX it is returned as a UV, the output flags are clear, and nothing is written to *result. If the value is > UV_MAX "grok_hex" returns UV_MAX, sets "PERL_SCAN_GREATER_THAN_UV_MAX" in the output flags, and writes the value to *result (or the value is discarded if result is NULL).
The hex number may optionally be prefixed with ``0x'' or ``x'' unless "PERL_SCAN_DISALLOW_PREFIX" is set in *flags on entry. If "PERL_SCAN_ALLOW_UNDERSCORES" is set in *flags then the hex number may use '_' characters to separate digits.
UV grok_hex(char* start, STRLEN* len, I32* flags, NV *result)
If the value of the number can fit an in UV, it is returned in the *valuep IS_NUMBER_IN_UV will be set to indicate that *valuep is valid, IS_NUMBER_IN_UV will never be set unless *valuep is valid, but *valuep may have been assigned to during processing even though IS_NUMBER_IN_UV is not set on return. If valuep is NULL, IS_NUMBER_IN_UV will be set for the same cases as when valuep is non-NULL, but no actual assignment (or SEGV) will occur.
IS_NUMBER_NOT_INT will be set with IS_NUMBER_IN_UV if trailing decimals were seen (in which case *valuep gives the true value truncated to an integer), and IS_NUMBER_NEG if the number is negative (in which case *valuep holds the absolute value). IS_NUMBER_IN_UV is not set if e notation was used or the number is larger than a UV.
int grok_number(const char *pv, STRLEN len, UV *valuep)
bool grok_numeric_radix(const char **sp, const char *send)
On entry start and *len give the string to scan, *flags gives conversion flags, and result should be NULL or a pointer to an NV. The scan stops at the end of the string, or the first invalid character. Unless "PERL_SCAN_SILENT_ILLDIGIT" is set in *flags, encountering an invalid character will also trigger a warning. On return *len is set to the length of the scanned string, and *flags gives output flags.
If the value is <= UV_MAX it is returned as a UV, the output flags are clear, and nothing is written to *result. If the value is > UV_MAX "grok_oct" returns UV_MAX, sets "PERL_SCAN_GREATER_THAN_UV_MAX" in the output flags, and writes the value to *result (or the value is discarded if result is NULL).
If "PERL_SCAN_ALLOW_UNDERSCORES" is set in *flags then the octal number may use '_' characters to separate digits.
UV grok_oct(char* start, STRLEN* len_p, I32* flags, NV *result)
NV scan_bin(char* start, STRLEN len, STRLEN* retlen)
NV scan_hex(char* start, STRLEN len, STRLEN* retlen)
NV scan_oct(char* start, STRLEN len, STRLEN* retlen)
Constant subs can be created with "newCONSTSUB" or as described in ``Constant Functions'' in perlsub.
SV* cv_const_sv(CV* cv)
CV* newCONSTSUB(HV* stash, char* name, SV* sv)
SV* pad_sv(PADOFFSET po)
dMARK;
dORIGMARK;
dSP;
void EXTEND(SP, int nitems)
void mPUSHi(IV iv)
void mPUSHn(NV nv)
void mPUSHp(char* str, STRLEN len)
void mPUSHu(UV uv)
void mXPUSHi(IV iv)
void mXPUSHn(NV nv)
void mXPUSHp(char* str, STRLEN len)
void mXPUSHu(UV uv)
IV POPi
long POPl
NV POPn
char* POPp
char* POPpbytex
char* POPpx
SV* POPs
void PUSHi(IV iv)
void PUSHMARK(SP)
void PUSHmortal()
void PUSHn(NV nv)
void PUSHp(char* str, STRLEN len)
void PUSHs(SV* sv)
void PUSHu(UV uv)
PUTBACK;
SPAGAIN;
void XPUSHi(IV iv)
void XPUSHmortal()
void XPUSHn(NV nv)
void XPUSHp(char* str, STRLEN len)
void XPUSHs(SV* sv)
void XPUSHu(UV uv)
void XSRETURN(int nitems)
XSRETURN_EMPTY;
void XSRETURN_IV(IV iv)
XSRETURN_NO;
void XSRETURN_NV(NV nv)
void XSRETURN_PV(char* str)
XSRETURN_UNDEF;
void XSRETURN_UV(IV uv)
XSRETURN_YES;
void XST_mIV(int pos, IV iv)
void XST_mNO(int pos)
void XST_mNV(int pos, NV nv)
void XST_mPV(int pos, char* str)
void XST_mUNDEF(int pos)
void XST_mYES(int pos)
NOTE: the perl_ form of this function is deprecated.
SV* get_sv(const char* name, I32 create)
I32 looks_like_number(SV* sv)
SV* newRV_inc(SV* sv)
SV* newRV_noinc(SV *sv)
SV* NEWSV(int id, STRLEN len)
SV* newSV(STRLEN len)
SV* newSVhek(const HEK *hek)
SV* newSViv(IV i)
SV* newSVnv(NV n)
SV* newSVpv(const char* s, STRLEN len)
SV* newSVpvf(const char* pat, ...)
SV* newSVpvn(const char* s, STRLEN len)
SV* newSVpvn_share(const char* s, I32 len, U32 hash)
SV* newSVrv(SV* rv, const char* classname)
SV* newSVsv(SV* old)
SV* newSVuv(UV u)
STRLEN SvCUR(SV* sv)
void SvCUR_set(SV* sv, STRLEN len)
char* SvEND(SV* sv)
char * SvGROW(SV* sv, STRLEN len)
bool SvIOK(SV* sv)
bool SvIOKp(SV* sv)
bool SvIOK_notUV(SV* sv)
void SvIOK_off(SV* sv)
void SvIOK_on(SV* sv)
void SvIOK_only(SV* sv)
void SvIOK_only_UV(SV* sv)
bool SvIOK_UV(SV* sv)
bool SvIsCOW(SV* sv)
bool SvIsCOW_shared_hash(SV* sv)
IV SvIV(SV* sv)
IV SvIVX(SV* sv)
IV SvIVx(SV* sv)
void SvIV_set(SV* sv, IV val)
STRLEN SvLEN(SV* sv)
void SvLEN_set(SV* sv, STRLEN len)
void SvMAGIC_set(SV* sv, MAGIC* val)
bool SvNIOK(SV* sv)
bool SvNIOKp(SV* sv)
void SvNIOK_off(SV* sv)
bool SvNOK(SV* sv)
bool SvNOKp(SV* sv)
void SvNOK_off(SV* sv)
void SvNOK_on(SV* sv)
void SvNOK_only(SV* sv)
NV SvNV(SV* sv)
NV SvNVX(SV* sv)
NV SvNVx(SV* sv)
void SvNV_set(SV* sv, NV val)
bool SvOK(SV* sv)
bool SvOOK(SV* sv)
bool SvPOK(SV* sv)
bool SvPOKp(SV* sv)
void SvPOK_off(SV* sv)
void SvPOK_on(SV* sv)
void SvPOK_only(SV* sv)
void SvPOK_only_UTF8(SV* sv)
char* SvPV(SV* sv, STRLEN len)
char* SvPVbyte(SV* sv, STRLEN len)
char* SvPVbytex(SV* sv, STRLEN len)
char* SvPVbytex_force(SV* sv, STRLEN len)
char* SvPVbyte_force(SV* sv, STRLEN len)
char* SvPVbyte_nolen(SV* sv)
char* SvPVutf8(SV* sv, STRLEN len)
char* SvPVutf8x(SV* sv, STRLEN len)
char* SvPVutf8x_force(SV* sv, STRLEN len)
char* SvPVutf8_force(SV* sv, STRLEN len)
char* SvPVutf8_nolen(SV* sv)
char* SvPVX(SV* sv)
char* SvPVx(SV* sv, STRLEN len)
char* SvPV_force(SV* sv, STRLEN len)
char* SvPV_force_nomg(SV* sv, STRLEN len)
char* SvPV_nolen(SV* sv)
void SvPV_set(SV* sv, char* val)
U32 SvREFCNT(SV* sv)
void SvREFCNT_dec(SV* sv)
SV* SvREFCNT_inc(SV* sv)
bool SvROK(SV* sv)
void SvROK_off(SV* sv)
void SvROK_on(SV* sv)
SV* SvRV(SV* sv)
void SvRV_set(SV* sv, SV* val)
HV* SvSTASH(SV* sv)
void SvSTASH_set(SV* sv, STASH* val)
void SvTAINT(SV* sv)
bool SvTAINTED(SV* sv)
void SvTAINTED_off(SV* sv)
void SvTAINTED_on(SV* sv)
bool SvTRUE(SV* sv)
svtype SvTYPE(SV* sv)
void SvUOK(SV* sv)
void SvUPGRADE(SV* sv, svtype type)
bool SvUTF8(SV* sv)
void SvUTF8_off(SV *sv)
void SvUTF8_on(SV *sv)
UV SvUV(SV* sv)
UV SvUVX(SV* sv)
UV SvUVx(SV* sv)
void SvUV_set(SV* sv, UV val)
bool sv_2bool(SV* sv)
CV* sv_2cv(SV* sv, HV** st, GV** gvp, I32 lref)
IO* sv_2io(SV* sv)
IV sv_2iv(SV* sv)
SV* sv_2mortal(SV* sv)
NV sv_2nv(SV* sv)
Usually accessed via the "SvPVbyte" macro.
char* sv_2pvbyte(SV* sv, STRLEN* lp)
Usually accessed via the "SvPVbyte_nolen" macro.
char* sv_2pvbyte_nolen(SV* sv)
Usually accessed via the "SvPVutf8" macro.
char* sv_2pvutf8(SV* sv, STRLEN* lp)
Usually accessed via the "SvPVutf8_nolen" macro.
char* sv_2pvutf8_nolen(SV* sv)
char* sv_2pv_flags(SV* sv, STRLEN* lp, I32 flags)
UV sv_2uv(SV* sv)
int sv_backoff(SV* sv)
SV* sv_bless(SV* sv, HV* stash)
void sv_catpv(SV* sv, const char* ptr)
void sv_catpvf(SV* sv, const char* pat, ...)
void sv_catpvf_mg(SV *sv, const char* pat, ...)
void sv_catpvn(SV* sv, const char* ptr, STRLEN len)
void sv_catpvn_flags(SV* sv, const char* ptr, STRLEN len, I32 flags)
void sv_catpvn_mg(SV *sv, const char *ptr, STRLEN len)
void sv_catpvn_nomg(SV* sv, const char* ptr, STRLEN len)
void sv_catpv_mg(SV *sv, const char *ptr)
void sv_catsv(SV* dsv, SV* ssv)
void sv_catsv_flags(SV* dsv, SV* ssv, I32 flags)
void sv_catsv_mg(SV *dstr, SV *sstr)
void sv_catsv_nomg(SV* dsv, SV* ssv)
void sv_chop(SV* sv, char* ptr)
void sv_clear(SV* sv)
I32 sv_cmp(SV* sv1, SV* sv2)
I32 sv_cmp_locale(SV* sv1, SV* sv2)
Any scalar variable may carry PERL_MAGIC_collxfrm magic that contains the scalar data of the variable, but transformed to such a format that a normal memory comparison can be used to compare the data according to the locale settings.
char* sv_collxfrm(SV* sv, STRLEN* nxp)
void sv_copypv(SV* dsv, SV* ssv)
void sv_dec(SV* sv)
bool sv_derived_from(SV* sv, const char* name)
I32 sv_eq(SV* sv1, SV* sv2)
void sv_force_normal(SV *sv)
void sv_force_normal_flags(SV *sv, U32 flags)
void sv_free(SV* sv)
char* sv_gets(SV* sv, PerlIO* fp, I32 append)
char* sv_grow(SV* sv, STRLEN newlen)
void sv_inc(SV* sv)
void sv_insert(SV* bigsv, STRLEN offset, STRLEN len, char* little, STRLEN littlelen)
int sv_isa(SV* sv, const char* name)
int sv_isobject(SV* sv)
IV sv_iv(SV* sv)
STRLEN sv_len(SV* sv)
STRLEN sv_len_utf8(SV* sv)
See "sv_magicext" (which "sv_magic" now calls) for a description of the handling of the "name" and "namlen" arguments.
You need to use "sv_magicext" to add magic to SvREADONLY SVs and also to add more than one instance of the same 'how'.
void sv_magic(SV* sv, SV* obj, int how, const char* name, I32 namlen)
Note that "sv_magicext" will allow things that "sv_magic" will not. In particular, you can add magic to SvREADONLY SVs, and add more than one instance of the same 'how'.
If "namlen" is greater than zero then a "savepvn" copy of "name" is stored, if "namlen" is zero then "name" is stored as-is and - as another special case - if "(name && namlen == HEf_SVKEY)" then "name" is assumed to contain an "SV*" and is stored as-is with its REFCNT incremented.
(This is now used as a subroutine by "sv_magic".)
MAGIC * sv_magicext(SV* sv, SV* obj, int how, MGVTBL *vtbl, const char* name, I32 namlen)
SV* sv_mortalcopy(SV* oldsv)
SV* sv_newmortal()
SV* sv_newref(SV* sv)
NV sv_nv(SV* sv)
void sv_pos_b2u(SV* sv, I32* offsetp)
void sv_pos_u2b(SV* sv, I32* offsetp, I32* lenp)
char* sv_pv(SV *sv)
char* sv_pvbyte(SV *sv)
char* sv_pvbyten(SV *sv, STRLEN *len)
char* sv_pvbyten_force(SV* sv, STRLEN* lp)
char* sv_pvn(SV *sv, STRLEN *len)
char* sv_pvn_force(SV* sv, STRLEN* lp)
char* sv_pvn_force_flags(SV* sv, STRLEN* lp, I32 flags)
char* sv_pvutf8(SV *sv)
char* sv_pvutf8n(SV *sv, STRLEN *len)
char* sv_pvutf8n_force(SV* sv, STRLEN* lp)
char* sv_reftype(SV* sv, int ob)
void sv_replace(SV* sv, SV* nsv)
void sv_report_used()
void sv_reset(char* s, HV* stash)
SV* sv_rvweaken(SV *sv)
void sv_setiv(SV* sv, IV num)
void sv_setiv_mg(SV *sv, IV i)
void sv_setnv(SV* sv, NV num)
void sv_setnv_mg(SV *sv, NV num)
void sv_setpv(SV* sv, const char* ptr)
void sv_setpvf(SV* sv, const char* pat, ...)
void sv_setpvf_mg(SV *sv, const char* pat, ...)
void sv_setpviv(SV* sv, IV num)
void sv_setpviv_mg(SV *sv, IV iv)
void sv_setpvn(SV* sv, const char* ptr, STRLEN len)
void sv_setpvn_mg(SV *sv, const char *ptr, STRLEN len)
void sv_setpv_mg(SV *sv, const char *ptr)
SV* sv_setref_iv(SV* rv, const char* classname, IV iv)
SV* sv_setref_nv(SV* rv, const char* classname, NV nv)
Do not use with other Perl types such as HV, AV, SV, CV, because those objects will become corrupted by the pointer copy process.
Note that "sv_setref_pvn" copies the string while this copies the pointer.
SV* sv_setref_pv(SV* rv, const char* classname, void* pv)
Note that "sv_setref_pv" copies the pointer while this copies the string.
SV* sv_setref_pvn(SV* rv, const char* classname, char* pv, STRLEN n)
SV* sv_setref_uv(SV* rv, const char* classname, UV uv)
You probably want to use one of the assortment of wrappers, such as "SvSetSV", "SvSetSV_nosteal", "SvSetMagicSV" and "SvSetMagicSV_nosteal".
void sv_setsv(SV* dsv, SV* ssv)
You probably want to use one of the assortment of wrappers, such as "SvSetSV", "SvSetSV_nosteal", "SvSetMagicSV" and "SvSetMagicSV_nosteal".
This is the primary function for copying scalars, and most other copy-ish functions and macros use this underneath.
void sv_setsv_flags(SV* dsv, SV* ssv, I32 flags)
void sv_setsv_mg(SV *dstr, SV *sstr)
void sv_setsv_nomg(SV* dsv, SV* ssv)
void sv_setuv(SV* sv, UV num)
void sv_setuv_mg(SV *sv, UV u)
I32 sv_true(SV *sv)
int sv_unmagic(SV* sv, int type)
void sv_unref(SV* sv)
void sv_unref_flags(SV* sv, U32 flags)
bool sv_upgrade(SV* sv, U32 mt)
void sv_usepvn(SV* sv, char* ptr, STRLEN len)
void sv_usepvn_mg(SV *sv, char *ptr, STRLEN len)
NOTE: this function is experimental and may change or be removed without notice.
bool sv_utf8_decode(SV *sv)
This is not as a general purpose Unicode to byte encoding interface: use the Encode extension for that.
NOTE: this function is experimental and may change or be removed without notice.
bool sv_utf8_downgrade(SV *sv, bool fail_ok)
void sv_utf8_encode(SV *sv)
This is not as a general purpose byte encoding to Unicode interface: use the Encode extension for that.
STRLEN sv_utf8_upgrade(SV *sv)
This is not as a general purpose byte encoding to Unicode interface: use the Encode extension for that.
STRLEN sv_utf8_upgrade_flags(SV *sv, I32 flags)
UV sv_uv(SV* sv)
Usually used via its frontend "sv_catpvf".
void sv_vcatpvf(SV* sv, const char* pat, va_list* args)
XXX Except that it maybe_tainted is never assigned to.
Usually used via one of its frontends "sv_vcatpvf" and "sv_vcatpvf_mg".
void sv_vcatpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted)
Usually used via its frontend "sv_catpvf_mg".
void sv_vcatpvf_mg(SV* sv, const char* pat, va_list* args)
Usually used via its frontend "sv_setpvf".
void sv_vsetpvf(SV* sv, const char* pat, va_list* args)
Usually used via one of its frontends "sv_vsetpvf" and "sv_vsetpvf_mg".
void sv_vsetpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted)
Usually used via its frontend "sv_setpvf_mg".
void sv_vsetpvf_mg(SV* sv, const char* pat, va_list* args)
NOTE: this function is experimental and may change or be removed without notice.
U8* bytes_from_utf8(U8 *s, STRLEN *len, bool *is_utf8)
If you want to convert to UTF-8 from other encodings than ASCII, see sv_recode_to_utf8().
NOTE: this function is experimental and may change or be removed without notice.
U8* bytes_to_utf8(U8 *s, STRLEN *len)
If the pe1 and pe2 are non-NULL, the scanning pointers will be copied in there (they will point at the beginning of the next character). If the pointers behind pe1 or pe2 are non-NULL, they are the end pointers beyond which scanning will not continue under any circumstances. If the byte lengths l1 and l2 are non-zero, s1+l1 and s2+l2 will be used as goal end pointers that will also stop the scan, and which qualify towards defining a successful match: all the scans that define an explicit length must reach their goal pointers for a match to succeed).
For case-insensitiveness, the ``casefolding'' of Unicode is used instead of upper/lowercasing both the characters, see http://www.unicode.org/unicode/reports/tr21/ (Case Mappings).
I32 ibcmp_utf8(const char* a, char **pe1, UV l1, bool u1, const char* b, char **pe2, UV l2, bool u2)
STRLEN is_utf8_char(U8 *p)
See also is_utf8_string_loclen() and is_utf8_string_loc().
bool is_utf8_string(U8 *s, STRLEN len)
See also is_utf8_string_loclen() and is_utf8_string().
bool is_utf8_string_loc(U8 *s, STRLEN len, U8 **p)
See also is_utf8_string_loc() and is_utf8_string().
bool is_utf8_string_loclen(const U8 *s, STRLEN len, const U8 **ep, STRLEN *el)
The flags argument can have UNI_DISPLAY_ISPRINT set to display isPRINT()able characters as themselves, UNI_DISPLAY_BACKSLASH to display the \\[nrfta\\] as the backslashed versions (like '\n') (UNI_DISPLAY_BACKSLASH is preferred over UNI_DISPLAY_ISPRINT for \\). UNI_DISPLAY_QQ (and its alias UNI_DISPLAY_REGEX) have both UNI_DISPLAY_BACKSLASH and UNI_DISPLAY_ISPRINT turned on.
The pointer to the PV of the dsv is returned.
char* pv_uni_display(SV *dsv, U8 *spv, STRLEN len, STRLEN pvlim, UV flags)
Returns TRUE if the terminator was found, else returns FALSE.
bool sv_cat_decode(SV* dsv, SV *encoding, SV *ssv, int *offset, char* tstr, int tlen)
If the sv already is UTF-8 (or if it is not POK), or if the encoding is not a reference, nothing is done to the sv. If the encoding is not an "Encode::XS" Encoding object, bad things will happen. (See lib/encoding.pm and Encode).
The PV of the sv is returned.
char* sv_recode_to_utf8(SV* sv, SV *encoding)
The flags argument is as in pv_uni_display().
The pointer to the PV of the dsv is returned.
char* sv_uni_display(SV *dsv, SV *ssv, STRLEN pvlim, UV flags)
The ``ustrp'' is a pointer to the character buffer to put the conversion result to. The ``lenp'' is a pointer to the length of the result.
The ``swashp'' is a pointer to the swash to use.
Both the special and normal mappings are stored lib/unicore/To/Foo.pl, and loaded by SWASHGET, using lib/utf8_heavy.pl. The special (usually, but not always, a multicharacter mapping), is tried first.
The ``special'' is a string like ``utf8::ToSpecLower'', which means the hash %utf8::ToSpecLower. The access to the hash is through Perl_to_utf8_case().
The ``normal'' is a string like ``ToLower'' which means the swash %utf8::ToLower.
UV to_utf8_case(U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, char *normal, char *special)
The first character of the foldcased version is returned (but note, as explained above, that there may be more.)
UV to_utf8_fold(U8 *p, U8* ustrp, STRLEN *lenp)
The first character of the lowercased version is returned (but note, as explained above, that there may be more.)
UV to_utf8_lower(U8 *p, U8* ustrp, STRLEN *lenp)
The first character of the titlecased version is returned (but note, as explained above, that there may be more.)
UV to_utf8_title(U8 *p, U8* ustrp, STRLEN *lenp)
The first character of the uppercased version is returned (but note, as explained above, that there may be more.)
UV to_utf8_upper(U8 *p, U8* ustrp, STRLEN *lenp)
Allows length and flags to be passed to low level routine.
UV utf8n_to_uvchr(U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
If "s" does not point to a well-formed UTF-8 character, the behaviour is dependent on the value of "flags": if it contains UTF8_CHECK_ONLY, it is assumed that the caller will raise a warning, and this function will silently just set "retlen" to "-1" and return zero. If the "flags" does not contain UTF8_CHECK_ONLY, warnings about malformations will be given, "retlen" will be set to the expected length of the UTF-8 character in bytes, and zero will be returned.
The "flags" can also contain various flags to allow deviations from the strict UTF-8 encoding (see utf8.h).
Most code should use utf8_to_uvchr() rather than call this directly.
UV utf8n_to_uvuni(U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
WARNING: use only if you *know* that the pointers point inside the same UTF-8 buffer.
IV utf8_distance(U8 *a, U8 *b)
WARNING: do not use the following unless you *know* "off" is within the UTF-8 data pointed to by "s" *and* that on entry "s" is aligned on the first byte of character or just after the last byte of a character.
U8* utf8_hop(U8 *s, I32 off)
STRLEN utf8_length(U8* s, U8 *e)
NOTE: this function is experimental and may change or be removed without notice.
U8* utf8_to_bytes(U8 *s, STRLEN *len)
If "s" does not point to a well-formed UTF-8 character, zero is returned and retlen is set, if possible, to -1.
UV utf8_to_uvchr(U8 *s, STRLEN *retlen)
This function should only be used when returned UV is considered an index into the Unicode semantic tables (e.g. swashes).
If "s" does not point to a well-formed UTF-8 character, zero is returned and retlen is set, if possible, to -1.
UV utf8_to_uvuni(U8 *s, STRLEN *retlen)
d = uvchr_to_utf8(d, uv);
is the recommended wide native character-aware way of saying
*(d++) = uv;
U8* uvchr_to_utf8(U8 *d, UV uv)
d = uvuni_to_utf8_flags(d, uv, flags);
or, in most cases,
d = uvuni_to_utf8(d, uv);
(which is equivalent to)
d = uvuni_to_utf8_flags(d, uv, 0);
is the recommended Unicode-aware way of saying
*(d++) = uv;
U8* uvuni_to_utf8_flags(U8 *d, UV uv, UV flags)
I32 ax
char* CLASS
dAX;
dAXMARK;
dITEMS;
dXSARGS;
dXSI32;
I32 items
I32 ix
(whatever) RETVAL
SV* ST(int ix)
(whatever) THIS
XS_VERSION_BOOTCHECK;
If you want to throw an exception object, assign the object to $@ and then pass "Nullch" to croak():
errsv = get_sv("@", TRUE); sv_setsv(errsv, exception_object); croak(Nullch);
void croak(const char* pat, ...)
void warn(const char* pat, ...)
With lots of help and suggestions from Dean Roehrich, Malcolm Beattie, Andreas Koenig, Paul Hudson, Ilya Zakharevich, Paul Marquess, Neil Bowers, Matthew Green, Tim Bunce, Spider Boardman, Ulrich Pfeifer, Stephen McCamant, and Gurusamy Sarathy.
API Listing originally by Dean Roehrich <[email protected]>.
Updated to be autogenerated from comments in the source by Benjamin Stuhl.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |