📄 ch08_69.htm
字号:
#endif</pre></blockquote><p>which are used to determine if a constant will be defined.</p><p>A <tt class="literal">macro</tt> of <tt class="literal">1</tt> signals that theconstant is always defined, so the <tt class="literal">#if/#endif</tt> testis omitted.</p></dd><dt><b><tt class="literal">default</tt> </b></dt><dd>Default value to use (instead of <tt class="literal">croak</tt> ing with"your vendor has not defined . . . ) if the macroisn't defined. Specifies a reference to an arraywith type followed by value(s).</p></dd><dt><b><tt class="literal">pre</tt> </b></dt><dd>C code to use before the assignment of the value of the constant.This allows you to use temporary variables to extract a value frompart of a <tt class="literal">struct</tt> and return this as<tt class="literal">value</tt>. This C code is placed at the start of ablock, so you can declare variables in it.</p></dd><dt><b><tt class="literal">post</tt> </b></dt><dd>C code to place between the assignment of <tt class="literal">value</tt>(temporary) and the return from the function. This allows you toclear up anything in <tt class="literal">pre</tt>. Rarely needed.</p></dd><dt><b><tt class="literal">def_pre</tt> </b></dt><dt><b><tt class="literal">def_post</tt> </b></dt><dd>Equivalents of <tt class="literal">pre</tt> and <tt class="literal">post</tt> forthe default value.</p></dd><dt><b><tt class="literal">utf8</tt> </b></dt><dd>Generated internally. Is <tt class="literal">0</tt> or undefined if name is7-bit ASCII, <tt class="literal">no</tt> if the name is 8-bit (and soshould match only if <tt class="literal">SvUTF8()</tt> is false), and<tt class="literal">yes</tt> if the name is<tt class="literal">utf8</tt>-encoded.</p></dd></dl></div><a name="INDEX-1406" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>constant_types</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>constant_types</pre><p>Returns a single scalar with <tt class="literal">#define</tt> definitionsfor the constants used internally between the generated C and XSfunctions.</p></div><a name="INDEX-1407" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>C_stringify</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>C_stringify <em class="replaceable">name</em></pre><p>Returns a 7-bit ASCII correctly <tt class="literal">\</tt>-escaped versionof the string passed. Suitable for C <tt class="literal">""</tt> or<tt class="literal">''</tt>. It will die if passed Unicode characters.</p></div><a name="INDEX-1408" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>dump_names</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>dump_names <em class="replaceable">default_type</em>, <em class="replaceable">types</em>, <em class="replaceable">indent</em>, <em class="replaceable">options</em>, <em class="replaceable">item </em>...</pre><p>An internal function to generate the embedded Perl code to regeneratethe constant subroutines. <em class="replaceable"><tt>default_type</tt></em>,<em class="replaceable"><tt>types</tt></em>, and<em class="replaceable"><tt>item</tt></em>s are the same as for<tt class="literal">C_constant</tt>. <em class="replaceable"><tt>indent</tt></em> isthe number of spaces to indent. <em class="replaceable"><tt>options</tt></em> isa hashref of options; currently, only<tt class="literal">declare_types</tt> is recognized. If the value is true,a <em class="replaceable"><tt>types</tt></em> is always declared in thegenerated Perl code; if defined and false, one is never declared; andif undefined, <em class="replaceable"><tt>types</tt></em> is declared only ifthe values in <em class="replaceable"><tt>types</tt></em> as passed in cannot beinferred from <em class="replaceable"><tt>default_types</tt></em> and the<em class="replaceable"><tt>item</tt></em>s.</p></div><a name="INDEX-1409" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>memEQ_clause </b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>memEQ_clause <em class="replaceable">name</em>, <em class="replaceable">checked_at</em>, <em class="replaceable">indent</em></pre><p>Returns a suitable C <tt class="literal">if</tt> statement to check whether<em class="replaceable"><tt>name</tt></em> is equal to the C variable<em class="replaceable"><tt>name</tt></em>. If<em class="replaceable"><tt>checked_at</tt></em> is defined, then it is used toavoid <tt class="literal">memEQ</tt> for short names.</p></div><a name="INDEX-1410" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>params</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>params <em class="replaceable">what</em></pre><p>An internal function. <em class="replaceable">what</em> should be ahashref of types the constant function will return.<tt class="literal">params</tt> returns a hashref keyed <tt class="literal">IV NV PVSV</tt> to show which combination of pointers will be needed inthe C argument list.</p></div><a name="INDEX-1411" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>perl_stringify</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>perl_stringify <em class="replaceable">name</em></pre><p>Returns a 7-bit ASCII correctly <tt class="literal">\</tt>-escaped versionof the string passed. Suitable for a Perl <tt class="literal">""</tt>string.</p></div><a name="INDEX-1412" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>return_clause</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>return_clause <em class="replaceable">item</em>, <em class="replaceable">indent</em></pre><p>Returns a suitable <tt class="literal">#ifdef</tt> clause.<em class="replaceable"><tt>item</tt></em> is a hashref passed to<tt class="literal">C_constant</tt> and <tt class="literal">match_clause</tt>.<em class="replaceable"><tt>indent</tt></em> is the number of spaces to indent;defaulting is <tt class="literal">6</tt>.</p></div><a name="INDEX-1413" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>switch_clause</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>switch_clause <em class="replaceable">indent</em>, <em class="replaceable">namelen</em>, <em class="replaceable">itemhash</em>, <em class="replaceable">item </em>...</pre><p>An internal function to generate a suitable <tt class="literal">switch</tt>clause, called by <tt class="literal">C_constant</tt>.<em class="replaceable"><tt>item</tt></em>s are in the hashref format as givenin the description of <tt class="literal">C_constant</tt> and must all havenames of the same length, given by<em class="replaceable"><tt>namelen</tt></em>.<em class="replaceable"><tt>itemhash</tt></em> is a reference to a hash, keyedby name, with values as the hashrefs in the<em class="replaceable"><tt>item</tt></em> list.</p></div><a name="INDEX-1414" /><div class="refentry"><table width="515" border="0" cellpadding="5"><tr><td align="left"><font size="+1"><b>XS_constant</b></font></td><td align="right"><i></i></td></tr></table><hr width="515" size="3" noshade="true" align="left" color="black" /><pre>XS_constant <em class="replaceable">package</em>, <em class="replaceable">types</em>, <em class="replaceable">subname</em>, <em class="replaceable">c_subname</em></pre><p>Generates the XS code to implement the Perl subroutine<em class="replaceable"><tt>package</tt></em><tt class="literal">::constant</tt> usedby <em class="replaceable"><tt>package</tt></em><tt class="literal">::AUTOLOAD</tt> toload constants. This XS code is a wrapper around a C subroutineusually generated by <tt class="literal">C_constant</tt> and usually named<tt class="literal">constant</tt></p><p><em class="replaceable"><tt>types</tt></em> should be given either as acomma-separated list of types that the C subroutine<tt class="literal">constant</tt> will generate or as a reference to ahash. It should be the same list of types that<tt class="literal">C_constant</tt> was given. Otherwise,<tt class="literal">XS_constant</tt> and <tt class="literal">C_constant</tt> mayhave different ideas about the number of parameters passed to the Cfunction <tt class="literal">constant</tt>.</p><p>You can call the Perl visible subroutine something other than"constant" if you give theparameter <em class="replaceable"><tt>subname</tt></em>. The C subroutine itcalls defaults to the name of the Perl visible subroutine, unless yougive the parameter <em class="replaceable"><tt>c_subname</tt></em>.</p></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch08_68.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0" /></a></td><td align="right" valign="top" width="228"><a href="ch08_70.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr><tr><td align="left" valign="top" width="228">8.68. ExtUtils::Command::MM</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0" /></a></td><td align="right" valign="top" width="228">8.70. ExtUtils::Embed</td></tr></table></div><hr width="684" align="left" /><img src="../gifs/navbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links" /><p><p><font size="-1"><a href="copyrght.htm">Copyright © 2002</a> O'Reilly & Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -