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