Moving files to packaging and extracing new tarball.
[profile/ivi/glib2.git] / docs / reference / gobject / html / glib-mkenums.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>glib-mkenums</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GObject Reference Manual">
8 <link rel="up" href="rn02.html" title="Tools Reference">
9 <link rel="prev" href="rn02.html" title="Tools Reference">
10 <link rel="next" href="glib-genmarshal.html" title="glib-genmarshal">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
16 <td><a accesskey="p" href="rn02.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17 <td><a accesskey="u" href="rn02.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
18 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
19 <th width="100%" align="center">GObject Reference Manual</th>
20 <td><a accesskey="n" href="glib-genmarshal.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
21 </tr></table>
22 <div lang="en" class="refentry">
23 <a name="glib-mkenums"></a><div class="titlepage"></div>
24 <div class="refnamediv"><table width="100%"><tr>
25 <td valign="top">
26 <h2><span class="refentrytitle">glib-mkenums</span></h2>
27 <p>glib-mkenums — C language enum description generation utility</p>
28 </td>
29 <td valign="top" align="right"></td>
30 </tr></table></div>
31 <div class="refsynopsisdiv">
32 <h2>Synopsis</h2>
33 <div class="cmdsynopsis"><p><code class="command">glib-mkenums</code>  [options...] [files...]</p></div>
34 </div>
35 <div class="refsect1">
36 <a name="id441412"></a><h2>Description</h2>
37 <p><span class="command"><strong>glib-mkenums</strong></span> is a small perl-script utility that parses C
38 code to extract enum definitions and produces enum descriptions based on text
39 templates specified by the user. Most frequently this script is used to 
40 produce C code that contains enum values as strings so programs can provide 
41 value name strings for introspection.
42 </p>
43 </div>
44 <div class="refsect1">
45 <a name="id428682"></a><h2>Invocation</h2>
46 <p><span class="command"><strong>glib-mkenums</strong></span> takes a list of valid C code files as
47 input. The options specified control the text that is output, certain 
48 substitutions are performed on the text templates for keywords enclosed 
49 in @ characters.
50 </p>
51 <div class="refsect2">
52 <a name="id432462"></a><h3>Options</h3>
53 <div class="variablelist"><table border="0">
54 <col align="left" valign="top">
55 <tbody>
56 <tr>
57 <td><p><span class="term"><code class="option">--fhead</code> <em class="replaceable"><code>text</code></em></span></p></td>
58 <td><p>
59 Put out <em class="replaceable"><code>text</code></em> prior to processing input files.
60 </p></td>
61 </tr>
62 <tr>
63 <td><p><span class="term"><code class="option">--fprod</code> <em class="replaceable"><code>text</code></em></span></p></td>
64 <td><p>
65 Put out <em class="replaceable"><code>text</code></em> everytime a new input file 
66 is being processed.
67 </p></td>
68 </tr>
69 <tr>
70 <td><p><span class="term"><code class="option">--ftail</code> <em class="replaceable"><code>text</code></em></span></p></td>
71 <td><p>
72 Put out <em class="replaceable"><code>text</code></em> after all input files have been 
73 processed.
74 </p></td>
75 </tr>
76 <tr>
77 <td><p><span class="term"><code class="option">--eprod</code> <em class="replaceable"><code>text</code></em></span></p></td>
78 <td><p>
79 Put out <em class="replaceable"><code>text</code></em> everytime an enum is encountered 
80 in the input files.
81 </p></td>
82 </tr>
83 <tr>
84 <td><p><span class="term"><code class="option">--vhead</code> <em class="replaceable"><code>text</code></em></span></p></td>
85 <td><p>
86 Put out <em class="replaceable"><code>text</code></em> before iterating over the set of 
87 values of an enum.
88 </p></td>
89 </tr>
90 <tr>
91 <td><p><span class="term"><code class="option">--vprod</code> <em class="replaceable"><code>text</code></em></span></p></td>
92 <td><p>
93 Put out <em class="replaceable"><code>text</code></em> for every value of an enum.
94 </p></td>
95 </tr>
96 <tr>
97 <td><p><span class="term"><code class="option">--vtail</code> <em class="replaceable"><code>text</code></em></span></p></td>
98 <td><p>
99 Put out <em class="replaceable"><code>text</code></em> after iterating over all values 
100 of an enum.
101 </p></td>
102 </tr>
103 <tr>
104 <td><p><span class="term"><code class="option">--comments</code> <em class="replaceable"><code>text</code></em></span></p></td>
105 <td><p>
106 Template for auto-generated comments, the default (for C code generations) is
107 <code class="literal">"/* @comment@ */"</code>.
108 </p></td>
109 </tr>
110 <tr>
111 <td><p><span class="term"><code class="option">--template</code> <em class="replaceable"><code>file</code></em></span></p></td>
112 <td>
113 <p>
114 Read templates from the given file. The templates are enclosed in
115 specially-formatted C comments
116 </p>
117 <pre class="programlisting">
118 /*** BEGIN section ***/
119 /*** END section ***/
120 </pre>
121 <p>
122 where section may be <code class="literal">file-header</code>, 
123 <code class="literal">file-production</code>, <code class="literal">file-tail</code>,
124 <code class="literal">enumeration-production</code>, <code class="literal">value-header</code>, 
125 <code class="literal">value-production</code>, <code class="literal">value-tail</code> or
126 <code class="literal">comment</code>.
127 </p>
128 </td>
129 </tr>
130 <tr>
131 <td><p><span class="term"><code class="option">--identifier-prefix</code> <em class="replaceable"><code>prefix</code></em></span></p></td>
132 <td><p>
133 Indicates what portion of the enum name should be intepreted as the
134 prefix (eg, the "<code class="literal">Gtk</code>" in
135 "<code class="literal">GtkDirectionType</code>"). Normally this will be figured
136 out automatically, but you may need to override the default if your
137 namespace is capitalized oddly.
138 </p></td>
139 </tr>
140 <tr>
141 <td><p><span class="term"><code class="option">--symbol-prefix</code> <em class="replaceable"><code>prefix</code></em></span></p></td>
142 <td><p>
143 Indicates what prefix should be used to correspond to the identifier
144 prefix in related C function names (eg, the "<code class="literal">gtk</code>"
145 in "<code class="literal">gtk_direction_type_get_type</code>". Equivalently,
146 this is the lowercase version of the prefix component of the enum
147 value names (eg, the "<code class="literal">GTK</code>" in
148 "<code class="literal">GTK_DIR_UP</code>". The default value is the identifier
149 prefix, converted to lowercase.
150 </p></td>
151 </tr>
152 <tr>
153 <td><p><span class="term"><code class="option">--help</code></span></p></td>
154 <td><p>
155 Print brief help and exit.
156 </p></td>
157 </tr>
158 <tr>
159 <td><p><span class="term"><code class="option">--version</code></span></p></td>
160 <td><p>
161 Print version and exit.
162 </p></td>
163 </tr>
164 </tbody>
165 </table></div>
166 </div>
167 <hr>
168 <div class="refsect2">
169 <a name="id416414"></a><h3>Production text substitutions</h3>
170 <p>
171 Certain keywords enclosed in @ characters will be substituted in the 
172 emitted text. For the substitution examples of the keywords below, 
173 the following example enum definition is assumed:
174 </p>
175 <pre class="programlisting">
176 typedef enum
177 {
178   PREFIX_THE_XVALUE    = 1 &lt;&lt; 3,
179   PREFIX_ANOTHER_VALUE = 1 &lt;&lt; 4
180 } PrefixTheXEnum;
181 </pre>
182 <p>
183 </p>
184 <div class="variablelist"><table border="0">
185 <col align="left" valign="top">
186 <tbody>
187 <tr>
188 <td><p><span class="term">@EnumName@</span></p></td>
189 <td><p>
190 The name of the enum currently being processed, enum names are assumed to be
191 properly namespaced and to use mixed capitalization to separate
192 words (e.g. PrefixTheXEnum).
193 </p></td>
194 </tr>
195 <tr>
196 <td><p><span class="term">@enum_name@</span></p></td>
197 <td><p>
198 The enum name with words lowercase and word-separated by underscores 
199 (e.g. prefix_the_xenum).
200 </p></td>
201 </tr>
202 <tr>
203 <td><p><span class="term">@ENUMNAME@</span></p></td>
204 <td><p>
205 The enum name with words uppercase and word-separated by underscores 
206 (e.g. PREFIX_THE_XENUM).
207 </p></td>
208 </tr>
209 <tr>
210 <td><p><span class="term">@ENUMSHORT@</span></p></td>
211 <td><p>
212 The enum name with words uppercase and word-separated by underscores, 
213 prefix stripped (e.g. THE_XENUM).
214 </p></td>
215 </tr>
216 <tr>
217 <td><p><span class="term">@VALUENAME@</span></p></td>
218 <td><p>
219 The enum value name currently being processed with words uppercase and 
220 word-separated by underscores,
221 this is the assumed literal notation of enum values in the C sources 
222 (e.g. PREFIX_THE_XVALUE).
223 </p></td>
224 </tr>
225 <tr>
226 <td><p><span class="term">@valuenick@</span></p></td>
227 <td><p>
228 A nick name for the enum value currently being processed, this is usually 
229 generated by stripping common prefix words of all the enum values of the 
230 current enum, the words are lowercase and underscores are substituted by a 
231 minus (e.g. the-xvalue).
232 </p></td>
233 </tr>
234 <tr>
235 <td><p><span class="term">@valuenum@</span></p></td>
236 <td><p>
237 The integer value for the enum value currently being processed.  This is
238 calculated by using <span class="command"><strong>perl</strong></span> to attempt to evaluate the
239 expression as it appears in the C source code.  If evaluation fails then
240 <span class="command"><strong>glib-mkenums</strong></span> will exit with an error status, but this
241 only happens if <code class="literal">@valuenum@</code> appears in your value
242 production template.  (Since: 2.26)
243 </p></td>
244 </tr>
245 <tr>
246 <td><p><span class="term">@type@</span></p></td>
247 <td><p>
248 This is substituted either by "enum" or "flags", depending on whether the 
249 enum value definitions contained bit-shift operators or not (e.g. flags).
250 </p></td>
251 </tr>
252 <tr>
253 <td><p><span class="term">@Type@</span></p></td>
254 <td><p>
255 The same as <code class="literal">@type@</code> with the first letter capitalized (e.g. Flags).
256 </p></td>
257 </tr>
258 <tr>
259 <td><p><span class="term">@TYPE@</span></p></td>
260 <td><p>
261 The same as <code class="literal">@type@</code> with all letters uppercased (e.g. FLAGS).
262 </p></td>
263 </tr>
264 <tr>
265 <td><p><span class="term">@filename@</span></p></td>
266 <td><p>
267 The name of the input file currently being processed (e.g. foo.h).
268 </p></td>
269 </tr>
270 <tr>
271 <td><p><span class="term">@basename@</span></p></td>
272 <td><p>
273 The base name of the input file currently being processed (e.g. foo.h). (Since: 2.22)
274 </p></td>
275 </tr>
276 </tbody>
277 </table></div>
278 <p>
279 </p>
280 </div>
281 <hr>
282 <div class="refsect2">
283 <a name="id453459"></a><h3>Trigraph extensions</h3>
284 <p>
285 Some C comments are treated specially in the parsed enum definitions, 
286 such comments start out with the trigraph sequence <code class="literal">/*&lt;</code> 
287 and end with the trigraph sequence <code class="literal">&gt;*/</code>.
288 Per enum definition, the options "skip" and "flags" can be specified, to 
289 indicate this enum definition to be skipped, or for it to be treated as 
290 a flags definition, or to specify the common prefix to be stripped from 
291 all values to generate value nicknames, respectively. The "underscore_name"
292 option can be used to specify the word separation used in the *_get_type()
293 function. For instance, /*&lt; underscore_name=gnome_vfs_uri_hide_options &gt;*/.
294 </p>
295 <p>
296 Per value definition, the options "skip" and "nick" are supported. 
297 The former causes the value to be skipped, and the latter can be used to 
298 specify the otherwise auto-generated nickname.
299 Examples:
300 </p>
301 <pre class="programlisting">
302 typedef enum /*&lt; skip &gt;*/
303 {
304   PREFIX_FOO
305 } PrefixThisEnumWillBeSkipped;
306 typedef enum /*&lt; flags,prefix=PREFIX &gt;*/
307 {
308   PREFIX_THE_ZEROTH_VALUE,      /*&lt; skip &gt;*/
309   PREFIX_THE_FIRST_VALUE,
310   PREFIX_THE_SECOND_VALUE,
311   PREFIX_THE_THIRD_VALUE,       /*&lt; nick=the-last-value &gt;*/
312 } PrefixTheFlagsEnum;
313 </pre>
314 <p>
315 </p>
316 </div>
317 </div>
318 <div class="refsect1">
319 <a name="id443936"></a><h2>See also</h2>
320 <p>
321 <span class="citerefentry"><span class="refentrytitle">glib-genmarshal</span>(1)</span>
322 </p>
323 </div>
324 </div>
325 <div class="footer">
326 <hr>
327           Generated by GTK-Doc V1.18</div>
328 </body>
329 </html>