Moving files to packaging and extracing new tarball.
[profile/ivi/glib2.git] / docs / reference / gobject / glib-mkenums.1
1 '\" t
2 .\"     Title: glib-mkenums
3 .\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
4 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
5 .\"      Date: 03/05/2012
6 .\"    Manual: User Commands
7 .\"    Source: User Commands
8 .\"  Language: English
9 .\"
10 .TH "GLIB\-MKENUMS" "1" "03/05/2012" "User Commands" "User Commands"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 glib-mkenums \- C language enum description generation utility
32 .SH "SYNOPSIS"
33 .HP \w'\fBglib\-mkenums\fR\ 'u
34 \fBglib\-mkenums\fR [options...] [files...]
35 .SH "DESCRIPTION"
36 .PP
37 \fBglib\-mkenums\fR
38 is a small perl\-script utility that parses C code to extract enum definitions and produces enum descriptions based on text templates specified by the user\&. Most frequently this script is used to produce C code that contains enum values as strings so programs can provide value name strings for introspection\&.
39 .SH "INVOCATION"
40 .PP
41 \fBglib\-mkenums\fR
42 takes a list of valid C code files as input\&. The options specified control the text that is output, certain substitutions are performed on the text templates for keywords enclosed in @ characters\&.
43 .SS "Options"
44 .PP
45 \fB\-\-fhead\fR \fItext\fR
46 .RS 4
47 Put out
48 \fItext\fR
49 prior to processing input files\&.
50 .RE
51 .PP
52 \fB\-\-fprod\fR \fItext\fR
53 .RS 4
54 Put out
55 \fItext\fR
56 everytime a new input file is being processed\&.
57 .RE
58 .PP
59 \fB\-\-ftail\fR \fItext\fR
60 .RS 4
61 Put out
62 \fItext\fR
63 after all input files have been processed\&.
64 .RE
65 .PP
66 \fB\-\-eprod\fR \fItext\fR
67 .RS 4
68 Put out
69 \fItext\fR
70 everytime an enum is encountered in the input files\&.
71 .RE
72 .PP
73 \fB\-\-vhead\fR \fItext\fR
74 .RS 4
75 Put out
76 \fItext\fR
77 before iterating over the set of values of an enum\&.
78 .RE
79 .PP
80 \fB\-\-vprod\fR \fItext\fR
81 .RS 4
82 Put out
83 \fItext\fR
84 for every value of an enum\&.
85 .RE
86 .PP
87 \fB\-\-vtail\fR \fItext\fR
88 .RS 4
89 Put out
90 \fItext\fR
91 after iterating over all values of an enum\&.
92 .RE
93 .PP
94 \fB\-\-comments\fR \fItext\fR
95 .RS 4
96 Template for auto\-generated comments, the default (for C code generations) is
97 "/* @comment@ */"\&.
98 .RE
99 .PP
100 \fB\-\-template\fR \fIfile\fR
101 .RS 4
102 Read templates from the given file\&. The templates are enclosed in specially\-formatted C comments
103 .sp
104 .if n \{\
105 .RS 4
106 .\}
107 .nf
108 /*** BEGIN section ***/
109 /*** END section ***/
110 .fi
111 .if n \{\
112 .RE
113 .\}
114 .sp
115 where section may be
116 file\-header,
117 file\-production,
118 file\-tail,
119 enumeration\-production,
120 value\-header,
121 value\-production,
122 value\-tail
123 or
124 comment\&.
125 .RE
126 .PP
127 \fB\-\-identifier\-prefix\fR \fIprefix\fR
128 .RS 4
129 Indicates what portion of the enum name should be intepreted as the prefix (eg, the "Gtk" in "GtkDirectionType")\&. Normally this will be figured out automatically, but you may need to override the default if your namespace is capitalized oddly\&.
130 .RE
131 .PP
132 \fB\-\-symbol\-prefix\fR \fIprefix\fR
133 .RS 4
134 Indicates what prefix should be used to correspond to the identifier prefix in related C function names (eg, the "gtk" in "gtk_direction_type_get_type"\&. Equivalently, this is the lowercase version of the prefix component of the enum value names (eg, the "GTK" in "GTK_DIR_UP"\&. The default value is the identifier prefix, converted to lowercase\&.
135 .RE
136 .PP
137 \fB\-\-help\fR
138 .RS 4
139 Print brief help and exit\&.
140 .RE
141 .PP
142 \fB\-\-version\fR
143 .RS 4
144 Print version and exit\&.
145 .RE
146 .SS "Production text substitutions"
147 .PP
148 Certain keywords enclosed in @ characters will be substituted in the emitted text\&. For the substitution examples of the keywords below, the following example enum definition is assumed:
149 .sp
150 .if n \{\
151 .RS 4
152 .\}
153 .nf
154 typedef enum
155 {
156   PREFIX_THE_XVALUE    = 1 << 3,
157   PREFIX_ANOTHER_VALUE = 1 << 4
158 } PrefixTheXEnum;
159 .fi
160 .if n \{\
161 .RE
162 .\}
163 .PP
164 @EnumName@
165 .RS 4
166 The name of the enum currently being processed, enum names are assumed to be properly namespaced and to use mixed capitalization to separate words (e\&.g\&. PrefixTheXEnum)\&.
167 .RE
168 .PP
169 @enum_name@
170 .RS 4
171 The enum name with words lowercase and word\-separated by underscores (e\&.g\&. prefix_the_xenum)\&.
172 .RE
173 .PP
174 @ENUMNAME@
175 .RS 4
176 The enum name with words uppercase and word\-separated by underscores (e\&.g\&. PREFIX_THE_XENUM)\&.
177 .RE
178 .PP
179 @ENUMSHORT@
180 .RS 4
181 The enum name with words uppercase and word\-separated by underscores, prefix stripped (e\&.g\&. THE_XENUM)\&.
182 .RE
183 .PP
184 @VALUENAME@
185 .RS 4
186 The enum value name currently being processed with words uppercase and word\-separated by underscores, this is the assumed literal notation of enum values in the C sources (e\&.g\&. PREFIX_THE_XVALUE)\&.
187 .RE
188 .PP
189 @valuenick@
190 .RS 4
191 A nick name for the enum value currently being processed, this is usually generated by stripping common prefix words of all the enum values of the current enum, the words are lowercase and underscores are substituted by a minus (e\&.g\&. the\-xvalue)\&.
192 .RE
193 .PP
194 @valuenum@
195 .RS 4
196 The integer value for the enum value currently being processed\&. This is calculated by using
197 \fBperl\fR
198 to attempt to evaluate the expression as it appears in the C source code\&. If evaluation fails then
199 \fBglib\-mkenums\fR
200 will exit with an error status, but this only happens if
201 @valuenum@
202 appears in your value production template\&. (Since: 2\&.26)
203 .RE
204 .PP
205 @type@
206 .RS 4
207 This is substituted either by "enum" or "flags", depending on whether the enum value definitions contained bit\-shift operators or not (e\&.g\&. flags)\&.
208 .RE
209 .PP
210 @Type@
211 .RS 4
212 The same as
213 @type@
214 with the first letter capitalized (e\&.g\&. Flags)\&.
215 .RE
216 .PP
217 @TYPE@
218 .RS 4
219 The same as
220 @type@
221 with all letters uppercased (e\&.g\&. FLAGS)\&.
222 .RE
223 .PP
224 @filename@
225 .RS 4
226 The name of the input file currently being processed (e\&.g\&. foo\&.h)\&.
227 .RE
228 .PP
229 @basename@
230 .RS 4
231 The base name of the input file currently being processed (e\&.g\&. foo\&.h)\&. (Since: 2\&.22)
232 .RE
233 .SS "Trigraph extensions"
234 .PP
235 Some C comments are treated specially in the parsed enum definitions, such comments start out with the trigraph sequence
236 /*<
237 and end with the trigraph sequence
238 >*/\&. Per enum definition, the options "skip" and "flags" can be specified, to indicate this enum definition to be skipped, or for it to be treated as a flags definition, or to specify the common prefix to be stripped from all values to generate value nicknames, respectively\&. The "underscore_name" option can be used to specify the word separation used in the *_get_type() function\&. For instance, /*< underscore_name=gnome_vfs_uri_hide_options >*/\&.
239 .PP
240 Per value definition, the options "skip" and "nick" are supported\&. The former causes the value to be skipped, and the latter can be used to specify the otherwise auto\-generated nickname\&. Examples:
241 .sp
242 .if n \{\
243 .RS 4
244 .\}
245 .nf
246 typedef enum /*< skip >*/
247 {
248   PREFIX_FOO
249 } PrefixThisEnumWillBeSkipped;
250 typedef enum /*< flags,prefix=PREFIX >*/
251 {
252   PREFIX_THE_ZEROTH_VALUE,      /*< skip >*/
253   PREFIX_THE_FIRST_VALUE,
254   PREFIX_THE_SECOND_VALUE,
255   PREFIX_THE_THIRD_VALUE,       /*< nick=the\-last\-value >*/
256 } PrefixTheFlagsEnum;
257 .fi
258 .if n \{\
259 .RE
260 .\}
261 .sp
262 .SH "SEE ALSO"
263 .PP
264
265 \fBglib-genmarshal\fR(1)