Imported Upstream version 2.50.2
[platform/upstream/glib.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: GObject Reference Manual</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.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.25.1 (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="5"><tr valign="middle">
16 <td width="100%" align="left" class="shortcuts"></td>
17 <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
18 <td><a accesskey="u" href="rn02.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
19 <td><a accesskey="p" href="rn02.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
20 <td><a accesskey="n" href="glib-genmarshal.html"><img src="right.png" width="16" height="16" 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 class="gallery_image" 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>  [OPTION...] [FILE...]</p></div>
34 </div>
35 <div class="refsect1">
36 <a name="id-1.5.2.5"></a><h2>Description</h2>
37 <p><span class="command"><strong>glib-mkenums</strong></span> is a small perl-script utility that
38 parses C code to extract enum definitions and produces enum descriptions based
39 on text 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 <p><span class="command"><strong>glib-mkenums</strong></span> takes a list of valid C code files as
44 input. The options specified control the text that is output, certain
45 substitutions are performed on the text templates for keywords enclosed
46 in @ characters.
47 </p>
48 <div class="refsect2">
49 <a name="id-1.5.2.5.4"></a><h3>Production text substitutions</h3>
50 <p>
51 Certain keywords enclosed in @ characters will be substituted in the
52 emitted text. For the substitution examples of the keywords below,
53 the following example enum definition is assumed:
54 </p>
55 <div class="informalexample">
56   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
57     <tbody>
58       <tr>
59         <td class="listing_lines" align="right"><pre>1
60 2
61 3
62 4
63 5</pre></td>
64         <td class="listing_code"><pre class="programlisting"><span class="gtkdoc kwc">typedef</span> <span class="gtkdoc kwb">enum</span>
65 <span class="gtkdoc opt">{</span>
66   PREFIX_THE_XVALUE    <span class="gtkdoc opt">=</span> <span class="number">1</span> <span class="gtkdoc opt">&lt;&lt;</span> <span class="number">3</span><span class="gtkdoc opt">,</span>
67   PREFIX_ANOTHER_VALUE <span class="gtkdoc opt">=</span> <span class="number">1</span> <span class="gtkdoc opt">&lt;&lt;</span> <span class="number">4</span>
68 <span class="gtkdoc opt">}</span> PrefixTheXEnum<span class="gtkdoc opt">;</span></pre></td>
69       </tr>
70     </tbody>
71   </table>
72 </div>
73
74 <p>
75 </p>
76 <div class="variablelist"><table border="0" class="variablelist">
77 <colgroup>
78 <col align="left" valign="top">
79 <col>
80 </colgroup>
81 <tbody>
82 <tr>
83 <td><p><span class="term">@EnumName@</span></p></td>
84 <td><p>
85 The name of the enum currently being processed, enum names are assumed to be
86 properly namespaced and to use mixed capitalization to separate
87 words (e.g. PrefixTheXEnum).
88 </p></td>
89 </tr>
90 <tr>
91 <td><p><span class="term">@enum_name@</span></p></td>
92 <td><p>
93 The enum name with words lowercase and word-separated by underscores
94 (e.g. prefix_the_xenum).
95 </p></td>
96 </tr>
97 <tr>
98 <td><p><span class="term">@ENUMNAME@</span></p></td>
99 <td><p>
100 The enum name with words uppercase and word-separated by underscores
101 (e.g. PREFIX_THE_XENUM).
102 </p></td>
103 </tr>
104 <tr>
105 <td><p><span class="term">@ENUMSHORT@</span></p></td>
106 <td><p>
107 The enum name with words uppercase and word-separated by underscores,
108 prefix stripped (e.g. THE_XENUM).
109 </p></td>
110 </tr>
111 <tr>
112 <td><p><span class="term">@ENUMPREFIX@</span></p></td>
113 <td><p>
114 The prefix of the enum name (e.g. PREFIX).
115 </p></td>
116 </tr>
117 <tr>
118 <td><p><span class="term">@VALUENAME@</span></p></td>
119 <td><p>
120 The enum value name currently being processed with words uppercase and
121 word-separated by underscores,
122 this is the assumed literal notation of enum values in the C sources
123 (e.g. PREFIX_THE_XVALUE).
124 </p></td>
125 </tr>
126 <tr>
127 <td><p><span class="term">@valuenick@</span></p></td>
128 <td><p>
129 A nick name for the enum value currently being processed, this is usually
130 generated by stripping common prefix words of all the enum values of the
131 current enum, the words are lowercase and underscores are substituted by a
132 minus (e.g. the-xvalue).
133 </p></td>
134 </tr>
135 <tr>
136 <td><p><span class="term">@valuenum@</span></p></td>
137 <td><p>
138 The integer value for the enum value currently being processed.  This is
139 calculated by using <span class="command"><strong>perl</strong></span> to attempt to evaluate the
140 expression as it appears in the C source code.  If evaluation fails then
141 <span class="command"><strong>glib-mkenums</strong></span> will exit with an error status, but this
142 only happens if <code class="literal">@valuenum@</code> appears in your value
143 production template.  (Since: 2.26)
144 </p></td>
145 </tr>
146 <tr>
147 <td><p><span class="term">@type@</span></p></td>
148 <td><p>
149 This is substituted either by "enum" or "flags", depending on whether the
150 enum value definitions contained bit-shift operators or not (e.g. flags).
151 </p></td>
152 </tr>
153 <tr>
154 <td><p><span class="term">@Type@</span></p></td>
155 <td><p>
156 The same as <code class="literal">@type@</code> with the first letter capitalized (e.g. Flags).
157 </p></td>
158 </tr>
159 <tr>
160 <td><p><span class="term">@TYPE@</span></p></td>
161 <td><p>
162 The same as <code class="literal">@type@</code> with all letters uppercased (e.g. FLAGS).
163 </p></td>
164 </tr>
165 <tr>
166 <td><p><span class="term">@filename@</span></p></td>
167 <td><p>
168 The name of the input file currently being processed (e.g. foo.h).
169 </p></td>
170 </tr>
171 <tr>
172 <td><p><span class="term">@basename@</span></p></td>
173 <td><p>
174 The base name of the input file currently being processed (e.g. foo.h). (Since: 2.22)
175 </p></td>
176 </tr>
177 </tbody>
178 </table></div>
179 <p>
180 </p>
181 </div>
182 <hr>
183 <div class="refsect2">
184 <a name="id-1.5.2.5.5"></a><h3>Trigraph extensions</h3>
185 <p>
186 Some C comments are treated specially in the parsed enum definitions,
187 such comments start out with the trigraph sequence <code class="literal">/*&lt;</code>
188 and end with the trigraph sequence <code class="literal">&gt;*/</code>.
189 Per enum definition, the options "skip" and "flags" can be specified, to
190 indicate this enum definition to be skipped, or for it to be treated as
191 a flags definition, or to specify the common prefix to be stripped from
192 all values to generate value nicknames, respectively. The "underscore_name"
193 option can be used to specify the word separation used in the *_get_type()
194 function. For instance, /*&lt; underscore_name=gnome_vfs_uri_hide_options &gt;*/.
195 </p>
196 <p>
197 Per value definition, the options "skip" and "nick" are supported.
198 The former causes the value to be skipped, and the latter can be used to
199 specify the otherwise auto-generated nickname.
200 Examples:
201 </p>
202 <div class="informalexample">
203   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
204     <tbody>
205       <tr>
206         <td class="listing_lines" align="right"><pre>1
207 2
208 3
209 4
210 5
211 6
212 7
213 8
214 9
215 10
216 11</pre></td>
217         <td class="listing_code"><pre class="programlisting"><span class="gtkdoc kwc">typedef</span> <span class="gtkdoc kwb">enum</span> <span class="comment">/*&lt; skip &gt;*/</span>
218 <span class="gtkdoc opt">{</span>
219   PREFIX_FOO
220 <span class="gtkdoc opt">}</span> PrefixThisEnumWillBeSkipped<span class="gtkdoc opt">;</span>
221 <span class="gtkdoc kwc">typedef</span> <span class="gtkdoc kwb">enum</span> <span class="comment">/*&lt; flags,prefix=PREFIX &gt;*/</span>
222 <span class="gtkdoc opt">{</span>
223   PREFIX_THE_ZEROTH_VALUE<span class="gtkdoc opt">,</span>      <span class="comment">/*&lt; skip &gt;*/</span>
224   PREFIX_THE_FIRST_VALUE<span class="gtkdoc opt">,</span>
225   PREFIX_THE_SECOND_VALUE<span class="gtkdoc opt">,</span>
226   PREFIX_THE_THIRD_VALUE<span class="gtkdoc opt">,</span>       <span class="comment">/*&lt; nick=the-last-value &gt;*/</span>
227 <span class="gtkdoc opt">}</span> PrefixTheFlagsEnum<span class="gtkdoc opt">;</span></pre></td>
228       </tr>
229     </tbody>
230   </table>
231 </div>
232
233 <p>
234 </p>
235 </div>
236 </div>
237 <div class="refsect1">
238 <a name="id-1.5.2.6"></a><h2>Options</h2>
239 <div class="variablelist"><table border="0" class="variablelist">
240 <colgroup>
241 <col align="left" valign="top">
242 <col>
243 </colgroup>
244 <tbody>
245 <tr>
246 <td><p><span class="term"><code class="option">--fhead</code> <em class="replaceable"><code>TEXT</code></em></span></p></td>
247 <td><p>
248 Put out <em class="replaceable"><code>TEXT</code></em> prior to processing input files.
249 </p></td>
250 </tr>
251 <tr>
252 <td><p><span class="term"><code class="option">--fprod</code> <em class="replaceable"><code>TEXT</code></em></span></p></td>
253 <td><p>
254 Put out <em class="replaceable"><code>TEXT</code></em> everytime a new input file
255 is being processed.
256 </p></td>
257 </tr>
258 <tr>
259 <td><p><span class="term"><code class="option">--ftail</code> <em class="replaceable"><code>TEXT</code></em></span></p></td>
260 <td><p>
261 Put out <em class="replaceable"><code>TEXT</code></em> after all input files have been
262 processed.
263 </p></td>
264 </tr>
265 <tr>
266 <td><p><span class="term"><code class="option">--eprod</code> <em class="replaceable"><code>TEXT</code></em></span></p></td>
267 <td><p>
268 Put out <em class="replaceable"><code>TEXT</code></em> everytime an enum is encountered
269 in the input files.
270 </p></td>
271 </tr>
272 <tr>
273 <td><p><span class="term"><code class="option">--vhead</code> <em class="replaceable"><code>TEXT</code></em></span></p></td>
274 <td><p>
275 Put out <em class="replaceable"><code>TEXT</code></em> before iterating over the set of
276 values of an enum.
277 </p></td>
278 </tr>
279 <tr>
280 <td><p><span class="term"><code class="option">--vprod</code> <em class="replaceable"><code>TEXT</code></em></span></p></td>
281 <td><p>
282 Put out <em class="replaceable"><code>TEXT</code></em> for every value of an enum.
283 </p></td>
284 </tr>
285 <tr>
286 <td><p><span class="term"><code class="option">--vtail</code> <em class="replaceable"><code>TEXT</code></em></span></p></td>
287 <td><p>
288 Put out <em class="replaceable"><code>TEXT</code></em> after iterating over all values
289 of an enum.
290 </p></td>
291 </tr>
292 <tr>
293 <td><p><span class="term"><code class="option">--comments</code> <em class="replaceable"><code>TEXT</code></em></span></p></td>
294 <td><p>
295 Template for auto-generated comments, the default (for C code generations) is
296 <code class="literal">"/* @comment@ */"</code>.
297 </p></td>
298 </tr>
299 <tr>
300 <td><p><span class="term"><code class="option">--template</code> <em class="replaceable"><code>FILE</code></em></span></p></td>
301 <td>
302 <p>
303 Read templates from the given file. The templates are enclosed in
304 specially-formatted C comments
305 </p>
306 <div class="informalexample">
307   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
308     <tbody>
309       <tr>
310         <td class="listing_lines" align="right"><pre>1
311 2</pre></td>
312         <td class="listing_code"><pre class="programlisting"><span class="comment">/*** BEGIN section ***/</span>
313 <span class="comment">/*** END section ***/</span></pre></td>
314       </tr>
315     </tbody>
316   </table>
317 </div>
318
319 <p>
320 where section may be <code class="literal">file-header</code>,
321 <code class="literal">file-production</code>, <code class="literal">file-tail</code>,
322 <code class="literal">enumeration-production</code>, <code class="literal">value-header</code>,
323 <code class="literal">value-production</code>, <code class="literal">value-tail</code> or
324 <code class="literal">comment</code>.
325 </p>
326 </td>
327 </tr>
328 <tr>
329 <td><p><span class="term"><code class="option">--identifier-prefix</code> <em class="replaceable"><code>PREFIX</code></em></span></p></td>
330 <td><p>
331 Indicates what portion of the enum name should be intepreted as the
332 prefix (eg, the "<code class="literal">Gtk</code>" in
333 "<code class="literal">GtkDirectionType</code>"). Normally this will be figured
334 out automatically, but you may need to override the default if your
335 namespace is capitalized oddly.
336 </p></td>
337 </tr>
338 <tr>
339 <td><p><span class="term"><code class="option">--symbol-prefix</code> <em class="replaceable"><code>PREFIX</code></em></span></p></td>
340 <td><p>
341 Indicates what prefix should be used to correspond to the identifier
342 prefix in related C function names (eg, the "<code class="literal">gtk</code>"
343 in "<code class="literal">gtk_direction_type_get_type</code>". Equivalently,
344 this is the lowercase version of the prefix component of the enum
345 value names (eg, the "<code class="literal">GTK</code>" in
346 "<code class="literal">GTK_DIR_UP</code>". The default value is the identifier
347 prefix, converted to lowercase.
348 </p></td>
349 </tr>
350 <tr>
351 <td><p><span class="term"><code class="option">--help</code></span></p></td>
352 <td><p>
353 Print brief help and exit.
354 </p></td>
355 </tr>
356 <tr>
357 <td><p><span class="term"><code class="option">--version</code></span></p></td>
358 <td><p>
359 Print version and exit.
360 </p></td>
361 </tr>
362 </tbody>
363 </table></div>
364 </div>
365 <div class="refsect1">
366 <a name="id-1.5.2.7"></a><h2>See also</h2>
367 <p>
368 <span class="citerefentry"><span class="refentrytitle">glib-genmarshal</span>(1)</span>
369 </p>
370 </div>
371 </div>
372 <div class="footer">
373 <hr>Generated by GTK-Doc V1.25.1</div>
374 </body>
375 </html>