glib-mkenums(1) User Commands glib-mkenums(1)
NAME
glib-mkenums - generate C language enum description
SYNOPSIS
glib-mkenums [--comments text] [--eprod text] [--fhead text] [--fprod text] [--ftail text] [--help] [--version] [--vhead text] [--vprod
text] [--vtail text] [file...]
DESCRIPTION
glib-mkenums parses C code to extract enum definitions, and produces enum descriptions based on text templates specified by the user. glib-
mkenums produces C code that contains enum values as strings, which allows programs to provide value name strings.
EXTENDED DESCRIPTION
This section provides more information about text substitution and trigraph extensions.
Text Substitution
glib-mkenums substitutes certain keywords, which are enclosed in @ characters, when creating the output text. For the substitution examples
of the keywords in this section, the following example enum definition is assumed:
typedef enum
{
PREFIX_THE_XVALUE = 1 << 3,
PREFIX_ANOTHER_VALUE = 1 << 4
} PrefixTheXEnum;
glib-mkenums substitutes the following keywords:
@EnumName@ The name of the enum currently being processed. enum names are assumed to be properly namespaced and to use mixed
capitalization to separate words (for example, PrefixTheXEnum).
@enum_name@ The enum name with words in lowercase and each word separated by underscores (for example, prefix_the_xenum).
@ENUMNAME@ The enum name with words in uppercase and each word separated by underscores (for example, PREFIX_THE_XENUM).
@ENUMSHORT@ The enum name with words in uppercase and each word separated by underscores, and with the prefix stripped (for
example, THE_XENUM).
@VALUENAME@ The enum value name currently being processed, with words in uppercase and each word separated by underscores. This
is the assumed literal notation of enum values in the C sources (for example, PREFIX_THE_XVALUE).
@valuenick@ A nickname for the enum value currently being processed. This is usually generated by stripping the common prefix
words of all of the enum values of the current enum, with words in lowercase and underscores substituted by hyphens
(for example, the-xvalue).
@type@ This is substituted either by enum or flags, depending on whether the enum value definitions contain bit-shift
operators or not (for example, flags).
@Type@ Same as @type@, but with the first letter capitalized (for example, Flags).
@TYPE@ Same as @type@, but with all letters in uppercase (for example, FLAGS).
@filename@ The name of the input file currently being processed (for example, foo.h).
Trigraph Extensions
Some C comments in the parsed enum definitions are treated as special. Such comments start with the trigraph sequence /*< and end with the
trigraph sequence >*/.
Per enum definition, the skip and flags options are supported. The skip option indicates that this enum definition should be skipped. The
flags option specifies that this enum definition should be treated as a flags definition, or specifies the common prefix to be stripped
from all values to generate value nicknames.
Per value definition, the skip and nick options are supported. The skip option causes the value to be skipped. The nick option specifies
the otherwise autogenerated nickname.
OPTIONS
The following options are supported:
--comments text Output text.
--eprod text Output text every time an enum occurs in the input files.
--fhead text Output text prior to processing input files.
--fprod text Output text every time a new input file is processed.
--ftail text Output text when all input files have been processed.
--help Show usage and basic help information.
--version Show version information.
--vhead text Output text before iterating the set of values of an enum.
--vprod text Output text for every value of an enum.
--vtail text Output text after iterating all values of an enum.
OPERANDS
The following operands are supported:
file Specifies a valid C code file.
EXAMPLES
Example 1: Examples of Trigraph Extensions
typedef enum /*< skip >*/
{
PREFIX_FOO
} PrefixThisEnumWillBeSkipped;
typedef enum /*< flags,prefix=PREFIX >*/
{
PREFIX_THE_ZEROTH_VALUE, /*< skip >*/
PREFIX_THE_FIRST_VALUE,
PREFIX_THE_SECOND_VALUE,
PREFIX_THE_THIRD_VALUE, /*< nick=the-last-value >*/
} PrefixTheFlagsEnum;
EXIT STATUS
The following exit values are returned:
0 Application exited successfully
>0 Application exited with failure
FILES
The following files are used by this application:
/usr/bin/glib-mkenums The command-line executable for the application.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWgnome-base-libs-devel |
+-----------------------------+-----------------------------+
|Interface stability |External |
+-----------------------------+-----------------------------+
SEE ALSO
glib-genmarshal(1), libglib-2.0(3)
NOTES
Updated by Brian Cameron, Sun Microsystems Inc., 2003. Written by Tim Janik.
SunOS 5.10 7 Apr 2003 glib-mkenums(1)