Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | .\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "ExtUtils::Constant 3" | |
132 | .TH ExtUtils::Constant 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide" | |
133 | .SH "NAME" | |
134 | ExtUtils::Constant \- generate XS code to import C header constants | |
135 | .SH "SYNOPSIS" | |
136 | .IX Header "SYNOPSIS" | |
137 | .Vb 7 | |
138 | \& use ExtUtils::Constant qw (WriteConstants); | |
139 | \& WriteConstants( | |
140 | \& NAME => 'Foo', | |
141 | \& NAMES => [qw(FOO BAR BAZ)], | |
142 | \& ); | |
143 | \& # Generates wrapper code to make the values of the constants FOO BAR BAZ | |
144 | \& # available to perl | |
145 | .Ve | |
146 | .SH "DESCRIPTION" | |
147 | .IX Header "DESCRIPTION" | |
148 | ExtUtils::Constant facilitates generating C and \s-1XS\s0 wrapper code to allow | |
149 | perl modules to \s-1AUTOLOAD\s0 constants defined in C library header files. | |
150 | It is principally used by the \f(CW\*(C`h2xs\*(C'\fR utility, on which this code is based. | |
151 | It doesn't contain the routines to scan header files to extract these | |
152 | constants. | |
153 | .SH "USAGE" | |
154 | .IX Header "USAGE" | |
155 | Generally one only needs to call the \f(CW\*(C`WriteConstants\*(C'\fR function, and then | |
156 | .PP | |
157 | .Vb 1 | |
158 | \& #include "const-c.inc" | |
159 | .Ve | |
160 | .PP | |
161 | in the C section of \f(CW\*(C`Foo.xs\*(C'\fR | |
162 | .PP | |
163 | .Vb 1 | |
164 | \& INCLUDE const-xs.inc | |
165 | .Ve | |
166 | .PP | |
167 | in the \s-1XS\s0 section of \f(CW\*(C`Foo.xs\*(C'\fR. | |
168 | .PP | |
169 | For greater flexibility use \f(CW\*(C`constant_types()\*(C'\fR, \f(CW\*(C`C_constant\*(C'\fR and | |
170 | \&\f(CW\*(C`XS_constant\*(C'\fR, with which \f(CW\*(C`WriteConstants\*(C'\fR is implemented. | |
171 | .PP | |
172 | Currently this module understands the following types. h2xs may only know | |
173 | a subset. The sizes of the numeric types are chosen by the \f(CW\*(C`Configure\*(C'\fR | |
174 | script at compile time. | |
175 | .IP "\s-1IV\s0" 4 | |
176 | .IX Item "IV" | |
177 | signed integer, at least 32 bits. | |
178 | .IP "\s-1UV\s0" 4 | |
179 | .IX Item "UV" | |
180 | unsigned integer, the same size as \fI\s-1IV\s0\fR | |
181 | .IP "\s-1NV\s0" 4 | |
182 | .IX Item "NV" | |
183 | floating point type, probably \f(CW\*(C`double\*(C'\fR, possibly \f(CW\*(C`long double\*(C'\fR | |
184 | .IP "\s-1PV\s0" 4 | |
185 | .IX Item "PV" | |
186 | \&\s-1NUL\s0 terminated string, length will be determined with \f(CW\*(C`strlen\*(C'\fR | |
187 | .IP "\s-1PVN\s0" 4 | |
188 | .IX Item "PVN" | |
189 | A fixed length thing, given as a [pointer, length] pair. If you know the | |
190 | length of a string at compile time you may use this instead of \fI\s-1PV\s0\fR | |
191 | .IP "\s-1SV\s0" 4 | |
192 | .IX Item "SV" | |
193 | A \fBmortal\fR \s-1SV\s0. | |
194 | .IP "\s-1YES\s0" 4 | |
195 | .IX Item "YES" | |
196 | Truth. (\f(CW\*(C`PL_sv_yes\*(C'\fR) The value is not needed (and ignored). | |
197 | .IP "\s-1NO\s0" 4 | |
198 | .IX Item "NO" | |
199 | Defined Falsehood. (\f(CW\*(C`PL_sv_no\*(C'\fR) The value is not needed (and ignored). | |
200 | .IP "\s-1UNDEF\s0" 4 | |
201 | .IX Item "UNDEF" | |
202 | \&\f(CW\*(C`undef\*(C'\fR. The value of the macro is not needed. | |
203 | .SH "FUNCTIONS" | |
204 | .IX Header "FUNCTIONS" | |
205 | .IP "C_stringify \s-1NAME\s0" 4 | |
206 | .IX Item "C_stringify NAME" | |
207 | A function which returns a 7 bit \s-1ASCII\s0 correctly \e escaped version of the | |
208 | string passed suitable for C's "" or ''. It will die if passed Unicode | |
209 | characters. | |
210 | .IP "perl_stringify \s-1NAME\s0" 4 | |
211 | .IX Item "perl_stringify NAME" | |
212 | A function which returns a 7 bit \s-1ASCII\s0 correctly \e escaped version of the | |
213 | string passed suitable for a perl "" string. | |
214 | .IP "constant_types" 4 | |
215 | .IX Item "constant_types" | |
216 | A function returning a single scalar with \f(CW\*(C`#define\*(C'\fR definitions for the | |
217 | constants used internally between the generated C and \s-1XS\s0 functions. | |
218 | .IP "memEQ_clause \s-1NAME\s0, \s-1CHECKED_AT\s0, \s-1INDENT\s0" 4 | |
219 | .IX Item "memEQ_clause NAME, CHECKED_AT, INDENT" | |
220 | A function to return a suitable C \f(CW\*(C`if\*(C'\fR statement to check whether \fI\s-1NAME\s0\fR | |
221 | is equal to the C variable \f(CW\*(C`name\*(C'\fR. If \fI\s-1CHECKED_AT\s0\fR is defined, then it | |
222 | is used to avoid \f(CW\*(C`memEQ\*(C'\fR for short names, or to generate a comment to | |
223 | highlight the position of the character in the \f(CW\*(C`switch\*(C'\fR statement. | |
224 | .IP "assign \s-1INDENT\s0, \s-1TYPE\s0, \s-1PRE\s0, \s-1POST\s0, \s-1VALUE\s0..." 4 | |
225 | .IX Item "assign INDENT, TYPE, PRE, POST, VALUE..." | |
226 | A function to return a suitable assignment clause. If \fI\s-1TYPE\s0\fR is aggregate | |
227 | (eg \fI\s-1PVN\s0\fR expects both pointer and length) then there should be multiple | |
228 | \&\fI\s-1VALUE\s0\fRs for the components. \fI\s-1PRE\s0\fR and \fI\s-1POST\s0\fR if defined give snippets | |
229 | of C code to proceed and follow the assignment. \fI\s-1PRE\s0\fR will be at the start | |
230 | of a block, so variables may be defined in it. | |
231 | .IP "return_clause" 4 | |
232 | .IX Item "return_clause" | |
233 | return_clause \s-1ITEM\s0, \s-1INDENT\s0 | |
234 | .Sp | |
235 | A function to return a suitable \f(CW\*(C`#ifdef\*(C'\fR clause. \fI\s-1ITEM\s0\fR is a hashref | |
236 | (as passed to \f(CW\*(C`C_constant\*(C'\fR and \f(CW\*(C`match_clause\*(C'\fR. \fI\s-1INDENT\s0\fR is the number | |
237 | of spaces to indent, defaulting to 6. | |
238 | .Sp | |
239 | \&\s-1XXX\s0 document me | |
240 | .IP "switch_clause \s-1INDENT\s0, \s-1NAMELEN\s0, \s-1ITEMHASH\s0, \s-1ITEM\s0..." 4 | |
241 | .IX Item "switch_clause INDENT, NAMELEN, ITEMHASH, ITEM..." | |
242 | An internal function to generate a suitable \f(CW\*(C`switch\*(C'\fR clause, called by | |
243 | \&\f(CW\*(C`C_constant\*(C'\fR \fI\s-1ITEM\s0\fRs are in the hash ref format as given in the description | |
244 | of \f(CW\*(C`C_constant\*(C'\fR, and must all have the names of the same length, given by | |
245 | \&\fI\s-1NAMELEN\s0\fR (This is not checked). \fI\s-1ITEMHASH\s0\fR is a reference to a hash, | |
246 | keyed by name, values being the hashrefs in the \fI\s-1ITEM\s0\fR list. | |
247 | (No parameters are modified, and there can be keys in the \fI\s-1ITEMHASH\s0\fR that | |
248 | are not in the list of \fI\s-1ITEM\s0\fRs without causing problems). | |
249 | .IP "params \s-1WHAT\s0" 4 | |
250 | .IX Item "params WHAT" | |
251 | An internal function. \fI\s-1WHAT\s0\fR should be a hashref of types the constant | |
252 | function will return. \fIparams\fR returns a hashref keyed \s-1IV\s0 \s-1NV\s0 \s-1PV\s0 \s-1SV\s0 to show | |
253 | which combination of pointers will be needed in the C argument list. | |
254 | .IP "dump_names" 4 | |
255 | .IX Item "dump_names" | |
256 | dump_names \s-1DEFAULT_TYPE\s0, \s-1TYPES\s0, \s-1INDENT\s0, \s-1OPTIONS\s0, \s-1ITEM\s0... | |
257 | .Sp | |
258 | An internal function to generate the embedded perl code that will regenerate | |
259 | the constant subroutines. \fI\s-1DEFAULT_TYPE\s0\fR, \fI\s-1TYPES\s0\fR and \fI\s-1ITEM\s0\fRs are the | |
260 | same as for C_constant. \fI\s-1INDENT\s0\fR is treated as number of spaces to indent | |
261 | by. \fI\s-1OPTIONS\s0\fR is a hashref of options. Currently only \f(CW\*(C`declare_types\*(C'\fR is | |
262 | recognised. If the value is true a \f(CW$types\fR is always declared in the perl | |
263 | code generated, if defined and false never declared, and if undefined \f(CW$types\fR | |
264 | is only declared if the values in \fI\s-1TYPES\s0\fR as passed in cannot be inferred from | |
265 | \&\fI\s-1DEFAULT_TYPES\s0\fR and the \fI\s-1ITEM\s0\fRs. | |
266 | .IP "dogfood" 4 | |
267 | .IX Item "dogfood" | |
268 | dogfood \s-1PACKAGE\s0, \s-1SUBNAME\s0, \s-1DEFAULT_TYPE\s0, \s-1TYPES\s0, \s-1INDENT\s0, \s-1BREAKOUT\s0, \s-1ITEM\s0... | |
269 | .Sp | |
270 | An internal function to generate the embedded perl code that will regenerate | |
271 | the constant subroutines. Parameters are the same as for C_constant. | |
272 | .IP "C_constant" 4 | |
273 | .IX Item "C_constant" | |
274 | C_constant \s-1PACKAGE\s0, \s-1SUBNAME\s0, \s-1DEFAULT_TYPE\s0, \s-1TYPES\s0, \s-1INDENT\s0, \s-1BREAKOUT\s0, \s-1ITEM\s0... | |
275 | .Sp | |
276 | A function that returns a \fBlist\fR of C subroutine definitions that return | |
277 | the value and type of constants when passed the name by the \s-1XS\s0 wrapper. | |
278 | \&\fI\s-1ITEM\s0...\fR gives a list of constant names. Each can either be a string, | |
279 | which is taken as a C macro name, or a reference to a hash with the following | |
280 | keys | |
281 | .RS 4 | |
282 | .IP "name" 8 | |
283 | .IX Item "name" | |
284 | The name of the constant, as seen by the perl code. | |
285 | .IP "type" 8 | |
286 | .IX Item "type" | |
287 | The type of the constant (\fI\s-1IV\s0\fR, \fI\s-1NV\s0\fR etc) | |
288 | .IP "value" 8 | |
289 | .IX Item "value" | |
290 | A C expression for the value of the constant, or a list of C expressions if | |
291 | the type is aggregate. This defaults to the \fIname\fR if not given. | |
292 | .IP "macro" 8 | |
293 | .IX Item "macro" | |
294 | The C pre-processor macro to use in the \f(CW\*(C`#ifdef\*(C'\fR. This defaults to the | |
295 | \&\fIname\fR, and is mainly used if \fIvalue\fR is an \f(CW\*(C`enum\*(C'\fR. If a reference an | |
296 | array is passed then the first element is used in place of the \f(CW\*(C`#ifdef\*(C'\fR | |
297 | line, and the second element in place of the \f(CW\*(C`#endif\*(C'\fR. This allows | |
298 | pre-processor constructions such as | |
299 | .Sp | |
300 | .Vb 5 | |
301 | \& #if defined (foo) | |
302 | \& #if !defined (bar) | |
303 | \& ... | |
304 | \& #endif | |
305 | \& #endif | |
306 | .Ve | |
307 | .Sp | |
308 | to be used to determine if a constant is to be defined. | |
309 | .Sp | |
310 | A \*(L"macro\*(R" 1 signals that the constant is always defined, so the \f(CW\*(C`#if\*(C'\fR/\f(CW\*(C`#endif\*(C'\fR | |
311 | test is omitted. | |
312 | .IP "default" 8 | |
313 | .IX Item "default" | |
314 | Default value to use (instead of \f(CW\*(C`croak\*(C'\fRing with \*(L"your vendor has not | |
315 | defined...\*(R") to return if the macro isn't defined. Specify a reference to | |
316 | an array with type followed by value(s). | |
317 | .IP "pre" 8 | |
318 | .IX Item "pre" | |
319 | C code to use before the assignment of the value of the constant. This allows | |
320 | you to use temporary variables to extract a value from part of a \f(CW\*(C`struct\*(C'\fR | |
321 | and return this as \fIvalue\fR. This C code is places at the start of a block, | |
322 | so you can declare variables in it. | |
323 | .IP "post" 8 | |
324 | .IX Item "post" | |
325 | C code to place between the assignment of value (to a temporary) and the | |
326 | return from the function. This allows you to clear up anything in \fIpre\fR. | |
327 | Rarely needed. | |
328 | .IP "def_pre =item def_post" 8 | |
329 | .IX Item "def_pre =item def_post" | |
330 | Equivalents of \fIpre\fR and \fIpost\fR for the default value. | |
331 | .IP "utf8" 8 | |
332 | .IX Item "utf8" | |
333 | Generated internally. Is zero or undefined if name is 7 bit \s-1ASCII\s0, | |
334 | \&\*(L"no\*(R" if the name is 8 bit (and so should only match if \fISvUTF8()\fR is false), | |
335 | \&\*(L"yes\*(R" if the name is utf8 encoded. | |
336 | .Sp | |
337 | The internals automatically clone any name with characters 128\-255 but none | |
338 | 256+ (ie one that could be either in bytes or utf8) into a second entry | |
339 | which is utf8 encoded. | |
340 | .RE | |
341 | .RS 4 | |
342 | .Sp | |
343 | \&\fI\s-1PACKAGE\s0\fR is the name of the package, and is only used in comments inside the | |
344 | generated C code. | |
345 | .Sp | |
346 | The next 5 arguments can safely be given as \f(CW\*(C`undef\*(C'\fR, and are mainly used | |
347 | for recursion. \fI\s-1SUBNAME\s0\fR defaults to \f(CW\*(C`constant\*(C'\fR if undefined. | |
348 | .Sp | |
349 | \&\fI\s-1DEFAULT_TYPE\s0\fR is the type returned by \f(CW\*(C`ITEM\*(C'\fRs that don't specify their | |
350 | type. In turn it defaults to \fI\s-1IV\s0\fR. \fI\s-1TYPES\s0\fR should be given either as a comma | |
351 | separated list of types that the C subroutine \f(CW\*(C`constant\*(C'\fR will generate or as | |
352 | a reference to a hash. \fI\s-1DEFAULT_TYPE\s0\fR will be added to the list if not | |
353 | present, as will any types given in the list of \fI\s-1ITEM\s0\fRs. The resultant list | |
354 | should be the same list of types that \f(CW\*(C`XS_constant\*(C'\fR is given. [Otherwise | |
355 | \&\f(CW\*(C`XS_constant\*(C'\fR and \f(CW\*(C`C_constant\*(C'\fR may differ in the number of parameters to the | |
356 | constant function. \fI\s-1INDENT\s0\fR is currently unused and ignored. In future it may | |
357 | be used to pass in information used to change the C indentation style used.] | |
358 | The best way to maintain consistency is to pass in a hash reference and let | |
359 | this function update it. | |
360 | .Sp | |
361 | \&\fI\s-1BREAKOUT\s0\fR governs when child functions of \fI\s-1SUBNAME\s0\fR are generated. If there | |
362 | are \fI\s-1BREAKOUT\s0\fR or more \fI\s-1ITEM\s0\fRs with the same length of name, then the code | |
363 | to switch between them is placed into a function named \fI\s-1SUBNAME\s0\fR_\fI\s-1LEN\s0\fR, for | |
364 | example \f(CW\*(C`constant_5\*(C'\fR for names 5 characters long. The default \fI\s-1BREAKOUT\s0\fR is | |
365 | 3. A single \f(CW\*(C`ITEM\*(C'\fR is always inlined. | |
366 | .RE | |
367 | .IP "XS_constant \s-1PACKAGE\s0, \s-1TYPES\s0, \s-1SUBNAME\s0, C_SUBNAME" 4 | |
368 | .IX Item "XS_constant PACKAGE, TYPES, SUBNAME, C_SUBNAME" | |
369 | A function to generate the \s-1XS\s0 code to implement the perl subroutine | |
370 | \&\fI\s-1PACKAGE\s0\fR::constant used by \fI\s-1PACKAGE\s0\fR::AUTOLOAD to load constants. | |
371 | This \s-1XS\s0 code is a wrapper around a C subroutine usually generated by | |
372 | \&\f(CW\*(C`C_constant\*(C'\fR, and usually named \f(CW\*(C`constant\*(C'\fR. | |
373 | .Sp | |
374 | \&\fI\s-1TYPES\s0\fR should be given either as a comma separated list of types that the | |
375 | C subroutine \f(CW\*(C`constant\*(C'\fR will generate or as a reference to a hash. It should | |
376 | be the same list of types as \f(CW\*(C`C_constant\*(C'\fR was given. | |
377 | [Otherwise \f(CW\*(C`XS_constant\*(C'\fR and \f(CW\*(C`C_constant\*(C'\fR may have different ideas about | |
378 | the number of parameters passed to the C function \f(CW\*(C`constant\*(C'\fR] | |
379 | .Sp | |
380 | You can call the perl visible subroutine something other than \f(CW\*(C`constant\*(C'\fR if | |
381 | you give the parameter \fI\s-1SUBNAME\s0\fR. The C subroutine it calls defaults to | |
382 | the name of the perl visible subroutine, unless you give the parameter | |
383 | \&\fIC_SUBNAME\fR. | |
384 | .IP "autoload \s-1PACKAGE\s0, \s-1VERSION\s0, \s-1AUTOLOADER\s0" 4 | |
385 | .IX Item "autoload PACKAGE, VERSION, AUTOLOADER" | |
386 | A function to generate the \s-1AUTOLOAD\s0 subroutine for the module \fI\s-1PACKAGE\s0\fR | |
387 | \&\fI\s-1VERSION\s0\fR is the perl version the code should be backwards compatible with. | |
388 | It defaults to the version of perl running the subroutine. If \fI\s-1AUTOLOADER\s0\fR | |
389 | is true, the \s-1AUTOLOAD\s0 subroutine falls back on AutoLoader::AUTOLOAD for all | |
390 | names that the \fIconstant()\fR routine doesn't recognise. | |
391 | .IP "WriteMakefileSnippet" 4 | |
392 | .IX Item "WriteMakefileSnippet" | |
393 | WriteMakefileSnippet \s-1ATTRIBUTE\s0 => \s-1VALUE\s0 [, ...] | |
394 | .Sp | |
395 | A function to generate perl code for Makefile.PL that will regenerate | |
396 | the constant subroutines. Parameters are named as passed to \f(CW\*(C`WriteConstants\*(C'\fR, | |
397 | with the addition of \f(CW\*(C`INDENT\*(C'\fR to specify the number of leading spaces | |
398 | (default 2). | |
399 | .Sp | |
400 | Currently 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 | |
401 | \&\f(CW\*(C`XS_FILE\*(C'\fR are recognised. | |
402 | .IP "WriteConstants \s-1ATTRIBUTE\s0 => \s-1VALUE\s0 [, ...]" 4 | |
403 | .IX Item "WriteConstants ATTRIBUTE => VALUE [, ...]" | |
404 | Writes a file of C code and a file of \s-1XS\s0 code which you should \f(CW\*(C`#include\*(C'\fR | |
405 | and \f(CW\*(C`INCLUDE\*(C'\fR in the C and \s-1XS\s0 sections respectively of your module's \s-1XS\s0 | |
406 | code. You probaby want to do this in your \f(CW\*(C`Makefile.PL\*(C'\fR, so that you can | |
407 | easily edit the list of constants without touching the rest of your module. | |
408 | The attributes supported are | |
409 | .RS 4 | |
410 | .IP "\s-1NAME\s0" 4 | |
411 | .IX Item "NAME" | |
412 | Name of the module. This must be specified | |
413 | .IP "\s-1DEFAULT_TYPE\s0" 4 | |
414 | .IX Item "DEFAULT_TYPE" | |
415 | The default type for the constants. If not specified \f(CW\*(C`IV\*(C'\fR is assumed. | |
416 | .IP "\s-1BREAKOUT_AT\s0" 4 | |
417 | .IX Item "BREAKOUT_AT" | |
418 | The names of the constants are grouped by length. Generate child subroutines | |
419 | for each group with this number or more names in. | |
420 | .IP "\s-1NAMES\s0" 4 | |
421 | .IX Item "NAMES" | |
422 | An array of constants' names, either scalars containing names, or hashrefs | |
423 | as detailed in \*(L"C_constant\*(R". | |
424 | .IP "C_FILE" 4 | |
425 | .IX Item "C_FILE" | |
426 | The name of the file to write containing the C code. The default is | |
427 | \&\f(CW\*(C`const\-c.inc\*(C'\fR. The \f(CW\*(C`\-\*(C'\fR in the name ensures that the file can't be | |
428 | mistaken for anything related to a legitimate perl package name, and | |
429 | not naming the file \f(CW\*(C`.c\*(C'\fR avoids having to override Makefile.PL's | |
430 | \&\f(CW\*(C`.xs\*(C'\fR to \f(CW\*(C`.c\*(C'\fR rules. | |
431 | .IP "\s-1XS_FILE\s0" 4 | |
432 | .IX Item "XS_FILE" | |
433 | The name of the file to write containing the \s-1XS\s0 code. The default is | |
434 | \&\f(CW\*(C`const\-xs.inc\*(C'\fR. | |
435 | .IP "\s-1SUBNAME\s0" 4 | |
436 | .IX Item "SUBNAME" | |
437 | The perl visible name of the \s-1XS\s0 subroutine generated which will return the | |
438 | constants. The default is \f(CW\*(C`constant\*(C'\fR. | |
439 | .IP "C_SUBNAME" 4 | |
440 | .IX Item "C_SUBNAME" | |
441 | The name of the C subroutine generated which will return the constants. | |
442 | The default is \fI\s-1SUBNAME\s0\fR. Child subroutines have \f(CW\*(C`_\*(C'\fR and the name | |
443 | length appended, so constants with 10 character names would be in | |
444 | \&\f(CW\*(C`constant_10\*(C'\fR with the default \fI\s-1XS_SUBNAME\s0\fR. | |
445 | .RE | |
446 | .RS 4 | |
447 | .RE | |
448 | .SH "AUTHOR" | |
449 | .IX Header "AUTHOR" | |
450 | Nicholas Clark <nick@ccl4.org> based on the code in \f(CW\*(C`h2xs\*(C'\fR by Larry Wall and | |
451 | others |