<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Generating the .defs files.</title> <link rel="stylesheet" href="style.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.75.1"> <link rel="home" href="index.html" title="Programming with gtkmm"> <link rel="up" href="chapter-wrapping-c-libraries.html" title="Appendix H. Wrapping C Libraries with gmmproc"> <link rel="prev" href="chapter-wrapping-c-libraries.html" title="Appendix H. Wrapping C Libraries with gmmproc"> <link rel="next" href="sec-wrapping-hg-files.html" title="The .hg and .ccg files"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr><th colspan="3" align="center">Generating the .defs files.</th></tr> <tr> <td width="20%" align="left"> <a accesskey="p" href="chapter-wrapping-c-libraries.html"><img src="icons/prev.png" alt="Prev"></a> </td> <th width="60%" align="center">Appendix H. Wrapping C Libraries with gmmproc</th> <td width="20%" align="right"> <a accesskey="n" href="sec-wrapping-hg-files.html"><img src="icons/next.png" alt="Next"></a> </td> </tr> </table> <hr> </div> <div class="sect1" title="Generating the .defs files."> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> <a name="sec-wrapping-defs-files"></a>Generating the .defs files.</h2></div></div></div> <p>The <code class="filename">.defs</code> file are text files, in a lisp format, that describe the API of a C library, including its </p> <div class="itemizedlist"><ul class="itemizedlist" type="disc"> <li class="listitem"><p>objects (GObjects, widgets, interfaces, boxed-types and plain structs)</p></li> <li class="listitem"><p>functions</p></li> <li class="listitem"><p>enums</p></li> <li class="listitem"><p>signals</p></li> <li class="listitem"><p>properties</p></li> <li class="listitem"><p>vfuncs</p></li> </ul></div> <p> </p> <p>At the moment, we have separate tools for generating different parts of these <code class="filename">.defs</code>, so we split them up into separate files. For instance, in the <code class="filename">gtk/src</code> directory of the <span class="application">gtkmm</span> sources, you will find these files: </p> <div class="variablelist"><dl> <dt><span class="term"><code class="filename">gtk.defs</code></span></dt> <dd><p>Includes the other files.</p></dd> <dt><span class="term"><code class="filename">gtk_methods.defs</code></span></dt> <dd><p>Objects and functions.</p></dd> <dt><span class="term"><code class="filename">gtk_enums.defs</code></span></dt> <dd><p>Enumerations.</p></dd> <dt><span class="term"><code class="filename">gtk_signals.defs</code></span></dt> <dd><p>Signals and properties.</p></dd> <dt><span class="term"><code class="filename">gtk_vfuncs.defs</code></span></dt> <dd><p>vfuncs (function pointer member fields in structs), written by hand.</p></dd> </dl></div> <p> </p> <div class="sect2" title="Generating the methods .defs"> <div class="titlepage"><div><div><h3 class="title"> <a name="generating-defs-methods"></a>Generating the methods .defs</h3></div></div></div> <p>This <code class="filename">.defs</code> file describes objects and their functions. It is generated by the <span class="command"><strong>h2def.py</strong></span> script which you can find in pygobject's <code class="filename">codegen</code> directory. For instance, </p> <pre class="programlisting"> $ ./h2def.py /usr/include/gtk-2.0/gtk/*.h > gtk_methods.defs </pre> <p> </p> </div> <div class="sect2" title="Generating the enums .defs"> <div class="titlepage"><div><div><h3 class="title"> <a name="generating-defs-enums"></a>Generating the enums .defs</h3></div></div></div> <p>This <code class="filename">.defs</code> file describes enum types and their possible values. It is generated by the <code class="filename">enum.pl</code> script which you can find in glibmm's <code class="filename">tools</code> directory. For instance, </p> <pre class="programlisting"> $ ./enum.pl /usr/include/gtk-2.0/gtk/*.h > gtk_enums.defs </pre> <p> </p> </div> <div class="sect2" title="Generating the signals and properties .defs"> <div class="titlepage"><div><div><h3 class="title"> <a name="generating-defs-signals-properties"></a>Generating the signals and properties .defs</h3></div></div></div> <p>This <code class="filename">.defs</code> file describes signals and properties. It is generated by the special <code class="filename">extra_defs</code> utility that is in every wrapping project, such as <code class="filename">gtkmm/tools/extra_defs_gen/</code>. For instance </p> <pre class="programlisting"> $ cd tools/extra_defs_gen $ ./generate_extra_defs > gtk_signals.defs </pre> <p> </p> <p>You must edit the source code of your own <code class="filename">generate_extra_defs</code> tool in order to generate the <code class="filename">.defs</code> for the GObject C types that you wish to wrap. In the skeleton source tree, the source file is named <code class="filename">codegen/extradefs/generate_extra_defs_skeleton.cc</code>. If not done so already, the file should be renamed, with the basename of your new binding substituted for the <code class="varname">skeleton</code> placeholder. The <code class="filename">codegen/Makefile.am</code> file should also mention the new source filename.</p> <p>Then edit the <code class="filename">.cc</code> file to specify the correct types. For instance, your <code class="function">main()</code> function might look like this: </p> <pre class="programlisting"> #include <libsomething.h> int main(int, char**) { something_init(); std::cout << get_defs(EXAMPLE_TYPE_SOMETHING) << get_defs(EXAMPLE_TYPE_THING); return 0; } </pre> <p> </p> </div> <div class="sect2" title="Writing the vfuncs .defs"> <div class="titlepage"><div><div><h3 class="title"> <a name="writing-defs-vfuncs"></a>Writing the vfuncs .defs</h3></div></div></div> <p> </p> <pre class="programlisting"> </pre> <p> </p> </div> </div> <div class="navfooter"> <hr> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"> <a accesskey="p" href="chapter-wrapping-c-libraries.html"><img src="icons/prev.png" alt="Prev"></a> </td> <td width="20%" align="center"><a accesskey="u" href="chapter-wrapping-c-libraries.html"><img src="icons/up.png" alt="Up"></a></td> <td width="40%" align="right"> <a accesskey="n" href="sec-wrapping-hg-files.html"><img src="icons/next.png" alt="Next"></a> </td> </tr> <tr> <td width="40%" align="left" valign="top">Appendix H. Wrapping C Libraries with gmmproc </td> <td width="20%" align="center"><a accesskey="h" href="index.html"><img src="icons/home.png" alt="Home"></a></td> <td width="40%" align="right" valign="top"> The .hg and .ccg files</td> </tr> </table> </div> </body> </html>