Improvements from Owen's feedback.
[platform/upstream/glib.git] / docs / reference / gobject / glib-mkenums.1
1 .\"Generated by db2man.xsl. Don't modify this, modify the source.
2 .de Sh \" Subsection
3 .br
4 .if t .Sp
5 .ne 5
6 .PP
7 \fB\\$1\fR
8 .PP
9 ..
10 .de Sp \" Vertical space (when we can't use .PP)
11 .if t .sp .5v
12 .if n .sp
13 ..
14 .de Ip \" List item
15 .br
16 .ie \\n(.$>=3 .ne \\$3
17 .el .ne 3
18 .IP "\\$1" \\$2
19 ..
20 .TH "GLIB-MKENUMS" 1 "" "" ""
21 .SH NAME
22 glib-mkenums \- C language enum description generation utility
23 .SH "SYNOPSIS"
24
25 .nf
26 \fBglib-mkenums\fR [options...] [files...]
27 .fi
28
29 .SH "DESCRIPTION"
30
31 .PP
32  \fBglib-mkenums\fR 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\&.
33
34 .SH "INVOKATION"
35
36 .PP
37  \fBglib-mkenums\fR 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\&.
38
39 .SS "Options"
40
41 .TP
42 \fB--fhead\fR \fItext\fR
43 Put out \fItext\fR prior to processing input files\&.
44
45 .TP
46 \fB--fprod\fR \fItext\fR
47 Put out \fItext\fR everytime a new input file is being processed\&.
48
49 .TP
50 \fB--ftail\fR \fItext\fR
51 Put out \fItext\fR after all input files have been processed\&.
52
53 .TP
54 \fB--eprod\fR \fItext\fR
55 Put out \fItext\fR everytime an enum is encountered in the input files\&.
56
57 .TP
58 \fB--vhead\fR \fItext\fR
59 Put out \fItext\fR before iterating over the set of values of an enum\&.
60
61 .TP
62 \fB--vprod\fR \fItext\fR
63 Put out \fItext\fR for every value of an enum\&.
64
65 .TP
66 \fB--vtail\fR \fItext\fR
67 Put out \fItext\fR after iterating over all values of an enum\&.
68
69 .TP
70 \fB--comments\fR \fItext\fR
71 Template for auto-generated comments, the default (for C code generations) is "/* @comment@ */"\&.
72
73 .TP
74 \fB--template\fR \fIfile\fR
75 Read templates from the given file\&. The templates are enclosed in specially-formatted C comments .nf /*** BEGIN section ***/ /*** END section ***/ .fi where section may be file-header, file-production, file-tail, enumeration-production, value-header, value-production, value-tail or comment\&.
76
77 .TP
78 \fB--help\fR
79 Print brief help and exit\&.
80
81 .TP
82 \fB--version\fR
83 Print version and exit\&.
84
85 .SS "Production text substitutions"
86
87 .PP
88 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: 
89
90 .nf
91
92 typedef enum
93 {
94   PREFIX_THE_XVALUE    = 1 << 3,
95   PREFIX_ANOTHER_VALUE = 1 << 4
96 } PrefixTheXEnum;
97
98 .fi
99   
100
101 .TP
102 @EnumName@
103 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)\&.
104
105 .TP
106 @enum_name@
107 The enum name with words lowercase and word-separated by underscores (e\&.g\&. prefix_the_xenum)\&.
108
109 .TP
110 @ENUMNAME@
111 The enum name with words uppercase and word-separated by underscores (e\&.g\&. PREFIX_THE_XENUM)\&.
112
113 .TP
114 @ENUMSHORT@
115 The enum name with words uppercase and word-separated by underscores, prefix stripped (e\&.g\&. THE_XENUM)\&.
116
117 .TP
118 @VALUENAME@
119 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)\&.
120
121 .TP
122 @valuenick@
123 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)\&.
124
125 .TP
126 @type@
127 This is substituted either by "enum" or "flags", depending on whether the enum value definitions contained bit-shift operators or not (e\&.g\&. flags)\&.
128
129 .TP
130 @Type@
131 The same as @type@ with the first letter capitalized (e\&.g\&. Flags)\&.
132
133 .TP
134 @TYPE@
135 The same as @type@ with all letters uppercased (e\&.g\&. FLAGS)\&.
136
137 .TP
138 @filename@
139 The name of the input file currently being processed (e\&.g\&. foo\&.h)\&.
140  
141
142 .SS "Trigraph extensions"
143
144 .PP
145 Some C comments are treated specially in the parsed enum definitions, such comments start out with the trigraph sequence /*< and end with the trigraph sequence >*/\&. 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\&. 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: 
146
147 .nf
148
149 typedef enum /*< skip >*/
150 {
151   PREFIX_FOO
152 } PrefixThisEnumWillBeSkipped;
153 typedef enum /*< flags,prefix=PREFIX >*/
154 {
155   PREFIX_THE_ZEROTH_VALUE,      /*< skip >*/
156   PREFIX_THE_FIRST_VALUE,
157   PREFIX_THE_SECOND_VALUE,
158   PREFIX_THE_THIRD_VALUE,       /*< nick=the-last-value >*/
159 } PrefixTheFlagsEnum;
160
161 .fi
162  
163
164 .SH "SEE ALSO"
165
166 .PP
167  \fBglib-genmarshal\fR(1)
168