perlapi.html
来自「perl教程」· HTML 代码 · 共 2,025 行 · 第 1/5 页
HTML
2,025 行
<dt><strong><a name="item_mg_set">mg_set</a></strong>
<dd>
<p>Do magic after a value is assigned to the SV. See <a href="#item_sv_magic"><code>sv_magic</code></a>.</p>
</dd>
<dd>
<pre>
int mg_set(SV* sv)</pre>
</dd>
</li>
<dt><strong><a name="item_svgetmagic">SvGETMAGIC</a></strong>
<dd>
<p>Invokes <a href="#item_mg_get"><code>mg_get</code></a> on an SV if it has 'get' magic. This macro evaluates its
argument more than once.</p>
</dd>
<dd>
<pre>
void SvGETMAGIC(SV* sv)</pre>
</dd>
</li>
<dt><strong><a name="item_svlock">SvLOCK</a></strong>
<dd>
<p>Arranges for a mutual exclusion lock to be obtained on sv if a suitable module
has been loaded.</p>
</dd>
<dd>
<pre>
void SvLOCK(SV* sv)</pre>
</dd>
</li>
<dt><strong><a name="item_svsetmagic">SvSETMAGIC</a></strong>
<dd>
<p>Invokes <a href="#item_mg_set"><code>mg_set</code></a> on an SV if it has 'set' magic. This macro evaluates its
argument more than once.</p>
</dd>
<dd>
<pre>
void SvSETMAGIC(SV* sv)</pre>
</dd>
</li>
<dt><strong><a name="item_svsetmagicsv">SvSetMagicSV</a></strong>
<dd>
<p>Like <a href="#item_svsetsv"><code>SvSetSV</code></a>, but does any set magic required afterwards.</p>
</dd>
<dd>
<pre>
void SvSetMagicSV(SV* dsb, SV* ssv)</pre>
</dd>
</li>
<dt><strong><a name="item_svsetmagicsv_nosteal">SvSetMagicSV_nosteal</a></strong>
<dd>
<p>Like <a href="#item_svsetsv_nosteal"><code>SvSetSV_nosteal</code></a>, but does any set magic required afterwards.</p>
</dd>
<dd>
<pre>
void SvSetMagicSV_nosteal(SV* dsv, SV* ssv)</pre>
</dd>
</li>
<dt><strong><a name="item_svsetsv">SvSetSV</a></strong>
<dd>
<p>Calls <a href="#item_sv_setsv"><code>sv_setsv</code></a> if dsv is not the same as ssv. May evaluate arguments
more than once.</p>
</dd>
<dd>
<pre>
void SvSetSV(SV* dsb, SV* ssv)</pre>
</dd>
</li>
<dt><strong><a name="item_svsetsv_nosteal">SvSetSV_nosteal</a></strong>
<dd>
<p>Calls a non-destructive version of <a href="#item_sv_setsv"><code>sv_setsv</code></a> if dsv is not the same as
ssv. May evaluate arguments more than once.</p>
</dd>
<dd>
<pre>
void SvSetSV_nosteal(SV* dsv, SV* ssv)</pre>
</dd>
</li>
<dt><strong><a name="item_svshare">SvSHARE</a></strong>
<dd>
<p>Arranges for sv to be shared between threads if a suitable module
has been loaded.</p>
</dd>
<dd>
<pre>
void SvSHARE(SV* sv)</pre>
</dd>
</li>
<dt><strong><a name="item_svunlock">SvUNLOCK</a></strong>
<dd>
<p>Releases a mutual exclusion lock on sv if a suitable module
has been loaded.</p>
</dd>
<dd>
<pre>
void SvUNLOCK(SV* sv)</pre>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="memory_management">Memory Management</a></h1>
<dl>
<dt><strong><a name="item_copy">Copy</a></strong>
<dd>
<p>The XSUB-writer's interface to the C <code>memcpy</code> function. The <code>src</code> is the
source, <code>dest</code> is the destination, <code>nitems</code> is the number of items, and <code>type</code> is
the type. May fail on overlapping copies. See also <a href="#item_move"><code>Move</code></a>.</p>
</dd>
<dd>
<pre>
void Copy(void* src, void* dest, int nitems, type)</pre>
</dd>
</li>
<dt><strong><a name="item_copyd">CopyD</a></strong>
<dd>
<p>Like <a href="#item_copy"><code>Copy</code></a> but returns dest. Useful for encouraging compilers to tail-call
optimise.</p>
</dd>
<dd>
<pre>
void * CopyD(void* src, void* dest, int nitems, type)</pre>
</dd>
</li>
<dt><strong><a name="item_move">Move</a></strong>
<dd>
<p>The XSUB-writer's interface to the C <code>memmove</code> function. The <code>src</code> is the
source, <code>dest</code> is the destination, <code>nitems</code> is the number of items, and <code>type</code> is
the type. Can do overlapping moves. See also <a href="#item_copy"><code>Copy</code></a>.</p>
</dd>
<dd>
<pre>
void Move(void* src, void* dest, int nitems, type)</pre>
</dd>
</li>
<dt><strong><a name="item_moved">MoveD</a></strong>
<dd>
<p>Like <a href="#item_move"><code>Move</code></a> but returns dest. Useful for encouraging compilers to tail-call
optimise.</p>
</dd>
<dd>
<pre>
void * MoveD(void* src, void* dest, int nitems, type)</pre>
</dd>
</li>
<dt><strong><a name="item_newx">Newx</a></strong>
<dd>
<p>The XSUB-writer's interface to the C <code>malloc</code> function.</p>
</dd>
<dd>
<pre>
void Newx(void* ptr, int nitems, type)</pre>
</dd>
</li>
<dt><strong><a name="item_newxc">Newxc</a></strong>
<dd>
<p>The XSUB-writer's interface to the C <code>malloc</code> function, with
cast.</p>
</dd>
<dd>
<pre>
void Newxc(void* ptr, int nitems, type, cast)</pre>
</dd>
</li>
<dt><strong><a name="item_newxz">Newxz</a></strong>
<dd>
<p>The XSUB-writer's interface to the C <code>malloc</code> function. The allocated
memory is zeroed with <code>memzero</code>.</p>
</dd>
<dd>
<p>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.</p>
</dd>
<dd>
<pre>
void Newxz(void* ptr, int nitems, type)</pre>
</dd>
</li>
<dt><strong><a name="item_poison">Poison</a></strong>
<dd>
<p>Fill up memory with a pattern (byte 0xAB over and over again) that
hopefully catches attempts to access uninitialized memory.</p>
</dd>
<dd>
<pre>
void Poison(void* dest, int nitems, type)</pre>
</dd>
</li>
<dt><strong><a name="item_renew">Renew</a></strong>
<dd>
<p>The XSUB-writer's interface to the C <code>realloc</code> function.</p>
</dd>
<dd>
<pre>
void Renew(void* ptr, int nitems, type)</pre>
</dd>
</li>
<dt><strong><a name="item_renewc">Renewc</a></strong>
<dd>
<p>The XSUB-writer's interface to the C <code>realloc</code> function, with
cast.</p>
</dd>
<dd>
<pre>
void Renewc(void* ptr, int nitems, type, cast)</pre>
</dd>
</li>
<dt><strong><a name="item_safefree">Safefree</a></strong>
<dd>
<p>The XSUB-writer's interface to the C <code>free</code> function.</p>
</dd>
<dd>
<pre>
void Safefree(void* ptr)</pre>
</dd>
</li>
<dt><strong><a name="item_savepv">savepv</a></strong>
<dd>
<p>Perl's version of <code>strdup()</code>. Returns a pointer to a newly allocated
string which is a duplicate of <code>pv</code>. The size of the string is
determined by <code>strlen()</code>. The memory allocated for the new string can
be freed with the <a href="#item_safefree"><code>Safefree()</code></a> function.</p>
</dd>
<dd>
<pre>
char* savepv(const char* pv)</pre>
</dd>
</li>
<dt><strong><a name="item_savepvn">savepvn</a></strong>
<dd>
<p>Perl's version of what <code>strndup()</code> would be if it existed. Returns a
pointer to a newly allocated string which is a duplicate of the first
<code>len</code> bytes from <code>pv</code>. The memory allocated for the new string can be
freed with the <a href="#item_safefree"><code>Safefree()</code></a> function.</p>
</dd>
<dd>
<pre>
char* savepvn(const char* pv, I32 len)</pre>
</dd>
</li>
<dt><strong><a name="item_savesharedpv">savesharedpv</a></strong>
<dd>
<p>A version of <a href="#item_savepv"><code>savepv()</code></a> which allocates the duplicate string in memory
which is shared between threads.</p>
</dd>
<dd>
<pre>
char* savesharedpv(const char* pv)</pre>
</dd>
</li>
<dt><strong><a name="item_savesvpv">savesvpv</a></strong>
<dd>
<p>A version of <a href="#item_savepv"><code>savepv()</code></a>/<a href="#item_savepvn"><code>savepvn()</code></a> which gets the string to duplicate from
the passed in SV using <a href="#item_svpv"><code>SvPV()</code></a></p>
</dd>
<dd>
<pre>
char* savesvpv(SV* sv)</pre>
</dd>
</li>
<dt><strong><a name="item_structcopy">StructCopy</a></strong>
<dd>
<p>This is an architecture-independent macro to copy one structure to another.</p>
</dd>
<dd>
<pre>
void StructCopy(type src, type dest, type)</pre>
</dd>
</li>
<dt><strong><a name="item_zero">Zero</a></strong>
<dd>
<p>The XSUB-writer's interface to the C <code>memzero</code> function. The <code>dest</code> is the
destination, <code>nitems</code> is the number of items, and <code>type</code> is the type.</p>
</dd>
<dd>
<pre>
void Zero(void* dest, int nitems, type)</pre>
</dd>
</li>
<dt><strong><a name="item_zerod">ZeroD</a></strong>
<dd>
<p>Like <a href="#item_zero"><code>Zero</code></a> but returns dest. Useful for encouraging compilers to tail-call
optimise.</p>
</dd>
<dd>
<pre>
void * ZeroD(void* dest, int nitems, type)</pre>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="miscellaneous_functions">Miscellaneous Functions</a></h1>
<dl>
<dt><strong><a name="item_fbm_compile">fbm_compile</a></strong>
<dd>
<p>Analyses the string in order to make fast searches on it using <a href="#item_fbm_instr"><code>fbm_instr()</code></a>
-- the Boyer-Moore algorithm.</p>
</dd>
<dd>
<pre>
void fbm_compile(SV* sv, U32 flags)</pre>
</dd>
</li>
<dt><strong><a name="item_fbm_instr">fbm_instr</a></strong>
<dd>
<p>Returns the location of the SV in the string delimited by <code>str</code> and
<code>strend</code>. It returns <a href="#item_nullch"><code>Nullch</code></a> if the string can't be found. The <code>sv</code>
does not have to be fbm_compiled, but the search will not be as fast
then.</p>
</dd>
<dd>
<pre>
char* fbm_instr(unsigned char* big, unsigned char* bigend, SV* littlesv, U32 flags)</pre>
</dd>
</li>
<dt><strong><a name="item_form">form</a></strong>
<dd>
<p>Takes a sprintf-style format pattern and conventional
(non-SV) arguments and returns the formatted string.</p>
</dd>
<dd>
<pre>
(char *) Perl_form(pTHX_ const char* pat, ...)</pre>
</dd>
<dd>
<p>can be used any place a string (char *) is required:</p>
</dd>
<dd>
<pre>
char * s = Perl_form("%d.%d",major,minor);</pre>
</dd>
<dd>
<p>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).</p>
</dd>
<dd>
<pre>
char* form(const char* pat, ...)</pre>
</dd>
</li>
<dt><strong><a name="item_getcwd_sv">getcwd_sv</a></strong>
<dd>
<p>Fill the sv with current working directory</p>
</dd>
<dd>
<pre>
int getcwd_sv(SV* sv)</pre>
</dd>
</li>
<dt><strong><a name="item_streq">strEQ</a></strong>
<dd>
<p>Test two strings to see if they are equal. Returns true or false.</p>
</dd>
<dd>
<pre>
bool strEQ(char* s1, char* s2)</pre>
</dd>
</li>
<dt><strong><a name="item_strge">strGE</a></strong>
<dd>
<p>Test two strings to see if the first, <code>s1</code>, is greater than or equal to
the second, <code>s2</code>. Returns true or false.</p>
</dd>
<dd>
<pre>
bool st
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?