2.20.0
[platform/upstream/glib.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.74.2 <http://docbook.sf.net/>
5 .\"      Date: 03/13/2009
6 .\"    Manual: [FIXME: manual]
7 .\"    Source: [FIXME: source]
8 .\"  Language: English
9 .\"
10 .TH "GLIB\-MKENUMS" "1" "03/13/2009" "[FIXME: source]" "[FIXME: manual]"
11 .\" -----------------------------------------------------------------
12 .\" * set default formatting
13 .\" -----------------------------------------------------------------
14 .\" disable hyphenation
15 .nh
16 .\" disable justification (adjust text to left margin only)
17 .ad l
18 .\" -----------------------------------------------------------------
19 .\" * MAIN CONTENT STARTS HERE *
20 .\" -----------------------------------------------------------------
21 .SH "NAME"
22 glib-mkenums \- C language enum description generation utility
23 .SH "SYNOPSIS"
24 .HP \w'\fBglib\-mkenums\fR\ 'u
25 \fBglib\-mkenums\fR [options...] [files...]
26 .SH "DESCRIPTION"
27 .PP
28 \fBglib\-mkenums\fR
29 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\&.
30 .SH "INVOCATION"
31 .PP
32 \fBglib\-mkenums\fR
33 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\&.
34 .SS "Options"
35 .PP
36 \fB\-\-fhead\fR \fItext\fR
37 .RS 4
38 Put out
39 \fItext\fR
40 prior to processing input files\&.
41 .RE
42 .PP
43 \fB\-\-fprod\fR \fItext\fR
44 .RS 4
45 Put out
46 \fItext\fR
47 everytime a new input file is being processed\&.
48 .RE
49 .PP
50 \fB\-\-ftail\fR \fItext\fR
51 .RS 4
52 Put out
53 \fItext\fR
54 after all input files have been processed\&.
55 .RE
56 .PP
57 \fB\-\-eprod\fR \fItext\fR
58 .RS 4
59 Put out
60 \fItext\fR
61 everytime an enum is encountered in the input files\&.
62 .RE
63 .PP
64 \fB\-\-vhead\fR \fItext\fR
65 .RS 4
66 Put out
67 \fItext\fR
68 before iterating over the set of values of an enum\&.
69 .RE
70 .PP
71 \fB\-\-vprod\fR \fItext\fR
72 .RS 4
73 Put out
74 \fItext\fR
75 for every value of an enum\&.
76 .RE
77 .PP
78 \fB\-\-vtail\fR \fItext\fR
79 .RS 4
80 Put out
81 \fItext\fR
82 after iterating over all values of an enum\&.
83 .RE
84 .PP
85 \fB\-\-comments\fR \fItext\fR
86 .RS 4
87 Template for auto\-generated comments, the default (for C code generations) is
88 "/* @comment@ */"\&.
89 .RE
90 .PP
91 \fB\-\-template\fR \fIfile\fR
92 .RS 4
93 Read templates from the given file\&. The templates are enclosed in specially\-formatted C comments
94 .sp
95 .if n \{\
96 .RS 4
97 .\}
98 .nf
99 /*** BEGIN section ***/
100 /*** END section ***/
101 .fi
102 .if n \{\
103 .RE
104 .\}
105 .sp
106 where section may be
107 file\-header,
108 file\-production,
109 file\-tail,
110 enumeration\-production,
111 value\-header,
112 value\-production,
113 value\-tail
114 or
115 comment\&.
116 .RE
117 .PP
118 \fB\-\-help\fR
119 .RS 4
120 Print brief help and exit\&.
121 .RE
122 .PP
123 \fB\-\-version\fR
124 .RS 4
125 Print version and exit\&.
126 .RE
127 .SS "Production text substitutions"
128 .PP
129 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:
130 .sp
131 .if n \{\
132 .RS 4
133 .\}
134 .nf
135 typedef enum
136 {
137   PREFIX_THE_XVALUE    = 1 << 3,
138   PREFIX_ANOTHER_VALUE = 1 << 4
139 } PrefixTheXEnum;
140 .fi
141 .if n \{\
142 .RE
143 .\}
144 .PP
145 @EnumName@
146 .RS 4
147 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)\&.
148 .RE
149 .PP
150 @enum_name@
151 .RS 4
152 The enum name with words lowercase and word\-separated by underscores (e\&.g\&. prefix_the_xenum)\&.
153 .RE
154 .PP
155 @ENUMNAME@
156 .RS 4
157 The enum name with words uppercase and word\-separated by underscores (e\&.g\&. PREFIX_THE_XENUM)\&.
158 .RE
159 .PP
160 @ENUMSHORT@
161 .RS 4
162 The enum name with words uppercase and word\-separated by underscores, prefix stripped (e\&.g\&. THE_XENUM)\&.
163 .RE
164 .PP
165 @VALUENAME@
166 .RS 4
167 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)\&.
168 .RE
169 .PP
170 @valuenick@
171 .RS 4
172 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)\&.
173 .RE
174 .PP
175 @type@
176 .RS 4
177 This is substituted either by "enum" or "flags", depending on whether the enum value definitions contained bit\-shift operators or not (e\&.g\&. flags)\&.
178 .RE
179 .PP
180 @Type@
181 .RS 4
182 The same as
183 @type@
184 with the first letter capitalized (e\&.g\&. Flags)\&.
185 .RE
186 .PP
187 @TYPE@
188 .RS 4
189 The same as
190 @type@
191 with all letters uppercased (e\&.g\&. FLAGS)\&.
192 .RE
193 .PP
194 @filename@
195 .RS 4
196 The name of the input file currently being processed (e\&.g\&. foo\&.h)\&.
197 .RE
198 .SS "Trigraph extensions"
199 .PP
200 Some C comments are treated specially in the parsed enum definitions, such comments start out with the trigraph sequence
201 /*<
202 and end with the trigraph sequence
203 >*/\&. 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 "lowercase_name" option can be used to specify the word separation used in the *_get_type() function\&. For instance, /*< lowercase_name=gnome_vfs_uri_hide_options >*/\&.
204 .PP
205 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:
206 .sp
207 .if n \{\
208 .RS 4
209 .\}
210 .nf
211 typedef enum /*< skip >*/
212 {
213   PREFIX_FOO
214 } PrefixThisEnumWillBeSkipped;
215 typedef enum /*< flags,prefix=PREFIX >*/
216 {
217   PREFIX_THE_ZEROTH_VALUE,      /*< skip >*/
218   PREFIX_THE_FIRST_VALUE,
219   PREFIX_THE_SECOND_VALUE,
220   PREFIX_THE_THIRD_VALUE,       /*< nick=the\-last\-value >*/
221 } PrefixTheFlagsEnum;
222 .fi
223 .if n \{\
224 .RE
225 .\}
226 .sp
227 .SH "SEE ALSO"
228 .PP
229 \fBglib\-genmarshal\fR(1)