📄 extutils::constant.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "ExtUtils::Constant 3".TH ExtUtils::Constant 3 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"ExtUtils::Constant \- generate XS code to import C header constants.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 7\& use ExtUtils::Constant qw (WriteConstants);\& WriteConstants(\& NAME => \*(AqFoo\*(Aq,\& NAMES => [qw(FOO BAR BAZ)],\& );\& # Generates wrapper code to make the values of the constants FOO BAR BAZ\& # available to perl.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"ExtUtils::Constant facilitates generating C and \s-1XS\s0 wrapper code to allowperl modules to \s-1AUTOLOAD\s0 constants defined in C library header files.It is principally used by the \f(CW\*(C`h2xs\*(C'\fR utility, on which this code is based.It doesn't contain the routines to scan header files to extract theseconstants..SH "USAGE".IX Header "USAGE"Generally one only needs to call the \f(CW\*(C`WriteConstants\*(C'\fR function, and then.PP.Vb 1\& #include "const\-c.inc".Ve.PPin the C section of \f(CW\*(C`Foo.xs\*(C'\fR.PP.Vb 1\& INCLUDE: const\-xs.inc.Ve.PPin the \s-1XS\s0 section of \f(CW\*(C`Foo.xs\*(C'\fR..PPFor greater flexibility use \f(CW\*(C`constant_types()\*(C'\fR, \f(CW\*(C`C_constant\*(C'\fR and\&\f(CW\*(C`XS_constant\*(C'\fR, with which \f(CW\*(C`WriteConstants\*(C'\fR is implemented..PPCurrently this module understands the following types. h2xs may only knowa subset. The sizes of the numeric types are chosen by the \f(CW\*(C`Configure\*(C'\fRscript at compile time..IP "\s-1IV\s0" 4.IX Item "IV"signed integer, at least 32 bits..IP "\s-1UV\s0" 4.IX Item "UV"unsigned integer, the same size as \fI\s-1IV\s0\fR.IP "\s-1NV\s0" 4.IX Item "NV"floating point type, probably \f(CW\*(C`double\*(C'\fR, possibly \f(CW\*(C`long double\*(C'\fR.IP "\s-1PV\s0" 4.IX Item "PV"\&\s-1NUL\s0 terminated string, length will be determined with \f(CW\*(C`strlen\*(C'\fR.IP "\s-1PVN\s0" 4.IX Item "PVN"A fixed length thing, given as a [pointer, length] pair. If you know thelength of a string at compile time you may use this instead of \fI\s-1PV\s0\fR.IP "\s-1SV\s0" 4.IX Item "SV"A \fBmortal\fR \s-1SV\s0..IP "\s-1YES\s0" 4.IX Item "YES"Truth. (\f(CW\*(C`PL_sv_yes\*(C'\fR) The value is not needed (and ignored)..IP "\s-1NO\s0" 4.IX Item "NO"Defined Falsehood. (\f(CW\*(C`PL_sv_no\*(C'\fR) The value is not needed (and ignored)..IP "\s-1UNDEF\s0" 4.IX Item "UNDEF"\&\f(CW\*(C`undef\*(C'\fR. The value of the macro is not needed..SH "FUNCTIONS".IX Header "FUNCTIONS".IP "constant_types" 4.IX Item "constant_types"A function returning a single scalar with \f(CW\*(C`#define\*(C'\fR definitions for theconstants used internally between the generated C and \s-1XS\s0 functions..IP "XS_constant \s-1PACKAGE\s0, \s-1TYPES\s0, \s-1SUBNAME\s0, C_SUBNAME" 4.IX Item "XS_constant PACKAGE, TYPES, SUBNAME, C_SUBNAME"A function to generate the \s-1XS\s0 code to implement the perl subroutine\&\fI\s-1PACKAGE\s0\fR::constant used by \fI\s-1PACKAGE\s0\fR::AUTOLOAD to load constants.This \s-1XS\s0 code is a wrapper around a C subroutine usually generated by\&\f(CW\*(C`C_constant\*(C'\fR, and usually named \f(CW\*(C`constant\*(C'\fR..Sp\&\fI\s-1TYPES\s0\fR should be given either as a comma separated list of types that theC subroutine \f(CW\*(C`constant\*(C'\fR will generate or as a reference to a hash. It shouldbe the same list of types as \f(CW\*(C`C_constant\*(C'\fR was given.[Otherwise \f(CW\*(C`XS_constant\*(C'\fR and \f(CW\*(C`C_constant\*(C'\fR may have different ideas aboutthe number of parameters passed to the C function \f(CW\*(C`constant\*(C'\fR].SpYou can call the perl visible subroutine something other than \f(CW\*(C`constant\*(C'\fR ifyou give the parameter \fI\s-1SUBNAME\s0\fR. The C subroutine it calls defaults tothe name of the perl visible subroutine, unless you give the parameter\&\fIC_SUBNAME\fR..IP "autoload \s-1PACKAGE\s0, \s-1VERSION\s0, \s-1AUTOLOADER\s0" 4.IX Item "autoload PACKAGE, VERSION, AUTOLOADER"A function to generate the \s-1AUTOLOAD\s0 subroutine for the module \fI\s-1PACKAGE\s0\fR\&\fI\s-1VERSION\s0\fR is the perl version the code should be backwards compatible with.It defaults to the version of perl running the subroutine. If \fI\s-1AUTOLOADER\s0\fRis true, the \s-1AUTOLOAD\s0 subroutine falls back on AutoLoader::AUTOLOAD for allnames that the \fIconstant()\fR routine doesn't recognise..IP "WriteMakefileSnippet" 4.IX Item "WriteMakefileSnippet"WriteMakefileSnippet \s-1ATTRIBUTE\s0 => \s-1VALUE\s0 [, ...].SpA function to generate perl code for Makefile.PL that will regeneratethe constant subroutines. Parameters are named as passed to \f(CW\*(C`WriteConstants\*(C'\fR,with the addition of \f(CW\*(C`INDENT\*(C'\fR to specify the number of leading spaces(default 2)..SpCurrently only \f(CW\*(C`INDENT\*(C'\fR, \f(CW\*(C`NAME\*(C'\fR, \f(CW\*(C`DEFAULT_TYPE\*(C'\fR, \f(CW\*(C`NAMES\*(C'\fR, \f(CW\*(C`C_FILE\*(C'\fR and\&\f(CW\*(C`XS_FILE\*(C'\fR are recognised..IP "WriteConstants \s-1ATTRIBUTE\s0 => \s-1VALUE\s0 [, ...]" 4.IX Item "WriteConstants ATTRIBUTE => VALUE [, ...]"Writes a file of C code and a file of \s-1XS\s0 code which you should \f(CW\*(C`#include\*(C'\fRand \f(CW\*(C`INCLUDE\*(C'\fR in the C and \s-1XS\s0 sections respectively of your module's \s-1XS\s0code. You probably want to do this in your \f(CW\*(C`Makefile.PL\*(C'\fR, so that you caneasily edit the list of constants without touching the rest of your module.The attributes supported are.RS 4.IP "\s-1NAME\s0" 4.IX Item "NAME"Name of the module. This must be specified.IP "\s-1DEFAULT_TYPE\s0" 4.IX Item "DEFAULT_TYPE"The default type for the constants. If not specified \f(CW\*(C`IV\*(C'\fR is assumed..IP "\s-1BREAKOUT_AT\s0" 4.IX Item "BREAKOUT_AT"The names of the constants are grouped by length. Generate child subroutinesfor each group with this number or more names in..IP "\s-1NAMES\s0" 4.IX Item "NAMES"An array of constants' names, either scalars containing names, or hashrefsas detailed in \*(L"C_constant\*(R"..IP "C_FH" 4.IX Item "C_FH"A filehandle to write the C code to. If not given, then \fIC_FILE\fR is openedfor writing..IP "C_FILE" 4.IX Item "C_FILE"The name of the file to write containing the C code. The default is\&\f(CW\*(C`const\-c.inc\*(C'\fR. The \f(CW\*(C`\-\*(C'\fR in the name ensures that the file can't bemistaken for anything related to a legitimate perl package name, andnot naming the file \f(CW\*(C`.c\*(C'\fR avoids having to override Makefile.PL's\&\f(CW\*(C`.xs\*(C'\fR to \f(CW\*(C`.c\*(C'\fR rules..IP "\s-1XS_FH\s0" 4.IX Item "XS_FH"A filehandle to write the \s-1XS\s0 code to. If not given, then \fI\s-1XS_FILE\s0\fR is openedfor writing..IP "\s-1XS_FILE\s0" 4.IX Item "XS_FILE"The name of the file to write containing the \s-1XS\s0 code. The default is\&\f(CW\*(C`const\-xs.inc\*(C'\fR..IP "\s-1SUBNAME\s0" 4.IX Item "SUBNAME"The perl visible name of the \s-1XS\s0 subroutine generated which will return theconstants. The default is \f(CW\*(C`constant\*(C'\fR..IP "C_SUBNAME" 4.IX Item "C_SUBNAME"The name of the C subroutine generated which will return the constants.The default is \fI\s-1SUBNAME\s0\fR. Child subroutines have \f(CW\*(C`_\*(C'\fR and the namelength appended, so constants with 10 character names would be in\&\f(CW\*(C`constant_10\*(C'\fR with the default \fI\s-1XS_SUBNAME\s0\fR..RE.RS 4.RE.SH "AUTHOR".IX Header "AUTHOR"Nicholas Clark <nick@ccl4.org> based on the code in \f(CW\*(C`h2xs\*(C'\fR by Larry Wall andothers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -