1GLIB-MKENUMS(1)                  User Commands                 GLIB-MKENUMS(1)
2
3
4

NAME

6       glib-mkenums - C language enum description generation utility
7

SYNOPSIS

9       glib-mkenums [options...] [files...]
10

DESCRIPTION

12       glib-mkenums is a small perl-script utility that parses C code to
13       extract enum definitions and produces enum descriptions based on text
14       templates specified by the user. Most frequently this script is used to
15       produce C code that contains enum values as strings so programs can
16       provide value name strings for introspection.
17

INVOCATION

19       glib-mkenums takes a list of valid C code files as input. The options
20       specified control the text that is output, certain substitutions are
21       performed on the text templates for keywords enclosed in @ characters.
22
23   Options
24       --fhead text
25           Put out text prior to processing input files.
26
27       --fprod text
28           Put out text everytime a new input file is being processed.
29
30       --ftail text
31           Put out text after all input files have been processed.
32
33       --eprod text
34           Put out text everytime an enum is encountered in the input files.
35
36       --vhead text
37           Put out text before iterating over the set of values of an enum.
38
39       --vprod text
40           Put out text for every value of an enum.
41
42       --vtail text
43           Put out text after iterating over all values of an enum.
44
45       --comments text
46           Template for auto-generated comments, the default (for C code
47           generations) is "/* @comment@ */".
48
49       --template file
50           Read templates from the given file. The templates are enclosed in
51           specially-formatted C comments
52
53               /*** BEGIN section ***/
54               /*** END section ***/
55
56           where section may be file-header, file-production, file-tail,
57           enumeration-production, value-header, value-production, value-tail
58           or comment.
59
60       --help
61           Print brief help and exit.
62
63       --version
64           Print version and exit.
65
66   Production text substitutions
67       Certain keywords enclosed in @ characters will be substituted in the
68       emitted text. For the substitution examples of the keywords below, the
69       following example enum definition is assumed:
70
71           typedef enum
72           {
73             PREFIX_THE_XVALUE    = 1 << 3,
74             PREFIX_ANOTHER_VALUE = 1 << 4
75           } PrefixTheXEnum;
76
77       @EnumName@
78           The name of the enum currently being processed, enum names are
79           assumed to be properly namespaced and to use mixed capitalization
80           to separate words (e.g. PrefixTheXEnum).
81
82       @enum_name@
83           The enum name with words lowercase and word-separated by
84           underscores (e.g. prefix_the_xenum).
85
86       @ENUMNAME@
87           The enum name with words uppercase and word-separated by
88           underscores (e.g. PREFIX_THE_XENUM).
89
90       @ENUMSHORT@
91           The enum name with words uppercase and word-separated by
92           underscores, prefix stripped (e.g. THE_XENUM).
93
94       @VALUENAME@
95           The enum value name currently being processed with words uppercase
96           and word-separated by underscores, this is the assumed literal
97           notation of enum values in the C sources (e.g. PREFIX_THE_XVALUE).
98
99       @valuenick@
100           A nick name for the enum value currently being processed, this is
101           usually generated by stripping common prefix words of all the enum
102           values of the current enum, the words are lowercase and underscores
103           are substituted by a minus (e.g. the-xvalue).
104
105       @valuenum@
106           The integer value for the enum value currently being processed.
107           This is calculated by using perl to attempt to evaluate the
108           expression as it appears in the C source code. If evaluation fails
109           then glib-mkenums will exit with an error status, but this only
110           happens if @valuenum@ appears in your value production template.
111           (Since: 2.26)
112
113       @type@
114           This is substituted either by "enum" or "flags", depending on
115           whether the enum value definitions contained bit-shift operators or
116           not (e.g. flags).
117
118       @Type@
119           The same as @type@ with the first letter capitalized (e.g. Flags).
120
121       @TYPE@
122           The same as @type@ with all letters uppercased (e.g. FLAGS).
123
124       @filename@
125           The name of the input file currently being processed (e.g. foo.h).
126
127       @basename@
128           The base name of the input file currently being processed (e.g.
129           foo.h). (Since: 2.22)
130
131   Trigraph extensions
132       Some C comments are treated specially in the parsed enum definitions,
133       such comments start out with the trigraph sequence /*< and end with the
134       trigraph sequence >*/. Per enum definition, the options "skip" and
135       "flags" can be specified, to indicate this enum definition to be
136       skipped, or for it to be treated as a flags definition, or to specify
137       the common prefix to be stripped from all values to generate value
138       nicknames, respectively. The "lowercase_name" option can be used to
139       specify the word separation used in the *_get_type() function. For
140       instance, /*< lowercase_name=gnome_vfs_uri_hide_options >*/.
141
142       Per value definition, the options "skip" and "nick" are supported. The
143       former causes the value to be skipped, and the latter can be used to
144       specify the otherwise auto-generated nickname. Examples:
145
146           typedef enum /*< skip >*/
147           {
148             PREFIX_FOO
149           } PrefixThisEnumWillBeSkipped;
150           typedef enum /*< flags,prefix=PREFIX >*/
151           {
152             PREFIX_THE_ZEROTH_VALUE,    /*< skip >*/
153             PREFIX_THE_FIRST_VALUE,
154             PREFIX_THE_SECOND_VALUE,
155             PREFIX_THE_THIRD_VALUE,     /*< nick=the-last-value >*/
156           } PrefixTheFlagsEnum;
157
158

SEE ALSO

160       glib-genmarshal(1)
161
162
163
164User Commands                     06/05/2011                   GLIB-MKENUMS(1)
Impressum