glib-mkenums.html   [plain text]


<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>glib-mkenums</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="GObject Reference Manual"><link rel="up" href="rn02.html" title="Tools Reference"><link rel="previous" href="rn02.html" title="Tools Reference"><link rel="next" href="glib-genmarshal.html" title="glib-genmarshal"><link rel="preface" href="pr01.html" title="Introduction"><link rel="reference" href="rn01.html" title="API Reference"><link rel="refentry" href="gobject-Type-Information.html" title="GType"><link rel="refentry" href="GTypePlugin.html" title="GTypePlugin"><link rel="refentry" href="GTypeModule.html" title="GTypeModule"><link rel="refentry" href="gobject-The-Base-Object-Type.html" title="GObject"><link rel="refentry" href="gobject-Enumeration-and-Flag-Types.html" title="Enums and Flags"><link rel="refentry" href="gobject-Boxed-Types.html" title="GBoxed"><link rel="refentry" href="gobject-Generic-values.html" title="Generic Values"><link rel="refentry" href="gobject-Standard-Parameter-and-Value-Types.html" title="Parameters and Values"><link rel="refentry" href="gobject-Varargs-Value-Collection.html" title="Varargs Value Collection"><link rel="refentry" href="gobject-GParamSpec.html" title="GParamSpec"><link rel="refentry" href="gobject-Signals.html" title="Signals"><link rel="refentry" href="gobject-Closures.html" title="Closures"><link rel="refentry" href="gobject-Value-arrays.html" title="Value arrays"><link rel="reference" href="rn02.html" title="Tools Reference"><link rel="refentry" href="glib-mkenums.html" title="glib-mkenums"><link rel="refentry" href="glib-genmarshal.html" title="glib-genmarshal"><link rel="refentry" href="gobject-query.html" title="gobject-query"><link rel="index" href="ix01.html" title="Index"><link rel="section" href="glib-mkenums.html#id2919480" title="Description"><link rel="section" href="glib-mkenums.html#id2919500" title="Invokation"><link rel="section" href="glib-mkenums.html#id2920014" title="See also"><meta name="generator" content="GTK-Doc V1.2 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="rn02.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="rn02.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GObject Reference Manual</th><td><a accesskey="n" href="glib-genmarshal.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="glib-mkenums"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2><span class="refentrytitle">glib-mkenums</span></h2><p>glib-mkenums &#8212; C language enum description generation utility</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><tt class="command">glib-mkenums</tt>  [options...] [files...]</p></div></div><div class="refsect1" lang="en"><a name="id2919480"></a><h2>Description</h2><p>
<span><b class="command">glib-mkenums</b></span> 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.
</p></div><div class="refsect1" lang="en"><a name="id2919500"></a><h2>Invokation</h2><p>
<span><b class="command">glib-mkenums</b></span> 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.
</p><div class="refsect2" lang="en"><a name="id2919518"></a><h3>Options</h3><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><tt class="option">--fhead</tt> <i class="replaceable"><tt>text</tt></i></span></td><td><p>
Put out <i class="replaceable"><tt>text</tt></i> prior to processing input files.
</p></td></tr><tr><td><span class="term"><tt class="option">--fprod</tt> <i class="replaceable"><tt>text</tt></i></span></td><td><p>
Put out <i class="replaceable"><tt>text</tt></i> everytime a new input file 
is being processed.
</p></td></tr><tr><td><span class="term"><tt class="option">--ftail</tt> <i class="replaceable"><tt>text</tt></i></span></td><td><p>
Put out <i class="replaceable"><tt>text</tt></i> after all input files have been 
processed.
</p></td></tr><tr><td><span class="term"><tt class="option">--eprod</tt> <i class="replaceable"><tt>text</tt></i></span></td><td><p>
Put out <i class="replaceable"><tt>text</tt></i> everytime an enum is encountered 
in the input files.
</p></td></tr><tr><td><span class="term"><tt class="option">--vhead</tt> <i class="replaceable"><tt>text</tt></i></span></td><td><p>
Put out <i class="replaceable"><tt>text</tt></i> before iterating over the set of 
values of an enum.
</p></td></tr><tr><td><span class="term"><tt class="option">--vprod</tt> <i class="replaceable"><tt>text</tt></i></span></td><td><p>
Put out <i class="replaceable"><tt>text</tt></i> for every value of an enum.
</p></td></tr><tr><td><span class="term"><tt class="option">--vtail</tt> <i class="replaceable"><tt>text</tt></i></span></td><td><p>
Put out <i class="replaceable"><tt>text</tt></i> after iterating over all values 
of an enum.
</p></td></tr><tr><td><span class="term"><tt class="option">--comments</tt> <i class="replaceable"><tt>text</tt></i></span></td><td><p>
Template for auto-generated comments, the default (for C code generations) is
<tt class="literal">"/* @comment@ */"</tt>.
</p></td></tr><tr><td><span class="term"><tt class="option">--template</tt> <i class="replaceable"><tt>file</tt></i></span></td><td><p>
Read templates from the given file. The templates are enclosed in
specially-formatted C comments
</p><pre class="programlisting">
/*** BEGIN section ***/
/*** END section ***/
</pre><p>
where section may be <tt class="literal">file-header</tt>, 
<tt class="literal">file-production</tt>, <tt class="literal">file-tail</tt>,
<tt class="literal">enumeration-production</tt>, <tt class="literal">value-header</tt>, 
<tt class="literal">value-production</tt>, <tt class="literal">value-tail</tt> or
<tt class="literal">comment</tt>.
</p></td></tr><tr><td><span class="term"><tt class="option">--help</tt></span></td><td><p>
Print brief help and exit.
</p></td></tr><tr><td><span class="term"><tt class="option">--version</tt></span></td><td><p>
Print version and exit.
</p></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2919786"></a><h3>Production text substitutions</h3><p>
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:
</p><pre class="programlisting">
typedef enum
{
  PREFIX_THE_XVALUE    = 1 &lt;&lt; 3,
  PREFIX_ANOTHER_VALUE = 1 &lt;&lt; 4
} PrefixTheXEnum;
</pre><p>
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term">@EnumName@</span></td><td><p>
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).
</p></td></tr><tr><td><span class="term">@enum_name@</span></td><td><p>
The enum name with words lowercase and word-separated by underscores 
(e.g. prefix_the_xenum).
</p></td></tr><tr><td><span class="term">@ENUMNAME@</span></td><td><p>
The enum name with words uppercase and word-separated by underscores 
(e.g. PREFIX_THE_XENUM).
</p></td></tr><tr><td><span class="term">@ENUMSHORT@</span></td><td><p>
The enum name with words uppercase and word-separated by underscores, 
prefix stripped (e.g. THE_XENUM).
</p></td></tr><tr><td><span class="term">@VALUENAME@</span></td><td><p>
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).
</p></td></tr><tr><td><span class="term">@valuenick@</span></td><td><p>
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).
</p></td></tr><tr><td><span class="term">@type@</span></td><td><p>
This is substituted either by "enum" or "flags", depending on whether the 
enum value definitions contained bit-shift operators or not (e.g. flags).
</p></td></tr><tr><td><span class="term">@Type@</span></td><td><p>
The same as <tt class="literal">@type@</tt> with the first letter capitalized (e.g. Flags).
</p></td></tr><tr><td><span class="term">@TYPE@</span></td><td><p>
The same as <tt class="literal">@type@</tt> with all letters uppercased (e.g. FLAGS).
</p></td></tr><tr><td><span class="term">@filename@</span></td><td><p>
The name of the input file currently being processed (e.g. foo.h).
</p></td></tr></tbody></table></div><p>
</p></div><hr><div class="refsect2" lang="en"><a name="id2919955"></a><h3>Trigraph extensions</h3><p>
Some C comments are treated specially in the parsed enum definitions, 
such comments start out with the trigraph sequence <tt class="literal">/*&lt;</tt> 
and end with the trigraph sequence <tt class="literal">&gt;*/</tt>.
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, /*&lt; lowercase_name=gnome_vfs_uri_hide_options &gt;*/.
</p><p>
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:
</p><pre class="programlisting">
typedef enum /*&lt; skip &gt;*/
{
  PREFIX_FOO
} PrefixThisEnumWillBeSkipped;
typedef enum /*&lt; flags,prefix=PREFIX &gt;*/
{
  PREFIX_THE_ZEROTH_VALUE,	/*&lt; skip &gt;*/
  PREFIX_THE_FIRST_VALUE,
  PREFIX_THE_SECOND_VALUE,
  PREFIX_THE_THIRD_VALUE,	/*&lt; nick=the-last-value &gt;*/
} PrefixTheFlagsEnum;
</pre><p>
</p></div></div><div class="refsect1" lang="en"><a name="id2920014"></a><h2>See also</h2><p>
<span><b class="command">glib-genmarshal</b></span>(1)
</p></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="rn02.html"><b>&lt;&lt; Tools Reference</b></a></td><td align="right"><a accesskey="n" href="glib-genmarshal.html"><b>glib-genmarshal &gt;&gt;</b></a></td></tr></table></body></html>