1ExtUtils::Constant::BaseP(e3rplm)Programmers ReferenceEGxutiUdteils::Constant::Base(3pm)
2
3
4

NAME

6       ExtUtils::Constant::Base - base class for ExtUtils::Constant objects
7

SYNOPSIS

9           require ExtUtils::Constant::Base;
10           @ISA = 'ExtUtils::Constant::Base';
11

DESCRIPTION

13       ExtUtils::Constant::Base provides a base implementation of methods to
14       generate C code to give fast constant value lookup by named string.
15       Currently it's mostly used ExtUtils::Constant::XS, which generates the
16       lookup code for the constant() subroutine found in many XS modules.
17

USAGE

19       ExtUtils::Constant::Base exports no subroutines. The following methods
20       are available
21
22       header
23           A method returning a scalar containing definitions needed, typi‐
24           cally for a C header file.
25
26       memEQ_clause args_hashref
27           A method to return a suitable C "if" statement to check whether
28           name is equal to the C variable "name". If checked_at is defined,
29           then it is used to avoid "memEQ" for short names, or to generate a
30           comment to highlight the position of the character in the "switch"
31           statement.
32
33           If i<checked_at> is a reference to a scalar, then instead it gives
34           the characters pre-checked at the beginning, (and the number of
35           chars by which the C variable name has been advanced. These need to
36           be chopped from the front of name).
37
38       dump_names arg_hashref, ITEM...
39           An internal function to generate the embedded perl code that will
40           regenerate the constant subroutines.  default_type, types and ITEMs
41           are the same as for C_constant.  indent is treated as number of
42           spaces to indent by.  If "declare_types" is true a $types is always
43           declared in the perl code generated, if defined and false never
44           declared, and if undefined $types is only declared if the values in
45           types as passed in cannot be inferred from default_types and the
46           ITEMs.
47
48       assign arg_hashref, VALUE...
49           A method to return a suitable assignment clause. If type is aggre‐
50           gate (eg PVN expects both pointer and length) then there should be
51           multiple VALUEs for the components. pre and post if defined give
52           snippets of C code to proceed and follow the assignment. pre will
53           be at the start of a block, so variables may be defined in it.
54
55       return_clause arg_hashref, ITEM
56           A method to return a suitable "#ifdef" clause. ITEM is a hashref
57           (as passed to "C_constant" and "match_clause". indent is the number
58           of spaces to indent, defaulting to 6.
59
60       switch_clause arg_hashref, NAMELEN, ITEMHASH, ITEM...
61           An internal method to generate a suitable "switch" clause, called
62           by "C_constant" ITEMs are in the hash ref format as given in the
63           description of "C_constant", and must all have the names of the
64           same length, given by NAMELEN.  ITEMHASH is a reference to a hash,
65           keyed by name, values being the hashrefs in the ITEM list.  (No
66           parameters are modified, and there can be keys in the ITEMHASH that
67           are not in the list of ITEMs without causing problems - the hash is
68           passed in to save generating it afresh for each call).
69
70       params WHAT
71           An "internal" method, subject to change, currently called to allow
72           an overriding class to cache information that will then be passed
73           into all the "*param*" calls. (Yes, having to read the source to
74           make sense of this is considered a known bug). WHAT is be a hashref
75           of types the constant function will return. In ExtUtils::Con‐
76           stant::XS this method is used to returns a hashref keyed IV NV PV
77           SV to show which combination of pointers will be needed in the C
78           argument list generated by C_constant_other_params_definition and
79           C_constant_other_params
80
81       dogfood arg_hashref, ITEM...
82           An internal function to generate the embedded perl code that will
83           regenerate the constant subroutines.  Parameters are the same as
84           for C_constant.
85
86           Currently the base class does nothing and returns an empty string.
87
88       C_constant arg_hashref, ITEM...
89           A function that returns a list of C subroutine definitions that
90           return the value and type of constants when passed the name by the
91           XS wrapper.  ITEM... gives a list of constant names. Each can
92           either be a string, which is taken as a C macro name, or a refer‐
93           ence to a hash with the following keys
94
95           name    The name of the constant, as seen by the perl code.
96
97           type    The type of the constant (IV, NV etc)
98
99           value   A C expression for the value of the constant, or a list of
100                   C expressions if the type is aggregate. This defaults to
101                   the name if not given.
102
103           macro   The C pre-processor macro to use in the "#ifdef". This
104                   defaults to the name, and is mainly used if value is an
105                   "enum". If a reference an array is passed then the first
106                   element is used in place of the "#ifdef" line, and the sec‐
107                   ond element in place of the "#endif". This allows pre-pro‐
108                   cessor constructions such as
109
110                       #if defined (foo)
111                       #if !defined (bar)
112                       ...
113                       #endif
114                       #endif
115
116                   to be used to determine if a constant is to be defined.
117
118                   A "macro" 1 signals that the constant is always defined, so
119                   the "#if"/"#endif" test is omitted.
120
121           default Default value to use (instead of "croak"ing with "your ven‐
122                   dor has not defined...") to return if the macro isn't
123                   defined. Specify a reference to an array with type followed
124                   by value(s).
125
126           pre     C code to use before the assignment of the value of the
127                   constant. This allows you to use temporary variables to
128                   extract a value from part of a "struct" and return this as
129                   value. This C code is places at the start of a block, so
130                   you can declare variables in it.
131
132           post    C code to place between the assignment of value (to a tem‐
133                   porary) and the return from the function. This allows you
134                   to clear up anything in pre.  Rarely needed.
135
136           def_pre
137           def_post
138                   Equivalents of pre and post for the default value.
139
140           utf8    Generated internally. Is zero or undefined if name is 7 bit
141                   ASCII, "no" if the name is 8 bit (and so should only match
142                   if SvUTF8() is false), "yes" if the name is utf8 encoded.
143
144                   The internals automatically clone any name with characters
145                   128-255 but none 256+ (ie one that could be either in bytes
146                   or utf8) into a second entry which is utf8 encoded.
147
148           weight  Optional sorting weight for names, to determine the order
149                   of linear testing when multiple names fall in the same case
150                   of a switch clause.  Higher comes earlier, undefined
151                   defaults to zero.
152
153           In the argument hashref, package is the name of the package, and is
154           only used in comments inside the generated C code. subname defaults
155           to "constant" if undefined.
156
157           default_type is the type returned by "ITEM"s that don't specify
158           their type. It defaults to the value of "default_type()". types
159           should be given either as a comma separated list of types that the
160           C subroutine subname will generate or as a reference to a hash.
161           default_type will be added to the list if not present, as will any
162           types given in the list of ITEMs. The resultant list should be the
163           same list of types that "XS_constant" is given. [Otherwise "XS_con‐
164           stant" and "C_constant" may differ in the number of parameters to
165           the constant function. indent is currently unused and ignored. In
166           future it may be used to pass in information used to change the C
167           indentation style used.]  The best way to maintain consistency is
168           to pass in a hash reference and let this function update it.
169
170           breakout governs when child functions of subname are generated.  If
171           there are breakout or more ITEMs with the same length of name, then
172           the code to switch between them is placed into a function named
173           subname_len, for example "constant_5" for names 5 characters long.
174           The default breakout is 3.  A single "ITEM" is always inlined.
175

BUGS

177       Not everything is documented yet.
178
179       Probably others.
180

AUTHOR

182       Nicholas Clark <nick@ccl4.org> based on the code in "h2xs" by Larry
183       Wall and others
184
185
186
187perl v5.8.8                       2001-09-21     ExtUtils::Constant::Base(3pm)
Impressum