<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.liberty-eiffel.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tybor</id>
	<title>Liberty Eiffel Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.liberty-eiffel.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tybor"/>
	<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php/Special:Contributions/Tybor"/>
	<updated>2026-04-14T04:16:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.0</generator>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Clean&amp;diff=2703</id>
		<title>Clean</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Clean&amp;diff=2703"/>
		<updated>2023-12-17T10:53:47Z</updated>

		<summary type="html">&lt;p&gt;Tybor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tool]]&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
 se clean [options] &amp;lt;Root-Name&amp;gt; ... &lt;br /&gt;
Command clean removes all intermediate files produced by previous compile, or compile_to_c runs. &lt;br /&gt;
Names (&amp;lt;Root-Name&amp;gt; ...) can have the Eiffel suffix, no suffix at all, or the suffix used for Liberty Eiffel command files on your system (.make on UNIX or .BAT on Windows for example).&lt;br /&gt;
&lt;br /&gt;
= Options =&lt;br /&gt;
  -help:&lt;br /&gt;
&lt;br /&gt;
Display a brief summary of the command-line syntax and a complete list of finder options. &lt;br /&gt;
&lt;br /&gt;
 -no_remove:&lt;br /&gt;
&lt;br /&gt;
Print the name of files that would be removed, but do not remove them.e. &lt;br /&gt;
&lt;br /&gt;
 -verbose:&lt;br /&gt;
&lt;br /&gt;
Print system information during the compilation (full path of loaded files, type inference score, removed files, etc.). &lt;br /&gt;
&lt;br /&gt;
 -version:&lt;br /&gt;
&lt;br /&gt;
Show the number of the version of LibertyEiffel you're using. &lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
== Example 1 ==&lt;br /&gt;
To remove intermediate files produced for the HELLO_WORLD program. &lt;br /&gt;
Type:  clean hello_world&lt;br /&gt;
You can also type:  clean hello_world.e &lt;br /&gt;
or you can also type:  clean HELLO_WORLD &lt;br /&gt;
on Unix, you can type:  clean hello_world.make &lt;br /&gt;
on Windows, you can do:  clean hello_world.BAT &lt;br /&gt;
&lt;br /&gt;
== Example 2 ==&lt;br /&gt;
Under Unix or Windows, remove all intermediates files in the current directory : clean *.e&lt;br /&gt;
&lt;br /&gt;
If the root class file is not in the current directory, you can type (for Unix) : clean *.make&lt;br /&gt;
&lt;br /&gt;
Option -verbose can be used to see which files are removed.&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Release_Notes_(Versions_history)&amp;diff=2701</id>
		<title>Release Notes (Versions history)</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Release_Notes_(Versions_history)&amp;diff=2701"/>
		<updated>2022-07-05T06:13:36Z</updated>

		<summary type="html">&lt;p&gt;Tybor: /* Curtiss (2022.dev, to be named after Glenn Curtiss) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Releases]]&lt;br /&gt;
== Liberty Eiffel (latest release first) ==&lt;br /&gt;
For other upcoming releases see the [[upcoming releases|list of names]].&lt;br /&gt;
=== Curtiss (2022.dev, to be named after [https://en.wikipedia.org/wiki/Glenn_Curtiss Glenn Curtiss]) ===&lt;br /&gt;
* not yet released (see next section for current release notes)&lt;br /&gt;
* User-visible changes:&lt;br /&gt;
** added support for assign (note: it applies to the setter, while ISE version applies to the getter)&lt;br /&gt;
** redesign of eiffeldoc generated HTML to reduce its size dramatically&lt;br /&gt;
** addition of a zsh completer for se&lt;br /&gt;
** updated dependency of BDW GC to version 8.x&lt;br /&gt;
** installation script (install.sh) now supports the latest libgc-dev library (external garbage collector)&lt;br /&gt;
** finally removed the obsolete classes GEN_RAND, MIN_STAND and STD_RAND&lt;br /&gt;
** removed support for some unused legacy platforms (OpenVMS, Amiga, Elate, BeOS, OS/2, Macintosh, HP RISC, IBM370, NS32000, MIPS, Pyramid 9810, SPARC, VAX, Motorola 68000) - in case you have a real use case for those we are happy to readd it&lt;br /&gt;
** removed support for some unused backend C-compilers (i.e. Watcom-C)&lt;br /&gt;
** removed obsolete feature &amp;quot;is_basic_expanded_type&amp;quot; from class ANY&lt;br /&gt;
** obsolete keyword 'creation' now generates an error&lt;br /&gt;
** obsolete class READY_DESCRIPTION removed from sequencer cluster&lt;br /&gt;
** 'is_prime' feature added to class INTEGER_GENERAL&lt;br /&gt;
** 'is_fibonacci' feature added to class INTEGER_GENERAL&lt;br /&gt;
** constants 'Tau', 'Sqr_tau' and 'Inv_tau' added to math_constants.e&lt;br /&gt;
** C-runtime now C99 compliant&lt;br /&gt;
** C-runtime now thread-safe &lt;br /&gt;
** C-code generator does not yet generate C99 compliant C-code, currently being worked on (likely for the Dennis-release).&lt;br /&gt;
** RUN_FEATUREs now have clear names (hopefully)&lt;br /&gt;
** to better support the user access rights model of the current Windows versions, the config file is no longer written to a root directory but rather to %ALLUSERSPROFILE% or %USERPROFILE% &lt;br /&gt;
* Known bugs:&lt;br /&gt;
** see [https://savannah.gnu.org/bugs/?group=liberty-eiffel] for the full list&lt;br /&gt;
&lt;br /&gt;
=== Bell (2016.05, named after [https://en.wikipedia.org/wiki/Alexander_Graham_Bell Alexander Graham Bell]) ===&lt;br /&gt;
* released in May 2016&lt;br /&gt;
* first release since Liberty Eiffel has become the official GNU Eiffel compiler&lt;br /&gt;
* User-visible changes:&lt;br /&gt;
** changed Environment Variable name from SmartEiffel to LibertyEiffel (anyhow, normally it should not be necessary to set this one)&lt;br /&gt;
** new tool [[Mock]]&lt;br /&gt;
** removed linebreaks in compiler output&lt;br /&gt;
** many bugfixes&lt;br /&gt;
** GC call at exit is optional&lt;br /&gt;
** generic creation&lt;br /&gt;
** agents are now [https://en.wikipedia.org/wiki/Closure_(computer_programming) closures ]&lt;br /&gt;
** finder now finds all classes in the universe with the given name, not only the first one&lt;br /&gt;
** keyword '''is''' at the beginning of a feature is now deprecated&lt;br /&gt;
** Added support for alias &amp;quot;[]&amp;quot; and alias &amp;quot;()&amp;quot;&lt;br /&gt;
** constants are now visible in the eiffeldoc generated documentation&lt;br /&gt;
* Known bugs:&lt;br /&gt;
** there is still an issue in both GC implementations (classical SEGC and BDW), if it shows up, it often yields a &amp;quot;Bad target type&amp;quot; runtime error.&lt;br /&gt;
** for the full list see [https://savannah.gnu.org/bugs/?group=liberty-eiffel]&lt;br /&gt;
&lt;br /&gt;
=== Adler (2013.11, named after [http://en.wikipedia.org/wiki/Charles_Adler,_Jr. Charles Adler, Jr.]) ===&lt;br /&gt;
* First release as Liberty Eiffel&lt;br /&gt;
* User-visible changes:&lt;br /&gt;
** Added [[library_class:NATURAL_8|&amp;lt;tt&amp;gt;NATURAL_8&amp;lt;/tt&amp;gt;]], [[library_class:NATURAL_16|&amp;lt;tt&amp;gt;NATURAL_16&amp;lt;/tt&amp;gt;]], [[library_class:NATURAL_32|&amp;lt;tt&amp;gt;NATURAL_32&amp;lt;/tt&amp;gt;]], and [[library_class:NATURAL_64|&amp;lt;tt&amp;gt;NATURAL_64&amp;lt;/tt&amp;gt;]] classes. See &amp;lt;tt&amp;gt;tutorial/natural.e&amp;lt;/tt&amp;gt; for examples.&lt;br /&gt;
** Even low-level features (i.e. &amp;lt;tt&amp;gt;external &amp;quot;built_in&amp;quot;&amp;lt;/tt&amp;gt;) are now checking their assertions. As an example, division by zero is now checked by assertions.&lt;br /&gt;
** Inlined dynamic dispatch for better performance&lt;br /&gt;
** A missing export clause is deprecated. Use &amp;lt;tt&amp;gt;{ANY}&amp;lt;/tt&amp;gt; instead.&lt;br /&gt;
** New core libraries: cli, json, log, parse (beware, these libraries are not yet tuned to be used without GC)&lt;br /&gt;
** Improved libraries: string (with notably a new [[library_class:FIXED_STRING|&amp;lt;tt&amp;gt;FIXED_STRING&amp;lt;/tt&amp;gt;]] class)&lt;br /&gt;
** Wrapper libraries: gtk, gdk, readline, ffi...&lt;br /&gt;
** A new tool that can generate mocks to help unit testing&lt;br /&gt;
** [http://hboehm.info/gc/ BDW] GC support&lt;br /&gt;
** Collections implementation of is_equal changed to compare the contained objects using their is_equal functions instead of = (which was formerly the functionality of is_equal_map). The old functionality of is_equal is available by fast_is_equal.&lt;br /&gt;
* Developer changes:&lt;br /&gt;
** The web site now belongs to the repository&lt;br /&gt;
** Automatic testing tools (ET on the web, and &amp;lt;tt&amp;gt;watch_eiffeltest.sh&amp;lt;/tt&amp;gt; in the shell)&lt;br /&gt;
** Automatic Debian packages generation&lt;br /&gt;
* Known bugs:&lt;br /&gt;
** BDW GC is not well tested; currently weak references seem not to work properly; and the GC is not run at program exit (it should run all finalizers)&lt;br /&gt;
** Sometimes SmartEiffel's native GC behaves wrongly, analysis is welcome&lt;br /&gt;
** Some of the newer core libraries do not work very well when there is no GC&lt;br /&gt;
** See the [https://savannah.gnu.org/bugs/?group=liberty-eiffel bugs page]&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Finder&amp;diff=2323</id>
		<title>Finder</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Finder&amp;diff=2323"/>
		<updated>2016-05-30T07:52:32Z</updated>

		<summary type="html">&lt;p&gt;Tybor: /* Options */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tool]]&lt;br /&gt;
== Usage ==&lt;br /&gt;
  se find [options] [&amp;lt;ACEfile.ace&amp;gt;] &amp;lt;Class&amp;gt; &lt;br /&gt;
The find command tells you which file is loaded when searching for an Eiffel &amp;lt;Class&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
When an Eiffel file is found, find prints the full path name on standard output. &lt;br /&gt;
&lt;br /&gt;
The exit status is set to GENERAL.exit_success_code only when an existing file is found (thus allowing usage of the find command in shell scripts). &lt;br /&gt;
As for other commands, when the ACE file mode is used, only the content of the &amp;lt;ACEfile.ace&amp;gt; file is used to search the source file. &lt;br /&gt;
To see the loading path used by LibertyEiffel, you can for example type the find command using a bad (non-existent) class name. &lt;br /&gt;
In ACE file mode, the loading path can be updated by modifying the ACE file itself. In traditional mode (i.e. no ACE file), the default loading path may also be tailored (see below).&lt;br /&gt;
&lt;br /&gt;
== Options ==&lt;br /&gt;
 -help:&lt;br /&gt;
Display a brief summary of the command-line syntax and a complete list of find options. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 -version:&lt;br /&gt;
Show the number of the version of LibertyEiffel you're using. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 -verbose:&lt;br /&gt;
Print system information during the compilation (full path of loaded files, type inference score, removed files, etc.). &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 -loadpath &amp;lt;loadpath_file&amp;gt;:&lt;br /&gt;
Adds a loadpath file for class lookup. See below for details on the loading path constitution.&lt;br /&gt;
&lt;br /&gt;
-raw:&lt;br /&gt;
Does not display the cluster name. Its only output is usually the path name of the class so it is useful in scripts.&lt;br /&gt;
&lt;br /&gt;
== Where does Find search? ==&lt;br /&gt;
&lt;br /&gt;
This is explained in detail in the [[class loading]] section. Note that finder will find all classes with a given name.&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Tutorial_tour&amp;diff=2228</id>
		<title>Tutorial tour</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Tutorial_tour&amp;diff=2228"/>
		<updated>2016-04-01T23:04:51Z</updated>

		<summary type="html">&lt;p&gt;Tybor: /* io cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the guided tour of the tutorial!&lt;br /&gt;
&lt;br /&gt;
All the classes in the tutorial are provided with your LibertyEiffel installation, in the &amp;lt;code&amp;gt;tutorial&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
=== Easy starting: Hello World! ===&lt;br /&gt;
&lt;br /&gt;
To compile the program, go to the &amp;lt;code&amp;gt;LibertyEiffel/tutorial&amp;lt;/code&amp;gt; directory and execute the command:&lt;br /&gt;
&lt;br /&gt;
 se c HELLO_WORLD make -o hello&lt;br /&gt;
&lt;br /&gt;
The meaning of the command is&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;se&amp;lt;/code&amp;gt;&lt;br /&gt;
|the front-end tool for the LibertyEiffel compiler&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;&lt;br /&gt;
|the tool invoked by &amp;lt;code&amp;gt;se&amp;lt;/code&amp;gt; for compile into an executable&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;HELLO_WORLD&amp;lt;/code&amp;gt;&lt;br /&gt;
|the class of which an object is created (you may also write it in lower-case, or use its filename with the &amp;lt;code&amp;gt;.e&amp;lt;/code&amp;gt; extension) we call it root class, as this is the root of the programs object tree&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
|the creation procedure of the &amp;lt;code&amp;gt;HELLO_WORLD&amp;lt;/code&amp;gt; class to call&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;-o hello&amp;lt;/code&amp;gt;&lt;br /&gt;
|generates an executable with the name hello (linux) or hello.exe (windows)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The command produces an executable, usually &amp;lt;code&amp;gt;hello&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;hello.exe&amp;lt;/code&amp;gt; depending on the system. After compiling is finished, you can run the executable.&lt;br /&gt;
&lt;br /&gt;
This unavoidable program is in the file &amp;lt;code&amp;gt;hello_world.e&amp;lt;/code&amp;gt; and lets you grasp the basic concepts of Eiffel. Those concepts are:&lt;br /&gt;
* '''Everything is a class'''. In Eiffel, outside classes there is no salvation.&lt;br /&gt;
* The program starts by '''creating an object''' (of the root class) and initializing it by execution of the given root creation procedure. Here, the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; feature in the class &amp;lt;code&amp;gt;HELLO_WORLD&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Each file is named after the name of the class it contains, in lower-case, with the &amp;lt;code&amp;gt;.e&amp;lt;/code&amp;gt; extension.&lt;br /&gt;
* Each class comes with a set of '''features''', all its attributes and methods which come in form of functions (if they return a result) or procedures (in case they just 'do' something)&lt;br /&gt;
* Note the special object &amp;lt;code&amp;gt;io&amp;lt;/code&amp;gt; that allows you to write text on the standard output. We will see that it also lets you read data.&lt;br /&gt;
* For the Eiffel syntax, look [[Syntax_diagrams|here]].&lt;br /&gt;
&lt;br /&gt;
Please take a look at the following examples in the tutorial folder to see some classical example programs (some of them are in organized in folders for better overview)&lt;br /&gt;
* fibonacci.e&lt;br /&gt;
* knight.e&lt;br /&gt;
* pyramide.e and pyramide2.e&lt;br /&gt;
* hanoi&lt;br /&gt;
* parking&lt;br /&gt;
* triangle&lt;br /&gt;
&lt;br /&gt;
To compile the other samples you must obviously modify the compiler command to give another root class .&lt;br /&gt;
&lt;br /&gt;
== Some important concepts ==&lt;br /&gt;
&lt;br /&gt;
=== Comments ===&lt;br /&gt;
As in every programming language there is the possibility to write comments into the source code, which do not have any effect for the final program, but are for the developer or reader of the source code to get an understanding of the ideas and algorithms behind the code.&lt;br /&gt;
A comment in Eiffel starts with the sequence of a couple of minus signs and is terminated by a newline (RETURN).&lt;br /&gt;
 -- this is a comment in Eiffel&lt;br /&gt;
 a := b + 3 -- comments are also allowed after some code&lt;br /&gt;
&lt;br /&gt;
=== Manifest notations ===&lt;br /&gt;
LibertyEiffel comes with a big set of available datatypes. Famous examples as INTEGER, BOOLEAN, CHARACTER and STRING. For those (and also many collection types) there is the possibility to directly denote them in the program code, using the notations&lt;br /&gt;
 123&lt;br /&gt;
 True, False&lt;br /&gt;
 'a'&lt;br /&gt;
 &amp;quot;STRING&amp;quot;&lt;br /&gt;
See tutorial file manifest_notation.e for an example with nearly all options to define objects by manifest notations.&lt;br /&gt;
&lt;br /&gt;
=== Everything is an Object ===&lt;br /&gt;
As mentioned above, in Eiffel every useful thing is an object. There are two different kinds of objects: expanded objects and referenced object. Expanded objects are passed by value, while reference objects are - who guesses - passed by reference. In case you write 7 in the source code this is a shorthand for an instance of the expanded type INTEGER and therefore it is an expanded object. Whenever you assign it to a variable or pass it to another feature it gets copied. A STRING object - e. g. denoted by &amp;quot;Hello World!&amp;quot; in the source code is a reference object, created implicitly by the compiler, allocated on the heap and passed by reference.&lt;br /&gt;
&lt;br /&gt;
=== Local variables and Assignments ===&lt;br /&gt;
Every routine may define variables in a &amp;quot;local block&amp;quot; before its body (which start with the keyword do):&lt;br /&gt;
 make&lt;br /&gt;
    local&lt;br /&gt;
       a: INTEGER&lt;br /&gt;
       s: STRING&lt;br /&gt;
    do&lt;br /&gt;
       a := 5&lt;br /&gt;
       a := a + 1&lt;br /&gt;
       s := &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The visibility of these variables is limited to the method they are defined in and they do not keep their value from one execution of that routine to another. Assignment is done by the assignment operator &amp;quot;:=&amp;quot; which changes the variable (or let's say writable entity) on the left side to the value of the expression on the right side. In case of the &amp;quot;Hello World!&amp;quot; assignment a new object of type STRING is created on the heap, initialized to the text &amp;quot;Hello World!&amp;quot; and a link to this object is stored in the local variable s.&lt;br /&gt;
&lt;br /&gt;
=== Loops ===&lt;br /&gt;
In Eiffel we have exactly one construct to do something repeatedly, so no need to learn about for, do-while, while, anyhow, one is sufficient:&lt;br /&gt;
 from&lt;br /&gt;
   -- initialization&lt;br /&gt;
 invariant&lt;br /&gt;
   -- what shall stay true during repetition&lt;br /&gt;
 variant&lt;br /&gt;
   -- non-negative, but decreasing numeric value&lt;br /&gt;
 until&lt;br /&gt;
   -- termination condition&lt;br /&gt;
 loop&lt;br /&gt;
   -- what to do several times&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Note, that the termination condition is an expression of type BOOLEAN and the loop body is executed until the condition evaluates to True, which differs in the logic from e. g. the loop constructs in C.&lt;br /&gt;
&lt;br /&gt;
The most strange things for newcomers are probably the [https://en.wikipedia.org/wiki/Loop_invariant invariant] and the [https://en.wikipedia.org/wiki/Loop_variant variant]. While the first is a BOOLEAN condition, that stays true for every iteration, the latter is an INTEGER value which decreases with every iteration and always stays positive and therefore shows that the loop terminates. Both are optional and are not used very often in practice, even though they are essential in case we want to prove a program to be totally correct (and therefore terminates). I fear, that these formal loop assertions stay more or less unused until a formal verification tool is able to take real benefit from them.&lt;br /&gt;
&lt;br /&gt;
See tutorial/loops.e for an example of the Greatest Common Divider algorithm to show the usage of the loop.&lt;br /&gt;
&lt;br /&gt;
=== Input-output ===&lt;br /&gt;
&lt;br /&gt;
==== io cluster ====&lt;br /&gt;
&lt;br /&gt;
The input-output cluster is made up of several parts. &lt;br /&gt;
&lt;br /&gt;
The  io/basic subcluster contains the staples of &lt;br /&gt;
&lt;br /&gt;
* the definitions of standard input and output streams, [[library_class:STD_INPUT|STD_INPUT]] and [[library_class:STD_OUTPUT|STD_OUTPUT]] that are available to all classes. In fact [[library_class:ANY|ANY]] offers those features:&lt;br /&gt;
** io: [[library_class:STD_INPUT_OUTPUT|STD_INPUT_OUTPUT]] -- Handle to standard file setup.&lt;br /&gt;
** std_input: [[library_class:STD_INPUT|STD_INPUT]] -- The standard input stream&lt;br /&gt;
** std_output: [[library_class:STD_OUTPUT|STD_OUTPUT]] -- The standard output stream&lt;br /&gt;
** std_error: [[library_class:STD_ERROR|STD_ERROR]] -- The standard error stream&lt;br /&gt;
** standard_streams: [[library_class:STANDARD_STREAMS|STANDARD_STREAMS]], a singleton that allows to redirect std_input_stream, std_output_stream as well as std_error_stream. &lt;br /&gt;
&lt;br /&gt;
Beyond this standards streams that are available to all processes you can get read files in the operative file system using an  [[library_class:INPUT_STREAM|INPUT_STREAM]] using [[library_class:BINARY_FILE_READ|BINARY_FILE_READ]] to read a binary file or [[library_class:TEXT_FILE_READ|TEXT_FILE_READ]] to read a text file.&lt;br /&gt;
Similarly, to write a file you use an [[library_class:OUTPUT_STREAM|OUTPUT_STREAM]] such as [[library_class:BINARY_FILE_WRITE|BINARY_FILE_WRITE]] for binary files or [[library_class:TEXT_FILE_WRITE|TEXT_FILE_WRITE]] for text files. &lt;br /&gt;
&lt;br /&gt;
[[library_class:READLINE_INPUT_STREAM|READLINE_INPUT_STREAM]] is an input stream where the data is read from Command Line Interface (CLI) using the GNU readline library. You probabily have already used this library without knowing as it is used by several programs as at the time this notes has been written almost nine hundred packages in Debian use a version of readline&lt;br /&gt;
 &lt;br /&gt;
You may have noticed that Eiffel uses streams to access files. This is a much more flexible way to access data. In fact when you use an [[library_class:INPUT_STREAM|INPUT_STREAM]] the actual data can come from plain files, or from a string with  [[library_class:STRING_INPUT_STREAM|STRING_INPUT_STREAM]] or any classes that conforms to and INPUT_STREAM, or more properly any live type that is a proper heir of INPUT_STREAM, such as BINARY_INPUT_STREAM, EZMQ_SOCKET_INPUT (a sockect messaging library), FILTER_INPUT_STREAM{ (put references to filters and explaiin BASE64_INPUT_STREAM, HTTP_CLIENT_INPUT_STREAM, MONITORED_INPUT_STREAM, QUOTED_PRINTABLE_INPUT_STREAM, TEMPLATE_INPUT_STREAM&lt;br /&gt;
), TERMINAL_INPUT_STREAM.&lt;br /&gt;
&lt;br /&gt;
Mostly for testing purposes there are also [[library_class:NULL_INPUT_STREAM|NULL_INPUT_STREAM]], a &amp;quot;null&amp;quot; stream provides an unbroken sequence of zero, like /dev/zero does on Unix and &lt;br /&gt;
[[library_class:NULL_OUTPUT_STREAM|NULL_OUTPUT_STREAM]] that swallows any character like /dev/null does on Unix. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* directory&lt;br /&gt;
* basic_directory?&lt;br /&gt;
&lt;br /&gt;
=== Arguments ===&lt;br /&gt;
print_arguments.e&lt;br /&gt;
&lt;br /&gt;
=== Feature calls ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Contracts ===&lt;br /&gt;
Contracts are the main reason why Eiffel is superior to many other languages...&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
=== Garbage collection ===&lt;br /&gt;
Eiffel is garbage collected. That means, the objects created on the heap will automatically be freed after they lost reachability from the rest of the executing program.&lt;br /&gt;
&lt;br /&gt;
=== ACE files ===&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
including iterator and sorting&lt;br /&gt;
&lt;br /&gt;
=== Downcasting ===&lt;br /&gt;
downcasting.e&lt;br /&gt;
&lt;br /&gt;
== To go further ==&lt;br /&gt;
&lt;br /&gt;
=== Agents ===&lt;br /&gt;
... and tuples&lt;br /&gt;
&lt;br /&gt;
=== external ===&lt;br /&gt;
&lt;br /&gt;
=== cecil ===&lt;br /&gt;
&lt;br /&gt;
=== Memory management ===&lt;br /&gt;
memory&lt;br /&gt;
&lt;br /&gt;
== Extension libraries ==&lt;br /&gt;
&lt;br /&gt;
=== Random ===&lt;br /&gt;
&lt;br /&gt;
=== Date &amp;amp; time ===&lt;br /&gt;
&lt;br /&gt;
=== Storable ===&lt;br /&gt;
&lt;br /&gt;
=== Sequencer ===&lt;br /&gt;
&lt;br /&gt;
=== Vision ===&lt;br /&gt;
visiopn, signal&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
&lt;br /&gt;
=== Execution ===&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Tutorial_tour&amp;diff=2227</id>
		<title>Tutorial tour</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Tutorial_tour&amp;diff=2227"/>
		<updated>2016-04-01T21:14:14Z</updated>

		<summary type="html">&lt;p&gt;Tybor: /* Input-output */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the guided tour of the tutorial!&lt;br /&gt;
&lt;br /&gt;
All the classes in the tutorial are provided with your LibertyEiffel installation, in the &amp;lt;code&amp;gt;tutorial&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
=== Easy starting: Hello World! ===&lt;br /&gt;
&lt;br /&gt;
To compile the program, go to the &amp;lt;code&amp;gt;LibertyEiffel/tutorial&amp;lt;/code&amp;gt; directory and execute the command:&lt;br /&gt;
&lt;br /&gt;
 se c HELLO_WORLD make -o hello&lt;br /&gt;
&lt;br /&gt;
The meaning of the command is&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;se&amp;lt;/code&amp;gt;&lt;br /&gt;
|the front-end tool for the LibertyEiffel compiler&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;&lt;br /&gt;
|the tool invoked by &amp;lt;code&amp;gt;se&amp;lt;/code&amp;gt; for compile into an executable&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;HELLO_WORLD&amp;lt;/code&amp;gt;&lt;br /&gt;
|the class of which an object is created (you may also write it in lower-case, or use its filename with the &amp;lt;code&amp;gt;.e&amp;lt;/code&amp;gt; extension) we call it root class, as this is the root of the programs object tree&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
|the creation procedure of the &amp;lt;code&amp;gt;HELLO_WORLD&amp;lt;/code&amp;gt; class to call&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;-o hello&amp;lt;/code&amp;gt;&lt;br /&gt;
|generates an executable with the name hello (linux) or hello.exe (windows)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The command produces an executable, usually &amp;lt;code&amp;gt;hello&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;hello.exe&amp;lt;/code&amp;gt; depending on the system. After compiling is finished, you can run the executable.&lt;br /&gt;
&lt;br /&gt;
This unavoidable program is in the file &amp;lt;code&amp;gt;hello_world.e&amp;lt;/code&amp;gt; and lets you grasp the basic concepts of Eiffel. Those concepts are:&lt;br /&gt;
* '''Everything is a class'''. In Eiffel, outside classes there is no salvation.&lt;br /&gt;
* The program starts by '''creating an object''' (of the root class) and initializing it by execution of the given root creation procedure. Here, the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; feature in the class &amp;lt;code&amp;gt;HELLO_WORLD&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Each file is named after the name of the class it contains, in lower-case, with the &amp;lt;code&amp;gt;.e&amp;lt;/code&amp;gt; extension.&lt;br /&gt;
* Each class comes with a set of '''features''', all its attributes and methods which come in form of functions (if they return a result) or procedures (in case they just 'do' something)&lt;br /&gt;
* Note the special object &amp;lt;code&amp;gt;io&amp;lt;/code&amp;gt; that allows you to write text on the standard output. We will see that it also lets you read data.&lt;br /&gt;
* For the Eiffel syntax, look [[Syntax_diagrams|here]].&lt;br /&gt;
&lt;br /&gt;
Please take a look at the following examples in the tutorial folder to see some classical example programs (some of them are in organized in folders for better overview)&lt;br /&gt;
* fibonacci.e&lt;br /&gt;
* knight.e&lt;br /&gt;
* pyramide.e and pyramide2.e&lt;br /&gt;
* hanoi&lt;br /&gt;
* parking&lt;br /&gt;
* triangle&lt;br /&gt;
&lt;br /&gt;
To compile the other samples you must obviously modify the compiler command to give another root class .&lt;br /&gt;
&lt;br /&gt;
== Some important concepts ==&lt;br /&gt;
&lt;br /&gt;
=== Comments ===&lt;br /&gt;
As in every programming language there is the possibility to write comments into the source code, which do not have any effect for the final program, but are for the developer or reader of the source code to get an understanding of the ideas and algorithms behind the code.&lt;br /&gt;
A comment in Eiffel starts with the sequence of a couple of minus signs and is terminated by a newline (RETURN).&lt;br /&gt;
 -- this is a comment in Eiffel&lt;br /&gt;
 a := b + 3 -- comments are also allowed after some code&lt;br /&gt;
&lt;br /&gt;
=== Manifest notations ===&lt;br /&gt;
LibertyEiffel comes with a big set of available datatypes. Famous examples as INTEGER, BOOLEAN, CHARACTER and STRING. For those (and also many collection types) there is the possibility to directly denote them in the program code, using the notations&lt;br /&gt;
 123&lt;br /&gt;
 True, False&lt;br /&gt;
 'a'&lt;br /&gt;
 &amp;quot;STRING&amp;quot;&lt;br /&gt;
See tutorial file manifest_notation.e for an example with nearly all options to define objects by manifest notations.&lt;br /&gt;
&lt;br /&gt;
=== Everything is an Object ===&lt;br /&gt;
As mentioned above, in Eiffel every useful thing is an object. There are two different kinds of objects: expanded objects and referenced object. Expanded objects are passed by value, while reference objects are - who guesses - passed by reference. In case you write 7 in the source code this is a shorthand for an instance of the expanded type INTEGER and therefore it is an expanded object. Whenever you assign it to a variable or pass it to another feature it gets copied. A STRING object - e. g. denoted by &amp;quot;Hello World!&amp;quot; in the source code is a reference object, created implicitly by the compiler, allocated on the heap and passed by reference.&lt;br /&gt;
&lt;br /&gt;
=== Local variables and Assignments ===&lt;br /&gt;
Every routine may define variables in a &amp;quot;local block&amp;quot; before its body (which start with the keyword do):&lt;br /&gt;
 make&lt;br /&gt;
    local&lt;br /&gt;
       a: INTEGER&lt;br /&gt;
       s: STRING&lt;br /&gt;
    do&lt;br /&gt;
       a := 5&lt;br /&gt;
       a := a + 1&lt;br /&gt;
       s := &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The visibility of these variables is limited to the method they are defined in and they do not keep their value from one execution of that routine to another. Assignment is done by the assignment operator &amp;quot;:=&amp;quot; which changes the variable (or let's say writable entity) on the left side to the value of the expression on the right side. In case of the &amp;quot;Hello World!&amp;quot; assignment a new object of type STRING is created on the heap, initialized to the text &amp;quot;Hello World!&amp;quot; and a link to this object is stored in the local variable s.&lt;br /&gt;
&lt;br /&gt;
=== Loops ===&lt;br /&gt;
In Eiffel we have exactly one construct to do something repeatedly, so no need to learn about for, do-while, while, anyhow, one is sufficient:&lt;br /&gt;
 from&lt;br /&gt;
   -- initialization&lt;br /&gt;
 invariant&lt;br /&gt;
   -- what shall stay true during repetition&lt;br /&gt;
 variant&lt;br /&gt;
   -- non-negative, but decreasing numeric value&lt;br /&gt;
 until&lt;br /&gt;
   -- termination condition&lt;br /&gt;
 loop&lt;br /&gt;
   -- what to do several times&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Note, that the termination condition is an expression of type BOOLEAN and the loop body is executed until the condition evaluates to True, which differs in the logic from e. g. the loop constructs in C.&lt;br /&gt;
&lt;br /&gt;
The most strange things for newcomers are probably the [https://en.wikipedia.org/wiki/Loop_invariant invariant] and the [https://en.wikipedia.org/wiki/Loop_variant variant]. While the first is a BOOLEAN condition, that stays true for every iteration, the latter is an INTEGER value which decreases with every iteration and always stays positive and therefore shows that the loop terminates. Both are optional and are not used very often in practice, even though they are essential in case we want to prove a program to be totally correct (and therefore terminates). I fear, that these formal loop assertions stay more or less unused until a formal verification tool is able to take real benefit from them.&lt;br /&gt;
&lt;br /&gt;
See tutorial/loops.e for an example of the Greatest Common Divider algorithm to show the usage of the loop.&lt;br /&gt;
&lt;br /&gt;
=== Input-output ===&lt;br /&gt;
&lt;br /&gt;
==== io cluster ====&lt;br /&gt;
&lt;br /&gt;
The input-output cluster is made up of several parts. &lt;br /&gt;
&lt;br /&gt;
The  io/basic subcluster contains the staples of &lt;br /&gt;
&lt;br /&gt;
* the definitions of standard input and output streams, [[library_class:STD_INPUT|STD_INPUT]] and [[library_class:STD_OUTPUT|STD_OUTPUT]] that are available to all classes. In fact [[library_class:ANY|ANY]] offers those features:&lt;br /&gt;
** io: [[library_class:STD_INPUT_OUTPUT|STD_INPUT_OUTPUT]] -- Handle to standard file setup.&lt;br /&gt;
** std_input: [[library_class:STD_INPUT|STD_INPUT]] -- The standard input stream&lt;br /&gt;
** std_output: [[library_class:STD_OUTPUT|STD_OUTPUT]] -- The standard output stream&lt;br /&gt;
** std_error: [[library_class:STD_ERROR|STD_ERROR]] -- The standard error stream&lt;br /&gt;
** standard_streams: [[library_class:STANDARD_STREAMS|STANDARD_STREAMS]], a singleton that allows to redirect std_input_stream, std_output_stream as well as std_error_stream. &lt;br /&gt;
&lt;br /&gt;
Beyond this standards streams that are available to all processes you can get read files in the operative file system using an  [[library_class:INPUT_STREAM|INPUT_STREAM]] using [[library_class:BINARY_FILE_READ|BINARY_FILE_READ]] to read a binary file or [[library_class:TEXT_FILE_READ|TEXT_FILE_READ]] to read a text file.&lt;br /&gt;
Similarly, to write a file you use an [[library_class:OUTPUT_STREAM|OUTPUT_STREAM]] such as [[library_class:BINARY_FILE_WRITE|BINARY_FILE_WRITE]] for binary files or [[library_class:TEXT_FILE_WRITE|TEXT_FILE_WRITE]] for text files. &lt;br /&gt;
&lt;br /&gt;
[[library_class:READLINE_INPUT_STREAM|READLINE_INPUT_STREAM]] is an input stream where the data is read from Command Line Interface (CLI) using the GNU readline library. You probabily have already used this library without knowing as it is used by several programs like &lt;br /&gt;
 &lt;br /&gt;
* directory&lt;br /&gt;
* basic_directory?&lt;br /&gt;
&lt;br /&gt;
=== Arguments ===&lt;br /&gt;
print_arguments.e&lt;br /&gt;
&lt;br /&gt;
=== Feature calls ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Contracts ===&lt;br /&gt;
Contracts are the main reason why Eiffel is superior to many other languages...&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
=== Garbage collection ===&lt;br /&gt;
Eiffel is garbage collected. That means, the objects created on the heap will automatically be freed after they lost reachability from the rest of the executing program.&lt;br /&gt;
&lt;br /&gt;
=== ACE files ===&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
including iterator and sorting&lt;br /&gt;
&lt;br /&gt;
=== Downcasting ===&lt;br /&gt;
downcasting.e&lt;br /&gt;
&lt;br /&gt;
== To go further ==&lt;br /&gt;
&lt;br /&gt;
=== Agents ===&lt;br /&gt;
... and tuples&lt;br /&gt;
&lt;br /&gt;
=== external ===&lt;br /&gt;
&lt;br /&gt;
=== cecil ===&lt;br /&gt;
&lt;br /&gt;
=== Memory management ===&lt;br /&gt;
memory&lt;br /&gt;
&lt;br /&gt;
== Extension libraries ==&lt;br /&gt;
&lt;br /&gt;
=== Random ===&lt;br /&gt;
&lt;br /&gt;
=== Date &amp;amp; time ===&lt;br /&gt;
&lt;br /&gt;
=== Storable ===&lt;br /&gt;
&lt;br /&gt;
=== Sequencer ===&lt;br /&gt;
&lt;br /&gt;
=== Vision ===&lt;br /&gt;
visiopn, signal&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
&lt;br /&gt;
=== Execution ===&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Tutorial_tour&amp;diff=2217</id>
		<title>Tutorial tour</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Tutorial_tour&amp;diff=2217"/>
		<updated>2016-03-31T09:17:54Z</updated>

		<summary type="html">&lt;p&gt;Tybor: /* Comments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the guided tour of the tutorial!&lt;br /&gt;
&lt;br /&gt;
All the classes in the tutorial are provided with your LibertyEiffel installation, in the &amp;lt;code&amp;gt;tutorial&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
=== Easy starting: Hello World! ===&lt;br /&gt;
&lt;br /&gt;
To compile the program, go to the &amp;lt;code&amp;gt;LibertyEiffel/tutorial&amp;lt;/code&amp;gt; directory and execute the command:&lt;br /&gt;
&lt;br /&gt;
 se c HELLO_WORLD make -o hello&lt;br /&gt;
&lt;br /&gt;
The meaning of the command is&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;se&amp;lt;/code&amp;gt;&lt;br /&gt;
|the front-end tool for the LibertyEiffel compiler&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;&lt;br /&gt;
|the tool invoked by &amp;lt;code&amp;gt;se&amp;lt;/code&amp;gt; for compile into an executable&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;HELLO_WORLD&amp;lt;/code&amp;gt;&lt;br /&gt;
|the class of which an object is created (you may also write it in lower-case, or use its filename with the &amp;lt;code&amp;gt;.e&amp;lt;/code&amp;gt; extension) we call it root class, as this is the root of the programs object tree&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt;&lt;br /&gt;
|the creation procedure of the &amp;lt;code&amp;gt;HELLO_WORLD&amp;lt;/code&amp;gt; class to call&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;code&amp;gt;-o hello&amp;lt;/code&amp;gt;&lt;br /&gt;
|generates an executable with the name hello (linux) or hello.exe (windows)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The command produces an executable, usually &amp;lt;code&amp;gt;hello&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;hello.exe&amp;lt;/code&amp;gt; depending on the system. After compiling is finished, you can run the executable.&lt;br /&gt;
&lt;br /&gt;
This unavoidable program is in the file &amp;lt;code&amp;gt;hello_world.e&amp;lt;/code&amp;gt; and lets you grasp the basic concepts of Eiffel. Those concepts are:&lt;br /&gt;
* '''Everything is a class'''. In Eiffel, outside classes there is no salvation.&lt;br /&gt;
* The program starts by '''creating an object''' (of the root class) and initializing it by execution of the given root creation procedure. Here, the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; feature in the class &amp;lt;code&amp;gt;HELLO_WORLD&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Each file is named after the name of the class it contains, in lower-case, with the &amp;lt;code&amp;gt;.e&amp;lt;/code&amp;gt; extension.&lt;br /&gt;
* Each class comes with a set of '''features''', all its attributes and methods which come in form of functions (if they return a result) or procedures (in case they just 'do' something)&lt;br /&gt;
* Note the special object &amp;lt;code&amp;gt;io&amp;lt;/code&amp;gt; that allows you to write text on the standard output. We will see that it also lets you read data.&lt;br /&gt;
* For the Eiffel syntax, look [[Syntax_diagrams|here]].&lt;br /&gt;
&lt;br /&gt;
Please take a look at the following examples in the tutorial folder to see some classical example programs (some of them are in organized in folders for better overview)&lt;br /&gt;
* fibonacci.e&lt;br /&gt;
* knight.e&lt;br /&gt;
* pyramide.e and pyramide2.e&lt;br /&gt;
* gcd&lt;br /&gt;
* hanoi&lt;br /&gt;
* parking&lt;br /&gt;
* triangle&lt;br /&gt;
&lt;br /&gt;
To compile the other samples you must obviously modify the compiler command to give another root class .&lt;br /&gt;
&lt;br /&gt;
== Some important concepts ==&lt;br /&gt;
&lt;br /&gt;
=== Comments ===&lt;br /&gt;
As in every programming language there is the possibility to write comments into the source code, which do not have any effect for the final program, but are for the developer or reader of the source code to get an understanding of the ideas and algorithms behind the code.&lt;br /&gt;
A comment in Eiffel starts with the sequence of a couple of minus signs and is terminated by a newline (RETURN).&lt;br /&gt;
 -- this is a comment in Eiffel&lt;br /&gt;
 a := b + 3 -- comments are also allowed after some code&lt;br /&gt;
&lt;br /&gt;
=== Manifest notations ===&lt;br /&gt;
LibertyEiffel comes with a big set of available datatypes. Famous examples as INTEGER, BOOLEAN, CHARACTER and STRING. For those (and also many collection types) there is the possibility to directly denote them in the program code, using the notations&lt;br /&gt;
 123&lt;br /&gt;
 True, False&lt;br /&gt;
 'a'&lt;br /&gt;
 &amp;quot;STRING&amp;quot;&lt;br /&gt;
See tutorial file manifest_notation.e for an example with nearly all options to define objects by manifest notations.&lt;br /&gt;
&lt;br /&gt;
=== Everything is an Object ===&lt;br /&gt;
As mentioned above, in Eiffel every useful thing is an object. There are two different kinds of objects: expanded objects and referenced object. Expanded objects are passed by value, while reference objects are - who guesses - passed by reference. In case you write 7 in the source code this is a shorthand for an instance of the expanded type INTEGER and therefore it is an expanded object. Whenever you assign it to a variable or pass it to another feature it gets copied. A STRING object - e. g. denoted by &amp;quot;Hello World!&amp;quot; in the source code is a reference object, created implicitly by the compiler, allocated on the heap and passed by reference.&lt;br /&gt;
&lt;br /&gt;
=== Local variables and Assignments ===&lt;br /&gt;
Every routine may define variables in a &amp;quot;local block&amp;quot; before its body (which start with the keyword do):&lt;br /&gt;
 make&lt;br /&gt;
    local&lt;br /&gt;
       a: INTEGER&lt;br /&gt;
       s: STRING&lt;br /&gt;
    do&lt;br /&gt;
       a := 5&lt;br /&gt;
       a := a + 1&lt;br /&gt;
       s := &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The visibility of these variables is limited to the method they are defined in and they do not keep their value from one execution of that routine to another. Assignment is done by the assignment operator &amp;quot;:=&amp;quot; which changes the variable (or let's say writable entity) on the left side to the value of the expression on the right side. In case of the &amp;quot;Hello World!&amp;quot; assignment a new object of type STRING is created on the heap, initialized to the text &amp;quot;Hello World!&amp;quot; and a link to this object is stored in the local variable s.&lt;br /&gt;
&lt;br /&gt;
=== Input-output ===&lt;br /&gt;
* io&lt;br /&gt;
* directory&lt;br /&gt;
* basic_directory?&lt;br /&gt;
&lt;br /&gt;
=== Arguments ===&lt;br /&gt;
print_arguments.e&lt;br /&gt;
&lt;br /&gt;
=== Feature calls ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Contracts ===&lt;br /&gt;
Contracts are the main reason why Eiffel is superior to many other languages...&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
=== Garbage collection ===&lt;br /&gt;
Eiffel is garbage collected. That means, the objects created on the heap will automatically be freed after they lost reachability from the rest of the executing program.&lt;br /&gt;
&lt;br /&gt;
=== ACE files ===&lt;br /&gt;
&lt;br /&gt;
=== Collections ===&lt;br /&gt;
including iterator and sorting&lt;br /&gt;
&lt;br /&gt;
=== Downcasting ===&lt;br /&gt;
downcasting.e&lt;br /&gt;
&lt;br /&gt;
== To go further ==&lt;br /&gt;
&lt;br /&gt;
=== Agents ===&lt;br /&gt;
... and tuples&lt;br /&gt;
&lt;br /&gt;
=== external ===&lt;br /&gt;
&lt;br /&gt;
=== cecil ===&lt;br /&gt;
&lt;br /&gt;
=== Memory management ===&lt;br /&gt;
memory&lt;br /&gt;
&lt;br /&gt;
== Extension libraries ==&lt;br /&gt;
&lt;br /&gt;
=== Random ===&lt;br /&gt;
&lt;br /&gt;
=== Date &amp;amp; time ===&lt;br /&gt;
&lt;br /&gt;
=== Storable ===&lt;br /&gt;
&lt;br /&gt;
=== Sequencer ===&lt;br /&gt;
&lt;br /&gt;
=== Vision ===&lt;br /&gt;
visiopn, signal&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
&lt;br /&gt;
=== Execution ===&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Lib/kernel&amp;diff=2216</id>
		<title>Lib/kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Lib/kernel&amp;diff=2216"/>
		<updated>2016-03-30T15:59:55Z</updated>

		<summary type="html">&lt;p&gt;Tybor: Created page with &amp;quot;The classes in the kenel cluster are basic   === ANY ===  The class ANY is the everpresent root of all your objects.  All classes defined in a Liberty Ei...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The classes in the kenel cluster are basic &lt;br /&gt;
&lt;br /&gt;
=== ANY ===&lt;br /&gt;
&lt;br /&gt;
[[library_class:ANY|The class ANY]] is the everpresent root of all your objects.&lt;br /&gt;
&lt;br /&gt;
All classes defined in a Liberty Eiffel system implicitly insert all the features of class [[library_class:ANY|ANY]].&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Wrapping_C_libraries&amp;diff=2215</id>
		<title>Wrapping C libraries</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Wrapping_C_libraries&amp;diff=2215"/>
		<updated>2016-03-24T15:56:54Z</updated>

		<summary type="html">&lt;p&gt;Tybor: /* Text to be still reviewd */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Interfacing]]&lt;br /&gt;
== Developer's guidelines ==&lt;br /&gt;
=== or how to write GNU-Eiffel wrappers for a C library ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;&lt;br /&gt;
&amp;quot;longum iter est per praecepta, breve et efficax per exempla&amp;quot;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;quot;The path of precept is long, that of example short and effectual.&amp;quot;&amp;lt;br/&amp;gt;&lt;br /&gt;
Seneca the Elder&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So instead of giving rules I guide you on my path of wrapping the ZLib library, one of the most widespread compression library.&lt;br /&gt;
&lt;br /&gt;
I deliberately chose a &amp;quot;low-level&amp;quot; library with very precise and narrow aims which lets to show basic wrapping techniques: a wider, properly designed library has infrastructures and details that requires to know some tricks from the beginning of the work, otherwise the resulting wrapper should be heavily re-worked on many times.&lt;br /&gt;
&lt;br /&gt;
I usually work with Debian and Ubuntu GNU/Linux, so all the system commands and the package names listed in this tutorial/how-to should apply without changes on Debian and Debian-derived machines. Other distributions, like Fedora, RedHat, Suse, Mandriva shall have similarly named packages. People using BSD OSes could have those libraries available in their package manager. As a last resort you can always download the sources, compile and install them manually. I hope you know how to do it, otherwise the rest of this document would be quite useless for you.&lt;br /&gt;
&lt;br /&gt;
==== Prerequites ====&lt;br /&gt;
&lt;br /&gt;
You should be proficient with:&lt;br /&gt;
&lt;br /&gt;
* the C language,&lt;br /&gt;
* the Eiffel language, &lt;br /&gt;
* the C library you want to wrap; you shall known how to use it in a C program; take some time to read the documentation of the library and to study the provided example in order to make yourself familiar with the style required to use the library. You will need them to provide extensive, readable documentation of your classes.&lt;br /&gt;
&lt;br /&gt;
==== Software prerequisites ====&lt;br /&gt;
&lt;br /&gt;
Make sure you have access on your machine to:&lt;br /&gt;
&lt;br /&gt;
* Liberty Eiffel, you may download the Debian packages from &lt;br /&gt;
* The C headers of the library to wrap; you shall be able to compile the examples of the library you're wrapping; so I issued&lt;br /&gt;
&lt;br /&gt;
    sudo apt-get install zlib1g-dev&lt;br /&gt;
&lt;br /&gt;
* Documentation of the library. Even if it is not absolutely necessary to make working wrappers they are indeed necessary to provide properly documented, therefore usable classes; (GNU) Eiffel has standard rules on how to document code and we shall abide to that; adapting the original C documentation while we wraps various features is a good style to handle documentation. Please do not leave any part of your code undocumented. Spend some time reading the documentation. It is always worth the effort.&lt;br /&gt;
&lt;br /&gt;
I would like to repeat the concept: even if source-code in general is intented to be read by a compiler to produce binary modules its readability and understandability for people is of the utmost importance. Code is not meant to be written-once and never re-read. It actually happens that good code will be read again and again by many people. The fact that programs are covered and protected by copyright laws is not incidental. It means that source code is the expression of an author, like a novel or poetry; I like to think that this fact includes in itself, in-nuce that source text will be read by people several time. And this reading does occour when the source-code text is well-written, well-documentated, useful for study and reuse if its license does allow it.&lt;br /&gt;
&lt;br /&gt;
This approach does resemble Knuth's Literate Programming and indeed many design choices made by Bertrand Meyer during the conception of Eiffel regarding readability and understandability of source-code, expecially those exposed in Object-Oriented Software Construction are strikingly similar to Knut's ideas.&lt;br /&gt;
&lt;br /&gt;
Let's return to our wrapping/binding work after a due phylosophical digression&lt;br /&gt;
&lt;br /&gt;
=== Preliminares ===&lt;br /&gt;
&lt;br /&gt;
Most data structure in C are usually handled by reference, i.e. using pointers. &lt;br /&gt;
&lt;br /&gt;
Passing objects by value is currently requires &amp;quot;expanded external classes&amp;quot; and will no be covered in this guide. Therefore if your library extensively pass structures around by value and not by reference (with a pointer), for example (TODO: put links to online example of passing structure by value) in function calls or contained in other structures our life will be quite hard. Fortunately enought most libraries handles most of its data structures by reference and zlib is no exception: in fact its basic functions takes pointers as first argument.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
== Identifying types and classes == &lt;br /&gt;
 &lt;br /&gt;
Now you will wonder how to identify the types used in Zlib. This is quite an extensive argument that people smarter than me already handled in great details here.&lt;br /&gt;
&lt;br /&gt;
A simplicistic rule-of-thumb specifically fitted to wrap libraries written in C is that when we have several functions that takes a pointer to a struct this struct is a good candidate for a class and those functions are good candidates to be wrapped as features usable by an Eiffel program.&lt;br /&gt;
&lt;br /&gt;
Zlib has many functions taking a z_streamp which is nothing more than a typedef-fed pointer to structure z_stream_s. We will wrap those facilities in the Eiffel's (non-expanded) class ZLIB_STREAM.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Code organization and class hierarchy. === &lt;br /&gt;
&lt;br /&gt;
Before diving into code writing let's spend some words on how to cleanly organize our work. We want to provide the user of our library a pretty object-oriented API; since he/she will look at the sources directly soon-or-later it is useful to separate the high-level features and classes, those that will be used directly in other Eiffel projects from the low-level details, like external features or plugins.&lt;br /&gt;
&lt;br /&gt;
We usually place each wrapper library in its own directory following this organization:&lt;br /&gt;
&lt;br /&gt;
* zlib/ &lt;br /&gt;
** examples -- Examples on how to use the Zlib wrappers &lt;br /&gt;
** library -- Contains the high-level classes, those used directly in Eiffel programs &lt;br /&gt;
*** externals -- Contains the low-level classes to interface with C (externals, macros, enumeration and so on) &lt;br /&gt;
**** generated -- Contains the low-level classes automatically generated with a tool such as wrappers_generator&lt;br /&gt;
*** loadpath.se -- Lists the clusters of the library itself, i.e. which directories contains its classes &lt;br /&gt;
** loadpath.se -- Lists the clusters used by the library, i.e. its dependencies &lt;br /&gt;
** tests -- Contains the tests to be used with eiffeltest tool&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the library is conceptually separated into different areas, subsystems or if it is simple too wide to put cleanly every public class into a single directory we can split the content of the directory library into several sub-directory, like GLib wrapper. See its directory layout:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* eiffel-glib/library/ &lt;br /&gt;
** core &lt;br /&gt;
** data_types &lt;br /&gt;
** externals &lt;br /&gt;
*** generated&lt;br /&gt;
** fundamentals&lt;br /&gt;
** utilities&lt;br /&gt;
&lt;br /&gt;
Let's fill &amp;lt;code&amp;gt;zlib/library/loadpath.se&amp;lt;/code&amp;gt;. It lists two directories: those containing the high-level classes, the same of the loadpath.se file itself, i.e. the current directory (.) and the ./externals directory which will contain deferred classes that provide access to external features.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ./&lt;br /&gt;
./externals/ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
zlib/loadpath.se will list the clusters used by the library itself, i.e. its dependencies. Like the previous it is a plain text file containing directories or other loadpaths file (Ok... I'm not assuming proficiency with GNU-Eiffel here). Zlib is quite a &amp;quot;plain&amp;quot; library and does not have dependencies - here we are speaking of dependencies of the Eiffel wrappers - so he only shall list only the base cluster of a wrapper library, ../common/loadpath.se and the soad-path of the library itself &amp;lt;./library/loadpath.se/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ../common/loadpath.se&lt;br /&gt;
./library/loadpath.se &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low-level access to functions ===&lt;br /&gt;
&lt;br /&gt;
Writing the Eiffel source code to access external C code is an extremely long, tedious and verbose process so a tool named '''wrappers_generator''' has been created.&lt;br /&gt;
&lt;br /&gt;
It was not included in binary form in the adler release since it was not ready for prime time. &lt;br /&gt;
Now it isn't robust as I would like but at least it processes sources like Gtk3, Glib, &amp;amp;slasho;mq and other libraries without crashing. &lt;br /&gt;
&lt;br /&gt;
It will be included into bell and later releases; before it's relase I would suggest to rebuild the compiler and work from the Git repository.&lt;br /&gt;
&lt;br /&gt;
You can get the sources from https://savannah.gnu.org/projects/liberty-eiffel/ or from https://github.com/LibertyEiffel/Liberty and build it with install.sh script which also build wrappers_generator. &lt;br /&gt;
&lt;br /&gt;
wrappers_generator does not parses C code directly but reads the output of gccxml or its successor, castxml. Those tools provides an XML description of the source code analyzed that greatly ease the task of generating glue code. In fact they were created for that purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;gccxml&amp;lt;/pre&amp;gt; is available in Debian stable while &amp;lt;pre&amp;gt;castxml&amp;lt;/pre&amp;gt; is available in Debian testing. Both are also available for Ubuntu, Redhat et cetera.&lt;br /&gt;
&lt;br /&gt;
Given an XML file and a list of C files (headers or sources) to wrap wrappers_generator:&lt;br /&gt;
&lt;br /&gt;
* for each source file create a deferred class containing all the wrappable functions found in that file; functions in foo.h are wrapped into FOO_EXTERNALS&lt;br /&gt;
* for each struct creates a deferred class containing queries and setters feature to manipulate all members which have an Eiffel wrapper type;&lt;br /&gt;
* the same is made for unions&lt;br /&gt;
* creates a deferred Eiffel class named like the xml file containing wrappers for all typedefs, so when you have to refer to C &amp;quot;long&amp;quot; which is notorious for change size on various platform you can use &amp;quot;like long&amp;quot; in Eiffel&lt;br /&gt;
* each enumeration is wrapped into expanded classes with proper queries and setters. That way they are as efficient as plain integers values but they can't assume arbitrary values; enum foobar is wrapped into FOOBAR_ENUM&lt;br /&gt;
* when the values of an enumeration are actually flags, i.e. they all are diffent powers of 2, it's wrapped as a &amp;quot;flag&amp;quot; enumeration with commands to set and unset each flag of the enum.&lt;br /&gt;
* C++ classes, namespaces and all its fineries are currently ignored&lt;br /&gt;
* macros, #defines and all cannot be handled since they are &amp;quot;preprocessed away&amp;quot; and their text is not preseted to gccxml or castxml&lt;br /&gt;
* variadic functions can't be wrapped in Eiffel &lt;br /&gt;
* it transform CamelCase into CAMEL_CASE for classes, camel_case for features (queries, commands and so on)&lt;br /&gt;
* if it doesn't exist it creates a directory plugin/c that will contain all the C code that will be compiled by liberty eiffel when using the library&lt;br /&gt;
&lt;br /&gt;
It does not try to give high-level, directly usable wrappers but it writes fairly verbose low-level wrappers that hopefully will save you quite a lot of typing. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The rest of this document still needs to be adapted.  ===&lt;br /&gt;
&lt;br /&gt;
Let's write some low-level classes. We will put the functions found in the include file /usr/include/zlib.h in the class ZLIB_EXTERNALS and the low-level getters and setters features for the structure z_stream structure in the class Z_STREAM_STRUCT (this scheme is also used by eiffel-gcc-xml tool; I know it is simplicistic and that it could produce name-clashes but it has worked fine until now. ). Here's some examples&lt;br /&gt;
C function	Eiffel feature&lt;br /&gt;
const char * zlibVersion (void);	zlib_version: POINTER&lt;br /&gt;
int deflateInit (z_streamp strm, int level);	deflate_init (a_stream: POINTER; a_level: INTEGER_32): INTEGER_32&lt;br /&gt;
int deflate (z_streamp strm, int flush);	deflate (a_stream: POINTER;a_flush: INTEGER_32): INTEGER&lt;br /&gt;
int deflateEnd (z_streamp strm);	deflate_end (a_stream: POINTER): INTEGER&lt;br /&gt;
int inflateInit (z_streamp strm);	inflate_init (a_stream: POINTER): INTEGER&lt;br /&gt;
int inflate (z_streamp strm, int flush);	inflate (a_stream: POINTER; a_flush: INTEGER): INTEGER&lt;br /&gt;
int inflateEnd (z_streamp strm);	inflate_end (a_stream: POINTER): INTEGER&lt;br /&gt;
&lt;br /&gt;
As you can see I have turned camelCaseFunction into camel_case_function which is far more in tune with Eiffel style. Int is actually an INTEGER_32 or only INTEGER (it still don't matter, even if I suspect that it will do soon: world is already filled with 64-bit machines and literally billion of devices with 4,8,16 bit CPU are in use today, not counting GPGPU)&lt;br /&gt;
&lt;br /&gt;
Let's take a look at ZLIB_EXTERNALS. You'll see many entries like&lt;br /&gt;
&lt;br /&gt;
 inflate_init (a_stream: POINTER): INTEGER is -- int inflateInit (z_streamp strm); &lt;br /&gt;
	external &amp;quot;plug_in&amp;quot; &lt;br /&gt;
	alias &amp;quot;{&lt;br /&gt;
		location: &amp;quot;${eiffel_libraries}/plugins&amp;quot; &lt;br /&gt;
		module_name: &amp;quot;zlib&amp;quot;&lt;br /&gt;
		feature_name: &amp;quot;inflateInit&amp;quot;&lt;br /&gt;
	}&amp;quot;&lt;br /&gt;
	end &lt;br /&gt;
&lt;br /&gt;
this entry tells us that the Eiffel feature &amp;quot;inflate_init&amp;quot; refers to the symbol &amp;quot;inflateInit&amp;quot; in the module &amp;quot;zlib&amp;quot; of the plugins found in the directory.&lt;br /&gt;
&lt;br /&gt;
Entries like this are the only &amp;quot;esoteric&amp;quot; Eiffel code you will see. All the details required to interface to C, to link to the actualy library and how to compile the code written in other languages is handled by the plugin part.&lt;br /&gt;
&lt;br /&gt;
Without using plugins every Eiffel program should know all the details required to compile a C application with zlib. It would require to always use ACE files - even for simple examples - because you need to provide proper &amp;quot;c_compiler_options&amp;quot; and &amp;quot;linker_options&amp;quot;; for a single, simple library like Zlib it looks a tame task, only requiring to add -lzlib to the &amp;quot;linker_options&amp;quot; but when you start building real-world application things will get complicated really fast.&lt;br /&gt;
&lt;br /&gt;
See SmartEiffel documentation on plugins.&lt;br /&gt;
&lt;br /&gt;
All those functions returns an integer with standardized values #defined in the C header. We will wrap them in the deferred class ZLIB_CONSTANTS.&lt;br /&gt;
&lt;br /&gt;
Deferred? Why deferred? We want to avoid the Eiffel programmer the burden to deal with all the details that C requires - otherwise we would have used plain C - so we do not want him/her to directly use that libraries. Deferred classes cannot have creation clauses so we are sure that no objects of type ZLIB_EXTERNALS and ZLIB_CONSTANTS will be created. They are helper classes that will be either inherited from or - more properly - inserted into ZLIB_STREAM and its effective heirs, ZLIB_INPUT_STREAM and ZLIB_OUTPUT_STREAM.&lt;br /&gt;
&lt;br /&gt;
Making sure that the Eiffel developer will not use low-level features directly is the main reason why all the external features are not exported to anyone else, using the syntax feature {} -- External calls. This way only heirs - conforming or not - of that class can use them; for people coming from C++ it's like having private functions members.&lt;br /&gt;
C types&lt;br /&gt;
&lt;br /&gt;
Here's a quick conversion table for various C types&lt;br /&gt;
C type	Eiffel type&lt;br /&gt;
int	INTEGER;&lt;br /&gt;
short int	INTEGER_16&lt;br /&gt;
long int	INTEGER_32 or 64&lt;br /&gt;
long long int	INTEGER_64&lt;br /&gt;
int8_t (defined at stdint.h, ISO C 99)	INTEGER_8&lt;br /&gt;
int16_t 	INTEGER_16&lt;br /&gt;
int32_t	INTEGER_32&lt;br /&gt;
int64_t	INTEGER_64&lt;br /&gt;
unsigned int	NATURAL&lt;br /&gt;
unsigned short int	NATURAL_16&lt;br /&gt;
unsigned long int	NATURAL_32 on 32-bit, NATURAL_64 on 64.bit. See long int&lt;br /&gt;
unsigned long long int	NATURAL_64&lt;br /&gt;
signed/unsigned char	CHARACTER&lt;br /&gt;
float	REAL_32&lt;br /&gt;
double	REAL_64&lt;br /&gt;
long double	REAL_EXTENDED&lt;br /&gt;
char	BOOLEAN&lt;br /&gt;
void* or any other pointer	POINTER&lt;br /&gt;
&lt;br /&gt;
Some notes:&lt;br /&gt;
&lt;br /&gt;
    intXX_t are defined in GNU systems (Linux Glibc, CygWin and similar).&lt;br /&gt;
    Currently INTEGER is mere alias for INTEGER_32 but this is bound to change in future version of SmartEiffel. Personally I think that it should be &amp;quot;the integer type with the same bit-lenght of C int&amp;quot;.&lt;br /&gt;
    A nice feature of long int is that is could be longer that int. So we can't really be sure whenever it is 32 or 64 bit. Usually it is an INTEGER_32 on 32-bit machines and INTEGER_64 on 64-bit machines. See this post on the SmartEiffel mailing list.&lt;br /&gt;
    The same problem applies for long unsigned int: NATURAL_32 on 32-bits and NATURAL_64 on 64-bit. This mismatch can be quite problematic and it will be discussed-addressed later.&lt;br /&gt;
    At the time of writing of this document SmartEiffel has some know issues regarding NATURALs types. If they actually do cause bugs there is an (unsatisfactory) workaround: use a bigger INTEGER. This implies a hidden conversion at C level and bargains correctness with a little waste of space and worse performance. Do not use an INTEGER of same size: it &amp;quot;usually&amp;quot; works nicely but this is a known source of nasty bugs since you will soon or later it will silently overflow.&lt;br /&gt;
&lt;br /&gt;
An enlighting explanation about C variable types and declarations can be read on Wikipedia (I find particurarly confusing - expecially for the novice - that char is at the same time an 8-bit integer and an encoding for ASCII characters. Most programmers could always end up thinking about it only as a character. After more than 30 years they could have called it &amp;quot;byte&amp;quot;. Yet this behaviour is fit the spirit of C very well. ).&lt;br /&gt;
&lt;br /&gt;
The resulting ZLIB_CONSTANTS class is almost boring and undocumented. I maintained the documentation level found in the original documentation, since those are values that will be handled only by the implementation of the wrapper.&lt;br /&gt;
&lt;br /&gt;
Have a look at WRAPPER_HANDLER. Eiffel has the ability to selectively export Any class that needs to access some of the&lt;br /&gt;
Access to structure field&lt;br /&gt;
&lt;br /&gt;
Let's wrap the z_stream structure (the structure name is actually struct z_stream_s typedeffed to z_stream during its definition); the wrapper will have a similar two layer design: the low-level Z_STREAM_STRUCT will be a deferred class, with feature {} -- Hidden, low-level getters and setters. This class will also have a feature struct_size: INTEGER that will be the value of sizeof(z_stream)&lt;br /&gt;
&lt;br /&gt;
Field named FooBar in the struct my_struct will be read with the Eiffel query my_struct_get_foo_bar and set with the command my_struct_set_foo_bar. Remember that those are low-level features; references to other objects will be pointers and its signature will be one of an external function: the first argument will be always the address of - a POINTER to - the wrapped struct.&lt;br /&gt;
Naming of placeholder arguments&lt;br /&gt;
&lt;br /&gt;
Placeholder names should be chosen in a way that makes the documentation of the feature in English as smooth as possible for a proper argument placeholder for the Gnu-Eiffel language. &amp;quot;CamelCase&amp;quot; will be translated into &amp;quot;a_camel_case&amp;quot;, &amp;quot;ENOO&amp;quot; is translated into &amp;quot;an_enoo&amp;quot;. Eventual underscores in front of `a_name' are removed: &amp;quot;__foo&amp;quot; becomes &amp;quot;a_foo&amp;quot;. The prefixed preposition is added to make clearer that the name refers to a generic value, not to a particular one. Always tries to use a placeholder that can be directly put in the feature's documentation without paraphrase.&lt;br /&gt;
ZLIB_STREAM, at last.&lt;br /&gt;
&lt;br /&gt;
So let's write something that will be used in an actual Eiffel program! We start writing ZLIB_STREAM from file common/skeleton that provides us the usual LGPL-2.1-or-later headers. It inserts ZLIB_EXTERNALS and Z_STREAM_STRUCT.&lt;br /&gt;
&lt;br /&gt;
TODO: finish this&lt;br /&gt;
The &amp;quot;common&amp;quot; cluster&lt;br /&gt;
&lt;br /&gt;
The basic building blocks of a wrapper library have been put in the common cluster.&lt;br /&gt;
&lt;br /&gt;
The WRAPPER class it the &amp;quot;fundamental&amp;quot; one even if embarassingly simple. Its only effective field (i.e.: stored, non-computed) is the handle POINTER. It shall handle the allocation and deallocation of the memory referred by handle so it is an heir of DISPOSABLE but it doesn't define dispose because there is no such a thing like a default memory handling in C.&lt;br /&gt;
&lt;br /&gt;
C_STRUCT inherits from WRAPPER and provides default implementations for copy, is_equal and from_external_pointer features; it introduces the deferred &amp;quot;struct_size&amp;quot; query which should give the same result of C operator sizeof(MyStruct).&lt;br /&gt;
&lt;br /&gt;
Note that there are - at least conceptually - other potentially heirs of WRAPPER, like pointers to functions&lt;br /&gt;
&lt;br /&gt;
Many C libraries often return const char* strings. Those strings shall not be modified and their memory will be handled by the library; by all other means they actually are plain strings. A correct behaviour is to write foo: STRING is do create Result.from_external_copy(a_function_returning_a_const_char_pointer(handle)) end; a STRING is meant to be manipulated and changed and has control on the memory of its content. Here we are instead given a piece of memory holding some text that is &amp;quot;mostly read-only&amp;quot; whose control is held by the library. To provide correct behaviour STRING must copy the buffer, from_external can't be used. CONST_STRING is an effective heir of STRING that provides efficient wrapping of &amp;quot;const strings&amp;quot;. It is usable like any other STRING but all the changes are made to a separe buffer preserving the original content - we are actually not allowed to change it. No further memory is allocated when a CONST_STRING is created: the buffer returned by the C library is used directly. For example, GTK+ has many calls like const gchar* gtk_entry_get_text (GtkEntry *entry); Memory efficiency is achieved making changing features slower. If you need to change its content consider using its feature string to get a new (non-const) STRING with the same content.&lt;br /&gt;
&lt;br /&gt;
TODO: add proper description about:&lt;br /&gt;
CACHING_FACTORY&lt;br /&gt;
C_ARRAY&lt;br /&gt;
COMPARABLE_C_STRUCT&lt;br /&gt;
COMPARABLE_WRAPPER&lt;br /&gt;
CONST_STRING&lt;br /&gt;
C_OWNED&lt;br /&gt;
C_STRUCT&lt;br /&gt;
EIFFEL_OWNED&lt;br /&gt;
ENUM&lt;br /&gt;
EXPANDED_WRAPPER&lt;br /&gt;
GLOBAL_CACHE&lt;br /&gt;
GLOBALLY_CACHED&lt;br /&gt;
HASHABLE_WRAPPER&lt;br /&gt;
ITERATOR_ON_C_ARRAY&lt;br /&gt;
LINKED_STRING&lt;br /&gt;
MIXED_MEMORY_HANDLING&lt;br /&gt;
NULL_TERMINATED_C_ARRAY&lt;br /&gt;
NULL_TERMINATED_STRING_ARRAY&lt;br /&gt;
POINTER_HANDLING&lt;br /&gt;
REFERENCE_COUNTED&lt;br /&gt;
SHARED&lt;br /&gt;
STRING_ARRAY&lt;br /&gt;
STRING_ARRAY_ITERATOR&lt;br /&gt;
WRAPPER_COLLECTION&lt;br /&gt;
WRAPPER_DICTIONARY&lt;br /&gt;
WRAPPER&lt;br /&gt;
WRAPPER_FACTORY&lt;br /&gt;
WRAPPER_HANDLER&lt;br /&gt;
WRAPPERS_CACHE&lt;br /&gt;
Enumerations&lt;br /&gt;
&lt;br /&gt;
There are two general tecnique to wrap an enum.&lt;br /&gt;
&lt;br /&gt;
    Put all the possible values of enumerations into a class as INTEGER constants accessibile to the user of your library. This is mostly similar to the actual usage of an enumeration. Each and every feature that accept an enum value as argument will need a precondition like is_valid_foo (a_foo_value)&lt;br /&gt;
    Create a new type. In fact an enumeration is an INTEGER that can assume only precise and prestabilited values, so that its value is correct and consistent all the times. Class ENUM provides some facilities to achieve this. It shall be used in classes like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    -- This file have been created by eiffel-gcc-xml.&lt;br /&gt;
    -- Any change will be lost by the next execution of the tool.&lt;br /&gt;
&lt;br /&gt;
    expanded class PANGO_WEIGHT&lt;br /&gt;
&lt;br /&gt;
    insert ENUM&lt;br /&gt;
&lt;br /&gt;
    creation default_create&lt;br /&gt;
    feature -- Validity&lt;br /&gt;
    	is_valid_value (a_value: INTEGER): BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := ((a_value = pango_weight_ultralight) or else&lt;br /&gt;
    				(a_value = pango_weight_light) or else&lt;br /&gt;
    				(a_value = pango_weight_normal) or else&lt;br /&gt;
    				(a_value = pango_weight_semibold) or else&lt;br /&gt;
    				(a_value = pango_weight_bold) or else&lt;br /&gt;
    				(a_value = pango_weight_ultrabold) or else&lt;br /&gt;
    				(a_value = pango_weight_heavy))&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature -- Setters&lt;br /&gt;
    	default_create,  set_ultralight is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_ultralight&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_light is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_light&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_normal is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_normal&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_semibold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_semibold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_bold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_bold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_ultrabold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_ultrabold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_heavy is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_heavy&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature -- Queries&lt;br /&gt;
    	is_ultralight: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_ultralight)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_light: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_light)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_normal: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_normal)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_semibold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_semibold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_bold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_bold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_ultrabold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_ultrabold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_heavy: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_heavy)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature {WRAPPER, WRAPPER_HANDLER} -- Low level values&lt;br /&gt;
    	pango_weight_ultralight: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_ULTRALIGHT&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_light: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_LIGHT&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_normal: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_NORMAL&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_semibold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_SEMIBOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_bold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_BOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_ultrabold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_ULTRABOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_heavy: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_HEAVY&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    As you can see each possible value has a setter command&amp;lt;br&amp;gt;(set_light, set_normal and so on) and a boolean&amp;lt;br&amp;gt;query (is_light, is_normal). As usual low-level values are accessible&amp;lt;br&amp;gt;only by a WRAPPER or a WRAPPER_HANDLER.&lt;br /&gt;
&lt;br /&gt;
Using eiffel-gcc-xml&lt;br /&gt;
&lt;br /&gt;
Have a look at the manually written ZLIB_EXTERNALS. Eiffel is a language that is meant to be easy to the reader at the cost of being verbose. All that text of source to access a bunch of C functions. Think about serious libraries that have literally thousands of functions, structures, and enumeration! Writing the low level side of those wrappers is a really long, tedious task, the kind of task that people usually would leave to an unfaticable, astonishgly fast yet quite dumb worker, a computer. Andreas Leitner - who is surely quite smarter than myself - wrote a C parser for his Eiffel Wrapper Generator. I do not have neither the time neither the abilities of Andreas but it seems that I'm more lucky than him. In fact by the time I got serious with this project, people with the same problem, requiring tons of wrappers for Python, produced gcc-xml. These days parsing XML is a considered a common task, a task to be left to standard libraries, so SmartEiffel have an XML parser. So I wrote a little tool name &amp;quot;eiffel-gcc-xml&amp;quot; that takes the output of gcc-xml as input to produce the low-level &amp;quot;external&amp;quot; classes that we need to access functions, structures and enumerations.&lt;br /&gt;
&lt;br /&gt;
Well, it actually requires a little more work since it breaks very often.&lt;br /&gt;
Memory handling&lt;br /&gt;
C_STRUCT is a wrapper for a data structure implemented in C programming language using a structure.&lt;br /&gt;
It does not make any assumption about memory handling; the developer of a SmartEiffel wrapper of a C library has to inherit to create a proper wrapper for it the developer shall inherit both from this class and from classes providing memory handling behavior, depending on how structure's memory shall be handled. This is decided  case-by-case by C library.&lt;br /&gt;
Currently available memory handling classes are:&lt;br /&gt;
&lt;br /&gt;
    C_OWNED: memory is always handled by the underlying C library.&lt;br /&gt;
    EIFFEL_OWNED: once created memory is fully handled by Eiffel runtime, usually with the Garbage Collector.&lt;br /&gt;
    GLOBALLY_CACHED: Until disposed by Eiffel the wrapper registered in wrappers dictionary will be the unique wrapper used on the Eiffel side.&lt;br /&gt;
    MIXED_MEMORY_HANDLING: whose memory can either by handled by the Eiffel library or by the underlying C code. Who handles memory is decided on a per-object based on the value of the flag `is_shared': handle will not be freed on dispose of the Eiffel wrapper object, when `is_shared' is true.&lt;br /&gt;
    REFERENCE_COUNTED: memory is handled thought reference counting, i.e.GObject&lt;br /&gt;
&lt;br /&gt;
Add proper examples of the various memory handling classes.&lt;br /&gt;
Implementing collections&lt;br /&gt;
Quite often objects are stored into containers or collections like arrays, linked lists, dictionaries, hashed-tables and so on. Many C libraries provides their own implementation of the classic containers, for example the GLib library provides GList, GSList, GHashTable and many others.&lt;br /&gt;
A WRAPPER_COLLECTION is a COLLECTION implemented wrapping some facilities offered by the wrapped C library, like GLib's linked list GList.&lt;br /&gt;
When you wrap those data structures you will encounter two kinds of problems:&lt;br /&gt;
&lt;br /&gt;
    Pointer returned by C containers could be newly allocated, not already wrapped by the Eiffel wrapper or already wrapper by the Eiffel wrapper. You can't naively create a new WRAPPER every time. Beside the obvious waste of memory and the stress you put on the garbage collector you will break most postconditions and invariant of a COLLECTION, since things that seems obvious like&lt;br /&gt;
&lt;br /&gt;
 do_stuff (my_collection: WRAPPER_COLLECTION[ITEM]) is require&lt;br /&gt;
my_collection/=Void not my_collection.is_empty local a,b: ITEM do a :=&lt;br /&gt;
my_collection.first b := my_collection.first check will_fail: a = b end end&lt;br /&gt;
&lt;br /&gt;
In fact a and b will be different wrappers referring to the same underlying C structure. A WRAPPER_COLLECTION shall  avoid this repeated, unnecessary and wrong creation of WRAPPERs, that will breaks invariants and post-conditions of a COLLECTION.&lt;br /&gt;
A solution is to inherit from WRAPPERS_CACHE, initializing cache at creation time and keeping it updated during usage. Cache's key is the address (pointer) to the wrapped C structure, value is the corresponding Eiffel wrapper. This way you can get back an already-created Eiffel wrapper.&lt;br /&gt;
Classes can implement different scheme; for example G_OBJECT_LIST retrieve the reference to the eventual WRAPPER directly from underlying GObject.&lt;br /&gt;
&lt;br /&gt;
    The container has no means to know how it shall create the wrapper for it, since C does not have the notion of generic, strongly typed container. The effective type of the containee is either not know by WRAPPER_COLLECTION or worse its conteinees  could actually belong to different classes, sharing a common ancestor.&lt;br /&gt;
    Since each library has its own idea on how the programmer shall handle �memory when dealing with containers an effective, non-deferred heir of WRAPPER_COLLECTION shall implement `wrapper' feature that given a pointer creates or retrieve a WRAPPER of the fittest class. Usually &amp;quot;plain&amp;quot; usage could return a fixed type; more elaborate type systems like GObject could provide the facilities necessary to pick a useful Eiffel type.&lt;br /&gt;
&lt;br /&gt;
TODO: finish it.&lt;br /&gt;
Comparability and hashability&lt;br /&gt;
Some collections does not require anything in particular to their containee, like arrays or linked lists. Other collections needs either to compare their containee or to obtain an hash value from it. Therefore wrapper classes that are conceptually comparable or hashable shall inherit from COMPARABLE_WRAPPER and HASHABLE_WRAPPER respectively so they could be stored into collections that requires such abilities.&lt;br /&gt;
How to adapt old wrappers&lt;br /&gt;
(This is almost obsolete) Previous design was a black-or-white design: a class was either Eiffel-owned or not; C_STRUCT's are &amp;quot;owned&amp;quot; by the Eiffel code, and the Eiffel side should keep then longest lived reference to this struct; SHARED_C_STRUCT modelled the non-Eiffel-owned.&lt;br /&gt;
This approach is overly simplicistic since real-life libraries implement a wide spectrum of memory handling policies. One solutions does not fit all needs. Study the documentation of the library and pick the right memory handling Eiffel class.&lt;br /&gt;
The long int problem&lt;br /&gt;
&lt;br /&gt;
Shortly it could be solved having two separate clusters one for 32bit, one for 64 bit where a deferred class defines a parameterless query for anchored declaration like&lt;br /&gt;
&lt;br /&gt;
long_int: INTEGER_32 is do end&lt;br /&gt;
&lt;br /&gt;
long_int: INTEGER_64 is do end&lt;br /&gt;
&lt;br /&gt;
but this looks like an unfeasible hack to me, at least now. Currently it is the only available answer; a &amp;quot;proper&amp;quot; solution would require changes in both the compiler and the standard library. I would like to know how ISE solved this.&lt;br /&gt;
&lt;br /&gt;
GObject-based libraries&lt;br /&gt;
&lt;br /&gt;
Nowadays many libraries are based on the GLib Object System also known as Gobject. This library &amp;quot;provides a portable object system and transparent cross-language interoperability&amp;quot;. It is used as the basic building block for literally hundeds of libraries and applications; in fact the command apt-cache rdepends libglib2.0-0 |wc -l told me that more than 2200 applications and libraries depend on either GLib or GObject.&lt;br /&gt;
&lt;br /&gt;
GObject implement its own classed type system. With the exception of basic types (and some other subtleties I will write later) all objects are structures referred by pointer, i.e. non-expanded classes in Eiffellese; the type of each object is identified by a number, a GType which has an associated structure to describe the class - the type - itself. During startup of the Eiffel application the wrapper library will register for each type name (i.e. GtkWindow, GtkButton....) it wraps an agent that given a pointer creates an Eiffel wrapper object for the creation_agents dictionary, with a call similar to creation_agents.put (agent create_gtk_window, &amp;quot;GtkWindow&amp;quot;), given the feature create_gtk_window (p: POINTER): GTK_WINDOW is do create Result.from_external_pointer(p) end.&lt;br /&gt;
&lt;br /&gt;
A Gobject can store arbitrary properties into itself. We use this to store a reference pointer to its Eiffel wrapper.&lt;br /&gt;
&lt;br /&gt;
When we receive a pointer to a Gobject the G_OBJECT_FACTORY first looks if this Gobject already has an attacked wrapper (an effective heir of G_OBJECT). Otherwise it ask the Gobject its GType and the associated class-name. It this class-name has a creation agent the wrapper is created invoking the retrieved creation agent; otherwise we recursively look at its parent class until we find a type that has a corresponding creation agent.&lt;br /&gt;
&lt;br /&gt;
When an effective G_OBJECT heir is actually created either explicitly because we know for sure its type or throught a creation agent the address of the wrapper is stored in the property &amp;quot;eiffel-wrapper&amp;quot; using the C function g_object_set_qdata (see store_eiffel_wrapper in G_OBJECT).&lt;br /&gt;
&lt;br /&gt;
As usual this approach is both correct, memory efficient and collection-friendly (see &amp;quot;Implementing collections&amp;quot; earlier) at the cost of being computing intensive. There are times when the wrapper library has to create transient wrappers for shortly lived objects. Here enters secondary wrappers, or G_OBJECTs that are not referred-by the GOBject they refer to. Letting code speak: having a_gtk_window_ptr: POINTER; my_window: GTK_WINDOW; factory: G_OBJECT_EXPANDED_FACTORY check create my_window.secondary_wrapper_from(a_gtk_window_ptr) /= factory.wrapper(a_gtk_window_ptr) end will hold and also create my_window.main_wrapper_from(a_gtk_window_ptr); check my_window = factory.wrapper(a_gtk_window_ptr) end will be successfully passed. The difference is that the first is only an allocation of a smallish object (few bytes) while the latter could potentially require several looks-up into a dictionary plus an O(n) search into the GObject properties (during g_object_get_qdata used to see if a wrapper does actually exist)&lt;br /&gt;
&lt;br /&gt;
TODO: show how to wrap a typical GObject-using library, like Gnome's GConf configuration system.&lt;br /&gt;
Commit's policy&lt;br /&gt;
&lt;br /&gt;
    There is no strict rule...&lt;br /&gt;
    Ideally each commit should provide compilable code and working examples.&lt;br /&gt;
    Provided examples and classes can be unfinished and uncomplete, can contain warnings, empty features and so on. My motto is &amp;quot;something is better than nothing&amp;quot;.&lt;br /&gt;
    it is nice to tell other developers what are you working on; anemail on eiffel-libraries-devel@gna.org suffice.&lt;br /&gt;
    I promise I won't track you with a 9-tail cat to bash you if you commit uncompilable code.&lt;br /&gt;
    Code that compiles is a good thing. Wisely designed code that compiles is better, since it has better performances; but I prefer published, working code even if has no state-of-the-art performances instead of&lt;br /&gt;
&lt;br /&gt;
Various very old notes&lt;br /&gt;
Those notes are left here to be worked on.&lt;br /&gt;
&lt;br /&gt;
Suggested&lt;br /&gt;
Start copying original documentation into an Eiffel class and comment it out entirely.&lt;br /&gt;
Add proper indexing clauses, then progressively convert it into Eiffel from top to bottom.&lt;br /&gt;
Sketch difficoult features into comments.&lt;br /&gt;
This behaviour is not meant to pile rubbish, but to quickly know how much work we still have to do.&lt;br /&gt;
This means that the resulting Eiffel  classes will be a derivative work of the original documentation of the library. This is usally not a problem these days because documentation is often automatically extracted from sources, so the Eiffel wrapper will end up having the same license of the wrapper library; for example our GTK+ wrapper being a derivative work of the actual GTK+ C library must abide its LGPL license.&lt;br /&gt;
All the infrastructure of GTK+, including GObject are - in my humble opinion - explicitly designed to make the life easy for people writing wrappers for loosely-typed languages such as Python, Perl and other scriptiong languages. This (sadly) means that life for heavily/strongly-typed languages such as Eiffel are make annoying.&lt;br /&gt;
Objects like closures and other amenities like that won't be wrapped until the rest is done and working.&lt;br /&gt;
&lt;br /&gt;
=== Incoming tools ===&lt;br /&gt;
&lt;br /&gt;
Libraries using gobject-introspection and typelib provides much more informations to write wrappers and binding for other languages.&lt;br /&gt;
&lt;br /&gt;
The metadata of a typelib file allows to directly produce high-level wrappers. &lt;br /&gt;
&lt;br /&gt;
This will give us support for Gtk3, Glib, Cairo and many many other libraries in a much faster way that manually wrapping each one. &lt;br /&gt;
&lt;br /&gt;
The tool that will generate such binding  will be named '''leggow''', acronym for '''Liberty Eiffel Generator of GObject Wrappers''' and it currently lies in the leggow branch in repository https://github.com/tybor/Liberty but it is currently only an idea.&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Wrapping_C_libraries&amp;diff=2214</id>
		<title>Wrapping C libraries</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Wrapping_C_libraries&amp;diff=2214"/>
		<updated>2016-03-24T15:56:25Z</updated>

		<summary type="html">&lt;p&gt;Tybor: /* Code organization and class hierarchy. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Interfacing]]&lt;br /&gt;
== Developer's guidelines ==&lt;br /&gt;
=== or how to write GNU-Eiffel wrappers for a C library ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;&lt;br /&gt;
&amp;quot;longum iter est per praecepta, breve et efficax per exempla&amp;quot;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;quot;The path of precept is long, that of example short and effectual.&amp;quot;&amp;lt;br/&amp;gt;&lt;br /&gt;
Seneca the Elder&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So instead of giving rules I guide you on my path of wrapping the ZLib library, one of the most widespread compression library.&lt;br /&gt;
&lt;br /&gt;
I deliberately chose a &amp;quot;low-level&amp;quot; library with very precise and narrow aims which lets to show basic wrapping techniques: a wider, properly designed library has infrastructures and details that requires to know some tricks from the beginning of the work, otherwise the resulting wrapper should be heavily re-worked on many times.&lt;br /&gt;
&lt;br /&gt;
I usually work with Debian and Ubuntu GNU/Linux, so all the system commands and the package names listed in this tutorial/how-to should apply without changes on Debian and Debian-derived machines. Other distributions, like Fedora, RedHat, Suse, Mandriva shall have similarly named packages. People using BSD OSes could have those libraries available in their package manager. As a last resort you can always download the sources, compile and install them manually. I hope you know how to do it, otherwise the rest of this document would be quite useless for you.&lt;br /&gt;
&lt;br /&gt;
==== Prerequites ====&lt;br /&gt;
&lt;br /&gt;
You should be proficient with:&lt;br /&gt;
&lt;br /&gt;
* the C language,&lt;br /&gt;
* the Eiffel language, &lt;br /&gt;
* the C library you want to wrap; you shall known how to use it in a C program; take some time to read the documentation of the library and to study the provided example in order to make yourself familiar with the style required to use the library. You will need them to provide extensive, readable documentation of your classes.&lt;br /&gt;
&lt;br /&gt;
==== Software prerequisites ====&lt;br /&gt;
&lt;br /&gt;
Make sure you have access on your machine to:&lt;br /&gt;
&lt;br /&gt;
* Liberty Eiffel, you may download the Debian packages from &lt;br /&gt;
* The C headers of the library to wrap; you shall be able to compile the examples of the library you're wrapping; so I issued&lt;br /&gt;
&lt;br /&gt;
    sudo apt-get install zlib1g-dev&lt;br /&gt;
&lt;br /&gt;
* Documentation of the library. Even if it is not absolutely necessary to make working wrappers they are indeed necessary to provide properly documented, therefore usable classes; (GNU) Eiffel has standard rules on how to document code and we shall abide to that; adapting the original C documentation while we wraps various features is a good style to handle documentation. Please do not leave any part of your code undocumented. Spend some time reading the documentation. It is always worth the effort.&lt;br /&gt;
&lt;br /&gt;
I would like to repeat the concept: even if source-code in general is intented to be read by a compiler to produce binary modules its readability and understandability for people is of the utmost importance. Code is not meant to be written-once and never re-read. It actually happens that good code will be read again and again by many people. The fact that programs are covered and protected by copyright laws is not incidental. It means that source code is the expression of an author, like a novel or poetry; I like to think that this fact includes in itself, in-nuce that source text will be read by people several time. And this reading does occour when the source-code text is well-written, well-documentated, useful for study and reuse if its license does allow it.&lt;br /&gt;
&lt;br /&gt;
This approach does resemble Knuth's Literate Programming and indeed many design choices made by Bertrand Meyer during the conception of Eiffel regarding readability and understandability of source-code, expecially those exposed in Object-Oriented Software Construction are strikingly similar to Knut's ideas.&lt;br /&gt;
&lt;br /&gt;
Let's return to our wrapping/binding work after a due phylosophical digression&lt;br /&gt;
&lt;br /&gt;
=== Preliminares ===&lt;br /&gt;
&lt;br /&gt;
Most data structure in C are usually handled by reference, i.e. using pointers. &lt;br /&gt;
&lt;br /&gt;
Passing objects by value is currently requires &amp;quot;expanded external classes&amp;quot; and will no be covered in this guide. Therefore if your library extensively pass structures around by value and not by reference (with a pointer), for example (TODO: put links to online example of passing structure by value) in function calls or contained in other structures our life will be quite hard. Fortunately enought most libraries handles most of its data structures by reference and zlib is no exception: in fact its basic functions takes pointers as first argument.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
== Identifying types and classes == &lt;br /&gt;
 &lt;br /&gt;
Now you will wonder how to identify the types used in Zlib. This is quite an extensive argument that people smarter than me already handled in great details here.&lt;br /&gt;
&lt;br /&gt;
A simplicistic rule-of-thumb specifically fitted to wrap libraries written in C is that when we have several functions that takes a pointer to a struct this struct is a good candidate for a class and those functions are good candidates to be wrapped as features usable by an Eiffel program.&lt;br /&gt;
&lt;br /&gt;
Zlib has many functions taking a z_streamp which is nothing more than a typedef-fed pointer to structure z_stream_s. We will wrap those facilities in the Eiffel's (non-expanded) class ZLIB_STREAM.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Code organization and class hierarchy. === &lt;br /&gt;
&lt;br /&gt;
Before diving into code writing let's spend some words on how to cleanly organize our work. We want to provide the user of our library a pretty object-oriented API; since he/she will look at the sources directly soon-or-later it is useful to separate the high-level features and classes, those that will be used directly in other Eiffel projects from the low-level details, like external features or plugins.&lt;br /&gt;
&lt;br /&gt;
We usually place each wrapper library in its own directory following this organization:&lt;br /&gt;
&lt;br /&gt;
* zlib/ &lt;br /&gt;
** examples -- Examples on how to use the Zlib wrappers &lt;br /&gt;
** library -- Contains the high-level classes, those used directly in Eiffel programs &lt;br /&gt;
*** externals -- Contains the low-level classes to interface with C (externals, macros, enumeration and so on) &lt;br /&gt;
**** generated -- Contains the low-level classes automatically generated with a tool such as wrappers_generator&lt;br /&gt;
*** loadpath.se -- Lists the clusters of the library itself, i.e. which directories contains its classes &lt;br /&gt;
** loadpath.se -- Lists the clusters used by the library, i.e. its dependencies &lt;br /&gt;
** tests -- Contains the tests to be used with eiffeltest tool&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the library is conceptually separated into different areas, subsystems or if it is simple too wide to put cleanly every public class into a single directory we can split the content of the directory library into several sub-directory, like GLib wrapper. See its directory layout:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* eiffel-glib/library/ &lt;br /&gt;
** core &lt;br /&gt;
** data_types &lt;br /&gt;
** externals &lt;br /&gt;
*** generated&lt;br /&gt;
** fundamentals&lt;br /&gt;
** utilities&lt;br /&gt;
&lt;br /&gt;
Let's fill &amp;lt;code&amp;gt;zlib/library/loadpath.se&amp;lt;/code&amp;gt;. It lists two directories: those containing the high-level classes, the same of the loadpath.se file itself, i.e. the current directory (.) and the ./externals directory which will contain deferred classes that provide access to external features.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ./&lt;br /&gt;
./externals/ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
zlib/loadpath.se will list the clusters used by the library itself, i.e. its dependencies. Like the previous it is a plain text file containing directories or other loadpaths file (Ok... I'm not assuming proficiency with GNU-Eiffel here). Zlib is quite a &amp;quot;plain&amp;quot; library and does not have dependencies - here we are speaking of dependencies of the Eiffel wrappers - so he only shall list only the base cluster of a wrapper library, ../common/loadpath.se and the soad-path of the library itself &amp;lt;./library/loadpath.se/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ../common/loadpath.se&lt;br /&gt;
./library/loadpath.se &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low-level access to functions ===&lt;br /&gt;
&lt;br /&gt;
Writing the Eiffel source code to access external C code is an extremely long, tedious and verbose process so a tool named '''wrappers_generator''' has been created.&lt;br /&gt;
&lt;br /&gt;
It was not included in binary form in the adler release since it was not ready for prime time. &lt;br /&gt;
Now it isn't robust as I would like but at least it processes sources like Gtk3, Glib, &amp;amp;slasho;mq and other libraries without crashing. &lt;br /&gt;
&lt;br /&gt;
It will be included into bell and later releases; before it's relase I would suggest to rebuild the compiler and work from the Git repository.&lt;br /&gt;
&lt;br /&gt;
You can get the sources from https://savannah.gnu.org/projects/liberty-eiffel/ or from https://github.com/LibertyEiffel/Liberty and build it with install.sh script which also build wrappers_generator. &lt;br /&gt;
&lt;br /&gt;
wrappers_generator does not parses C code directly but reads the output of gccxml or its successor, castxml. Those tools provides an XML description of the source code analyzed that greatly ease the task of generating glue code. In fact they were created for that purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;gccxml&amp;lt;/pre&amp;gt; is available in Debian stable while &amp;lt;pre&amp;gt;castxml&amp;lt;/pre&amp;gt; is available in Debian testing. Both are also available for Ubuntu, Redhat et cetera.&lt;br /&gt;
&lt;br /&gt;
Given an XML file and a list of C files (headers or sources) to wrap wrappers_generator:&lt;br /&gt;
&lt;br /&gt;
* for each source file create a deferred class containing all the wrappable functions found in that file; functions in foo.h are wrapped into FOO_EXTERNALS&lt;br /&gt;
* for each struct creates a deferred class containing queries and setters feature to manipulate all members which have an Eiffel wrapper type;&lt;br /&gt;
* the same is made for unions&lt;br /&gt;
* creates a deferred Eiffel class named like the xml file containing wrappers for all typedefs, so when you have to refer to C &amp;quot;long&amp;quot; which is notorious for change size on various platform you can use &amp;quot;like long&amp;quot; in Eiffel&lt;br /&gt;
* each enumeration is wrapped into expanded classes with proper queries and setters. That way they are as efficient as plain integers values but they can't assume arbitrary values; enum foobar is wrapped into FOOBAR_ENUM&lt;br /&gt;
* when the values of an enumeration are actually flags, i.e. they all are diffent powers of 2, it's wrapped as a &amp;quot;flag&amp;quot; enumeration with commands to set and unset each flag of the enum.&lt;br /&gt;
* C++ classes, namespaces and all its fineries are currently ignored&lt;br /&gt;
* macros, #defines and all cannot be handled since they are &amp;quot;preprocessed away&amp;quot; and their text is not preseted to gccxml or castxml&lt;br /&gt;
* variadic functions can't be wrapped in Eiffel &lt;br /&gt;
* it transform CamelCase into CAMEL_CASE for classes, camel_case for features (queries, commands and so on)&lt;br /&gt;
* if it doesn't exist it creates a directory plugin/c that will contain all the C code that will be compiled by liberty eiffel when using the library&lt;br /&gt;
&lt;br /&gt;
It does not try to give high-level, directly usable wrappers but it writes fairly verbose low-level wrappers that hopefully will save you quite a lot of typing. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Text to be still reviewd ====&lt;br /&gt;
&lt;br /&gt;
Let's write some low-level classes. We will put the functions found in the include file /usr/include/zlib.h in the class ZLIB_EXTERNALS and the low-level getters and setters features for the structure z_stream structure in the class Z_STREAM_STRUCT (this scheme is also used by eiffel-gcc-xml tool; I know it is simplicistic and that it could produce name-clashes but it has worked fine until now. ). Here's some examples&lt;br /&gt;
C function	Eiffel feature&lt;br /&gt;
const char * zlibVersion (void);	zlib_version: POINTER&lt;br /&gt;
int deflateInit (z_streamp strm, int level);	deflate_init (a_stream: POINTER; a_level: INTEGER_32): INTEGER_32&lt;br /&gt;
int deflate (z_streamp strm, int flush);	deflate (a_stream: POINTER;a_flush: INTEGER_32): INTEGER&lt;br /&gt;
int deflateEnd (z_streamp strm);	deflate_end (a_stream: POINTER): INTEGER&lt;br /&gt;
int inflateInit (z_streamp strm);	inflate_init (a_stream: POINTER): INTEGER&lt;br /&gt;
int inflate (z_streamp strm, int flush);	inflate (a_stream: POINTER; a_flush: INTEGER): INTEGER&lt;br /&gt;
int inflateEnd (z_streamp strm);	inflate_end (a_stream: POINTER): INTEGER&lt;br /&gt;
&lt;br /&gt;
As you can see I have turned camelCaseFunction into camel_case_function which is far more in tune with Eiffel style. Int is actually an INTEGER_32 or only INTEGER (it still don't matter, even if I suspect that it will do soon: world is already filled with 64-bit machines and literally billion of devices with 4,8,16 bit CPU are in use today, not counting GPGPU)&lt;br /&gt;
&lt;br /&gt;
Let's take a look at ZLIB_EXTERNALS. You'll see many entries like&lt;br /&gt;
&lt;br /&gt;
 inflate_init (a_stream: POINTER): INTEGER is -- int inflateInit (z_streamp strm); &lt;br /&gt;
	external &amp;quot;plug_in&amp;quot; &lt;br /&gt;
	alias &amp;quot;{&lt;br /&gt;
		location: &amp;quot;${eiffel_libraries}/plugins&amp;quot; &lt;br /&gt;
		module_name: &amp;quot;zlib&amp;quot;&lt;br /&gt;
		feature_name: &amp;quot;inflateInit&amp;quot;&lt;br /&gt;
	}&amp;quot;&lt;br /&gt;
	end &lt;br /&gt;
&lt;br /&gt;
this entry tells us that the Eiffel feature &amp;quot;inflate_init&amp;quot; refers to the symbol &amp;quot;inflateInit&amp;quot; in the module &amp;quot;zlib&amp;quot; of the plugins found in the directory.&lt;br /&gt;
&lt;br /&gt;
Entries like this are the only &amp;quot;esoteric&amp;quot; Eiffel code you will see. All the details required to interface to C, to link to the actualy library and how to compile the code written in other languages is handled by the plugin part.&lt;br /&gt;
&lt;br /&gt;
Without using plugins every Eiffel program should know all the details required to compile a C application with zlib. It would require to always use ACE files - even for simple examples - because you need to provide proper &amp;quot;c_compiler_options&amp;quot; and &amp;quot;linker_options&amp;quot;; for a single, simple library like Zlib it looks a tame task, only requiring to add -lzlib to the &amp;quot;linker_options&amp;quot; but when you start building real-world application things will get complicated really fast.&lt;br /&gt;
&lt;br /&gt;
See SmartEiffel documentation on plugins.&lt;br /&gt;
&lt;br /&gt;
All those functions returns an integer with standardized values #defined in the C header. We will wrap them in the deferred class ZLIB_CONSTANTS.&lt;br /&gt;
&lt;br /&gt;
Deferred? Why deferred? We want to avoid the Eiffel programmer the burden to deal with all the details that C requires - otherwise we would have used plain C - so we do not want him/her to directly use that libraries. Deferred classes cannot have creation clauses so we are sure that no objects of type ZLIB_EXTERNALS and ZLIB_CONSTANTS will be created. They are helper classes that will be either inherited from or - more properly - inserted into ZLIB_STREAM and its effective heirs, ZLIB_INPUT_STREAM and ZLIB_OUTPUT_STREAM.&lt;br /&gt;
&lt;br /&gt;
Making sure that the Eiffel developer will not use low-level features directly is the main reason why all the external features are not exported to anyone else, using the syntax feature {} -- External calls. This way only heirs - conforming or not - of that class can use them; for people coming from C++ it's like having private functions members.&lt;br /&gt;
C types&lt;br /&gt;
&lt;br /&gt;
Here's a quick conversion table for various C types&lt;br /&gt;
C type	Eiffel type&lt;br /&gt;
int	INTEGER;&lt;br /&gt;
short int	INTEGER_16&lt;br /&gt;
long int	INTEGER_32 or 64&lt;br /&gt;
long long int	INTEGER_64&lt;br /&gt;
int8_t (defined at stdint.h, ISO C 99)	INTEGER_8&lt;br /&gt;
int16_t 	INTEGER_16&lt;br /&gt;
int32_t	INTEGER_32&lt;br /&gt;
int64_t	INTEGER_64&lt;br /&gt;
unsigned int	NATURAL&lt;br /&gt;
unsigned short int	NATURAL_16&lt;br /&gt;
unsigned long int	NATURAL_32 on 32-bit, NATURAL_64 on 64.bit. See long int&lt;br /&gt;
unsigned long long int	NATURAL_64&lt;br /&gt;
signed/unsigned char	CHARACTER&lt;br /&gt;
float	REAL_32&lt;br /&gt;
double	REAL_64&lt;br /&gt;
long double	REAL_EXTENDED&lt;br /&gt;
char	BOOLEAN&lt;br /&gt;
void* or any other pointer	POINTER&lt;br /&gt;
&lt;br /&gt;
Some notes:&lt;br /&gt;
&lt;br /&gt;
    intXX_t are defined in GNU systems (Linux Glibc, CygWin and similar).&lt;br /&gt;
    Currently INTEGER is mere alias for INTEGER_32 but this is bound to change in future version of SmartEiffel. Personally I think that it should be &amp;quot;the integer type with the same bit-lenght of C int&amp;quot;.&lt;br /&gt;
    A nice feature of long int is that is could be longer that int. So we can't really be sure whenever it is 32 or 64 bit. Usually it is an INTEGER_32 on 32-bit machines and INTEGER_64 on 64-bit machines. See this post on the SmartEiffel mailing list.&lt;br /&gt;
    The same problem applies for long unsigned int: NATURAL_32 on 32-bits and NATURAL_64 on 64-bit. This mismatch can be quite problematic and it will be discussed-addressed later.&lt;br /&gt;
    At the time of writing of this document SmartEiffel has some know issues regarding NATURALs types. If they actually do cause bugs there is an (unsatisfactory) workaround: use a bigger INTEGER. This implies a hidden conversion at C level and bargains correctness with a little waste of space and worse performance. Do not use an INTEGER of same size: it &amp;quot;usually&amp;quot; works nicely but this is a known source of nasty bugs since you will soon or later it will silently overflow.&lt;br /&gt;
&lt;br /&gt;
An enlighting explanation about C variable types and declarations can be read on Wikipedia (I find particurarly confusing - expecially for the novice - that char is at the same time an 8-bit integer and an encoding for ASCII characters. Most programmers could always end up thinking about it only as a character. After more than 30 years they could have called it &amp;quot;byte&amp;quot;. Yet this behaviour is fit the spirit of C very well. ).&lt;br /&gt;
&lt;br /&gt;
The resulting ZLIB_CONSTANTS class is almost boring and undocumented. I maintained the documentation level found in the original documentation, since those are values that will be handled only by the implementation of the wrapper.&lt;br /&gt;
&lt;br /&gt;
Have a look at WRAPPER_HANDLER. Eiffel has the ability to selectively export Any class that needs to access some of the&lt;br /&gt;
Access to structure field&lt;br /&gt;
&lt;br /&gt;
Let's wrap the z_stream structure (the structure name is actually struct z_stream_s typedeffed to z_stream during its definition); the wrapper will have a similar two layer design: the low-level Z_STREAM_STRUCT will be a deferred class, with feature {} -- Hidden, low-level getters and setters. This class will also have a feature struct_size: INTEGER that will be the value of sizeof(z_stream)&lt;br /&gt;
&lt;br /&gt;
Field named FooBar in the struct my_struct will be read with the Eiffel query my_struct_get_foo_bar and set with the command my_struct_set_foo_bar. Remember that those are low-level features; references to other objects will be pointers and its signature will be one of an external function: the first argument will be always the address of - a POINTER to - the wrapped struct.&lt;br /&gt;
Naming of placeholder arguments&lt;br /&gt;
&lt;br /&gt;
Placeholder names should be chosen in a way that makes the documentation of the feature in English as smooth as possible for a proper argument placeholder for the Gnu-Eiffel language. &amp;quot;CamelCase&amp;quot; will be translated into &amp;quot;a_camel_case&amp;quot;, &amp;quot;ENOO&amp;quot; is translated into &amp;quot;an_enoo&amp;quot;. Eventual underscores in front of `a_name' are removed: &amp;quot;__foo&amp;quot; becomes &amp;quot;a_foo&amp;quot;. The prefixed preposition is added to make clearer that the name refers to a generic value, not to a particular one. Always tries to use a placeholder that can be directly put in the feature's documentation without paraphrase.&lt;br /&gt;
ZLIB_STREAM, at last.&lt;br /&gt;
&lt;br /&gt;
So let's write something that will be used in an actual Eiffel program! We start writing ZLIB_STREAM from file common/skeleton that provides us the usual LGPL-2.1-or-later headers. It inserts ZLIB_EXTERNALS and Z_STREAM_STRUCT.&lt;br /&gt;
&lt;br /&gt;
TODO: finish this&lt;br /&gt;
The &amp;quot;common&amp;quot; cluster&lt;br /&gt;
&lt;br /&gt;
The basic building blocks of a wrapper library have been put in the common cluster.&lt;br /&gt;
&lt;br /&gt;
The WRAPPER class it the &amp;quot;fundamental&amp;quot; one even if embarassingly simple. Its only effective field (i.e.: stored, non-computed) is the handle POINTER. It shall handle the allocation and deallocation of the memory referred by handle so it is an heir of DISPOSABLE but it doesn't define dispose because there is no such a thing like a default memory handling in C.&lt;br /&gt;
&lt;br /&gt;
C_STRUCT inherits from WRAPPER and provides default implementations for copy, is_equal and from_external_pointer features; it introduces the deferred &amp;quot;struct_size&amp;quot; query which should give the same result of C operator sizeof(MyStruct).&lt;br /&gt;
&lt;br /&gt;
Note that there are - at least conceptually - other potentially heirs of WRAPPER, like pointers to functions&lt;br /&gt;
&lt;br /&gt;
Many C libraries often return const char* strings. Those strings shall not be modified and their memory will be handled by the library; by all other means they actually are plain strings. A correct behaviour is to write foo: STRING is do create Result.from_external_copy(a_function_returning_a_const_char_pointer(handle)) end; a STRING is meant to be manipulated and changed and has control on the memory of its content. Here we are instead given a piece of memory holding some text that is &amp;quot;mostly read-only&amp;quot; whose control is held by the library. To provide correct behaviour STRING must copy the buffer, from_external can't be used. CONST_STRING is an effective heir of STRING that provides efficient wrapping of &amp;quot;const strings&amp;quot;. It is usable like any other STRING but all the changes are made to a separe buffer preserving the original content - we are actually not allowed to change it. No further memory is allocated when a CONST_STRING is created: the buffer returned by the C library is used directly. For example, GTK+ has many calls like const gchar* gtk_entry_get_text (GtkEntry *entry); Memory efficiency is achieved making changing features slower. If you need to change its content consider using its feature string to get a new (non-const) STRING with the same content.&lt;br /&gt;
&lt;br /&gt;
TODO: add proper description about:&lt;br /&gt;
CACHING_FACTORY&lt;br /&gt;
C_ARRAY&lt;br /&gt;
COMPARABLE_C_STRUCT&lt;br /&gt;
COMPARABLE_WRAPPER&lt;br /&gt;
CONST_STRING&lt;br /&gt;
C_OWNED&lt;br /&gt;
C_STRUCT&lt;br /&gt;
EIFFEL_OWNED&lt;br /&gt;
ENUM&lt;br /&gt;
EXPANDED_WRAPPER&lt;br /&gt;
GLOBAL_CACHE&lt;br /&gt;
GLOBALLY_CACHED&lt;br /&gt;
HASHABLE_WRAPPER&lt;br /&gt;
ITERATOR_ON_C_ARRAY&lt;br /&gt;
LINKED_STRING&lt;br /&gt;
MIXED_MEMORY_HANDLING&lt;br /&gt;
NULL_TERMINATED_C_ARRAY&lt;br /&gt;
NULL_TERMINATED_STRING_ARRAY&lt;br /&gt;
POINTER_HANDLING&lt;br /&gt;
REFERENCE_COUNTED&lt;br /&gt;
SHARED&lt;br /&gt;
STRING_ARRAY&lt;br /&gt;
STRING_ARRAY_ITERATOR&lt;br /&gt;
WRAPPER_COLLECTION&lt;br /&gt;
WRAPPER_DICTIONARY&lt;br /&gt;
WRAPPER&lt;br /&gt;
WRAPPER_FACTORY&lt;br /&gt;
WRAPPER_HANDLER&lt;br /&gt;
WRAPPERS_CACHE&lt;br /&gt;
Enumerations&lt;br /&gt;
&lt;br /&gt;
There are two general tecnique to wrap an enum.&lt;br /&gt;
&lt;br /&gt;
    Put all the possible values of enumerations into a class as INTEGER constants accessibile to the user of your library. This is mostly similar to the actual usage of an enumeration. Each and every feature that accept an enum value as argument will need a precondition like is_valid_foo (a_foo_value)&lt;br /&gt;
    Create a new type. In fact an enumeration is an INTEGER that can assume only precise and prestabilited values, so that its value is correct and consistent all the times. Class ENUM provides some facilities to achieve this. It shall be used in classes like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    -- This file have been created by eiffel-gcc-xml.&lt;br /&gt;
    -- Any change will be lost by the next execution of the tool.&lt;br /&gt;
&lt;br /&gt;
    expanded class PANGO_WEIGHT&lt;br /&gt;
&lt;br /&gt;
    insert ENUM&lt;br /&gt;
&lt;br /&gt;
    creation default_create&lt;br /&gt;
    feature -- Validity&lt;br /&gt;
    	is_valid_value (a_value: INTEGER): BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := ((a_value = pango_weight_ultralight) or else&lt;br /&gt;
    				(a_value = pango_weight_light) or else&lt;br /&gt;
    				(a_value = pango_weight_normal) or else&lt;br /&gt;
    				(a_value = pango_weight_semibold) or else&lt;br /&gt;
    				(a_value = pango_weight_bold) or else&lt;br /&gt;
    				(a_value = pango_weight_ultrabold) or else&lt;br /&gt;
    				(a_value = pango_weight_heavy))&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature -- Setters&lt;br /&gt;
    	default_create,  set_ultralight is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_ultralight&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_light is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_light&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_normal is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_normal&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_semibold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_semibold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_bold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_bold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_ultrabold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_ultrabold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_heavy is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_heavy&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature -- Queries&lt;br /&gt;
    	is_ultralight: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_ultralight)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_light: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_light)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_normal: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_normal)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_semibold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_semibold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_bold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_bold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_ultrabold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_ultrabold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_heavy: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_heavy)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature {WRAPPER, WRAPPER_HANDLER} -- Low level values&lt;br /&gt;
    	pango_weight_ultralight: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_ULTRALIGHT&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_light: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_LIGHT&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_normal: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_NORMAL&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_semibold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_SEMIBOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_bold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_BOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_ultrabold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_ULTRABOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_heavy: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_HEAVY&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    As you can see each possible value has a setter command&amp;lt;br&amp;gt;(set_light, set_normal and so on) and a boolean&amp;lt;br&amp;gt;query (is_light, is_normal). As usual low-level values are accessible&amp;lt;br&amp;gt;only by a WRAPPER or a WRAPPER_HANDLER.&lt;br /&gt;
&lt;br /&gt;
Using eiffel-gcc-xml&lt;br /&gt;
&lt;br /&gt;
Have a look at the manually written ZLIB_EXTERNALS. Eiffel is a language that is meant to be easy to the reader at the cost of being verbose. All that text of source to access a bunch of C functions. Think about serious libraries that have literally thousands of functions, structures, and enumeration! Writing the low level side of those wrappers is a really long, tedious task, the kind of task that people usually would leave to an unfaticable, astonishgly fast yet quite dumb worker, a computer. Andreas Leitner - who is surely quite smarter than myself - wrote a C parser for his Eiffel Wrapper Generator. I do not have neither the time neither the abilities of Andreas but it seems that I'm more lucky than him. In fact by the time I got serious with this project, people with the same problem, requiring tons of wrappers for Python, produced gcc-xml. These days parsing XML is a considered a common task, a task to be left to standard libraries, so SmartEiffel have an XML parser. So I wrote a little tool name &amp;quot;eiffel-gcc-xml&amp;quot; that takes the output of gcc-xml as input to produce the low-level &amp;quot;external&amp;quot; classes that we need to access functions, structures and enumerations.&lt;br /&gt;
&lt;br /&gt;
Well, it actually requires a little more work since it breaks very often.&lt;br /&gt;
Memory handling&lt;br /&gt;
C_STRUCT is a wrapper for a data structure implemented in C programming language using a structure.&lt;br /&gt;
It does not make any assumption about memory handling; the developer of a SmartEiffel wrapper of a C library has to inherit to create a proper wrapper for it the developer shall inherit both from this class and from classes providing memory handling behavior, depending on how structure's memory shall be handled. This is decided  case-by-case by C library.&lt;br /&gt;
Currently available memory handling classes are:&lt;br /&gt;
&lt;br /&gt;
    C_OWNED: memory is always handled by the underlying C library.&lt;br /&gt;
    EIFFEL_OWNED: once created memory is fully handled by Eiffel runtime, usually with the Garbage Collector.&lt;br /&gt;
    GLOBALLY_CACHED: Until disposed by Eiffel the wrapper registered in wrappers dictionary will be the unique wrapper used on the Eiffel side.&lt;br /&gt;
    MIXED_MEMORY_HANDLING: whose memory can either by handled by the Eiffel library or by the underlying C code. Who handles memory is decided on a per-object based on the value of the flag `is_shared': handle will not be freed on dispose of the Eiffel wrapper object, when `is_shared' is true.&lt;br /&gt;
    REFERENCE_COUNTED: memory is handled thought reference counting, i.e.GObject&lt;br /&gt;
&lt;br /&gt;
Add proper examples of the various memory handling classes.&lt;br /&gt;
Implementing collections&lt;br /&gt;
Quite often objects are stored into containers or collections like arrays, linked lists, dictionaries, hashed-tables and so on. Many C libraries provides their own implementation of the classic containers, for example the GLib library provides GList, GSList, GHashTable and many others.&lt;br /&gt;
A WRAPPER_COLLECTION is a COLLECTION implemented wrapping some facilities offered by the wrapped C library, like GLib's linked list GList.&lt;br /&gt;
When you wrap those data structures you will encounter two kinds of problems:&lt;br /&gt;
&lt;br /&gt;
    Pointer returned by C containers could be newly allocated, not already wrapped by the Eiffel wrapper or already wrapper by the Eiffel wrapper. You can't naively create a new WRAPPER every time. Beside the obvious waste of memory and the stress you put on the garbage collector you will break most postconditions and invariant of a COLLECTION, since things that seems obvious like&lt;br /&gt;
&lt;br /&gt;
 do_stuff (my_collection: WRAPPER_COLLECTION[ITEM]) is require&lt;br /&gt;
my_collection/=Void not my_collection.is_empty local a,b: ITEM do a :=&lt;br /&gt;
my_collection.first b := my_collection.first check will_fail: a = b end end&lt;br /&gt;
&lt;br /&gt;
In fact a and b will be different wrappers referring to the same underlying C structure. A WRAPPER_COLLECTION shall  avoid this repeated, unnecessary and wrong creation of WRAPPERs, that will breaks invariants and post-conditions of a COLLECTION.&lt;br /&gt;
A solution is to inherit from WRAPPERS_CACHE, initializing cache at creation time and keeping it updated during usage. Cache's key is the address (pointer) to the wrapped C structure, value is the corresponding Eiffel wrapper. This way you can get back an already-created Eiffel wrapper.&lt;br /&gt;
Classes can implement different scheme; for example G_OBJECT_LIST retrieve the reference to the eventual WRAPPER directly from underlying GObject.&lt;br /&gt;
&lt;br /&gt;
    The container has no means to know how it shall create the wrapper for it, since C does not have the notion of generic, strongly typed container. The effective type of the containee is either not know by WRAPPER_COLLECTION or worse its conteinees  could actually belong to different classes, sharing a common ancestor.&lt;br /&gt;
    Since each library has its own idea on how the programmer shall handle �memory when dealing with containers an effective, non-deferred heir of WRAPPER_COLLECTION shall implement `wrapper' feature that given a pointer creates or retrieve a WRAPPER of the fittest class. Usually &amp;quot;plain&amp;quot; usage could return a fixed type; more elaborate type systems like GObject could provide the facilities necessary to pick a useful Eiffel type.&lt;br /&gt;
&lt;br /&gt;
TODO: finish it.&lt;br /&gt;
Comparability and hashability&lt;br /&gt;
Some collections does not require anything in particular to their containee, like arrays or linked lists. Other collections needs either to compare their containee or to obtain an hash value from it. Therefore wrapper classes that are conceptually comparable or hashable shall inherit from COMPARABLE_WRAPPER and HASHABLE_WRAPPER respectively so they could be stored into collections that requires such abilities.&lt;br /&gt;
How to adapt old wrappers&lt;br /&gt;
(This is almost obsolete) Previous design was a black-or-white design: a class was either Eiffel-owned or not; C_STRUCT's are &amp;quot;owned&amp;quot; by the Eiffel code, and the Eiffel side should keep then longest lived reference to this struct; SHARED_C_STRUCT modelled the non-Eiffel-owned.&lt;br /&gt;
This approach is overly simplicistic since real-life libraries implement a wide spectrum of memory handling policies. One solutions does not fit all needs. Study the documentation of the library and pick the right memory handling Eiffel class.&lt;br /&gt;
The long int problem&lt;br /&gt;
&lt;br /&gt;
Shortly it could be solved having two separate clusters one for 32bit, one for 64 bit where a deferred class defines a parameterless query for anchored declaration like&lt;br /&gt;
&lt;br /&gt;
long_int: INTEGER_32 is do end&lt;br /&gt;
&lt;br /&gt;
long_int: INTEGER_64 is do end&lt;br /&gt;
&lt;br /&gt;
but this looks like an unfeasible hack to me, at least now. Currently it is the only available answer; a &amp;quot;proper&amp;quot; solution would require changes in both the compiler and the standard library. I would like to know how ISE solved this.&lt;br /&gt;
&lt;br /&gt;
GObject-based libraries&lt;br /&gt;
&lt;br /&gt;
Nowadays many libraries are based on the GLib Object System also known as Gobject. This library &amp;quot;provides a portable object system and transparent cross-language interoperability&amp;quot;. It is used as the basic building block for literally hundeds of libraries and applications; in fact the command apt-cache rdepends libglib2.0-0 |wc -l told me that more than 2200 applications and libraries depend on either GLib or GObject.&lt;br /&gt;
&lt;br /&gt;
GObject implement its own classed type system. With the exception of basic types (and some other subtleties I will write later) all objects are structures referred by pointer, i.e. non-expanded classes in Eiffellese; the type of each object is identified by a number, a GType which has an associated structure to describe the class - the type - itself. During startup of the Eiffel application the wrapper library will register for each type name (i.e. GtkWindow, GtkButton....) it wraps an agent that given a pointer creates an Eiffel wrapper object for the creation_agents dictionary, with a call similar to creation_agents.put (agent create_gtk_window, &amp;quot;GtkWindow&amp;quot;), given the feature create_gtk_window (p: POINTER): GTK_WINDOW is do create Result.from_external_pointer(p) end.&lt;br /&gt;
&lt;br /&gt;
A Gobject can store arbitrary properties into itself. We use this to store a reference pointer to its Eiffel wrapper.&lt;br /&gt;
&lt;br /&gt;
When we receive a pointer to a Gobject the G_OBJECT_FACTORY first looks if this Gobject already has an attacked wrapper (an effective heir of G_OBJECT). Otherwise it ask the Gobject its GType and the associated class-name. It this class-name has a creation agent the wrapper is created invoking the retrieved creation agent; otherwise we recursively look at its parent class until we find a type that has a corresponding creation agent.&lt;br /&gt;
&lt;br /&gt;
When an effective G_OBJECT heir is actually created either explicitly because we know for sure its type or throught a creation agent the address of the wrapper is stored in the property &amp;quot;eiffel-wrapper&amp;quot; using the C function g_object_set_qdata (see store_eiffel_wrapper in G_OBJECT).&lt;br /&gt;
&lt;br /&gt;
As usual this approach is both correct, memory efficient and collection-friendly (see &amp;quot;Implementing collections&amp;quot; earlier) at the cost of being computing intensive. There are times when the wrapper library has to create transient wrappers for shortly lived objects. Here enters secondary wrappers, or G_OBJECTs that are not referred-by the GOBject they refer to. Letting code speak: having a_gtk_window_ptr: POINTER; my_window: GTK_WINDOW; factory: G_OBJECT_EXPANDED_FACTORY check create my_window.secondary_wrapper_from(a_gtk_window_ptr) /= factory.wrapper(a_gtk_window_ptr) end will hold and also create my_window.main_wrapper_from(a_gtk_window_ptr); check my_window = factory.wrapper(a_gtk_window_ptr) end will be successfully passed. The difference is that the first is only an allocation of a smallish object (few bytes) while the latter could potentially require several looks-up into a dictionary plus an O(n) search into the GObject properties (during g_object_get_qdata used to see if a wrapper does actually exist)&lt;br /&gt;
&lt;br /&gt;
TODO: show how to wrap a typical GObject-using library, like Gnome's GConf configuration system.&lt;br /&gt;
Commit's policy&lt;br /&gt;
&lt;br /&gt;
    There is no strict rule...&lt;br /&gt;
    Ideally each commit should provide compilable code and working examples.&lt;br /&gt;
    Provided examples and classes can be unfinished and uncomplete, can contain warnings, empty features and so on. My motto is &amp;quot;something is better than nothing&amp;quot;.&lt;br /&gt;
    it is nice to tell other developers what are you working on; anemail on eiffel-libraries-devel@gna.org suffice.&lt;br /&gt;
    I promise I won't track you with a 9-tail cat to bash you if you commit uncompilable code.&lt;br /&gt;
    Code that compiles is a good thing. Wisely designed code that compiles is better, since it has better performances; but I prefer published, working code even if has no state-of-the-art performances instead of&lt;br /&gt;
&lt;br /&gt;
Various very old notes&lt;br /&gt;
Those notes are left here to be worked on.&lt;br /&gt;
&lt;br /&gt;
Suggested&lt;br /&gt;
Start copying original documentation into an Eiffel class and comment it out entirely.&lt;br /&gt;
Add proper indexing clauses, then progressively convert it into Eiffel from top to bottom.&lt;br /&gt;
Sketch difficoult features into comments.&lt;br /&gt;
This behaviour is not meant to pile rubbish, but to quickly know how much work we still have to do.&lt;br /&gt;
This means that the resulting Eiffel  classes will be a derivative work of the original documentation of the library. This is usally not a problem these days because documentation is often automatically extracted from sources, so the Eiffel wrapper will end up having the same license of the wrapper library; for example our GTK+ wrapper being a derivative work of the actual GTK+ C library must abide its LGPL license.&lt;br /&gt;
All the infrastructure of GTK+, including GObject are - in my humble opinion - explicitly designed to make the life easy for people writing wrappers for loosely-typed languages such as Python, Perl and other scriptiong languages. This (sadly) means that life for heavily/strongly-typed languages such as Eiffel are make annoying.&lt;br /&gt;
Objects like closures and other amenities like that won't be wrapped until the rest is done and working.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Incoming tools ===&lt;br /&gt;
&lt;br /&gt;
Libraries using gobject-introspection and typelib provides much more informations to write wrappers and binding for other languages.&lt;br /&gt;
&lt;br /&gt;
The metadata of a typelib file allows to directly produce high-level wrappers. &lt;br /&gt;
&lt;br /&gt;
This will give us support for Gtk3, Glib, Cairo and many many other libraries in a much faster way that manually wrapping each one. &lt;br /&gt;
&lt;br /&gt;
The tool that will generate such binding  will be named '''leggow''', acronym for '''Liberty Eiffel Generator of GObject Wrappers''' and it currently lies in the leggow branch in repository https://github.com/tybor/Liberty but it is currently only an idea.&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Wrapping_C_libraries&amp;diff=2213</id>
		<title>Wrapping C libraries</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Wrapping_C_libraries&amp;diff=2213"/>
		<updated>2016-03-24T15:55:59Z</updated>

		<summary type="html">&lt;p&gt;Tybor: /* The rest of this document still needs to be adapted. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Interfacing]]&lt;br /&gt;
== Developer's guidelines ==&lt;br /&gt;
=== or how to write GNU-Eiffel wrappers for a C library ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;&lt;br /&gt;
&amp;quot;longum iter est per praecepta, breve et efficax per exempla&amp;quot;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;quot;The path of precept is long, that of example short and effectual.&amp;quot;&amp;lt;br/&amp;gt;&lt;br /&gt;
Seneca the Elder&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So instead of giving rules I guide you on my path of wrapping the ZLib library, one of the most widespread compression library.&lt;br /&gt;
&lt;br /&gt;
I deliberately chose a &amp;quot;low-level&amp;quot; library with very precise and narrow aims which lets to show basic wrapping techniques: a wider, properly designed library has infrastructures and details that requires to know some tricks from the beginning of the work, otherwise the resulting wrapper should be heavily re-worked on many times.&lt;br /&gt;
&lt;br /&gt;
I usually work with Debian and Ubuntu GNU/Linux, so all the system commands and the package names listed in this tutorial/how-to should apply without changes on Debian and Debian-derived machines. Other distributions, like Fedora, RedHat, Suse, Mandriva shall have similarly named packages. People using BSD OSes could have those libraries available in their package manager. As a last resort you can always download the sources, compile and install them manually. I hope you know how to do it, otherwise the rest of this document would be quite useless for you.&lt;br /&gt;
&lt;br /&gt;
==== Prerequites ====&lt;br /&gt;
&lt;br /&gt;
You should be proficient with:&lt;br /&gt;
&lt;br /&gt;
* the C language,&lt;br /&gt;
* the Eiffel language, &lt;br /&gt;
* the C library you want to wrap; you shall known how to use it in a C program; take some time to read the documentation of the library and to study the provided example in order to make yourself familiar with the style required to use the library. You will need them to provide extensive, readable documentation of your classes.&lt;br /&gt;
&lt;br /&gt;
==== Software prerequisites ====&lt;br /&gt;
&lt;br /&gt;
Make sure you have access on your machine to:&lt;br /&gt;
&lt;br /&gt;
* Liberty Eiffel, you may download the Debian packages from &lt;br /&gt;
* The C headers of the library to wrap; you shall be able to compile the examples of the library you're wrapping; so I issued&lt;br /&gt;
&lt;br /&gt;
    sudo apt-get install zlib1g-dev&lt;br /&gt;
&lt;br /&gt;
* Documentation of the library. Even if it is not absolutely necessary to make working wrappers they are indeed necessary to provide properly documented, therefore usable classes; (GNU) Eiffel has standard rules on how to document code and we shall abide to that; adapting the original C documentation while we wraps various features is a good style to handle documentation. Please do not leave any part of your code undocumented. Spend some time reading the documentation. It is always worth the effort.&lt;br /&gt;
&lt;br /&gt;
I would like to repeat the concept: even if source-code in general is intented to be read by a compiler to produce binary modules its readability and understandability for people is of the utmost importance. Code is not meant to be written-once and never re-read. It actually happens that good code will be read again and again by many people. The fact that programs are covered and protected by copyright laws is not incidental. It means that source code is the expression of an author, like a novel or poetry; I like to think that this fact includes in itself, in-nuce that source text will be read by people several time. And this reading does occour when the source-code text is well-written, well-documentated, useful for study and reuse if its license does allow it.&lt;br /&gt;
&lt;br /&gt;
This approach does resemble Knuth's Literate Programming and indeed many design choices made by Bertrand Meyer during the conception of Eiffel regarding readability and understandability of source-code, expecially those exposed in Object-Oriented Software Construction are strikingly similar to Knut's ideas.&lt;br /&gt;
&lt;br /&gt;
Let's return to our wrapping/binding work after a due phylosophical digression&lt;br /&gt;
&lt;br /&gt;
=== Preliminares ===&lt;br /&gt;
&lt;br /&gt;
Most data structure in C are usually handled by reference, i.e. using pointers. &lt;br /&gt;
&lt;br /&gt;
Passing objects by value is currently requires &amp;quot;expanded external classes&amp;quot; and will no be covered in this guide. Therefore if your library extensively pass structures around by value and not by reference (with a pointer), for example (TODO: put links to online example of passing structure by value) in function calls or contained in other structures our life will be quite hard. Fortunately enought most libraries handles most of its data structures by reference and zlib is no exception: in fact its basic functions takes pointers as first argument.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
== Identifying types and classes == &lt;br /&gt;
 &lt;br /&gt;
Now you will wonder how to identify the types used in Zlib. This is quite an extensive argument that people smarter than me already handled in great details here.&lt;br /&gt;
&lt;br /&gt;
A simplicistic rule-of-thumb specifically fitted to wrap libraries written in C is that when we have several functions that takes a pointer to a struct this struct is a good candidate for a class and those functions are good candidates to be wrapped as features usable by an Eiffel program.&lt;br /&gt;
&lt;br /&gt;
Zlib has many functions taking a z_streamp which is nothing more than a typedef-fed pointer to structure z_stream_s. We will wrap those facilities in the Eiffel's (non-expanded) class ZLIB_STREAM.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Code organization and class hierarchy. === &lt;br /&gt;
&lt;br /&gt;
Before diving into code writing let's spend some words on how to cleanly organize our work. We want to provide the user of our library a pretty object-oriented API; since he/she will look at the sources directly soon-or-later it is useful to separate the high-level features and classes, those that will be used directly in other Eiffel projects from the low-level details, like external features or plugins.&lt;br /&gt;
&lt;br /&gt;
We usually place each wrapper library in its own directory following this organization:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
zlib/ &lt;br /&gt;
|-- examples -- Examples on how to use the Zlib wrappers &lt;br /&gt;
|-- library -- Contains the high-level classes, those used directly in Eiffel programs &lt;br /&gt;
|   |-- externals -- Contains the low-level classes to interface with C (externals, macros, enumeration and so on) &lt;br /&gt;
|   |    `- generated -- Contains the low-level classes automatically generated with a tool such as wrappers_generator&lt;br /&gt;
|   `-- loadpath.se -- Lists the clusters of the library itself, i.e. which directories contains its classes &lt;br /&gt;
|-- loadpath.se -- Lists the clusters used by the library, i.e. its dependencies &lt;br /&gt;
`-- tests -- Contains the tests to be used with eiffeltest tool&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* zlib/ &lt;br /&gt;
** examples -- Examples on how to use the Zlib wrappers &lt;br /&gt;
** library -- Contains the high-level classes, those used directly in Eiffel programs &lt;br /&gt;
*** externals -- Contains the low-level classes to interface with C (externals, macros, enumeration and so on) &lt;br /&gt;
**** generated -- Contains the low-level classes automatically generated with a tool such as wrappers_generator&lt;br /&gt;
*** loadpath.se -- Lists the clusters of the library itself, i.e. which directories contains its classes &lt;br /&gt;
** loadpath.se -- Lists the clusters used by the library, i.e. its dependencies &lt;br /&gt;
** tests -- Contains the tests to be used with eiffeltest tool&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the library is conceptually separated into different areas, subsystems or if it is simple too wide to put cleanly every public class into a single directory we can split the content of the directory library into several sub-directory, like GLib wrapper. See its directory layout:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* eiffel-glib/library/ &lt;br /&gt;
** core &lt;br /&gt;
** data_types &lt;br /&gt;
** externals &lt;br /&gt;
*** generated&lt;br /&gt;
** fundamentals&lt;br /&gt;
** utilities&lt;br /&gt;
&lt;br /&gt;
Let's fill &amp;lt;code&amp;gt;zlib/library/loadpath.se&amp;lt;/code&amp;gt;. It lists two directories: those containing the high-level classes, the same of the loadpath.se file itself, i.e. the current directory (.) and the ./externals directory which will contain deferred classes that provide access to external features.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ./&lt;br /&gt;
./externals/ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
zlib/loadpath.se will list the clusters used by the library itself, i.e. its dependencies. Like the previous it is a plain text file containing directories or other loadpaths file (Ok... I'm not assuming proficiency with GNU-Eiffel here). Zlib is quite a &amp;quot;plain&amp;quot; library and does not have dependencies - here we are speaking of dependencies of the Eiffel wrappers - so he only shall list only the base cluster of a wrapper library, ../common/loadpath.se and the soad-path of the library itself &amp;lt;./library/loadpath.se/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ../common/loadpath.se&lt;br /&gt;
./library/loadpath.se &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low-level access to functions ===&lt;br /&gt;
&lt;br /&gt;
Writing the Eiffel source code to access external C code is an extremely long, tedious and verbose process so a tool named '''wrappers_generator''' has been created.&lt;br /&gt;
&lt;br /&gt;
It was not included in binary form in the adler release since it was not ready for prime time. &lt;br /&gt;
Now it isn't robust as I would like but at least it processes sources like Gtk3, Glib, &amp;amp;slasho;mq and other libraries without crashing. &lt;br /&gt;
&lt;br /&gt;
It will be included into bell and later releases; before it's relase I would suggest to rebuild the compiler and work from the Git repository.&lt;br /&gt;
&lt;br /&gt;
You can get the sources from https://savannah.gnu.org/projects/liberty-eiffel/ or from https://github.com/LibertyEiffel/Liberty and build it with install.sh script which also build wrappers_generator. &lt;br /&gt;
&lt;br /&gt;
wrappers_generator does not parses C code directly but reads the output of gccxml or its successor, castxml. Those tools provides an XML description of the source code analyzed that greatly ease the task of generating glue code. In fact they were created for that purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;gccxml&amp;lt;/pre&amp;gt; is available in Debian stable while &amp;lt;pre&amp;gt;castxml&amp;lt;/pre&amp;gt; is available in Debian testing. Both are also available for Ubuntu, Redhat et cetera.&lt;br /&gt;
&lt;br /&gt;
Given an XML file and a list of C files (headers or sources) to wrap wrappers_generator:&lt;br /&gt;
&lt;br /&gt;
* for each source file create a deferred class containing all the wrappable functions found in that file; functions in foo.h are wrapped into FOO_EXTERNALS&lt;br /&gt;
* for each struct creates a deferred class containing queries and setters feature to manipulate all members which have an Eiffel wrapper type;&lt;br /&gt;
* the same is made for unions&lt;br /&gt;
* creates a deferred Eiffel class named like the xml file containing wrappers for all typedefs, so when you have to refer to C &amp;quot;long&amp;quot; which is notorious for change size on various platform you can use &amp;quot;like long&amp;quot; in Eiffel&lt;br /&gt;
* each enumeration is wrapped into expanded classes with proper queries and setters. That way they are as efficient as plain integers values but they can't assume arbitrary values; enum foobar is wrapped into FOOBAR_ENUM&lt;br /&gt;
* when the values of an enumeration are actually flags, i.e. they all are diffent powers of 2, it's wrapped as a &amp;quot;flag&amp;quot; enumeration with commands to set and unset each flag of the enum.&lt;br /&gt;
* C++ classes, namespaces and all its fineries are currently ignored&lt;br /&gt;
* macros, #defines and all cannot be handled since they are &amp;quot;preprocessed away&amp;quot; and their text is not preseted to gccxml or castxml&lt;br /&gt;
* variadic functions can't be wrapped in Eiffel &lt;br /&gt;
* it transform CamelCase into CAMEL_CASE for classes, camel_case for features (queries, commands and so on)&lt;br /&gt;
* if it doesn't exist it creates a directory plugin/c that will contain all the C code that will be compiled by liberty eiffel when using the library&lt;br /&gt;
&lt;br /&gt;
It does not try to give high-level, directly usable wrappers but it writes fairly verbose low-level wrappers that hopefully will save you quite a lot of typing. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Text to be still reviewd ====&lt;br /&gt;
&lt;br /&gt;
Let's write some low-level classes. We will put the functions found in the include file /usr/include/zlib.h in the class ZLIB_EXTERNALS and the low-level getters and setters features for the structure z_stream structure in the class Z_STREAM_STRUCT (this scheme is also used by eiffel-gcc-xml tool; I know it is simplicistic and that it could produce name-clashes but it has worked fine until now. ). Here's some examples&lt;br /&gt;
C function	Eiffel feature&lt;br /&gt;
const char * zlibVersion (void);	zlib_version: POINTER&lt;br /&gt;
int deflateInit (z_streamp strm, int level);	deflate_init (a_stream: POINTER; a_level: INTEGER_32): INTEGER_32&lt;br /&gt;
int deflate (z_streamp strm, int flush);	deflate (a_stream: POINTER;a_flush: INTEGER_32): INTEGER&lt;br /&gt;
int deflateEnd (z_streamp strm);	deflate_end (a_stream: POINTER): INTEGER&lt;br /&gt;
int inflateInit (z_streamp strm);	inflate_init (a_stream: POINTER): INTEGER&lt;br /&gt;
int inflate (z_streamp strm, int flush);	inflate (a_stream: POINTER; a_flush: INTEGER): INTEGER&lt;br /&gt;
int inflateEnd (z_streamp strm);	inflate_end (a_stream: POINTER): INTEGER&lt;br /&gt;
&lt;br /&gt;
As you can see I have turned camelCaseFunction into camel_case_function which is far more in tune with Eiffel style. Int is actually an INTEGER_32 or only INTEGER (it still don't matter, even if I suspect that it will do soon: world is already filled with 64-bit machines and literally billion of devices with 4,8,16 bit CPU are in use today, not counting GPGPU)&lt;br /&gt;
&lt;br /&gt;
Let's take a look at ZLIB_EXTERNALS. You'll see many entries like&lt;br /&gt;
&lt;br /&gt;
 inflate_init (a_stream: POINTER): INTEGER is -- int inflateInit (z_streamp strm); &lt;br /&gt;
	external &amp;quot;plug_in&amp;quot; &lt;br /&gt;
	alias &amp;quot;{&lt;br /&gt;
		location: &amp;quot;${eiffel_libraries}/plugins&amp;quot; &lt;br /&gt;
		module_name: &amp;quot;zlib&amp;quot;&lt;br /&gt;
		feature_name: &amp;quot;inflateInit&amp;quot;&lt;br /&gt;
	}&amp;quot;&lt;br /&gt;
	end &lt;br /&gt;
&lt;br /&gt;
this entry tells us that the Eiffel feature &amp;quot;inflate_init&amp;quot; refers to the symbol &amp;quot;inflateInit&amp;quot; in the module &amp;quot;zlib&amp;quot; of the plugins found in the directory.&lt;br /&gt;
&lt;br /&gt;
Entries like this are the only &amp;quot;esoteric&amp;quot; Eiffel code you will see. All the details required to interface to C, to link to the actualy library and how to compile the code written in other languages is handled by the plugin part.&lt;br /&gt;
&lt;br /&gt;
Without using plugins every Eiffel program should know all the details required to compile a C application with zlib. It would require to always use ACE files - even for simple examples - because you need to provide proper &amp;quot;c_compiler_options&amp;quot; and &amp;quot;linker_options&amp;quot;; for a single, simple library like Zlib it looks a tame task, only requiring to add -lzlib to the &amp;quot;linker_options&amp;quot; but when you start building real-world application things will get complicated really fast.&lt;br /&gt;
&lt;br /&gt;
See SmartEiffel documentation on plugins.&lt;br /&gt;
&lt;br /&gt;
All those functions returns an integer with standardized values #defined in the C header. We will wrap them in the deferred class ZLIB_CONSTANTS.&lt;br /&gt;
&lt;br /&gt;
Deferred? Why deferred? We want to avoid the Eiffel programmer the burden to deal with all the details that C requires - otherwise we would have used plain C - so we do not want him/her to directly use that libraries. Deferred classes cannot have creation clauses so we are sure that no objects of type ZLIB_EXTERNALS and ZLIB_CONSTANTS will be created. They are helper classes that will be either inherited from or - more properly - inserted into ZLIB_STREAM and its effective heirs, ZLIB_INPUT_STREAM and ZLIB_OUTPUT_STREAM.&lt;br /&gt;
&lt;br /&gt;
Making sure that the Eiffel developer will not use low-level features directly is the main reason why all the external features are not exported to anyone else, using the syntax feature {} -- External calls. This way only heirs - conforming or not - of that class can use them; for people coming from C++ it's like having private functions members.&lt;br /&gt;
C types&lt;br /&gt;
&lt;br /&gt;
Here's a quick conversion table for various C types&lt;br /&gt;
C type	Eiffel type&lt;br /&gt;
int	INTEGER;&lt;br /&gt;
short int	INTEGER_16&lt;br /&gt;
long int	INTEGER_32 or 64&lt;br /&gt;
long long int	INTEGER_64&lt;br /&gt;
int8_t (defined at stdint.h, ISO C 99)	INTEGER_8&lt;br /&gt;
int16_t 	INTEGER_16&lt;br /&gt;
int32_t	INTEGER_32&lt;br /&gt;
int64_t	INTEGER_64&lt;br /&gt;
unsigned int	NATURAL&lt;br /&gt;
unsigned short int	NATURAL_16&lt;br /&gt;
unsigned long int	NATURAL_32 on 32-bit, NATURAL_64 on 64.bit. See long int&lt;br /&gt;
unsigned long long int	NATURAL_64&lt;br /&gt;
signed/unsigned char	CHARACTER&lt;br /&gt;
float	REAL_32&lt;br /&gt;
double	REAL_64&lt;br /&gt;
long double	REAL_EXTENDED&lt;br /&gt;
char	BOOLEAN&lt;br /&gt;
void* or any other pointer	POINTER&lt;br /&gt;
&lt;br /&gt;
Some notes:&lt;br /&gt;
&lt;br /&gt;
    intXX_t are defined in GNU systems (Linux Glibc, CygWin and similar).&lt;br /&gt;
    Currently INTEGER is mere alias for INTEGER_32 but this is bound to change in future version of SmartEiffel. Personally I think that it should be &amp;quot;the integer type with the same bit-lenght of C int&amp;quot;.&lt;br /&gt;
    A nice feature of long int is that is could be longer that int. So we can't really be sure whenever it is 32 or 64 bit. Usually it is an INTEGER_32 on 32-bit machines and INTEGER_64 on 64-bit machines. See this post on the SmartEiffel mailing list.&lt;br /&gt;
    The same problem applies for long unsigned int: NATURAL_32 on 32-bits and NATURAL_64 on 64-bit. This mismatch can be quite problematic and it will be discussed-addressed later.&lt;br /&gt;
    At the time of writing of this document SmartEiffel has some know issues regarding NATURALs types. If they actually do cause bugs there is an (unsatisfactory) workaround: use a bigger INTEGER. This implies a hidden conversion at C level and bargains correctness with a little waste of space and worse performance. Do not use an INTEGER of same size: it &amp;quot;usually&amp;quot; works nicely but this is a known source of nasty bugs since you will soon or later it will silently overflow.&lt;br /&gt;
&lt;br /&gt;
An enlighting explanation about C variable types and declarations can be read on Wikipedia (I find particurarly confusing - expecially for the novice - that char is at the same time an 8-bit integer and an encoding for ASCII characters. Most programmers could always end up thinking about it only as a character. After more than 30 years they could have called it &amp;quot;byte&amp;quot;. Yet this behaviour is fit the spirit of C very well. ).&lt;br /&gt;
&lt;br /&gt;
The resulting ZLIB_CONSTANTS class is almost boring and undocumented. I maintained the documentation level found in the original documentation, since those are values that will be handled only by the implementation of the wrapper.&lt;br /&gt;
&lt;br /&gt;
Have a look at WRAPPER_HANDLER. Eiffel has the ability to selectively export Any class that needs to access some of the&lt;br /&gt;
Access to structure field&lt;br /&gt;
&lt;br /&gt;
Let's wrap the z_stream structure (the structure name is actually struct z_stream_s typedeffed to z_stream during its definition); the wrapper will have a similar two layer design: the low-level Z_STREAM_STRUCT will be a deferred class, with feature {} -- Hidden, low-level getters and setters. This class will also have a feature struct_size: INTEGER that will be the value of sizeof(z_stream)&lt;br /&gt;
&lt;br /&gt;
Field named FooBar in the struct my_struct will be read with the Eiffel query my_struct_get_foo_bar and set with the command my_struct_set_foo_bar. Remember that those are low-level features; references to other objects will be pointers and its signature will be one of an external function: the first argument will be always the address of - a POINTER to - the wrapped struct.&lt;br /&gt;
Naming of placeholder arguments&lt;br /&gt;
&lt;br /&gt;
Placeholder names should be chosen in a way that makes the documentation of the feature in English as smooth as possible for a proper argument placeholder for the Gnu-Eiffel language. &amp;quot;CamelCase&amp;quot; will be translated into &amp;quot;a_camel_case&amp;quot;, &amp;quot;ENOO&amp;quot; is translated into &amp;quot;an_enoo&amp;quot;. Eventual underscores in front of `a_name' are removed: &amp;quot;__foo&amp;quot; becomes &amp;quot;a_foo&amp;quot;. The prefixed preposition is added to make clearer that the name refers to a generic value, not to a particular one. Always tries to use a placeholder that can be directly put in the feature's documentation without paraphrase.&lt;br /&gt;
ZLIB_STREAM, at last.&lt;br /&gt;
&lt;br /&gt;
So let's write something that will be used in an actual Eiffel program! We start writing ZLIB_STREAM from file common/skeleton that provides us the usual LGPL-2.1-or-later headers. It inserts ZLIB_EXTERNALS and Z_STREAM_STRUCT.&lt;br /&gt;
&lt;br /&gt;
TODO: finish this&lt;br /&gt;
The &amp;quot;common&amp;quot; cluster&lt;br /&gt;
&lt;br /&gt;
The basic building blocks of a wrapper library have been put in the common cluster.&lt;br /&gt;
&lt;br /&gt;
The WRAPPER class it the &amp;quot;fundamental&amp;quot; one even if embarassingly simple. Its only effective field (i.e.: stored, non-computed) is the handle POINTER. It shall handle the allocation and deallocation of the memory referred by handle so it is an heir of DISPOSABLE but it doesn't define dispose because there is no such a thing like a default memory handling in C.&lt;br /&gt;
&lt;br /&gt;
C_STRUCT inherits from WRAPPER and provides default implementations for copy, is_equal and from_external_pointer features; it introduces the deferred &amp;quot;struct_size&amp;quot; query which should give the same result of C operator sizeof(MyStruct).&lt;br /&gt;
&lt;br /&gt;
Note that there are - at least conceptually - other potentially heirs of WRAPPER, like pointers to functions&lt;br /&gt;
&lt;br /&gt;
Many C libraries often return const char* strings. Those strings shall not be modified and their memory will be handled by the library; by all other means they actually are plain strings. A correct behaviour is to write foo: STRING is do create Result.from_external_copy(a_function_returning_a_const_char_pointer(handle)) end; a STRING is meant to be manipulated and changed and has control on the memory of its content. Here we are instead given a piece of memory holding some text that is &amp;quot;mostly read-only&amp;quot; whose control is held by the library. To provide correct behaviour STRING must copy the buffer, from_external can't be used. CONST_STRING is an effective heir of STRING that provides efficient wrapping of &amp;quot;const strings&amp;quot;. It is usable like any other STRING but all the changes are made to a separe buffer preserving the original content - we are actually not allowed to change it. No further memory is allocated when a CONST_STRING is created: the buffer returned by the C library is used directly. For example, GTK+ has many calls like const gchar* gtk_entry_get_text (GtkEntry *entry); Memory efficiency is achieved making changing features slower. If you need to change its content consider using its feature string to get a new (non-const) STRING with the same content.&lt;br /&gt;
&lt;br /&gt;
TODO: add proper description about:&lt;br /&gt;
CACHING_FACTORY&lt;br /&gt;
C_ARRAY&lt;br /&gt;
COMPARABLE_C_STRUCT&lt;br /&gt;
COMPARABLE_WRAPPER&lt;br /&gt;
CONST_STRING&lt;br /&gt;
C_OWNED&lt;br /&gt;
C_STRUCT&lt;br /&gt;
EIFFEL_OWNED&lt;br /&gt;
ENUM&lt;br /&gt;
EXPANDED_WRAPPER&lt;br /&gt;
GLOBAL_CACHE&lt;br /&gt;
GLOBALLY_CACHED&lt;br /&gt;
HASHABLE_WRAPPER&lt;br /&gt;
ITERATOR_ON_C_ARRAY&lt;br /&gt;
LINKED_STRING&lt;br /&gt;
MIXED_MEMORY_HANDLING&lt;br /&gt;
NULL_TERMINATED_C_ARRAY&lt;br /&gt;
NULL_TERMINATED_STRING_ARRAY&lt;br /&gt;
POINTER_HANDLING&lt;br /&gt;
REFERENCE_COUNTED&lt;br /&gt;
SHARED&lt;br /&gt;
STRING_ARRAY&lt;br /&gt;
STRING_ARRAY_ITERATOR&lt;br /&gt;
WRAPPER_COLLECTION&lt;br /&gt;
WRAPPER_DICTIONARY&lt;br /&gt;
WRAPPER&lt;br /&gt;
WRAPPER_FACTORY&lt;br /&gt;
WRAPPER_HANDLER&lt;br /&gt;
WRAPPERS_CACHE&lt;br /&gt;
Enumerations&lt;br /&gt;
&lt;br /&gt;
There are two general tecnique to wrap an enum.&lt;br /&gt;
&lt;br /&gt;
    Put all the possible values of enumerations into a class as INTEGER constants accessibile to the user of your library. This is mostly similar to the actual usage of an enumeration. Each and every feature that accept an enum value as argument will need a precondition like is_valid_foo (a_foo_value)&lt;br /&gt;
    Create a new type. In fact an enumeration is an INTEGER that can assume only precise and prestabilited values, so that its value is correct and consistent all the times. Class ENUM provides some facilities to achieve this. It shall be used in classes like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    -- This file have been created by eiffel-gcc-xml.&lt;br /&gt;
    -- Any change will be lost by the next execution of the tool.&lt;br /&gt;
&lt;br /&gt;
    expanded class PANGO_WEIGHT&lt;br /&gt;
&lt;br /&gt;
    insert ENUM&lt;br /&gt;
&lt;br /&gt;
    creation default_create&lt;br /&gt;
    feature -- Validity&lt;br /&gt;
    	is_valid_value (a_value: INTEGER): BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := ((a_value = pango_weight_ultralight) or else&lt;br /&gt;
    				(a_value = pango_weight_light) or else&lt;br /&gt;
    				(a_value = pango_weight_normal) or else&lt;br /&gt;
    				(a_value = pango_weight_semibold) or else&lt;br /&gt;
    				(a_value = pango_weight_bold) or else&lt;br /&gt;
    				(a_value = pango_weight_ultrabold) or else&lt;br /&gt;
    				(a_value = pango_weight_heavy))&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature -- Setters&lt;br /&gt;
    	default_create,  set_ultralight is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_ultralight&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_light is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_light&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_normal is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_normal&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_semibold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_semibold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_bold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_bold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_ultrabold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_ultrabold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_heavy is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_heavy&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature -- Queries&lt;br /&gt;
    	is_ultralight: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_ultralight)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_light: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_light)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_normal: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_normal)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_semibold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_semibold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_bold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_bold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_ultrabold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_ultrabold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_heavy: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_heavy)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature {WRAPPER, WRAPPER_HANDLER} -- Low level values&lt;br /&gt;
    	pango_weight_ultralight: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_ULTRALIGHT&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_light: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_LIGHT&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_normal: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_NORMAL&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_semibold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_SEMIBOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_bold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_BOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_ultrabold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_ULTRABOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_heavy: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_HEAVY&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    As you can see each possible value has a setter command&amp;lt;br&amp;gt;(set_light, set_normal and so on) and a boolean&amp;lt;br&amp;gt;query (is_light, is_normal). As usual low-level values are accessible&amp;lt;br&amp;gt;only by a WRAPPER or a WRAPPER_HANDLER.&lt;br /&gt;
&lt;br /&gt;
Using eiffel-gcc-xml&lt;br /&gt;
&lt;br /&gt;
Have a look at the manually written ZLIB_EXTERNALS. Eiffel is a language that is meant to be easy to the reader at the cost of being verbose. All that text of source to access a bunch of C functions. Think about serious libraries that have literally thousands of functions, structures, and enumeration! Writing the low level side of those wrappers is a really long, tedious task, the kind of task that people usually would leave to an unfaticable, astonishgly fast yet quite dumb worker, a computer. Andreas Leitner - who is surely quite smarter than myself - wrote a C parser for his Eiffel Wrapper Generator. I do not have neither the time neither the abilities of Andreas but it seems that I'm more lucky than him. In fact by the time I got serious with this project, people with the same problem, requiring tons of wrappers for Python, produced gcc-xml. These days parsing XML is a considered a common task, a task to be left to standard libraries, so SmartEiffel have an XML parser. So I wrote a little tool name &amp;quot;eiffel-gcc-xml&amp;quot; that takes the output of gcc-xml as input to produce the low-level &amp;quot;external&amp;quot; classes that we need to access functions, structures and enumerations.&lt;br /&gt;
&lt;br /&gt;
Well, it actually requires a little more work since it breaks very often.&lt;br /&gt;
Memory handling&lt;br /&gt;
C_STRUCT is a wrapper for a data structure implemented in C programming language using a structure.&lt;br /&gt;
It does not make any assumption about memory handling; the developer of a SmartEiffel wrapper of a C library has to inherit to create a proper wrapper for it the developer shall inherit both from this class and from classes providing memory handling behavior, depending on how structure's memory shall be handled. This is decided  case-by-case by C library.&lt;br /&gt;
Currently available memory handling classes are:&lt;br /&gt;
&lt;br /&gt;
    C_OWNED: memory is always handled by the underlying C library.&lt;br /&gt;
    EIFFEL_OWNED: once created memory is fully handled by Eiffel runtime, usually with the Garbage Collector.&lt;br /&gt;
    GLOBALLY_CACHED: Until disposed by Eiffel the wrapper registered in wrappers dictionary will be the unique wrapper used on the Eiffel side.&lt;br /&gt;
    MIXED_MEMORY_HANDLING: whose memory can either by handled by the Eiffel library or by the underlying C code. Who handles memory is decided on a per-object based on the value of the flag `is_shared': handle will not be freed on dispose of the Eiffel wrapper object, when `is_shared' is true.&lt;br /&gt;
    REFERENCE_COUNTED: memory is handled thought reference counting, i.e.GObject&lt;br /&gt;
&lt;br /&gt;
Add proper examples of the various memory handling classes.&lt;br /&gt;
Implementing collections&lt;br /&gt;
Quite often objects are stored into containers or collections like arrays, linked lists, dictionaries, hashed-tables and so on. Many C libraries provides their own implementation of the classic containers, for example the GLib library provides GList, GSList, GHashTable and many others.&lt;br /&gt;
A WRAPPER_COLLECTION is a COLLECTION implemented wrapping some facilities offered by the wrapped C library, like GLib's linked list GList.&lt;br /&gt;
When you wrap those data structures you will encounter two kinds of problems:&lt;br /&gt;
&lt;br /&gt;
    Pointer returned by C containers could be newly allocated, not already wrapped by the Eiffel wrapper or already wrapper by the Eiffel wrapper. You can't naively create a new WRAPPER every time. Beside the obvious waste of memory and the stress you put on the garbage collector you will break most postconditions and invariant of a COLLECTION, since things that seems obvious like&lt;br /&gt;
&lt;br /&gt;
 do_stuff (my_collection: WRAPPER_COLLECTION[ITEM]) is require&lt;br /&gt;
my_collection/=Void not my_collection.is_empty local a,b: ITEM do a :=&lt;br /&gt;
my_collection.first b := my_collection.first check will_fail: a = b end end&lt;br /&gt;
&lt;br /&gt;
In fact a and b will be different wrappers referring to the same underlying C structure. A WRAPPER_COLLECTION shall  avoid this repeated, unnecessary and wrong creation of WRAPPERs, that will breaks invariants and post-conditions of a COLLECTION.&lt;br /&gt;
A solution is to inherit from WRAPPERS_CACHE, initializing cache at creation time and keeping it updated during usage. Cache's key is the address (pointer) to the wrapped C structure, value is the corresponding Eiffel wrapper. This way you can get back an already-created Eiffel wrapper.&lt;br /&gt;
Classes can implement different scheme; for example G_OBJECT_LIST retrieve the reference to the eventual WRAPPER directly from underlying GObject.&lt;br /&gt;
&lt;br /&gt;
    The container has no means to know how it shall create the wrapper for it, since C does not have the notion of generic, strongly typed container. The effective type of the containee is either not know by WRAPPER_COLLECTION or worse its conteinees  could actually belong to different classes, sharing a common ancestor.&lt;br /&gt;
    Since each library has its own idea on how the programmer shall handle �memory when dealing with containers an effective, non-deferred heir of WRAPPER_COLLECTION shall implement `wrapper' feature that given a pointer creates or retrieve a WRAPPER of the fittest class. Usually &amp;quot;plain&amp;quot; usage could return a fixed type; more elaborate type systems like GObject could provide the facilities necessary to pick a useful Eiffel type.&lt;br /&gt;
&lt;br /&gt;
TODO: finish it.&lt;br /&gt;
Comparability and hashability&lt;br /&gt;
Some collections does not require anything in particular to their containee, like arrays or linked lists. Other collections needs either to compare their containee or to obtain an hash value from it. Therefore wrapper classes that are conceptually comparable or hashable shall inherit from COMPARABLE_WRAPPER and HASHABLE_WRAPPER respectively so they could be stored into collections that requires such abilities.&lt;br /&gt;
How to adapt old wrappers&lt;br /&gt;
(This is almost obsolete) Previous design was a black-or-white design: a class was either Eiffel-owned or not; C_STRUCT's are &amp;quot;owned&amp;quot; by the Eiffel code, and the Eiffel side should keep then longest lived reference to this struct; SHARED_C_STRUCT modelled the non-Eiffel-owned.&lt;br /&gt;
This approach is overly simplicistic since real-life libraries implement a wide spectrum of memory handling policies. One solutions does not fit all needs. Study the documentation of the library and pick the right memory handling Eiffel class.&lt;br /&gt;
The long int problem&lt;br /&gt;
&lt;br /&gt;
Shortly it could be solved having two separate clusters one for 32bit, one for 64 bit where a deferred class defines a parameterless query for anchored declaration like&lt;br /&gt;
&lt;br /&gt;
long_int: INTEGER_32 is do end&lt;br /&gt;
&lt;br /&gt;
long_int: INTEGER_64 is do end&lt;br /&gt;
&lt;br /&gt;
but this looks like an unfeasible hack to me, at least now. Currently it is the only available answer; a &amp;quot;proper&amp;quot; solution would require changes in both the compiler and the standard library. I would like to know how ISE solved this.&lt;br /&gt;
&lt;br /&gt;
GObject-based libraries&lt;br /&gt;
&lt;br /&gt;
Nowadays many libraries are based on the GLib Object System also known as Gobject. This library &amp;quot;provides a portable object system and transparent cross-language interoperability&amp;quot;. It is used as the basic building block for literally hundeds of libraries and applications; in fact the command apt-cache rdepends libglib2.0-0 |wc -l told me that more than 2200 applications and libraries depend on either GLib or GObject.&lt;br /&gt;
&lt;br /&gt;
GObject implement its own classed type system. With the exception of basic types (and some other subtleties I will write later) all objects are structures referred by pointer, i.e. non-expanded classes in Eiffellese; the type of each object is identified by a number, a GType which has an associated structure to describe the class - the type - itself. During startup of the Eiffel application the wrapper library will register for each type name (i.e. GtkWindow, GtkButton....) it wraps an agent that given a pointer creates an Eiffel wrapper object for the creation_agents dictionary, with a call similar to creation_agents.put (agent create_gtk_window, &amp;quot;GtkWindow&amp;quot;), given the feature create_gtk_window (p: POINTER): GTK_WINDOW is do create Result.from_external_pointer(p) end.&lt;br /&gt;
&lt;br /&gt;
A Gobject can store arbitrary properties into itself. We use this to store a reference pointer to its Eiffel wrapper.&lt;br /&gt;
&lt;br /&gt;
When we receive a pointer to a Gobject the G_OBJECT_FACTORY first looks if this Gobject already has an attacked wrapper (an effective heir of G_OBJECT). Otherwise it ask the Gobject its GType and the associated class-name. It this class-name has a creation agent the wrapper is created invoking the retrieved creation agent; otherwise we recursively look at its parent class until we find a type that has a corresponding creation agent.&lt;br /&gt;
&lt;br /&gt;
When an effective G_OBJECT heir is actually created either explicitly because we know for sure its type or throught a creation agent the address of the wrapper is stored in the property &amp;quot;eiffel-wrapper&amp;quot; using the C function g_object_set_qdata (see store_eiffel_wrapper in G_OBJECT).&lt;br /&gt;
&lt;br /&gt;
As usual this approach is both correct, memory efficient and collection-friendly (see &amp;quot;Implementing collections&amp;quot; earlier) at the cost of being computing intensive. There are times when the wrapper library has to create transient wrappers for shortly lived objects. Here enters secondary wrappers, or G_OBJECTs that are not referred-by the GOBject they refer to. Letting code speak: having a_gtk_window_ptr: POINTER; my_window: GTK_WINDOW; factory: G_OBJECT_EXPANDED_FACTORY check create my_window.secondary_wrapper_from(a_gtk_window_ptr) /= factory.wrapper(a_gtk_window_ptr) end will hold and also create my_window.main_wrapper_from(a_gtk_window_ptr); check my_window = factory.wrapper(a_gtk_window_ptr) end will be successfully passed. The difference is that the first is only an allocation of a smallish object (few bytes) while the latter could potentially require several looks-up into a dictionary plus an O(n) search into the GObject properties (during g_object_get_qdata used to see if a wrapper does actually exist)&lt;br /&gt;
&lt;br /&gt;
TODO: show how to wrap a typical GObject-using library, like Gnome's GConf configuration system.&lt;br /&gt;
Commit's policy&lt;br /&gt;
&lt;br /&gt;
    There is no strict rule...&lt;br /&gt;
    Ideally each commit should provide compilable code and working examples.&lt;br /&gt;
    Provided examples and classes can be unfinished and uncomplete, can contain warnings, empty features and so on. My motto is &amp;quot;something is better than nothing&amp;quot;.&lt;br /&gt;
    it is nice to tell other developers what are you working on; anemail on eiffel-libraries-devel@gna.org suffice.&lt;br /&gt;
    I promise I won't track you with a 9-tail cat to bash you if you commit uncompilable code.&lt;br /&gt;
    Code that compiles is a good thing. Wisely designed code that compiles is better, since it has better performances; but I prefer published, working code even if has no state-of-the-art performances instead of&lt;br /&gt;
&lt;br /&gt;
Various very old notes&lt;br /&gt;
Those notes are left here to be worked on.&lt;br /&gt;
&lt;br /&gt;
Suggested&lt;br /&gt;
Start copying original documentation into an Eiffel class and comment it out entirely.&lt;br /&gt;
Add proper indexing clauses, then progressively convert it into Eiffel from top to bottom.&lt;br /&gt;
Sketch difficoult features into comments.&lt;br /&gt;
This behaviour is not meant to pile rubbish, but to quickly know how much work we still have to do.&lt;br /&gt;
This means that the resulting Eiffel  classes will be a derivative work of the original documentation of the library. This is usally not a problem these days because documentation is often automatically extracted from sources, so the Eiffel wrapper will end up having the same license of the wrapper library; for example our GTK+ wrapper being a derivative work of the actual GTK+ C library must abide its LGPL license.&lt;br /&gt;
All the infrastructure of GTK+, including GObject are - in my humble opinion - explicitly designed to make the life easy for people writing wrappers for loosely-typed languages such as Python, Perl and other scriptiong languages. This (sadly) means that life for heavily/strongly-typed languages such as Eiffel are make annoying.&lt;br /&gt;
Objects like closures and other amenities like that won't be wrapped until the rest is done and working.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Incoming tools ===&lt;br /&gt;
&lt;br /&gt;
Libraries using gobject-introspection and typelib provides much more informations to write wrappers and binding for other languages.&lt;br /&gt;
&lt;br /&gt;
The metadata of a typelib file allows to directly produce high-level wrappers. &lt;br /&gt;
&lt;br /&gt;
This will give us support for Gtk3, Glib, Cairo and many many other libraries in a much faster way that manually wrapping each one. &lt;br /&gt;
&lt;br /&gt;
The tool that will generate such binding  will be named '''leggow''', acronym for '''Liberty Eiffel Generator of GObject Wrappers''' and it currently lies in the leggow branch in repository https://github.com/tybor/Liberty but it is currently only an idea.&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Wrapping_C_libraries&amp;diff=2212</id>
		<title>Wrapping C libraries</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Wrapping_C_libraries&amp;diff=2212"/>
		<updated>2016-03-24T15:55:27Z</updated>

		<summary type="html">&lt;p&gt;Tybor: /* TODO: add proper usage of wrappers-generator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Interfacing]]&lt;br /&gt;
== Developer's guidelines ==&lt;br /&gt;
=== or how to write GNU-Eiffel wrappers for a C library ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;&lt;br /&gt;
&amp;quot;longum iter est per praecepta, breve et efficax per exempla&amp;quot;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;quot;The path of precept is long, that of example short and effectual.&amp;quot;&amp;lt;br/&amp;gt;&lt;br /&gt;
Seneca the Elder&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So instead of giving rules I guide you on my path of wrapping the ZLib library, one of the most widespread compression library.&lt;br /&gt;
&lt;br /&gt;
I deliberately chose a &amp;quot;low-level&amp;quot; library with very precise and narrow aims which lets to show basic wrapping techniques: a wider, properly designed library has infrastructures and details that requires to know some tricks from the beginning of the work, otherwise the resulting wrapper should be heavily re-worked on many times.&lt;br /&gt;
&lt;br /&gt;
I usually work with Debian and Ubuntu GNU/Linux, so all the system commands and the package names listed in this tutorial/how-to should apply without changes on Debian and Debian-derived machines. Other distributions, like Fedora, RedHat, Suse, Mandriva shall have similarly named packages. People using BSD OSes could have those libraries available in their package manager. As a last resort you can always download the sources, compile and install them manually. I hope you know how to do it, otherwise the rest of this document would be quite useless for you.&lt;br /&gt;
&lt;br /&gt;
==== Prerequites ====&lt;br /&gt;
&lt;br /&gt;
You should be proficient with:&lt;br /&gt;
&lt;br /&gt;
* the C language,&lt;br /&gt;
* the Eiffel language, &lt;br /&gt;
* the C library you want to wrap; you shall known how to use it in a C program; take some time to read the documentation of the library and to study the provided example in order to make yourself familiar with the style required to use the library. You will need them to provide extensive, readable documentation of your classes.&lt;br /&gt;
&lt;br /&gt;
==== Software prerequisites ====&lt;br /&gt;
&lt;br /&gt;
Make sure you have access on your machine to:&lt;br /&gt;
&lt;br /&gt;
* Liberty Eiffel, you may download the Debian packages from &lt;br /&gt;
* The C headers of the library to wrap; you shall be able to compile the examples of the library you're wrapping; so I issued&lt;br /&gt;
&lt;br /&gt;
    sudo apt-get install zlib1g-dev&lt;br /&gt;
&lt;br /&gt;
* Documentation of the library. Even if it is not absolutely necessary to make working wrappers they are indeed necessary to provide properly documented, therefore usable classes; (GNU) Eiffel has standard rules on how to document code and we shall abide to that; adapting the original C documentation while we wraps various features is a good style to handle documentation. Please do not leave any part of your code undocumented. Spend some time reading the documentation. It is always worth the effort.&lt;br /&gt;
&lt;br /&gt;
I would like to repeat the concept: even if source-code in general is intented to be read by a compiler to produce binary modules its readability and understandability for people is of the utmost importance. Code is not meant to be written-once and never re-read. It actually happens that good code will be read again and again by many people. The fact that programs are covered and protected by copyright laws is not incidental. It means that source code is the expression of an author, like a novel or poetry; I like to think that this fact includes in itself, in-nuce that source text will be read by people several time. And this reading does occour when the source-code text is well-written, well-documentated, useful for study and reuse if its license does allow it.&lt;br /&gt;
&lt;br /&gt;
This approach does resemble Knuth's Literate Programming and indeed many design choices made by Bertrand Meyer during the conception of Eiffel regarding readability and understandability of source-code, expecially those exposed in Object-Oriented Software Construction are strikingly similar to Knut's ideas.&lt;br /&gt;
&lt;br /&gt;
Let's return to our wrapping/binding work after a due phylosophical digression&lt;br /&gt;
&lt;br /&gt;
=== Preliminares ===&lt;br /&gt;
&lt;br /&gt;
Most data structure in C are usually handled by reference, i.e. using pointers. &lt;br /&gt;
&lt;br /&gt;
Passing objects by value is currently requires &amp;quot;expanded external classes&amp;quot; and will no be covered in this guide. Therefore if your library extensively pass structures around by value and not by reference (with a pointer), for example (TODO: put links to online example of passing structure by value) in function calls or contained in other structures our life will be quite hard. Fortunately enought most libraries handles most of its data structures by reference and zlib is no exception: in fact its basic functions takes pointers as first argument.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
== The rest of this document still needs to be adapted.  == &lt;br /&gt;
== Identifying types and classes == &lt;br /&gt;
 &lt;br /&gt;
Now you will wonder how to identify the types used in Zlib. This is quite an extensive argument that people smarter than me already handled in great details here.&lt;br /&gt;
&lt;br /&gt;
A simplicistic rule-of-thumb specifically fitted to wrap libraries written in C is that when we have several functions that takes a pointer to a struct this struct is a good candidate for a class and those functions are good candidates to be wrapped as features usable by an Eiffel program.&lt;br /&gt;
&lt;br /&gt;
Zlib has many functions taking a z_streamp which is nothing more than a typedef-fed pointer to structure z_stream_s. We will wrap those facilities in the Eiffel's (non-expanded) class ZLIB_STREAM.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Code organization and class hierarchy. === &lt;br /&gt;
&lt;br /&gt;
Before diving into code writing let's spend some words on how to cleanly organize our work. We want to provide the user of our library a pretty object-oriented API; since he/she will look at the sources directly soon-or-later it is useful to separate the high-level features and classes, those that will be used directly in other Eiffel projects from the low-level details, like external features or plugins.&lt;br /&gt;
&lt;br /&gt;
We usually place each wrapper library in its own directory following this organization:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
zlib/ &lt;br /&gt;
|-- examples -- Examples on how to use the Zlib wrappers &lt;br /&gt;
|-- library -- Contains the high-level classes, those used directly in Eiffel programs &lt;br /&gt;
|   |-- externals -- Contains the low-level classes to interface with C (externals, macros, enumeration and so on) &lt;br /&gt;
|   |    `- generated -- Contains the low-level classes automatically generated with a tool such as wrappers_generator&lt;br /&gt;
|   `-- loadpath.se -- Lists the clusters of the library itself, i.e. which directories contains its classes &lt;br /&gt;
|-- loadpath.se -- Lists the clusters used by the library, i.e. its dependencies &lt;br /&gt;
`-- tests -- Contains the tests to be used with eiffeltest tool&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* zlib/ &lt;br /&gt;
** examples -- Examples on how to use the Zlib wrappers &lt;br /&gt;
** library -- Contains the high-level classes, those used directly in Eiffel programs &lt;br /&gt;
*** externals -- Contains the low-level classes to interface with C (externals, macros, enumeration and so on) &lt;br /&gt;
**** generated -- Contains the low-level classes automatically generated with a tool such as wrappers_generator&lt;br /&gt;
*** loadpath.se -- Lists the clusters of the library itself, i.e. which directories contains its classes &lt;br /&gt;
** loadpath.se -- Lists the clusters used by the library, i.e. its dependencies &lt;br /&gt;
** tests -- Contains the tests to be used with eiffeltest tool&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the library is conceptually separated into different areas, subsystems or if it is simple too wide to put cleanly every public class into a single directory we can split the content of the directory library into several sub-directory, like GLib wrapper. See its directory layout:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* eiffel-glib/library/ &lt;br /&gt;
** core &lt;br /&gt;
** data_types &lt;br /&gt;
** externals &lt;br /&gt;
*** generated&lt;br /&gt;
** fundamentals&lt;br /&gt;
** utilities&lt;br /&gt;
&lt;br /&gt;
Let's fill &amp;lt;code&amp;gt;zlib/library/loadpath.se&amp;lt;/code&amp;gt;. It lists two directories: those containing the high-level classes, the same of the loadpath.se file itself, i.e. the current directory (.) and the ./externals directory which will contain deferred classes that provide access to external features.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ./&lt;br /&gt;
./externals/ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
zlib/loadpath.se will list the clusters used by the library itself, i.e. its dependencies. Like the previous it is a plain text file containing directories or other loadpaths file (Ok... I'm not assuming proficiency with GNU-Eiffel here). Zlib is quite a &amp;quot;plain&amp;quot; library and does not have dependencies - here we are speaking of dependencies of the Eiffel wrappers - so he only shall list only the base cluster of a wrapper library, ../common/loadpath.se and the soad-path of the library itself &amp;lt;./library/loadpath.se/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ../common/loadpath.se&lt;br /&gt;
./library/loadpath.se &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low-level access to functions ===&lt;br /&gt;
&lt;br /&gt;
Writing the Eiffel source code to access external C code is an extremely long, tedious and verbose process so a tool named '''wrappers_generator''' has been created.&lt;br /&gt;
&lt;br /&gt;
It was not included in binary form in the adler release since it was not ready for prime time. &lt;br /&gt;
Now it isn't robust as I would like but at least it processes sources like Gtk3, Glib, &amp;amp;slasho;mq and other libraries without crashing. &lt;br /&gt;
&lt;br /&gt;
It will be included into bell and later releases; before it's relase I would suggest to rebuild the compiler and work from the Git repository.&lt;br /&gt;
&lt;br /&gt;
You can get the sources from https://savannah.gnu.org/projects/liberty-eiffel/ or from https://github.com/LibertyEiffel/Liberty and build it with install.sh script which also build wrappers_generator. &lt;br /&gt;
&lt;br /&gt;
wrappers_generator does not parses C code directly but reads the output of gccxml or its successor, castxml. Those tools provides an XML description of the source code analyzed that greatly ease the task of generating glue code. In fact they were created for that purpose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;gccxml&amp;lt;/pre&amp;gt; is available in Debian stable while &amp;lt;pre&amp;gt;castxml&amp;lt;/pre&amp;gt; is available in Debian testing. Both are also available for Ubuntu, Redhat et cetera.&lt;br /&gt;
&lt;br /&gt;
Given an XML file and a list of C files (headers or sources) to wrap wrappers_generator:&lt;br /&gt;
&lt;br /&gt;
* for each source file create a deferred class containing all the wrappable functions found in that file; functions in foo.h are wrapped into FOO_EXTERNALS&lt;br /&gt;
* for each struct creates a deferred class containing queries and setters feature to manipulate all members which have an Eiffel wrapper type;&lt;br /&gt;
* the same is made for unions&lt;br /&gt;
* creates a deferred Eiffel class named like the xml file containing wrappers for all typedefs, so when you have to refer to C &amp;quot;long&amp;quot; which is notorious for change size on various platform you can use &amp;quot;like long&amp;quot; in Eiffel&lt;br /&gt;
* each enumeration is wrapped into expanded classes with proper queries and setters. That way they are as efficient as plain integers values but they can't assume arbitrary values; enum foobar is wrapped into FOOBAR_ENUM&lt;br /&gt;
* when the values of an enumeration are actually flags, i.e. they all are diffent powers of 2, it's wrapped as a &amp;quot;flag&amp;quot; enumeration with commands to set and unset each flag of the enum.&lt;br /&gt;
* C++ classes, namespaces and all its fineries are currently ignored&lt;br /&gt;
* macros, #defines and all cannot be handled since they are &amp;quot;preprocessed away&amp;quot; and their text is not preseted to gccxml or castxml&lt;br /&gt;
* variadic functions can't be wrapped in Eiffel &lt;br /&gt;
* it transform CamelCase into CAMEL_CASE for classes, camel_case for features (queries, commands and so on)&lt;br /&gt;
* if it doesn't exist it creates a directory plugin/c that will contain all the C code that will be compiled by liberty eiffel when using the library&lt;br /&gt;
&lt;br /&gt;
It does not try to give high-level, directly usable wrappers but it writes fairly verbose low-level wrappers that hopefully will save you quite a lot of typing. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Text to be still reviewd ====&lt;br /&gt;
&lt;br /&gt;
Let's write some low-level classes. We will put the functions found in the include file /usr/include/zlib.h in the class ZLIB_EXTERNALS and the low-level getters and setters features for the structure z_stream structure in the class Z_STREAM_STRUCT (this scheme is also used by eiffel-gcc-xml tool; I know it is simplicistic and that it could produce name-clashes but it has worked fine until now. ). Here's some examples&lt;br /&gt;
C function	Eiffel feature&lt;br /&gt;
const char * zlibVersion (void);	zlib_version: POINTER&lt;br /&gt;
int deflateInit (z_streamp strm, int level);	deflate_init (a_stream: POINTER; a_level: INTEGER_32): INTEGER_32&lt;br /&gt;
int deflate (z_streamp strm, int flush);	deflate (a_stream: POINTER;a_flush: INTEGER_32): INTEGER&lt;br /&gt;
int deflateEnd (z_streamp strm);	deflate_end (a_stream: POINTER): INTEGER&lt;br /&gt;
int inflateInit (z_streamp strm);	inflate_init (a_stream: POINTER): INTEGER&lt;br /&gt;
int inflate (z_streamp strm, int flush);	inflate (a_stream: POINTER; a_flush: INTEGER): INTEGER&lt;br /&gt;
int inflateEnd (z_streamp strm);	inflate_end (a_stream: POINTER): INTEGER&lt;br /&gt;
&lt;br /&gt;
As you can see I have turned camelCaseFunction into camel_case_function which is far more in tune with Eiffel style. Int is actually an INTEGER_32 or only INTEGER (it still don't matter, even if I suspect that it will do soon: world is already filled with 64-bit machines and literally billion of devices with 4,8,16 bit CPU are in use today, not counting GPGPU)&lt;br /&gt;
&lt;br /&gt;
Let's take a look at ZLIB_EXTERNALS. You'll see many entries like&lt;br /&gt;
&lt;br /&gt;
 inflate_init (a_stream: POINTER): INTEGER is -- int inflateInit (z_streamp strm); &lt;br /&gt;
	external &amp;quot;plug_in&amp;quot; &lt;br /&gt;
	alias &amp;quot;{&lt;br /&gt;
		location: &amp;quot;${eiffel_libraries}/plugins&amp;quot; &lt;br /&gt;
		module_name: &amp;quot;zlib&amp;quot;&lt;br /&gt;
		feature_name: &amp;quot;inflateInit&amp;quot;&lt;br /&gt;
	}&amp;quot;&lt;br /&gt;
	end &lt;br /&gt;
&lt;br /&gt;
this entry tells us that the Eiffel feature &amp;quot;inflate_init&amp;quot; refers to the symbol &amp;quot;inflateInit&amp;quot; in the module &amp;quot;zlib&amp;quot; of the plugins found in the directory.&lt;br /&gt;
&lt;br /&gt;
Entries like this are the only &amp;quot;esoteric&amp;quot; Eiffel code you will see. All the details required to interface to C, to link to the actualy library and how to compile the code written in other languages is handled by the plugin part.&lt;br /&gt;
&lt;br /&gt;
Without using plugins every Eiffel program should know all the details required to compile a C application with zlib. It would require to always use ACE files - even for simple examples - because you need to provide proper &amp;quot;c_compiler_options&amp;quot; and &amp;quot;linker_options&amp;quot;; for a single, simple library like Zlib it looks a tame task, only requiring to add -lzlib to the &amp;quot;linker_options&amp;quot; but when you start building real-world application things will get complicated really fast.&lt;br /&gt;
&lt;br /&gt;
See SmartEiffel documentation on plugins.&lt;br /&gt;
&lt;br /&gt;
All those functions returns an integer with standardized values #defined in the C header. We will wrap them in the deferred class ZLIB_CONSTANTS.&lt;br /&gt;
&lt;br /&gt;
Deferred? Why deferred? We want to avoid the Eiffel programmer the burden to deal with all the details that C requires - otherwise we would have used plain C - so we do not want him/her to directly use that libraries. Deferred classes cannot have creation clauses so we are sure that no objects of type ZLIB_EXTERNALS and ZLIB_CONSTANTS will be created. They are helper classes that will be either inherited from or - more properly - inserted into ZLIB_STREAM and its effective heirs, ZLIB_INPUT_STREAM and ZLIB_OUTPUT_STREAM.&lt;br /&gt;
&lt;br /&gt;
Making sure that the Eiffel developer will not use low-level features directly is the main reason why all the external features are not exported to anyone else, using the syntax feature {} -- External calls. This way only heirs - conforming or not - of that class can use them; for people coming from C++ it's like having private functions members.&lt;br /&gt;
C types&lt;br /&gt;
&lt;br /&gt;
Here's a quick conversion table for various C types&lt;br /&gt;
C type	Eiffel type&lt;br /&gt;
int	INTEGER;&lt;br /&gt;
short int	INTEGER_16&lt;br /&gt;
long int	INTEGER_32 or 64&lt;br /&gt;
long long int	INTEGER_64&lt;br /&gt;
int8_t (defined at stdint.h, ISO C 99)	INTEGER_8&lt;br /&gt;
int16_t 	INTEGER_16&lt;br /&gt;
int32_t	INTEGER_32&lt;br /&gt;
int64_t	INTEGER_64&lt;br /&gt;
unsigned int	NATURAL&lt;br /&gt;
unsigned short int	NATURAL_16&lt;br /&gt;
unsigned long int	NATURAL_32 on 32-bit, NATURAL_64 on 64.bit. See long int&lt;br /&gt;
unsigned long long int	NATURAL_64&lt;br /&gt;
signed/unsigned char	CHARACTER&lt;br /&gt;
float	REAL_32&lt;br /&gt;
double	REAL_64&lt;br /&gt;
long double	REAL_EXTENDED&lt;br /&gt;
char	BOOLEAN&lt;br /&gt;
void* or any other pointer	POINTER&lt;br /&gt;
&lt;br /&gt;
Some notes:&lt;br /&gt;
&lt;br /&gt;
    intXX_t are defined in GNU systems (Linux Glibc, CygWin and similar).&lt;br /&gt;
    Currently INTEGER is mere alias for INTEGER_32 but this is bound to change in future version of SmartEiffel. Personally I think that it should be &amp;quot;the integer type with the same bit-lenght of C int&amp;quot;.&lt;br /&gt;
    A nice feature of long int is that is could be longer that int. So we can't really be sure whenever it is 32 or 64 bit. Usually it is an INTEGER_32 on 32-bit machines and INTEGER_64 on 64-bit machines. See this post on the SmartEiffel mailing list.&lt;br /&gt;
    The same problem applies for long unsigned int: NATURAL_32 on 32-bits and NATURAL_64 on 64-bit. This mismatch can be quite problematic and it will be discussed-addressed later.&lt;br /&gt;
    At the time of writing of this document SmartEiffel has some know issues regarding NATURALs types. If they actually do cause bugs there is an (unsatisfactory) workaround: use a bigger INTEGER. This implies a hidden conversion at C level and bargains correctness with a little waste of space and worse performance. Do not use an INTEGER of same size: it &amp;quot;usually&amp;quot; works nicely but this is a known source of nasty bugs since you will soon or later it will silently overflow.&lt;br /&gt;
&lt;br /&gt;
An enlighting explanation about C variable types and declarations can be read on Wikipedia (I find particurarly confusing - expecially for the novice - that char is at the same time an 8-bit integer and an encoding for ASCII characters. Most programmers could always end up thinking about it only as a character. After more than 30 years they could have called it &amp;quot;byte&amp;quot;. Yet this behaviour is fit the spirit of C very well. ).&lt;br /&gt;
&lt;br /&gt;
The resulting ZLIB_CONSTANTS class is almost boring and undocumented. I maintained the documentation level found in the original documentation, since those are values that will be handled only by the implementation of the wrapper.&lt;br /&gt;
&lt;br /&gt;
Have a look at WRAPPER_HANDLER. Eiffel has the ability to selectively export Any class that needs to access some of the&lt;br /&gt;
Access to structure field&lt;br /&gt;
&lt;br /&gt;
Let's wrap the z_stream structure (the structure name is actually struct z_stream_s typedeffed to z_stream during its definition); the wrapper will have a similar two layer design: the low-level Z_STREAM_STRUCT will be a deferred class, with feature {} -- Hidden, low-level getters and setters. This class will also have a feature struct_size: INTEGER that will be the value of sizeof(z_stream)&lt;br /&gt;
&lt;br /&gt;
Field named FooBar in the struct my_struct will be read with the Eiffel query my_struct_get_foo_bar and set with the command my_struct_set_foo_bar. Remember that those are low-level features; references to other objects will be pointers and its signature will be one of an external function: the first argument will be always the address of - a POINTER to - the wrapped struct.&lt;br /&gt;
Naming of placeholder arguments&lt;br /&gt;
&lt;br /&gt;
Placeholder names should be chosen in a way that makes the documentation of the feature in English as smooth as possible for a proper argument placeholder for the Gnu-Eiffel language. &amp;quot;CamelCase&amp;quot; will be translated into &amp;quot;a_camel_case&amp;quot;, &amp;quot;ENOO&amp;quot; is translated into &amp;quot;an_enoo&amp;quot;. Eventual underscores in front of `a_name' are removed: &amp;quot;__foo&amp;quot; becomes &amp;quot;a_foo&amp;quot;. The prefixed preposition is added to make clearer that the name refers to a generic value, not to a particular one. Always tries to use a placeholder that can be directly put in the feature's documentation without paraphrase.&lt;br /&gt;
ZLIB_STREAM, at last.&lt;br /&gt;
&lt;br /&gt;
So let's write something that will be used in an actual Eiffel program! We start writing ZLIB_STREAM from file common/skeleton that provides us the usual LGPL-2.1-or-later headers. It inserts ZLIB_EXTERNALS and Z_STREAM_STRUCT.&lt;br /&gt;
&lt;br /&gt;
TODO: finish this&lt;br /&gt;
The &amp;quot;common&amp;quot; cluster&lt;br /&gt;
&lt;br /&gt;
The basic building blocks of a wrapper library have been put in the common cluster.&lt;br /&gt;
&lt;br /&gt;
The WRAPPER class it the &amp;quot;fundamental&amp;quot; one even if embarassingly simple. Its only effective field (i.e.: stored, non-computed) is the handle POINTER. It shall handle the allocation and deallocation of the memory referred by handle so it is an heir of DISPOSABLE but it doesn't define dispose because there is no such a thing like a default memory handling in C.&lt;br /&gt;
&lt;br /&gt;
C_STRUCT inherits from WRAPPER and provides default implementations for copy, is_equal and from_external_pointer features; it introduces the deferred &amp;quot;struct_size&amp;quot; query which should give the same result of C operator sizeof(MyStruct).&lt;br /&gt;
&lt;br /&gt;
Note that there are - at least conceptually - other potentially heirs of WRAPPER, like pointers to functions&lt;br /&gt;
&lt;br /&gt;
Many C libraries often return const char* strings. Those strings shall not be modified and their memory will be handled by the library; by all other means they actually are plain strings. A correct behaviour is to write foo: STRING is do create Result.from_external_copy(a_function_returning_a_const_char_pointer(handle)) end; a STRING is meant to be manipulated and changed and has control on the memory of its content. Here we are instead given a piece of memory holding some text that is &amp;quot;mostly read-only&amp;quot; whose control is held by the library. To provide correct behaviour STRING must copy the buffer, from_external can't be used. CONST_STRING is an effective heir of STRING that provides efficient wrapping of &amp;quot;const strings&amp;quot;. It is usable like any other STRING but all the changes are made to a separe buffer preserving the original content - we are actually not allowed to change it. No further memory is allocated when a CONST_STRING is created: the buffer returned by the C library is used directly. For example, GTK+ has many calls like const gchar* gtk_entry_get_text (GtkEntry *entry); Memory efficiency is achieved making changing features slower. If you need to change its content consider using its feature string to get a new (non-const) STRING with the same content.&lt;br /&gt;
&lt;br /&gt;
TODO: add proper description about:&lt;br /&gt;
CACHING_FACTORY&lt;br /&gt;
C_ARRAY&lt;br /&gt;
COMPARABLE_C_STRUCT&lt;br /&gt;
COMPARABLE_WRAPPER&lt;br /&gt;
CONST_STRING&lt;br /&gt;
C_OWNED&lt;br /&gt;
C_STRUCT&lt;br /&gt;
EIFFEL_OWNED&lt;br /&gt;
ENUM&lt;br /&gt;
EXPANDED_WRAPPER&lt;br /&gt;
GLOBAL_CACHE&lt;br /&gt;
GLOBALLY_CACHED&lt;br /&gt;
HASHABLE_WRAPPER&lt;br /&gt;
ITERATOR_ON_C_ARRAY&lt;br /&gt;
LINKED_STRING&lt;br /&gt;
MIXED_MEMORY_HANDLING&lt;br /&gt;
NULL_TERMINATED_C_ARRAY&lt;br /&gt;
NULL_TERMINATED_STRING_ARRAY&lt;br /&gt;
POINTER_HANDLING&lt;br /&gt;
REFERENCE_COUNTED&lt;br /&gt;
SHARED&lt;br /&gt;
STRING_ARRAY&lt;br /&gt;
STRING_ARRAY_ITERATOR&lt;br /&gt;
WRAPPER_COLLECTION&lt;br /&gt;
WRAPPER_DICTIONARY&lt;br /&gt;
WRAPPER&lt;br /&gt;
WRAPPER_FACTORY&lt;br /&gt;
WRAPPER_HANDLER&lt;br /&gt;
WRAPPERS_CACHE&lt;br /&gt;
Enumerations&lt;br /&gt;
&lt;br /&gt;
There are two general tecnique to wrap an enum.&lt;br /&gt;
&lt;br /&gt;
    Put all the possible values of enumerations into a class as INTEGER constants accessibile to the user of your library. This is mostly similar to the actual usage of an enumeration. Each and every feature that accept an enum value as argument will need a precondition like is_valid_foo (a_foo_value)&lt;br /&gt;
    Create a new type. In fact an enumeration is an INTEGER that can assume only precise and prestabilited values, so that its value is correct and consistent all the times. Class ENUM provides some facilities to achieve this. It shall be used in classes like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    -- This file have been created by eiffel-gcc-xml.&lt;br /&gt;
    -- Any change will be lost by the next execution of the tool.&lt;br /&gt;
&lt;br /&gt;
    expanded class PANGO_WEIGHT&lt;br /&gt;
&lt;br /&gt;
    insert ENUM&lt;br /&gt;
&lt;br /&gt;
    creation default_create&lt;br /&gt;
    feature -- Validity&lt;br /&gt;
    	is_valid_value (a_value: INTEGER): BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := ((a_value = pango_weight_ultralight) or else&lt;br /&gt;
    				(a_value = pango_weight_light) or else&lt;br /&gt;
    				(a_value = pango_weight_normal) or else&lt;br /&gt;
    				(a_value = pango_weight_semibold) or else&lt;br /&gt;
    				(a_value = pango_weight_bold) or else&lt;br /&gt;
    				(a_value = pango_weight_ultrabold) or else&lt;br /&gt;
    				(a_value = pango_weight_heavy))&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature -- Setters&lt;br /&gt;
    	default_create,  set_ultralight is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_ultralight&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_light is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_light&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_normal is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_normal&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_semibold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_semibold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_bold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_bold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_ultrabold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_ultrabold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_heavy is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_heavy&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature -- Queries&lt;br /&gt;
    	is_ultralight: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_ultralight)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_light: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_light)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_normal: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_normal)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_semibold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_semibold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_bold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_bold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_ultrabold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_ultrabold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_heavy: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_heavy)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature {WRAPPER, WRAPPER_HANDLER} -- Low level values&lt;br /&gt;
    	pango_weight_ultralight: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_ULTRALIGHT&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_light: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_LIGHT&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_normal: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_NORMAL&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_semibold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_SEMIBOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_bold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_BOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_ultrabold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_ULTRABOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_heavy: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_HEAVY&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    As you can see each possible value has a setter command&amp;lt;br&amp;gt;(set_light, set_normal and so on) and a boolean&amp;lt;br&amp;gt;query (is_light, is_normal). As usual low-level values are accessible&amp;lt;br&amp;gt;only by a WRAPPER or a WRAPPER_HANDLER.&lt;br /&gt;
&lt;br /&gt;
Using eiffel-gcc-xml&lt;br /&gt;
&lt;br /&gt;
Have a look at the manually written ZLIB_EXTERNALS. Eiffel is a language that is meant to be easy to the reader at the cost of being verbose. All that text of source to access a bunch of C functions. Think about serious libraries that have literally thousands of functions, structures, and enumeration! Writing the low level side of those wrappers is a really long, tedious task, the kind of task that people usually would leave to an unfaticable, astonishgly fast yet quite dumb worker, a computer. Andreas Leitner - who is surely quite smarter than myself - wrote a C parser for his Eiffel Wrapper Generator. I do not have neither the time neither the abilities of Andreas but it seems that I'm more lucky than him. In fact by the time I got serious with this project, people with the same problem, requiring tons of wrappers for Python, produced gcc-xml. These days parsing XML is a considered a common task, a task to be left to standard libraries, so SmartEiffel have an XML parser. So I wrote a little tool name &amp;quot;eiffel-gcc-xml&amp;quot; that takes the output of gcc-xml as input to produce the low-level &amp;quot;external&amp;quot; classes that we need to access functions, structures and enumerations.&lt;br /&gt;
&lt;br /&gt;
Well, it actually requires a little more work since it breaks very often.&lt;br /&gt;
Memory handling&lt;br /&gt;
C_STRUCT is a wrapper for a data structure implemented in C programming language using a structure.&lt;br /&gt;
It does not make any assumption about memory handling; the developer of a SmartEiffel wrapper of a C library has to inherit to create a proper wrapper for it the developer shall inherit both from this class and from classes providing memory handling behavior, depending on how structure's memory shall be handled. This is decided  case-by-case by C library.&lt;br /&gt;
Currently available memory handling classes are:&lt;br /&gt;
&lt;br /&gt;
    C_OWNED: memory is always handled by the underlying C library.&lt;br /&gt;
    EIFFEL_OWNED: once created memory is fully handled by Eiffel runtime, usually with the Garbage Collector.&lt;br /&gt;
    GLOBALLY_CACHED: Until disposed by Eiffel the wrapper registered in wrappers dictionary will be the unique wrapper used on the Eiffel side.&lt;br /&gt;
    MIXED_MEMORY_HANDLING: whose memory can either by handled by the Eiffel library or by the underlying C code. Who handles memory is decided on a per-object based on the value of the flag `is_shared': handle will not be freed on dispose of the Eiffel wrapper object, when `is_shared' is true.&lt;br /&gt;
    REFERENCE_COUNTED: memory is handled thought reference counting, i.e.GObject&lt;br /&gt;
&lt;br /&gt;
Add proper examples of the various memory handling classes.&lt;br /&gt;
Implementing collections&lt;br /&gt;
Quite often objects are stored into containers or collections like arrays, linked lists, dictionaries, hashed-tables and so on. Many C libraries provides their own implementation of the classic containers, for example the GLib library provides GList, GSList, GHashTable and many others.&lt;br /&gt;
A WRAPPER_COLLECTION is a COLLECTION implemented wrapping some facilities offered by the wrapped C library, like GLib's linked list GList.&lt;br /&gt;
When you wrap those data structures you will encounter two kinds of problems:&lt;br /&gt;
&lt;br /&gt;
    Pointer returned by C containers could be newly allocated, not already wrapped by the Eiffel wrapper or already wrapper by the Eiffel wrapper. You can't naively create a new WRAPPER every time. Beside the obvious waste of memory and the stress you put on the garbage collector you will break most postconditions and invariant of a COLLECTION, since things that seems obvious like&lt;br /&gt;
&lt;br /&gt;
 do_stuff (my_collection: WRAPPER_COLLECTION[ITEM]) is require&lt;br /&gt;
my_collection/=Void not my_collection.is_empty local a,b: ITEM do a :=&lt;br /&gt;
my_collection.first b := my_collection.first check will_fail: a = b end end&lt;br /&gt;
&lt;br /&gt;
In fact a and b will be different wrappers referring to the same underlying C structure. A WRAPPER_COLLECTION shall  avoid this repeated, unnecessary and wrong creation of WRAPPERs, that will breaks invariants and post-conditions of a COLLECTION.&lt;br /&gt;
A solution is to inherit from WRAPPERS_CACHE, initializing cache at creation time and keeping it updated during usage. Cache's key is the address (pointer) to the wrapped C structure, value is the corresponding Eiffel wrapper. This way you can get back an already-created Eiffel wrapper.&lt;br /&gt;
Classes can implement different scheme; for example G_OBJECT_LIST retrieve the reference to the eventual WRAPPER directly from underlying GObject.&lt;br /&gt;
&lt;br /&gt;
    The container has no means to know how it shall create the wrapper for it, since C does not have the notion of generic, strongly typed container. The effective type of the containee is either not know by WRAPPER_COLLECTION or worse its conteinees  could actually belong to different classes, sharing a common ancestor.&lt;br /&gt;
    Since each library has its own idea on how the programmer shall handle �memory when dealing with containers an effective, non-deferred heir of WRAPPER_COLLECTION shall implement `wrapper' feature that given a pointer creates or retrieve a WRAPPER of the fittest class. Usually &amp;quot;plain&amp;quot; usage could return a fixed type; more elaborate type systems like GObject could provide the facilities necessary to pick a useful Eiffel type.&lt;br /&gt;
&lt;br /&gt;
TODO: finish it.&lt;br /&gt;
Comparability and hashability&lt;br /&gt;
Some collections does not require anything in particular to their containee, like arrays or linked lists. Other collections needs either to compare their containee or to obtain an hash value from it. Therefore wrapper classes that are conceptually comparable or hashable shall inherit from COMPARABLE_WRAPPER and HASHABLE_WRAPPER respectively so they could be stored into collections that requires such abilities.&lt;br /&gt;
How to adapt old wrappers&lt;br /&gt;
(This is almost obsolete) Previous design was a black-or-white design: a class was either Eiffel-owned or not; C_STRUCT's are &amp;quot;owned&amp;quot; by the Eiffel code, and the Eiffel side should keep then longest lived reference to this struct; SHARED_C_STRUCT modelled the non-Eiffel-owned.&lt;br /&gt;
This approach is overly simplicistic since real-life libraries implement a wide spectrum of memory handling policies. One solutions does not fit all needs. Study the documentation of the library and pick the right memory handling Eiffel class.&lt;br /&gt;
The long int problem&lt;br /&gt;
&lt;br /&gt;
Shortly it could be solved having two separate clusters one for 32bit, one for 64 bit where a deferred class defines a parameterless query for anchored declaration like&lt;br /&gt;
&lt;br /&gt;
long_int: INTEGER_32 is do end&lt;br /&gt;
&lt;br /&gt;
long_int: INTEGER_64 is do end&lt;br /&gt;
&lt;br /&gt;
but this looks like an unfeasible hack to me, at least now. Currently it is the only available answer; a &amp;quot;proper&amp;quot; solution would require changes in both the compiler and the standard library. I would like to know how ISE solved this.&lt;br /&gt;
&lt;br /&gt;
GObject-based libraries&lt;br /&gt;
&lt;br /&gt;
Nowadays many libraries are based on the GLib Object System also known as Gobject. This library &amp;quot;provides a portable object system and transparent cross-language interoperability&amp;quot;. It is used as the basic building block for literally hundeds of libraries and applications; in fact the command apt-cache rdepends libglib2.0-0 |wc -l told me that more than 2200 applications and libraries depend on either GLib or GObject.&lt;br /&gt;
&lt;br /&gt;
GObject implement its own classed type system. With the exception of basic types (and some other subtleties I will write later) all objects are structures referred by pointer, i.e. non-expanded classes in Eiffellese; the type of each object is identified by a number, a GType which has an associated structure to describe the class - the type - itself. During startup of the Eiffel application the wrapper library will register for each type name (i.e. GtkWindow, GtkButton....) it wraps an agent that given a pointer creates an Eiffel wrapper object for the creation_agents dictionary, with a call similar to creation_agents.put (agent create_gtk_window, &amp;quot;GtkWindow&amp;quot;), given the feature create_gtk_window (p: POINTER): GTK_WINDOW is do create Result.from_external_pointer(p) end.&lt;br /&gt;
&lt;br /&gt;
A Gobject can store arbitrary properties into itself. We use this to store a reference pointer to its Eiffel wrapper.&lt;br /&gt;
&lt;br /&gt;
When we receive a pointer to a Gobject the G_OBJECT_FACTORY first looks if this Gobject already has an attacked wrapper (an effective heir of G_OBJECT). Otherwise it ask the Gobject its GType and the associated class-name. It this class-name has a creation agent the wrapper is created invoking the retrieved creation agent; otherwise we recursively look at its parent class until we find a type that has a corresponding creation agent.&lt;br /&gt;
&lt;br /&gt;
When an effective G_OBJECT heir is actually created either explicitly because we know for sure its type or throught a creation agent the address of the wrapper is stored in the property &amp;quot;eiffel-wrapper&amp;quot; using the C function g_object_set_qdata (see store_eiffel_wrapper in G_OBJECT).&lt;br /&gt;
&lt;br /&gt;
As usual this approach is both correct, memory efficient and collection-friendly (see &amp;quot;Implementing collections&amp;quot; earlier) at the cost of being computing intensive. There are times when the wrapper library has to create transient wrappers for shortly lived objects. Here enters secondary wrappers, or G_OBJECTs that are not referred-by the GOBject they refer to. Letting code speak: having a_gtk_window_ptr: POINTER; my_window: GTK_WINDOW; factory: G_OBJECT_EXPANDED_FACTORY check create my_window.secondary_wrapper_from(a_gtk_window_ptr) /= factory.wrapper(a_gtk_window_ptr) end will hold and also create my_window.main_wrapper_from(a_gtk_window_ptr); check my_window = factory.wrapper(a_gtk_window_ptr) end will be successfully passed. The difference is that the first is only an allocation of a smallish object (few bytes) while the latter could potentially require several looks-up into a dictionary plus an O(n) search into the GObject properties (during g_object_get_qdata used to see if a wrapper does actually exist)&lt;br /&gt;
&lt;br /&gt;
TODO: show how to wrap a typical GObject-using library, like Gnome's GConf configuration system.&lt;br /&gt;
Commit's policy&lt;br /&gt;
&lt;br /&gt;
    There is no strict rule...&lt;br /&gt;
    Ideally each commit should provide compilable code and working examples.&lt;br /&gt;
    Provided examples and classes can be unfinished and uncomplete, can contain warnings, empty features and so on. My motto is &amp;quot;something is better than nothing&amp;quot;.&lt;br /&gt;
    it is nice to tell other developers what are you working on; anemail on eiffel-libraries-devel@gna.org suffice.&lt;br /&gt;
    I promise I won't track you with a 9-tail cat to bash you if you commit uncompilable code.&lt;br /&gt;
    Code that compiles is a good thing. Wisely designed code that compiles is better, since it has better performances; but I prefer published, working code even if has no state-of-the-art performances instead of&lt;br /&gt;
&lt;br /&gt;
Various very old notes&lt;br /&gt;
Those notes are left here to be worked on.&lt;br /&gt;
&lt;br /&gt;
Suggested&lt;br /&gt;
Start copying original documentation into an Eiffel class and comment it out entirely.&lt;br /&gt;
Add proper indexing clauses, then progressively convert it into Eiffel from top to bottom.&lt;br /&gt;
Sketch difficoult features into comments.&lt;br /&gt;
This behaviour is not meant to pile rubbish, but to quickly know how much work we still have to do.&lt;br /&gt;
This means that the resulting Eiffel  classes will be a derivative work of the original documentation of the library. This is usally not a problem these days because documentation is often automatically extracted from sources, so the Eiffel wrapper will end up having the same license of the wrapper library; for example our GTK+ wrapper being a derivative work of the actual GTK+ C library must abide its LGPL license.&lt;br /&gt;
All the infrastructure of GTK+, including GObject are - in my humble opinion - explicitly designed to make the life easy for people writing wrappers for loosely-typed languages such as Python, Perl and other scriptiong languages. This (sadly) means that life for heavily/strongly-typed languages such as Eiffel are make annoying.&lt;br /&gt;
Objects like closures and other amenities like that won't be wrapped until the rest is done and working.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Incoming tools ===&lt;br /&gt;
&lt;br /&gt;
Libraries using gobject-introspection and typelib provides much more informations to write wrappers and binding for other languages.&lt;br /&gt;
&lt;br /&gt;
The metadata of a typelib file allows to directly produce high-level wrappers. &lt;br /&gt;
&lt;br /&gt;
This will give us support for Gtk3, Glib, Cairo and many many other libraries in a much faster way that manually wrapping each one. &lt;br /&gt;
&lt;br /&gt;
The tool that will generate such binding  will be named '''leggow''', acronym for '''Liberty Eiffel Generator of GObject Wrappers''' and it currently lies in the leggow branch in repository https://github.com/tybor/Liberty but it is currently only an idea.&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Upcoming_release_names&amp;diff=2158</id>
		<title>Upcoming release names</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Upcoming_release_names&amp;diff=2158"/>
		<updated>2016-02-27T22:14:27Z</updated>

		<summary type="html">&lt;p&gt;Tybor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Liberty releases are named after famous engineers names starting by A for the first release, B for the second, and so on.&lt;br /&gt;
Here is a list of name suggestions for future releases:&lt;br /&gt;
* Alexander Graham Bell ('''&amp;quot;bell&amp;quot;''')&lt;br /&gt;
* Glenn Curtiss ('''&amp;quot;curtiss&amp;quot;''')&lt;br /&gt;
* Jack Dennis ('''&amp;quot;dennis&amp;quot;''')&lt;br /&gt;
* Gustave Eiffel ('''&amp;quot;eiffel&amp;quot;''') -- or is it too obvious?&lt;br /&gt;
* John Ambrose Fleming ('''&amp;quot;fleming&amp;quot;''') &lt;br /&gt;
* G?&lt;br /&gt;
* Grace Hopper ('''&amp;quot;hopper&amp;quot;''')&lt;br /&gt;
* I?&lt;br /&gt;
&lt;br /&gt;
Feel free to suggest any further names. You may read the lists of engineers on WikiPedia:&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Lists_of_engineers Lists of engineers]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/List_of_civil_engineers List of civil engineers]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/List_of_structural_engineers List of structural engineers]&lt;br /&gt;
&lt;br /&gt;
Each &amp;quot;released release&amp;quot; (sic) will also have a numeric tag in the form of &amp;quot;year.month&amp;quot; which is more simple to remember.&lt;br /&gt;
&lt;br /&gt;
Already released versions are listed in [[Versions history]].&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Tools&amp;diff=2156</id>
		<title>Tools</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Tools&amp;diff=2156"/>
		<updated>2016-02-27T21:13:06Z</updated>

		<summary type="html">&lt;p&gt;Tybor: /* Compiling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Tool]]&lt;br /&gt;
LibertyEiffel provides many tools besides the [[compile|compiler]].&lt;br /&gt;
&lt;br /&gt;
All those tools use the [[configuration file]].&lt;br /&gt;
&lt;br /&gt;
== The tools ==&lt;br /&gt;
&lt;br /&gt;
=== Tool box ===&lt;br /&gt;
&lt;br /&gt;
* [[se]]: a facade to all those tools&lt;br /&gt;
&lt;br /&gt;
=== Compiling ===&lt;br /&gt;
&lt;br /&gt;
* [[clean]]: remove the useless C files&lt;br /&gt;
* [[compile]]: the compiler (calls [[compile_to_c]])&lt;br /&gt;
* [[compile_to_c]]: the C compiler core&lt;br /&gt;
* [[extract_internals]]: the tentative inter-program object sharing tool&lt;br /&gt;
* [[wrappers_generator]]: a tools to generate low-level Eiffel wrappers for C code&lt;br /&gt;
&lt;br /&gt;
=== Searching and documenting ===&lt;br /&gt;
&lt;br /&gt;
* [[eiffeldoc]]: generates the whole documentation of a project&lt;br /&gt;
* [[finder]]: find a class&lt;br /&gt;
* [[pretty]]: make your source file pretty&lt;br /&gt;
* [[short]]: generates the interface documentation of a single class&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
* [[ace_check]]: check an [[ACE|ACE file]]&lt;br /&gt;
* [[class_check]]: check the [[parsing|syntax]] and the [[semantics]] of a source code&lt;br /&gt;
* [[eiffeltest]]: the LibertyEiffel testing tool&lt;br /&gt;
&lt;br /&gt;
=== Installing ===&lt;br /&gt;
&lt;br /&gt;
* [[install]]: installs the LibertyEiffel tools&lt;br /&gt;
&lt;br /&gt;
== The system core ==&lt;br /&gt;
&lt;br /&gt;
If you are interested by how the system works, either by sheer curiosity, either because you want to modify it, here are some explanations.&lt;br /&gt;
&lt;br /&gt;
If you want to create a new LibertyEiffel-oriented tool, this information is important too; also look at [[tool_class:EXTERNAL_TOOL|&amp;lt;tt&amp;gt;EXTERNAL_TOOL&amp;lt;/tt&amp;gt;]].&lt;br /&gt;
&lt;br /&gt;
* [[class loading]]&lt;br /&gt;
* [[parsing|syntactic analysis]]&lt;br /&gt;
* [[semantics|semantic analysis]]&lt;br /&gt;
* the [[optimizer]]&lt;br /&gt;
* the [[visitor|visitors]]&lt;br /&gt;
* code generation&lt;br /&gt;
** [[compile_to_c#Generation|compile_to_c]]&lt;br /&gt;
** [[compile_to_jvm#Generation|compile_to_jvm (obsolete)]]&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=GSoC_-_Google%27s_Summer_of_Code&amp;diff=2132</id>
		<title>GSoC - Google's Summer of Code</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=GSoC_-_Google%27s_Summer_of_Code&amp;diff=2132"/>
		<updated>2016-02-14T23:32:05Z</updated>

		<summary type="html">&lt;p&gt;Tybor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This year we as LibertyEiffel want to participate in [https://developers.google.com/open-source/gsoc/ Google's Summer of Code Program]. On this site we collect idea for projects. But let's give it all in correct order:&lt;br /&gt;
&lt;br /&gt;
= What is the Google Summer of Code? =&lt;br /&gt;
Summer of Code is Google's program to give students stipends for a 3 months programming task in an open source. Every participating student gets a mentor assigned (early birds might even have a chance to select ;-) who supports with his experience from the community. &lt;br /&gt;
&lt;br /&gt;
= When will all this happen? =&lt;br /&gt;
The [https://developers.google.com/open-source/gsoc/timeline timeline] is quite terse but the most important dates are application before 25th of March and free time between May 23 and August 23 to work on coding.&lt;br /&gt;
&lt;br /&gt;
= Why choosing LibertyEiffel for the Google Summer of Code? =&lt;br /&gt;
LibertyEiffel is the GNU compiler for the programming language Eiffel. It is based on the academic project SmartEiffel but evolved with the scope of being usable to real world programs. Eiffel in general is a very nice object oriented programming language which includes the specification of the program's functionality within the code. This is nice for debugging but also a step to be able to prove the program correct.&lt;br /&gt;
&lt;br /&gt;
= What could I do? =&lt;br /&gt;
We are open to your ideas, as we are convinced that you will perform best in case you what your heart burns for. Feel free to suggest a project on the mailing list an we will find a mentor or subtasks to add or remove to make it appropriate. In case you just want to do something great for LibertyEiffel you can choose from the following ideas.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Ideas =&lt;br /&gt;
== Windows Support ==&lt;br /&gt;
'''suggested by: '''ramack&lt;br /&gt;
&amp;lt;br /&amp;gt;'''summary: '''LibertyEiffel in theory is running several platforms, but recent development was limited to a GNU/Linux environment and for Microsoft Windows no compiler is known to work. Target is to integrate a free C compiler (e. g. PellesC), including necessary fixes to generate accepted C code, add missing implementations for plugins (exec, net), create an installer, run test suite on MS Windows.&lt;br /&gt;
&amp;lt;br /&amp;gt;'''difficulty: '''Easy&lt;br /&gt;
&amp;lt;br /&amp;gt;'''skills: '''Experience with C programming on Windows, basic Eiffel knowledge&lt;br /&gt;
&amp;lt;br /&amp;gt;'''potential mentors: '''ramack, Hans Zwakenberg&lt;br /&gt;
&amp;lt;br /&amp;gt;'''notes: '''&lt;br /&gt;
&lt;br /&gt;
== Eclipse integration ==&lt;br /&gt;
'''suggested by: '''ramack&lt;br /&gt;
&amp;lt;br /&amp;gt;'''summary: '''Integrate LibertyEiffel into Eclipse with Syntax highlighting, compilation (and parsing the output) and the sedb debugger&lt;br /&gt;
&amp;lt;br /&amp;gt;'''difficulty: '''Easy&lt;br /&gt;
&amp;lt;br /&amp;gt;'''skills: '''Java knowledge, Eiffel knowledge, experience with Eclipse (plugin development) would be good&lt;br /&gt;
&amp;lt;br /&amp;gt;'''potential mentors: '''ramack&lt;br /&gt;
&amp;lt;br /&amp;gt;'''notes: '''&lt;br /&gt;
&lt;br /&gt;
== Standard C11 conform C code ==&lt;br /&gt;
'''suggested by: '''ramack&lt;br /&gt;
&amp;lt;br /&amp;gt;'''summary: '''Make the LibertyEiffel compiler emit C11 compatible C code.&lt;br /&gt;
&amp;lt;br /&amp;gt;'''difficulty: '''Advanced&lt;br /&gt;
&amp;lt;br /&amp;gt;'''skills: '''Deep experience in C programming, basic Eiffel knowledge&lt;br /&gt;
&amp;lt;br /&amp;gt;'''potential mentors: '''ramack, Hans Zwakenberg&lt;br /&gt;
&amp;lt;br /&amp;gt;'''notes: '''can be extended to apply additional static checkers like pclint, MISRA rules, high C compiler warning levels&lt;br /&gt;
&lt;br /&gt;
== ECMA conformance ==&lt;br /&gt;
'''suggested by: '''ramack&lt;br /&gt;
&amp;lt;br /&amp;gt;'''summary: '''many ECMA features are already supported, implement the missing ones (beside No-variant agent conformance, which is not planned to be included in LibertyEiffel)&lt;br /&gt;
&amp;lt;br /&amp;gt;'''difficulty: '''Advanced&lt;br /&gt;
&amp;lt;br /&amp;gt;'''skills: '''Deep Eiffel knowledge, willingness to dig into the ECMA standard document&lt;br /&gt;
&amp;lt;br /&amp;gt;'''potential mentors: '''ramack,Cadrian&lt;br /&gt;
&amp;lt;br /&amp;gt;'''notes: '''obviously test cases shall also be derived for the new features&lt;br /&gt;
&lt;br /&gt;
== EiffelTest-NG ==&lt;br /&gt;
'''suggested by: '''ramack&lt;br /&gt;
&amp;lt;br /&amp;gt;'''summary: '''Implement a new version of the tool eiffeltest, to execute the test suite&lt;br /&gt;
&amp;lt;br /&amp;gt;'''difficulty: '''None/Easy/Advanced/Hard/Unmanageable&lt;br /&gt;
&amp;lt;br /&amp;gt;'''skills: '''Good Eiffel knowledge, interest in Software testing&lt;br /&gt;
&amp;lt;br /&amp;gt;'''potential mentors: '''ramack,Cadrian&lt;br /&gt;
&amp;lt;br /&amp;gt;'''notes: '''the features should include: parallel test execution, time/progress monitoring and estimation, improved test status (ET integration), Coverage measurement (different criteria like Branch, MC/DC)&lt;br /&gt;
&lt;br /&gt;
== Embedded Systems Readiness / Static Memory Allocation ==&lt;br /&gt;
'''suggested by: '''ramack&lt;br /&gt;
&amp;lt;br /&amp;gt;'''summary: '''Improve the applicability of LibertyEiffel programs to small embedded systems, by introduction of a mechanism to prevent dynamic memory allocation.&lt;br /&gt;
&amp;lt;br /&amp;gt;'''difficulty: '''Hard&lt;br /&gt;
&amp;lt;br /&amp;gt;'''skills: '''Deep understanding of Memory Managment, Eiffel experience&lt;br /&gt;
&amp;lt;br /&amp;gt;'''potential mentors: '''ramack&lt;br /&gt;
&amp;lt;br /&amp;gt;'''notes: '''&lt;br /&gt;
&lt;br /&gt;
== Resurrect the compile_to_jvm compiler ==&lt;br /&gt;
'''suggested by: '''ramack&lt;br /&gt;
&amp;lt;br /&amp;gt;'''summary: '''Back in the SmartEiffel times there was a JVM backend, which compiled Eiffel to Java bytecode. This should be made working again with an example to build an Android App in Eiffel.&lt;br /&gt;
&amp;lt;br /&amp;gt;'''difficulty: '''Hard&lt;br /&gt;
&amp;lt;br /&amp;gt;'''skills: '''Good Eiffel experience, Knowledge of Java Bytecode and Compiler technology.&lt;br /&gt;
&amp;lt;br /&amp;gt;'''potential mentors: '''ramack&lt;br /&gt;
&amp;lt;br /&amp;gt;'''notes: '''&lt;br /&gt;
&lt;br /&gt;
== Verification backend ==&lt;br /&gt;
'''suggested by: '''ramack&lt;br /&gt;
&amp;lt;br /&amp;gt;'''summary: '''generate proof obligations from contracts for formal verification, e. g. by generationg of ACSL specifications from the Eiffel contracts to use Frama-C as &amp;quot;verification backend&amp;quot;&lt;br /&gt;
&amp;lt;br /&amp;gt;'''difficulty: '''Hard&lt;br /&gt;
&amp;lt;br /&amp;gt;'''skills: '''background in formal verification, Eiffel experience&lt;br /&gt;
&amp;lt;br /&amp;gt;'''potential mentors: '''ramack&lt;br /&gt;
&amp;lt;br /&amp;gt;'''notes: '''&lt;br /&gt;
&lt;br /&gt;
== C++ support wrappers-generator  ==&lt;br /&gt;
'''suggested by: '''Tybor&lt;br /&gt;
&amp;lt;br /&amp;gt;'''summary: '''Add c++ support to wrappers-generator&lt;br /&gt;
&amp;lt;br /&amp;gt;'''difficulty: '''Advanced&lt;br /&gt;
&amp;lt;br /&amp;gt;'''skills: '''Good c++ knowledge, Good Eiffel experience.&lt;br /&gt;
&amp;lt;br /&amp;gt;'''potential mentors: '''Tybor&lt;br /&gt;
&amp;lt;br /&amp;gt;'''notes: '''C++ support could be a boon yet it would pose quite a few tricky problems as C++ object modeldiffers from Eiffel's in some ways.&lt;br /&gt;
&lt;br /&gt;
== Scientific wrappers  ==&lt;br /&gt;
'''suggested by: '''Tybor&lt;br /&gt;
&amp;lt;br /&amp;gt;'''summary: '''Add wrappers for scientific  purposes: complexes, intervals, arbitrary precision integers and floats. Interesting libraries could be:&lt;br /&gt;
* The GNU Multiple Precision Arithmetic Library https://gmplib.org/&lt;br /&gt;
* MPFR: multiple-precision floating-point computations with correct rounding. http://www.mpfr.org/&lt;br /&gt;
* Mpc: complex numbers with arbitrarily high precision and correct rounding of the result.&lt;br /&gt;
* Multi precision intervals http://mpfi.gforge.inria.fr/ https://gforge.inria.fr/projects/mpfi/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;'''difficulty: '''Advanced&lt;br /&gt;
&amp;lt;br /&amp;gt;'''skills: '''Good Eiffel experience.&lt;br /&gt;
&amp;lt;br /&amp;gt;'''potential mentors: '''Tybor&lt;br /&gt;
&amp;lt;br /&amp;gt;'''notes: ''' Several GNU libraries would be a nice addition to Liberty yet their wrappers should be expanded types to be really useful. &lt;br /&gt;
&lt;br /&gt;
== JavaScript backend ==&lt;br /&gt;
'''suggested by: '''Tybor&lt;br /&gt;
&amp;lt;br /&amp;gt;'''summary: '''Implement an Eiffel to Javascript transcompiler&lt;br /&gt;
&amp;lt;br /&amp;gt;'''difficulty: '''Easy/Advanced&lt;br /&gt;
&amp;lt;br /&amp;gt;'''skills: '''Medium Eiffel knowledge, good knowledge of Javascript&lt;br /&gt;
&amp;lt;br /&amp;gt;'''potential mentors: '''ybor,&lt;br /&gt;
&amp;lt;br /&amp;gt;'''notes: '''Javascript is the new &amp;quot;write once run everywhere as it is quickly becoming the new lingua franca of the web. Having an Eiffel to Javascript compielr would widen the usage fields available to Eiffel. A naive compiler would be easy; something that don't require writing tons of glue Eiffel libraries would be quite a harder task. Think about what's to provide &amp;quot;usable&amp;quot; wrappers for libraries such as RaphaelJS or Angular. Their design is all but strongly-typed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Idea Template Title ==&lt;br /&gt;
'''suggested by: '''ramack&lt;br /&gt;
&amp;lt;br /&amp;gt;'''summary: '''Summary of Project Idea (a few sentences)&lt;br /&gt;
&amp;lt;br /&amp;gt;'''difficulty: '''None/Easy/Advanced/Hard/Unmanageable&lt;br /&gt;
&amp;lt;br /&amp;gt;'''skills: '''what skills shall a student bring to do this?&lt;br /&gt;
&amp;lt;br /&amp;gt;'''potential mentors: '''ramack,Tybor,Cadrian&lt;br /&gt;
&amp;lt;br /&amp;gt;'''notes: '''anything further needs to be mentioned?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= How can I participate =&lt;br /&gt;
First you should register to the [[Get_in_touch|mailing list]]. Last you should add a page here in this wiki to present your project proposal and communicate the following:&lt;br /&gt;
* your name and contact data&lt;br /&gt;
* your background (other projects you are/have been involved&lt;br /&gt;
* list of known programming languages (rate with a scale of 3-10, omit the ones you know less)&lt;br /&gt;
* your background and interests (hobbies?)&lt;br /&gt;
* your motivation&lt;br /&gt;
* your timeline (idea is to have 12 week full time, but some planned absence for vacation or exams is acceptable, include milestones and project subtasks, duration of subtask should be in granularity of 1-2 weeks each)&lt;br /&gt;
* your project (what you want to do, why, how, etc. - This is THE main thing we are talking about)&lt;br /&gt;
In between (first and last) feel free to discuss ideas and details on list or privately with potential mentors.&lt;br /&gt;
&lt;br /&gt;
Afterwards we will decide which project to accept, based on the subjective estimation of the LibertyEiffel-GSoC-Ratio (benefit for LibertyEiffel * success rate / amount of mentor effort). Note: amount of mentor effort is not linear! Of course the mentors will support you as much as possible, but an Eiffel-newbie working on a compiler-core redesign is just no feasible...&lt;br /&gt;
&lt;br /&gt;
Of course it would be great if you could continue to maintain the project you worked on during GSoC even after the program.&lt;br /&gt;
&lt;br /&gt;
= What about additional questions? =&lt;br /&gt;
See our [[Get_in_touch]] page for contact data to the LibertyEiffel community or check the [https://developers.google.com/open-source/gsoc/faq FAQ] provided by Google for this program.&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Wrapping_C_libraries&amp;diff=1826</id>
		<title>Wrapping C libraries</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Wrapping_C_libraries&amp;diff=1826"/>
		<updated>2014-01-09T09:28:14Z</updated>

		<summary type="html">&lt;p&gt;Tybor: Created page with &amp;quot; == Developer's guidelines == === or how to write GNU-Eiffel wrappers for a C library ===  &amp;lt;cite&amp;gt; &amp;quot;longum iter est per praecepta, breve et efficax per exempla&amp;quot;&amp;lt;br/&amp;gt; &amp;quot;The path ...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Developer's guidelines ==&lt;br /&gt;
=== or how to write GNU-Eiffel wrappers for a C library ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;&lt;br /&gt;
&amp;quot;longum iter est per praecepta, breve et efficax per exempla&amp;quot;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;quot;The path of precept is long, that of example short and effectual.&amp;quot;&amp;lt;br/&amp;gt;&lt;br /&gt;
Seneca the Elder&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So instead of giving rules I guide you on my path of wrapping the ZLib library, one of the most widespread compression library.&lt;br /&gt;
&lt;br /&gt;
I deliberately chose a &amp;quot;low-level&amp;quot; library with very precise and narrow aims which lets to show basic wrapping techniques: a wider, properly designed library has infrastructures and details that requires to know some tricks from the beginning of the work, otherwise the resulting wrapper should be heavily re-worked on many times.&lt;br /&gt;
&lt;br /&gt;
I usually work with Debian and Ubuntu GNU/Linux, so all the system commands and the package names listed in this tutorial/how-to should apply without changes on Debian and Debian-derived machines. Other distributions, like Fedora, RedHat, Suse, Mandriva shall have similarly named packages. People using BSD OSes could have those libraries available in their package manager. As a last resort you can always download the sources, compile and install them manually. I hope you know how to do it, otherwise the rest of this document would be quite useless for you.&lt;br /&gt;
&lt;br /&gt;
==== Prerequites ====&lt;br /&gt;
&lt;br /&gt;
You should be proficient of:&lt;br /&gt;
&lt;br /&gt;
* the C language,&lt;br /&gt;
* the Eiffel language, &lt;br /&gt;
* the C library you want to wrap; you shall known how to use it in a C program; take some time to read the documentation of the library and to study the provided example in order to make yourself familiar with the style required to use the library. You will need them to provide extensive, readable documentation of your classes.&lt;br /&gt;
&lt;br /&gt;
==== Software prerequisites ====&lt;br /&gt;
&lt;br /&gt;
Make sure you have access on your machine to:&lt;br /&gt;
&lt;br /&gt;
* Liberty Eiffel, you may download the Debian packages from &lt;br /&gt;
* The C headers of the library to wrap; you shall be able to compile the examples of the library you're wrapping; so I issued&lt;br /&gt;
&lt;br /&gt;
    sudo apt-get install zlib1g-dev&lt;br /&gt;
&lt;br /&gt;
* Documentation of the library. Even if it is not absolutely necessary to make working wrappers they are indeed necessary to provide properly documented, therefore usable classes; (GNU) Eiffel has standard rules on how to document code and we shall abide to that; adapting the original C documentation while we wraps various features is a good style to handle documentation. Please do not leave any part of your code undocumented. Spend some time reading the documentation. It is always worth the effort.&lt;br /&gt;
&lt;br /&gt;
I would like to repeat the concept: even if source-code in general is intented to be read by a compiler to produce binary modules its readability and understandability for people is of the utmost importance. Code is not meant to be written-once and never re-read. It actually happens that good code will be read again and again by many people. The fact that programs are covered and protected by copyright laws is not incidental. It means that source code is the expression of an author, like a novel or poetry; I like to think that this fact includes in itself, in-nuce that source text will be read by people several time. And this reading does occour when the source-code text is well-written, well-documentated, useful for study and reuse if its license does allow it.&lt;br /&gt;
&lt;br /&gt;
This approach does resemble Knuth's Literate Programming and indeed many design choices made by Bertrand Meyer during the conception of Eiffel regarding readability and understandability of source-code, expecially those exposed in Object-Oriented Software Construction are strikingly similar to Knut's ideas.&lt;br /&gt;
&lt;br /&gt;
Let's return to our wrapping/binding work after a due phylosophical digression&lt;br /&gt;
&lt;br /&gt;
=== Preliminares ===&lt;br /&gt;
&lt;br /&gt;
Most data structure in C are usually handled by reference, i.e. using pointers. &lt;br /&gt;
&lt;br /&gt;
Passing objects by value is currently requires &amp;quot;expanded external classes&amp;quot; and will no be covered in this guide. Therefore if your library extensively pass structures around by value and not by reference (with a pointer), for example (TODO: put links to online example of passing structure by value) in function calls or contained in other structures our life will be quite hard. Fortunately enought most libraries handles most of its data structures by reference and zlib is no exception: in fact its basic functions takes pointers as first argument.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
== The rest of this document still needs to be adapted.  == &lt;br /&gt;
== TODO: add proper usage of wrappers-generator == &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Now you will wonder how to identify the types used in Zlib. This is quite an extensive argument that people smarter than me already handled in great details here.&lt;br /&gt;
&lt;br /&gt;
A simplicistic rule-of-thumb specifically fitted to wrap libraries written in C is that when we have several functions that takes a pointer to a struct this struct is a good candidate for a class and those functions are good candidates to be wrapped as features usable by an Eiffel program.&lt;br /&gt;
&lt;br /&gt;
Zlib has many functions taking a z_streamp which is nothing more than a typedef-fed pointer to structure z_stream_s. We will wrap those facilities in the Eiffel's (non-expanded) class ZLIB_STREAM.&lt;br /&gt;
Code organization and class hierarchy.&lt;br /&gt;
&lt;br /&gt;
Before diving into code writing let's spend some words on how to cleanly organize our work. We want to provide the user of our library a pretty object-oriented API; since he/she will look at the sources directly soon-or-later it is useful to separate the high-level features and classes, those that will be used directly in other Eiffel projects from the low-level details, like external features or plugins.&lt;br /&gt;
&lt;br /&gt;
We usually place each wrapper library in its own directory following this organization:&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
zlib/ &lt;br /&gt;
|-- examples -- Examples on how to use the Zlib wrappers &lt;br /&gt;
|-- library -- Contains the high-level classes, those used directly in Eiffel programs &lt;br /&gt;
|   |-- externals -- Contains the low-level classes to interface with C (externals, macros, enumeration and so on) &lt;br /&gt;
|   `-- loadpath.se -- Lists the clusters of the library itself, i.e. which directories contains its classes &lt;br /&gt;
|-- loadpath.se -- Lists the clusters used by the library, i.e. its dependencies &lt;br /&gt;
`-- tests -- Contains the tests to be used with eiffeltest tool&lt;br /&gt;
&lt;br /&gt;
If the library is conceptually separated into different areas, subsystems or if it is simple too wide to put cleanly every public class into a single directory we can split the content of the directory library into several sub-directory, like GLib wrapper. See its directory layout:&lt;br /&gt;
&lt;br /&gt;
eiffel-glib/library/ &lt;br /&gt;
|-- core &lt;br /&gt;
|-- data_types &lt;br /&gt;
|-- externals &lt;br /&gt;
|-- fundamentals&lt;br /&gt;
`-- utilities&lt;br /&gt;
&lt;br /&gt;
Let's fill zlib/library/loadpath.se. It lists two directories: those containing the high-level classes, the same of the loadpath.se file itself, i.e. the current directory (.) and the ./externals directory which will contain deferred classes that provide access to external features.&lt;br /&gt;
&lt;br /&gt;
 ./&lt;br /&gt;
./externals/ &lt;br /&gt;
&lt;br /&gt;
zlib/loadpath.se will list the clusters used by the library itself, i.e. its dependencies. Like the previous it is a plain text file containing directories or other loadpaths file (Ok... I'm not assuming proficiency with GNU-Eiffel here). Zlib is quite a &amp;quot;plain&amp;quot; library and does not have dependencies - here we are speaking of dependencies of the Eiffel wrappers - so he only shall list only the base cluster of a wrapper library, ../common/loadpath.se and the soad-path of the library itself &amp;lt;./library/loadpath.se/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 ../common/loadpath.se&lt;br /&gt;
./library/loadpath.se &lt;br /&gt;
&lt;br /&gt;
Low-level access to functions&lt;br /&gt;
&lt;br /&gt;
Let's write some low-level classes. We will put the functions found in the include file /usr/include/zlib.h in the class ZLIB_EXTERNALS and the low-level getters and setters features for the structure z_stream structure in the class Z_STREAM_STRUCT (this scheme is also used by eiffel-gcc-xml tool; I know it is simplicistic and that it could produce name-clashes but it has worked fine until now. ). Here's some examples&lt;br /&gt;
C function	Eiffel feature&lt;br /&gt;
const char * zlibVersion (void);	zlib_version: POINTER&lt;br /&gt;
int deflateInit (z_streamp strm, int level);	deflate_init (a_stream: POINTER; a_level: INTEGER_32): INTEGER_32&lt;br /&gt;
int deflate (z_streamp strm, int flush);	deflate (a_stream: POINTER;a_flush: INTEGER_32): INTEGER&lt;br /&gt;
int deflateEnd (z_streamp strm);	deflate_end (a_stream: POINTER): INTEGER&lt;br /&gt;
int inflateInit (z_streamp strm);	inflate_init (a_stream: POINTER): INTEGER&lt;br /&gt;
int inflate (z_streamp strm, int flush);	inflate (a_stream: POINTER; a_flush: INTEGER): INTEGER&lt;br /&gt;
int inflateEnd (z_streamp strm);	inflate_end (a_stream: POINTER): INTEGER&lt;br /&gt;
&lt;br /&gt;
As you can see I have turned camelCaseFunction into camel_case_function which is far more in tune with Eiffel style. Int is actually an INTEGER_32 or only INTEGER (it still don't matter, even if I suspect that it will do soon: world is already filled with 64-bit machines and literally billion of devices with 4,8,16 bit CPU are in use today, not counting GPGPU)&lt;br /&gt;
&lt;br /&gt;
Let's take a look at ZLIB_EXTERNALS. You'll see many entries like&lt;br /&gt;
&lt;br /&gt;
 inflate_init (a_stream: POINTER): INTEGER is -- int inflateInit (z_streamp strm); &lt;br /&gt;
	external &amp;quot;plug_in&amp;quot; &lt;br /&gt;
	alias &amp;quot;{&lt;br /&gt;
		location: &amp;quot;${eiffel_libraries}/plugins&amp;quot; &lt;br /&gt;
		module_name: &amp;quot;zlib&amp;quot;&lt;br /&gt;
		feature_name: &amp;quot;inflateInit&amp;quot;&lt;br /&gt;
	}&amp;quot;&lt;br /&gt;
	end &lt;br /&gt;
&lt;br /&gt;
this entry tells us that the Eiffel feature &amp;quot;inflate_init&amp;quot; refers to the symbol &amp;quot;inflateInit&amp;quot; in the module &amp;quot;zlib&amp;quot; of the plugins found in the directory.&lt;br /&gt;
&lt;br /&gt;
Entries like this are the only &amp;quot;esoteric&amp;quot; Eiffel code you will see. All the details required to interface to C, to link to the actualy library and how to compile the code written in other languages is handled by the plugin part.&lt;br /&gt;
&lt;br /&gt;
Without using plugins every Eiffel program should know all the details required to compile a C application with zlib. It would require to always use ACE files - even for simple examples - because you need to provide proper &amp;quot;c_compiler_options&amp;quot; and &amp;quot;linker_options&amp;quot;; for a single, simple library like Zlib it looks a tame task, only requiring to add -lzlib to the &amp;quot;linker_options&amp;quot; but when you start building real-world application things will get complicated really fast.&lt;br /&gt;
&lt;br /&gt;
See SmartEiffel documentation on plugins.&lt;br /&gt;
&lt;br /&gt;
All those functions returns an integer with standardized values #defined in the C header. We will wrap them in the deferred class ZLIB_CONSTANTS.&lt;br /&gt;
&lt;br /&gt;
Deferred? Why deferred? We want to avoid the Eiffel programmer the burden to deal with all the details that C requires - otherwise we would have used plain C - so we do not want him/her to directly use that libraries. Deferred classes cannot have creation clauses so we are sure that no objects of type ZLIB_EXTERNALS and ZLIB_CONSTANTS will be created. They are helper classes that will be either inherited from or - more properly - inserted into ZLIB_STREAM and its effective heirs, ZLIB_INPUT_STREAM and ZLIB_OUTPUT_STREAM.&lt;br /&gt;
&lt;br /&gt;
Making sure that the Eiffel developer will not use low-level features directly is the main reason why all the external features are not exported to anyone else, using the syntax feature {} -- External calls. This way only heirs - conforming or not - of that class can use them; for people coming from C++ it's like having private functions members.&lt;br /&gt;
C types&lt;br /&gt;
&lt;br /&gt;
Here's a quick conversion table for various C types&lt;br /&gt;
C type	Eiffel type&lt;br /&gt;
int	INTEGER;&lt;br /&gt;
short int	INTEGER_16&lt;br /&gt;
long int	INTEGER_32 or 64&lt;br /&gt;
long long int	INTEGER_64&lt;br /&gt;
int8_t (defined at stdint.h, ISO C 99)	INTEGER_8&lt;br /&gt;
int16_t 	INTEGER_16&lt;br /&gt;
int32_t	INTEGER_32&lt;br /&gt;
int64_t	INTEGER_64&lt;br /&gt;
unsigned int	NATURAL&lt;br /&gt;
unsigned short int	NATURAL_16&lt;br /&gt;
unsigned long int	NATURAL_32 on 32-bit, NATURAL_64 on 64.bit. See long int&lt;br /&gt;
unsigned long long int	NATURAL_64&lt;br /&gt;
signed/unsigned char	CHARACTER&lt;br /&gt;
float	REAL_32&lt;br /&gt;
double	REAL_64&lt;br /&gt;
long double	REAL_EXTENDED&lt;br /&gt;
char	BOOLEAN&lt;br /&gt;
void* or any other pointer	POINTER&lt;br /&gt;
&lt;br /&gt;
Some notes:&lt;br /&gt;
&lt;br /&gt;
    intXX_t are defined in GNU systems (Linux Glibc, CygWin and similar).&lt;br /&gt;
    Currently INTEGER is mere alias for INTEGER_32 but this is bound to change in future version of SmartEiffel. Personally I think that it should be &amp;quot;the integer type with the same bit-lenght of C int&amp;quot;.&lt;br /&gt;
    A nice feature of long int is that is could be longer that int. So we can't really be sure whenever it is 32 or 64 bit. Usually it is an INTEGER_32 on 32-bit machines and INTEGER_64 on 64-bit machines. See this post on the SmartEiffel mailing list.&lt;br /&gt;
    The same problem applies for long unsigned int: NATURAL_32 on 32-bits and NATURAL_64 on 64-bit. This mismatch can be quite problematic and it will be discussed-addressed later.&lt;br /&gt;
    At the time of writing of this document SmartEiffel has some know issues regarding NATURALs types. If they actually do cause bugs there is an (unsatisfactory) workaround: use a bigger INTEGER. This implies a hidden conversion at C level and bargains correctness with a little waste of space and worse performance. Do not use an INTEGER of same size: it &amp;quot;usually&amp;quot; works nicely but this is a known source of nasty bugs since you will soon or later it will silently overflow.&lt;br /&gt;
&lt;br /&gt;
An enlighting explanation about C variable types and declarations can be read on Wikipedia (I find particurarly confusing - expecially for the novice - that char is at the same time an 8-bit integer and an encoding for ASCII characters. Most programmers could always end up thinking about it only as a character. After more than 30 years they could have called it &amp;quot;byte&amp;quot;. Yet this behaviour is fit the spirit of C very well. ).&lt;br /&gt;
&lt;br /&gt;
The resulting ZLIB_CONSTANTS class is almost boring and undocumented. I maintained the documentation level found in the original documentation, since those are values that will be handled only by the implementation of the wrapper.&lt;br /&gt;
&lt;br /&gt;
Have a look at WRAPPER_HANDLER. Eiffel has the ability to selectively export Any class that needs to access some of the&lt;br /&gt;
Access to structure field&lt;br /&gt;
&lt;br /&gt;
Let's wrap the z_stream structure (the structure name is actually struct z_stream_s typedeffed to z_stream during its definition); the wrapper will have a similar two layer design: the low-level Z_STREAM_STRUCT will be a deferred class, with feature {} -- Hidden, low-level getters and setters. This class will also have a feature struct_size: INTEGER that will be the value of sizeof(z_stream)&lt;br /&gt;
&lt;br /&gt;
Field named FooBar in the struct my_struct will be read with the Eiffel query my_struct_get_foo_bar and set with the command my_struct_set_foo_bar. Remember that those are low-level features; references to other objects will be pointers and its signature will be one of an external function: the first argument will be always the address of - a POINTER to - the wrapped struct.&lt;br /&gt;
Naming of placeholder arguments&lt;br /&gt;
&lt;br /&gt;
Placeholder names should be chosen in a way that makes the documentation of the feature in English as smooth as possible for a proper argument placeholder for the Gnu-Eiffel language. &amp;quot;CamelCase&amp;quot; will be translated into &amp;quot;a_camel_case&amp;quot;, &amp;quot;ENOO&amp;quot; is translated into &amp;quot;an_enoo&amp;quot;. Eventual underscores in front of `a_name' are removed: &amp;quot;__foo&amp;quot; becomes &amp;quot;a_foo&amp;quot;. The prefixed preposition is added to make clearer that the name refers to a generic value, not to a particular one. Always tries to use a placeholder that can be directly put in the feature's documentation without paraphrase.&lt;br /&gt;
ZLIB_STREAM, at last.&lt;br /&gt;
&lt;br /&gt;
So let's write something that will be used in an actual Eiffel program! We start writing ZLIB_STREAM from file common/skeleton that provides us the usual LGPL-2.1-or-later headers. It inserts ZLIB_EXTERNALS and Z_STREAM_STRUCT.&lt;br /&gt;
&lt;br /&gt;
TODO: finish this&lt;br /&gt;
The &amp;quot;common&amp;quot; cluster&lt;br /&gt;
&lt;br /&gt;
The basic building blocks of a wrapper library have been put in the common cluster.&lt;br /&gt;
&lt;br /&gt;
The WRAPPER class it the &amp;quot;fundamental&amp;quot; one even if embarassingly simple. Its only effective field (i.e.: stored, non-computed) is the handle POINTER. It shall handle the allocation and deallocation of the memory referred by handle so it is an heir of DISPOSABLE but it doesn't define dispose because there is no such a thing like a default memory handling in C.&lt;br /&gt;
&lt;br /&gt;
C_STRUCT inherits from WRAPPER and provides default implementations for copy, is_equal and from_external_pointer features; it introduces the deferred &amp;quot;struct_size&amp;quot; query which should give the same result of C operator sizeof(MyStruct).&lt;br /&gt;
&lt;br /&gt;
Note that there are - at least conceptually - other potentially heirs of WRAPPER, like pointers to functions&lt;br /&gt;
&lt;br /&gt;
Many C libraries often return const char* strings. Those strings shall not be modified and their memory will be handled by the library; by all other means they actually are plain strings. A correct behaviour is to write foo: STRING is do create Result.from_external_copy(a_function_returning_a_const_char_pointer(handle)) end; a STRING is meant to be manipulated and changed and has control on the memory of its content. Here we are instead given a piece of memory holding some text that is &amp;quot;mostly read-only&amp;quot; whose control is held by the library. To provide correct behaviour STRING must copy the buffer, from_external can't be used. CONST_STRING is an effective heir of STRING that provides efficient wrapping of &amp;quot;const strings&amp;quot;. It is usable like any other STRING but all the changes are made to a separe buffer preserving the original content - we are actually not allowed to change it. No further memory is allocated when a CONST_STRING is created: the buffer returned by the C library is used directly. For example, GTK+ has many calls like const gchar* gtk_entry_get_text (GtkEntry *entry); Memory efficiency is achieved making changing features slower. If you need to change its content consider using its feature string to get a new (non-const) STRING with the same content.&lt;br /&gt;
&lt;br /&gt;
TODO: add proper description about:&lt;br /&gt;
CACHING_FACTORY&lt;br /&gt;
C_ARRAY&lt;br /&gt;
COMPARABLE_C_STRUCT&lt;br /&gt;
COMPARABLE_WRAPPER&lt;br /&gt;
CONST_STRING&lt;br /&gt;
C_OWNED&lt;br /&gt;
C_STRUCT&lt;br /&gt;
EIFFEL_OWNED&lt;br /&gt;
ENUM&lt;br /&gt;
EXPANDED_WRAPPER&lt;br /&gt;
GLOBAL_CACHE&lt;br /&gt;
GLOBALLY_CACHED&lt;br /&gt;
HASHABLE_WRAPPER&lt;br /&gt;
ITERATOR_ON_C_ARRAY&lt;br /&gt;
LINKED_STRING&lt;br /&gt;
MIXED_MEMORY_HANDLING&lt;br /&gt;
NULL_TERMINATED_C_ARRAY&lt;br /&gt;
NULL_TERMINATED_STRING_ARRAY&lt;br /&gt;
POINTER_HANDLING&lt;br /&gt;
REFERENCE_COUNTED&lt;br /&gt;
SHARED&lt;br /&gt;
STRING_ARRAY&lt;br /&gt;
STRING_ARRAY_ITERATOR&lt;br /&gt;
WRAPPER_COLLECTION&lt;br /&gt;
WRAPPER_DICTIONARY&lt;br /&gt;
WRAPPER&lt;br /&gt;
WRAPPER_FACTORY&lt;br /&gt;
WRAPPER_HANDLER&lt;br /&gt;
WRAPPERS_CACHE&lt;br /&gt;
Enumerations&lt;br /&gt;
&lt;br /&gt;
There are two general tecnique to wrap an enum.&lt;br /&gt;
&lt;br /&gt;
    Put all the possible values of enumerations into a class as INTEGER constants accessibile to the user of your library. This is mostly similar to the actual usage of an enumeration. Each and every feature that accept an enum value as argument will need a precondition like is_valid_foo (a_foo_value)&lt;br /&gt;
    Create a new type. In fact an enumeration is an INTEGER that can assume only precise and prestabilited values, so that its value is correct and consistent all the times. Class ENUM provides some facilities to achieve this. It shall be used in classes like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    -- This file have been created by eiffel-gcc-xml.&lt;br /&gt;
    -- Any change will be lost by the next execution of the tool.&lt;br /&gt;
&lt;br /&gt;
    expanded class PANGO_WEIGHT&lt;br /&gt;
&lt;br /&gt;
    insert ENUM&lt;br /&gt;
&lt;br /&gt;
    creation default_create&lt;br /&gt;
    feature -- Validity&lt;br /&gt;
    	is_valid_value (a_value: INTEGER): BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := ((a_value = pango_weight_ultralight) or else&lt;br /&gt;
    				(a_value = pango_weight_light) or else&lt;br /&gt;
    				(a_value = pango_weight_normal) or else&lt;br /&gt;
    				(a_value = pango_weight_semibold) or else&lt;br /&gt;
    				(a_value = pango_weight_bold) or else&lt;br /&gt;
    				(a_value = pango_weight_ultrabold) or else&lt;br /&gt;
    				(a_value = pango_weight_heavy))&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature -- Setters&lt;br /&gt;
    	default_create,  set_ultralight is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_ultralight&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_light is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_light&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_normal is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_normal&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_semibold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_semibold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_bold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_bold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_ultrabold is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_ultrabold&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	 set_heavy is&lt;br /&gt;
    		do&lt;br /&gt;
    			value := pango_weight_heavy&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature -- Queries&lt;br /&gt;
    	is_ultralight: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_ultralight)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_light: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_light)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_normal: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_normal)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_semibold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_semibold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_bold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_bold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_ultrabold: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_ultrabold)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    	is_heavy: BOOLEAN is&lt;br /&gt;
    		do&lt;br /&gt;
    			Result := (value=pango_weight_heavy)&lt;br /&gt;
    		end&lt;br /&gt;
&lt;br /&gt;
    feature {WRAPPER, WRAPPER_HANDLER} -- Low level values&lt;br /&gt;
    	pango_weight_ultralight: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_ULTRALIGHT&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_light: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_LIGHT&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_normal: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_NORMAL&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_semibold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_SEMIBOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_bold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_BOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_ultrabold: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_ULTRABOLD&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    	pango_weight_heavy: INTEGER is&lt;br /&gt;
    		external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
     		alias &amp;quot;{&lt;br /&gt;
     			location: &amp;quot;foo&amp;quot;&lt;br /&gt;
     			module: &amp;quot;bar&amp;quot;&lt;br /&gt;
     			feature_name: &amp;quot;PANGO_WEIGHT_HEAVY&amp;quot;&lt;br /&gt;
     			}&amp;quot;&lt;br /&gt;
     		end&lt;br /&gt;
&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    As you can see each possible value has a setter command (set_light, set_normal and so on) and a boolean query (is_light, is_normal). As usual low-level values are accessible only by a WRAPPER or a WRAPPER_HANDLER.&lt;br /&gt;
&lt;br /&gt;
Using eiffel-gcc-xml&lt;br /&gt;
&lt;br /&gt;
Have a look at the manually written ZLIB_EXTERNALS. Eiffel is a language that is meant to be easy to the reader at the cost of being verbose. All that text of source to access a bunch of C functions. Think about serious libraries that have literally thousands of functions, structures, and enumeration! Writing the low level side of those wrappers is a really long, tedious task, the kind of task that people usually would leave to an unfaticable, astonishgly fast yet quite dumb worker, a computer. Andreas Leitner - who is surely quite smarter than myself - wrote a C parser for his Eiffel Wrapper Generator. I do not have neither the time neither the abilities of Andreas but it seems that I'm more lucky than him. In fact by the time I got serious with this project, people with the same problem, requiring tons of wrappers for Python, produced gcc-xml. These days parsing XML is a considered a common task, a task to be left to standard libraries, so SmartEiffel have an XML parser. So I wrote a little tool name &amp;quot;eiffel-gcc-xml&amp;quot; that takes the output of gcc-xml as input to produce the low-level &amp;quot;external&amp;quot; classes that we need to access functions, structures and enumerations.&lt;br /&gt;
&lt;br /&gt;
Well, it actually requires a little more work since it breaks very often.&lt;br /&gt;
Memory handling&lt;br /&gt;
C_STRUCT is a wrapper for a data structure implemented in C programming language using a structure.&lt;br /&gt;
It does not make any assumption about memory handling; the developer of a SmartEiffel wrapper of a C library has to inherit to create a proper wrapper for it the developer shall inherit both from this class and from classes providing memory handling behavior, depending on how structure's memory shall be handled. This is decided  case-by-case by C library.&lt;br /&gt;
Currently available memory handling classes are:&lt;br /&gt;
&lt;br /&gt;
    C_OWNED: memory is always handled by the underlying C library.&lt;br /&gt;
    EIFFEL_OWNED: once created memory is fully handled by Eiffel runtime, usually with the Garbage Collector.&lt;br /&gt;
    GLOBALLY_CACHED: Until disposed by Eiffel the wrapper registered in wrappers dictionary will be the unique wrapper used on the Eiffel side.&lt;br /&gt;
    MIXED_MEMORY_HANDLING: whose memory can either by handled by the Eiffel library or by the underlying C code. Who handles memory is decided on a per-object based on the value of the flag `is_shared': handle will not be freed on dispose of the Eiffel wrapper object, when `is_shared' is true.&lt;br /&gt;
    REFERENCE_COUNTED: memory is handled thought reference counting, i.e.GObject&lt;br /&gt;
&lt;br /&gt;
Add proper examples of the various memory handling classes.&lt;br /&gt;
Implementing collections&lt;br /&gt;
Quite often objects are stored into containers or collections like arrays, linked lists, dictionaries, hashed-tables and so on. Many C libraries provides their own implementation of the classic containers, for example the GLib library provides GList, GSList, GHashTable and many others.&lt;br /&gt;
A WRAPPER_COLLECTION is a COLLECTION implemented wrapping some facilities offered by the wrapped C library, like GLib's linked list GList.&lt;br /&gt;
When you wrap those data structures you will encounter two kinds of problems:&lt;br /&gt;
&lt;br /&gt;
    Pointer returned by C containers could be newly allocated, not already wrapped by the Eiffel wrapper or already wrapper by the Eiffel wrapper. You can't naively create a new WRAPPER every time. Beside the obvious waste of memory and the stress you put on the garbage collector you will break most postconditions and invariant of a COLLECTION, since things that seems obvious like&lt;br /&gt;
&lt;br /&gt;
 do_stuff (my_collection: WRAPPER_COLLECTION[ITEM]) is require&lt;br /&gt;
my_collection/=Void not my_collection.is_empty local a,b: ITEM do a :=&lt;br /&gt;
my_collection.first b := my_collection.first check will_fail: a = b end end&lt;br /&gt;
&lt;br /&gt;
In fact a and b will be different wrappers referring to the same underlying C structure. A WRAPPER_COLLECTION shall  avoid this repeated, unnecessary and wrong creation of WRAPPERs, that will breaks invariants and post-conditions of a COLLECTION.&lt;br /&gt;
A solution is to inherit from WRAPPERS_CACHE, initializing cache at creation time and keeping it updated during usage. Cache's key is the address (pointer) to the wrapped C structure, value is the corresponding Eiffel wrapper. This way you can get back an already-created Eiffel wrapper.&lt;br /&gt;
Classes can implement different scheme; for example G_OBJECT_LIST retrieve the reference to the eventual WRAPPER directly from underlying GObject.&lt;br /&gt;
&lt;br /&gt;
    The container has no means to know how it shall create the wrapper for it, since C does not have the notion of generic, strongly typed container. The effective type of the containee is either not know by WRAPPER_COLLECTION or worse its conteinees  could actually belong to different classes, sharing a common ancestor.&lt;br /&gt;
    Since each library has its own idea on how the programmer shall handle �memory when dealing with containers an effective, non-deferred heir of WRAPPER_COLLECTION shall implement `wrapper' feature that given a pointer creates or retrieve a WRAPPER of the fittest class. Usually &amp;quot;plain&amp;quot; usage could return a fixed type; more elaborate type systems like GObject could provide the facilities necessary to pick a useful Eiffel type.&lt;br /&gt;
&lt;br /&gt;
TODO: finish it.&lt;br /&gt;
Comparability and hashability&lt;br /&gt;
Some collections does not require anything in particular to their containee, like arrays or linked lists. Other collections needs either to compare their containee or to obtain an hash value from it. Therefore wrapper classes that are conceptually comparable or hashable shall inherit from COMPARABLE_WRAPPER and HASHABLE_WRAPPER respectively so they could be stored into collections that requires such abilities.&lt;br /&gt;
How to adapt old wrappers&lt;br /&gt;
(This is almost obsolete) Previous design was a black-or-white design: a class was either Eiffel-owned or not; C_STRUCT's are &amp;quot;owned&amp;quot; by the Eiffel code, and the Eiffel side should keep then longest lived reference to this struct; SHARED_C_STRUCT modelled the non-Eiffel-owned.&lt;br /&gt;
This approach is overly simplicistic since real-life libraries implement a wide spectrum of memory handling policies. One solutions does not fit all needs. Study the documentation of the library and pick the right memory handling Eiffel class.&lt;br /&gt;
The long int problem&lt;br /&gt;
&lt;br /&gt;
Shortly it could be solved having two separate clusters one for 32bit, one for 64 bit where a deferred class defines a parameterless query for anchored declaration like&lt;br /&gt;
&lt;br /&gt;
long_int: INTEGER_32 is do end&lt;br /&gt;
&lt;br /&gt;
long_int: INTEGER_64 is do end&lt;br /&gt;
&lt;br /&gt;
but this looks like an unfeasible hack to me, at least now. Currently it is the only available answer; a &amp;quot;proper&amp;quot; solution would require changes in both the compiler and the standard library. I would like to know how ISE solved this.&lt;br /&gt;
&lt;br /&gt;
GObject-based libraries&lt;br /&gt;
&lt;br /&gt;
Nowadays many libraries are based on the GLib Object System also known as Gobject. This library &amp;quot;provides a portable object system and transparent cross-language interoperability&amp;quot;. It is used as the basic building block for literally hundeds of libraries and applications; in fact the command apt-cache rdepends libglib2.0-0 |wc -l told me that more than 2200 applications and libraries depend on either GLib or GObject.&lt;br /&gt;
&lt;br /&gt;
GObject implement its own classed type system. With the exception of basic types (and some other subtleties I will write later) all objects are structures referred by pointer, i.e. non-expanded classes in Eiffellese; the type of each object is identified by a number, a GType which has an associated structure to describe the class - the type - itself. During startup of the Eiffel application the wrapper library will register for each type name (i.e. GtkWindow, GtkButton....) it wraps an agent that given a pointer creates an Eiffel wrapper object for the creation_agents dictionary, with a call similar to creation_agents.put (agent create_gtk_window, &amp;quot;GtkWindow&amp;quot;), given the feature create_gtk_window (p: POINTER): GTK_WINDOW is do create Result.from_external_pointer(p) end.&lt;br /&gt;
&lt;br /&gt;
A Gobject can store arbitrary properties into itself. We use this to store a reference pointer to its Eiffel wrapper.&lt;br /&gt;
&lt;br /&gt;
When we receive a pointer to a Gobject the G_OBJECT_FACTORY first looks if this Gobject already has an attacked wrapper (an effective heir of G_OBJECT). Otherwise it ask the Gobject its GType and the associated class-name. It this class-name has a creation agent the wrapper is created invoking the retrieved creation agent; otherwise we recursively look at its parent class until we find a type that has a corresponding creation agent.&lt;br /&gt;
&lt;br /&gt;
When an effective G_OBJECT heir is actually created either explicitly because we know for sure its type or throught a creation agent the address of the wrapper is stored in the property &amp;quot;eiffel-wrapper&amp;quot; using the C function g_object_set_qdata (see store_eiffel_wrapper in G_OBJECT).&lt;br /&gt;
&lt;br /&gt;
As usual this approach is both correct, memory efficient and collection-friendly (see &amp;quot;Implementing collections&amp;quot; earlier) at the cost of being computing intensive. There are times when the wrapper library has to create transient wrappers for shortly lived objects. Here enters secondary wrappers, or G_OBJECTs that are not referred-by the GOBject they refer to. Letting code speak: having a_gtk_window_ptr: POINTER; my_window: GTK_WINDOW; factory: G_OBJECT_EXPANDED_FACTORY check create my_window.secondary_wrapper_from(a_gtk_window_ptr) /= factory.wrapper(a_gtk_window_ptr) end will hold and also create my_window.main_wrapper_from(a_gtk_window_ptr); check my_window = factory.wrapper(a_gtk_window_ptr) end will be successfully passed. The difference is that the first is only an allocation of a smallish object (few bytes) while the latter could potentially require several looks-up into a dictionary plus an O(n) search into the GObject properties (during g_object_get_qdata used to see if a wrapper does actually exist)&lt;br /&gt;
&lt;br /&gt;
TODO: show how to wrap a typical GObject-using library, like Gnome's GConf configuration system.&lt;br /&gt;
Commit's policy&lt;br /&gt;
&lt;br /&gt;
    There is no strict rule...&lt;br /&gt;
    Ideally each commit should provide compilable code and working examples.&lt;br /&gt;
    Provided examples and classes can be unfinished and uncomplete, can contain warnings, empty features and so on. My motto is &amp;quot;something is better than nothing&amp;quot;.&lt;br /&gt;
    it is nice to tell other developers what are you working on; anemail on eiffel-libraries-devel@gna.org suffice.&lt;br /&gt;
    I promise I won't track you with a 9-tail cat to bash you if you commit uncompilable code.&lt;br /&gt;
    Code that compiles is a good thing. Wisely designed code that compiles is better, since it has better performances; but I prefer published, working code even if has no state-of-the-art performances instead of&lt;br /&gt;
&lt;br /&gt;
Various very old notes&lt;br /&gt;
Those notes are left here to be worked on.&lt;br /&gt;
&lt;br /&gt;
Suggested&lt;br /&gt;
Start copying original documentation into an Eiffel class and comment it out entirely.&lt;br /&gt;
Add proper indexing clauses, then progressively convert it into Eiffel from top to bottom.&lt;br /&gt;
Sketch difficoult features into comments.&lt;br /&gt;
This behaviour is not meant to pile rubbish, but to quickly know how much work we still have to do.&lt;br /&gt;
This means that the resulting Eiffel  classes will be a derivative work of the original documentation of the library. This is usally not a problem these days because documentation is often automatically extracted from sources, so the Eiffel wrapper will end up having the same license of the wrapper library; for example our GTK+ wrapper being a derivative work of the actual GTK+ C library must abide its LGPL license.&lt;br /&gt;
All the infrastructure of GTK+, including GObject are - in my humble opinion - explicitly designed to make the life easy for people writing wrappers for loosely-typed languages such as Python, Perl and other scriptiong languages. This (sadly) means that life for heavily/strongly-typed languages such as Eiffel are make annoying.&lt;br /&gt;
Objects like closures and other amenities like that won't be wrapped until the rest is done and working.&lt;br /&gt;
Enumeration classes will be automatically created by the incoming eiffel-gcc-xml tool.&lt;br /&gt;
General&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Plugins&amp;diff=1770</id>
		<title>Plugins</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Plugins&amp;diff=1770"/>
		<updated>2013-08-08T10:51:33Z</updated>

		<summary type="html">&lt;p&gt;Tybor: /* C Generation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Smarteiffel]]&lt;br /&gt;
&lt;br /&gt;
Plugins are a means to augment in a spectactular manner the capabilities of SmartEiffel, by incorporating libraries which have the color, smell, and taste of the standard libraries. In fact, it's an extension of the standard Eiffel mechanism, [[externals]].&lt;br /&gt;
&lt;br /&gt;
The goal of plugins is independence from the [[Glossary#BackEnd|back-end]]. This means that, potentially, the ''same'' library could be used simultaneously by [[compile_to_c]] and [[compile_to_jvm]]. Note that in the future we want to provide other [[Glossary#BackEnd|back-ends]]. In this case, the plugin system will become more important.&lt;br /&gt;
&lt;br /&gt;
== How does it work&amp;amp;nbsp;? ==&lt;br /&gt;
&lt;br /&gt;
A plugin is made up of two interdependent parts&amp;amp;nbsp;:&lt;br /&gt;
&lt;br /&gt;
* the Eiffel side, which provides an interface usable by other Eiffel objects&amp;amp;nbsp;;&lt;br /&gt;
* the external side, which implements the plugin's interface for one or several  [[Glossary#BackEnd|back-ends]] (for example, C and Java).&lt;br /&gt;
&lt;br /&gt;
The Eiffel side is 100% Eiffel code, and it uses ''external'' features that allow crossing the barrier to the other side of the plugin. The barrier is managed by SmartEiffel&amp;amp;nbsp;: the compiler associates external functions with the ''external'' features using configuration files furnished by the plugin.&lt;br /&gt;
&lt;br /&gt;
== Eiffel Side ==&lt;br /&gt;
&lt;br /&gt;
The Eiffel side uses ''external'' features. The syntax is as follows:&lt;br /&gt;
&lt;br /&gt;
 feature&lt;br /&gt;
    my_plugin_feature is&lt;br /&gt;
       external &amp;quot;plug_in&amp;quot;&lt;br /&gt;
       alias &amp;quot;{&lt;br /&gt;
          location: &amp;quot;/path/to/my/plugins&amp;quot;&lt;br /&gt;
          module_name: &amp;quot;my_plugin&amp;quot;&lt;br /&gt;
          feature_name: &amp;quot;feature&amp;quot;&lt;br /&gt;
       }&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Of course, a feature can take arguments and return a result&amp;amp;nbsp;! (after all, it's an ''external'') ;-)&lt;br /&gt;
&lt;br /&gt;
'''Beware''' however, it is necessary to only pass and return only basic ''expanded'' base types&amp;amp;nbsp;:&lt;br /&gt;
([[library_class:INTEGER|&amp;lt;TT&amp;gt;INTEGER&amp;lt;/TT&amp;gt;]], [[library_class:BOOLEAN|&amp;lt;TT&amp;gt;BOOLEAN&amp;lt;/TT&amp;gt;]], etc.) or use [[library_class:POINTER|&amp;lt;TT&amp;gt;POINTER&amp;lt;/TT&amp;gt;]] (common usage: &amp;lt;TT&amp;gt;a_string.to_external&amp;lt;/TT&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
* '''location''' indicates the directory where you store one or many of your plugins. This path can contain environment variables (either true system environment variables, or variables definined in the &amp;lt;TT&amp;gt;[Environment]&amp;lt;/TT&amp;gt; section of your [[Configuration file|configuration file]]).&lt;br /&gt;
For example, the standard SmartEiffel libraries are defined by using the following ''location'':&lt;br /&gt;
 location: &amp;quot;${sys}plugins&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* '''module_name''' contains the plugin name itself. This must be the name of a sub-directory of ''location'' that contains a directory for a specific [[Glossary#BackEnd|back-end]] (for example, &amp;lt;TT&amp;gt;c&amp;lt;/TT&amp;gt; for the C generator, &amp;lt;TT&amp;gt;java&amp;lt;/TT&amp;gt; for the Java generator). The content of each of these sub-repositories depends on the generator, and is specified below.&lt;br /&gt;
&lt;br /&gt;
* '''feature_name''' is the name of the feature, function, method etc. named by the [[Glossary#BackEnd|back-end]] (for example, C calls functions, Java calls methods). What they're called is not important&amp;amp;nbsp;: they're all features ;-)&lt;br /&gt;
&lt;br /&gt;
== Dark side ==&lt;br /&gt;
&lt;br /&gt;
=== C Generation ===&lt;br /&gt;
&lt;br /&gt;
The C [[Glossary#BackEnd|back-end]] uses a sub-directory of your plugin named &amp;lt;TT&amp;gt;c&amp;lt;/TT&amp;gt;. the files used are:&lt;br /&gt;
&lt;br /&gt;
* all the &amp;lt;TT&amp;gt;.c&amp;lt;/TT&amp;gt; files, which are included in the compiler-generated C files&lt;br /&gt;
* all the &amp;lt;TT&amp;gt;.h&amp;lt;/TT&amp;gt; files, which are included in the compiler-generated header file&lt;br /&gt;
* the &amp;lt;TT&amp;gt;libs&amp;lt;/TT&amp;gt; file, which contains a description of the native libraries to link&lt;br /&gt;
* the &amp;lt;TT&amp;gt;paths&amp;lt;/TT&amp;gt; file, which contains a description of the paths used to find the libraries&lt;br /&gt;
* the &amp;lt;TT&amp;gt;includes&amp;lt;/TT&amp;gt; file, which contains a description of the paths used to find header files&lt;br /&gt;
* the &amp;lt;TT&amp;gt;auto_init&amp;lt;/TT&amp;gt; file, which contains a description of a possible initialization function called at the very start of the program&lt;br /&gt;
* the &amp;lt;TT&amp;gt;cecil.se&amp;lt;/TT&amp;gt; file, which is a [[cecil]] description automatically taken into account&lt;br /&gt;
* the &amp;lt;TT&amp;gt;compiler_options&amp;lt;/TT&amp;gt; and the &amp;lt;TT&amp;gt;linker_options&amp;lt;/TT&amp;gt; files which are passed verbatim to the underlying strata of compiling chain, usually a C compiler where they are parsed with a shell. They usually contains invocation of tools that gives the mutable correct flags to compile and link the library, i.e. pkg-config.&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;TT&amp;gt;.c&amp;lt;/TT&amp;gt; and &amp;lt;TT&amp;gt;.h&amp;lt;/TT&amp;gt;''' files are included in alphabetic order.&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;TT&amp;gt;includes&amp;lt;/TT&amp;gt;, &amp;lt;TT&amp;gt;libs&amp;lt;/TT&amp;gt; and &amp;lt;TT&amp;gt;paths&amp;lt;/TT&amp;gt;''' files use an identical syntax to that of the [[configuration file]], but with different keys:&lt;br /&gt;
* The sections carry the operating system name, the ''flavor'' from the configuration file and finally the C compiler used, in that order and separated by a period. If the plugin doesn't depend on one of these elements, it can be omitted.&lt;br /&gt;
* The keys in these files are only informative; however, the values are used to generate command line calls to the C compiler.&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;TT&amp;gt;auto_init&amp;lt;/TT&amp;gt;''' file uses the same syntax as the [[configuration file]], but with yet other keys:&lt;br /&gt;
* The default section (i.e. the first one, without a name between square brackets) contains one key, &amp;lt;TT&amp;gt;function&amp;lt;/TT&amp;gt; which value gives the name of the initialization function to call at the start of the system&lt;br /&gt;
* Any other section describes plugin dependencies. The must have two keys: &amp;lt;TT&amp;gt;location&amp;lt;/TT&amp;gt; and &amp;lt;TT&amp;gt;module_name&amp;lt;/TT&amp;gt; which have the same meaning as in the Eiffel alias. Those dependencies describe initialization order (initialize dependencies first).&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;TT&amp;gt;cecil.se&amp;lt;/TT&amp;gt;''' file is automatically included as it were specified by the &amp;lt;TT&amp;gt;-cecil&amp;lt;/TT&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
For examples, you can examine the configurations files for Vision or ncurses. There is also a tutorial called '''mini_gtk''' (in the &amp;lt;TT&amp;gt;SmartEiffel/tutorial/plugin&amp;lt;/TT&amp;gt; directory).&lt;br /&gt;
&lt;br /&gt;
'''Note''': when there are no arguments, names are generated without parentheses. This permits to attributes, variables and to macros. The absence of parentheses is not then a bug but a desired behavior. In the case where one wants  access to a function without an argument, it suffices to use a macro to replace a name without parentheses with the name of the function to call.&lt;br /&gt;
&lt;br /&gt;
=== Java Generation===&lt;br /&gt;
&lt;br /&gt;
For the Java [[Glossary#BackEnd|back-end]], the plugin sub-directory must be named &amp;lt;TT&amp;gt;java&amp;lt;/TT&amp;gt;.&lt;br /&gt;
The compiler uses the following files&amp;amp;nbsp;:&lt;br /&gt;
&lt;br /&gt;
* the &amp;lt;TT&amp;gt;.java&amp;lt;/TT&amp;gt; files are compiled using the command line options and/or from the configuration file (see [[compile_to_jvm]] for more detail). The &amp;lt;TT&amp;gt;.class&amp;lt;/TT&amp;gt; files so generated are automatically copied in the compilation directory of the program.&lt;br /&gt;
* the &amp;lt;TT&amp;gt;.class&amp;lt;/TT&amp;gt; files, if they are present and if they are more recent than the corresponding &amp;lt;TT&amp;gt;.java&amp;lt;/TT&amp;gt; files are utilized in place of a compilation of the &amp;lt;TT&amp;gt;.java&amp;lt;/TT&amp;gt; files, in the same manner as the  &amp;lt;TT&amp;gt;make&amp;lt;/TT&amp;gt; command under UNIX.&lt;br /&gt;
&lt;br /&gt;
To shorten the compilation time of a program dependent on plugins supplied with the compiler (like for example the &amp;lt;TT&amp;gt;io&amp;lt;/TT&amp;gt; plugin), the installer will compile the &amp;lt;TT&amp;gt;.java&amp;lt;/TT&amp;gt; plugin files during installation.&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Introduction&amp;diff=1735</id>
		<title>Introduction</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Introduction&amp;diff=1735"/>
		<updated>2013-04-05T22:30:34Z</updated>

		<summary type="html">&lt;p&gt;Tybor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Liberty Eiffel is a compiler for the Eiffel programming language =&lt;br /&gt;
&lt;br /&gt;
It '''continues''' the development of SmartEiffel, the GNU Eiffel Compiler.&lt;br /&gt;
&lt;br /&gt;
It is a complete, small and fast, Eiffel compiler, including an Eiffel to C compiler, documentation tools, a pretty printer, a debugger and various other tools.&lt;br /&gt;
&lt;br /&gt;
It also includes a large library of classes distributed under the terms of the MIT/X Consortium License and a comprehensive set of wrappers/bindings for widespread Free-Software libraries.&lt;br /&gt;
&lt;br /&gt;
Eiffel is an advanced object-oriented programming language that emphasizes the design and construction of high-quality and reusable software.&lt;br /&gt;
&lt;br /&gt;
= TODO =&lt;br /&gt;
on this page the following shall be done:&lt;br /&gt;
* rework content from SmartEiffel Wiki (below Origins of the SmartEiffel project)&lt;br /&gt;
* update links to Liberty plan and Documentation, after those pages are moved from github wiki to Mediawiki&lt;br /&gt;
&lt;br /&gt;
= Liberty's roots =&lt;br /&gt;
&lt;br /&gt;
== Origins ==&lt;br /&gt;
&lt;br /&gt;
Liberty has its origin in the [http://en.wikipedia.org/wiki/Statue_of_Liberty Statue of Liberty]. The structure of the Statue was designed and built by [http://en.wikipedia.org/wiki/Gustave_Eiffel Gustave Eiffel], a famous French engineer.&lt;br /&gt;
&lt;br /&gt;
The origins of the language is [http://www.eiffel.com Eiffel] and more specifically [http://smarteiffel.loria.fr SmartEiffel].&lt;br /&gt;
&lt;br /&gt;
== Manifesto ==&lt;br /&gt;
&lt;br /&gt;
We want to retain from SmartEiffel its rigour; but not its rigidity. Think of Liberty as ''SmartEiffel down from its ivory tower''.&lt;br /&gt;
&lt;br /&gt;
Liberty is free as in ''freedom''. We want people to contribute to Liberty from the start.&lt;br /&gt;
&lt;br /&gt;
So please, do join us to give Eiffel the leading position it should have won twenty years ago :-)&lt;br /&gt;
&lt;br /&gt;
== Foundation documents ==&lt;br /&gt;
&lt;br /&gt;
Those documents were published by the SmartEiffel team:&lt;br /&gt;
&lt;br /&gt;
* [http://www.jot.fm/issues/issue_2004_04/article7/ Conformance of agents in the Eiffel language]&lt;br /&gt;
* [http://www.loria.fr/~colnet/publis/icsr9.pdf Reconciling Subtyping and Code Reuse in Object-Oriented Languages]&lt;br /&gt;
&lt;br /&gt;
= Liberty's future =&lt;br /&gt;
&lt;br /&gt;
== The grand plan ==&lt;br /&gt;
&lt;br /&gt;
Liberty is at its beginnings. Have a look at the [[Liberty plan]].&lt;br /&gt;
&lt;br /&gt;
== Release names ==&lt;br /&gt;
See [[Versions history|list of released versions]] and [[Upcoming releases]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Documentation ==&lt;br /&gt;
[[Liberty language specification]]&lt;br /&gt;
[[Liberty compiler design notes]]&lt;br /&gt;
&lt;br /&gt;
= Community =&lt;br /&gt;
&lt;br /&gt;
You may join us via our mailing list by simply e-mailing to [mailto:libertyeiffel@librelist.com libertyeiffel@librelist.com] The archives are available on [http://librelist.com/browser/libertyeiffel/].&lt;br /&gt;
&lt;br /&gt;
[[Category:Smarteiffel]]&lt;br /&gt;
==Origins of the SmartEiffel project==&lt;br /&gt;
&lt;br /&gt;
During the course of his work on his thesis, [[User:Colnet|Dominique Colnet]], principal author of SmartEiffel, discovered the Eiffel language while editing an encyclopedic work on object oriented languages &lt;br /&gt;
([[Bibliography#MNCLT 1989|[MNCLT 1989]]], [[Bibliography#MNCLT 1991|[MNCLT 1991]]]).&lt;br /&gt;
&lt;br /&gt;
Holding the post of Assistant Professor of Computer Science in 1989, the Powers That Be at his educational institution at the time decided, in 1990, to use the Eiffel language for introductory computer science.&lt;br /&gt;
It is amusing to mention here that Dominique Colnet was at the time a fervent defender of Smalltalk.&lt;br /&gt;
As everyone knows, it's a pretty good thing that it's not up to a young Assistant Professor of Computer Science to decide which programming language is the best to use.&lt;br /&gt;
So, it is amusing to note that Dominique Colnet was forced to use Eiffel against his will in 1990!&lt;br /&gt;
&lt;br /&gt;
In order to reconcile his teaching and research work on the compilation of object oriented languages, Dominique Colnet decided therefore to abandon &lt;br /&gt;
Smalltalk for Eiffel and to establish a project to kill two birds with one stone: combine interesting research with a free product that would also be useful for teaching.&lt;br /&gt;
&lt;br /&gt;
The SmartEiffel project, originally named ''SmallEiffel'' actually commenced&lt;br /&gt;
during the year 1994 when Dominique Colnet decided to write his own Eiffel compiler.&lt;br /&gt;
&lt;br /&gt;
Writing an Eiffel compiler is no small undertaking.&lt;br /&gt;
Before making this decision, Dominique Colnet had begun to write a new Eiffel class library whose architecture simply corresponded nearly word for word with the base classes one could find at that time in Smalltalk-80 libraries ([[Bibliography#GR 1983|[GR 1983]]], &lt;br /&gt;
[[Bibliography#Goldberg 1984|[Goldberg 1984]]]).&lt;br /&gt;
Because of the very bad quality of the commercial Eiffel compilers available at that time the decision was taken to write a new one from scratch.&lt;br /&gt;
The new compiler was named ''SmallEiffel'' to make reference to both Smalltalk &lt;br /&gt;
and Eiffel ([[Bibliography#OOSC 1988|[OOSC 1988]]], [[Bibliography#ETL 1992|[ETL 1992]]]).&lt;br /&gt;
An entire year was necessary to write the first version of SmallEiffel and it was not until July 1995 that SmallEiffel was able to compile itself.&lt;br /&gt;
Since that time, more than ten years have passed and more than &lt;br /&gt;
[[versions_history|thirty versions]] have seen the light of day.&lt;br /&gt;
&lt;br /&gt;
==Little SmartEiffel developing into something big?==&lt;br /&gt;
Starting out as simple research prototype and teaching aid, SmartEiffel has seen its capabilities steadily increase from version to version since 1995.&lt;br /&gt;
&lt;br /&gt;
In 1998, on the occasion of a visit to LORIA by Richard Stallman, president and founder of the FSF (Free Software Foundation), the GNU designation was added to the project's name. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;EcmaEiffel&amp;quot;&amp;gt;&lt;br /&gt;
From 2002 and up to 2005, Dominique Colnet participated actively in meetings with the initial objective of standardizing the Eiffel language &lt;br /&gt;
('''ECMA''' standards committee TC39-TG4, ECMA standard number 367).&lt;br /&gt;
Of course it goes without saying that the entire SmartEiffel team is associated with the standards work and its many long discussions...&lt;br /&gt;
&lt;br /&gt;
Finally, in May 2005, the SmartEiffel project announced that it was going to continue to work on the ''true Eiffel language''.&lt;br /&gt;
In reality, the language described by the ECMA TC39-TG4 working group clearly diverges from what is conventionally called Eiffel.&lt;br /&gt;
ECMA-Eiffel is a very different language, and above all, not yet experimented.&lt;br /&gt;
The SmartEiffel team will never implement ECMA TC39-TG4.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At July 2005, at the time when we write these lines, after more than 10 years of work not only on the compiler but also on the Eiffel language itself, we, the SmartEiffel project, consider that the Eiffel language as we know it today, now contains nearly all desirable features.&lt;br /&gt;
Therefore, version 2.2 of SmartEiffel marks the debut of a new level of stability and corresponds to what we think of as being the ''true Eiffel language''.&lt;br /&gt;
&lt;br /&gt;
==Objectives of the SmartEiffel project==&lt;br /&gt;
The language is entering into a period of stability.&lt;br /&gt;
In fact, in version 2.2, the only important thing that is still missing is distributed programming, the [[FAQ#SCOOP|SCOOP]] mechanism.&lt;br /&gt;
Needless to say, the implementation of SCOOP will not negatively affect any existing software.&lt;br /&gt;
In our opinion, it is evident that one must truly move towards a &lt;br /&gt;
'''stable and validated language''' experimentally through work on a large palette of programs.&lt;br /&gt;
&lt;br /&gt;
We anticipate in the short term an important effort which began in version 2.2 concerning the implementation of libraries.&lt;br /&gt;
We are also going to '''more fully open up the project''' in order to augment the dynamics around SmartEiffel: to work on a Wiki for consolidation of documentation and to increase the number of people authorized to contribute to the source code of the project.&lt;br /&gt;
&lt;br /&gt;
Without modifying the language, we will work on novel tools in the domain of [[Glossary#TypePrediction|dynamic type prediction]] and on static assertion validation.&lt;br /&gt;
In fact, we think that '''the Eiffel language should remain simple'''. &lt;br /&gt;
The tools that we are going to integrate will, without any change to the language, focus on the following objectives:&lt;br /&gt;
* better predict [[FAQ#StaticVsDynamicType|dynamic types]] and obtain better  execution performance,&lt;br /&gt;
* statically validate assertions as well as detect calls without a target (calls on [[Void|&amp;lt;code&amp;gt;Void&amp;lt;/code&amp;gt;]]),&lt;br /&gt;
* statically resolve all typing problems tied to [[Glossary#Covariance|covariance]] and to change of export status ([[FAQ#CATCALL|CATCALLs]]).&lt;br /&gt;
Another way to describe the objectives of the SmartEiffel project is to give here our point of view on Eiffel, or more precisely on the spirit of Eiffel.&lt;br /&gt;
&lt;br /&gt;
==Eiffel, the spirit of Eiffel or the Eiffel method?==&lt;br /&gt;
Strictly speaking, Eiffel is a language and not truly a method.&lt;br /&gt;
That being said, after more than ten years of work on Eiffel and for Eiffel, we cannot help but notice that Eiffel is a good vehicle for a particular way of thinking and therefore as a way of working with computer software.&amp;lt;br&amp;gt;&lt;br /&gt;
We assert here, without fear of contradiction, that Eiffel is most probably the best current language for doing what is commonly called '''software engineering'''.&amp;lt;br&amp;gt;&lt;br /&gt;
This is no surprise when one knows that ''software engineering'' was our guiding principle from the start when we were making choices concerning the Eiffel language.&lt;br /&gt;
&lt;br /&gt;
Before presenting other aspects that we take into account after each evolution of the language, it is good to keep in mind that the perfect universal computer language for all kinds of applications does not exist and will probably never exist.&amp;lt;br&amp;gt;&lt;br /&gt;
Today and probably for some time to come, the concepts of computer programming languages remain empirical and any given language is only effective for only a given spectrum of applications.&amp;lt;br&amp;gt;&lt;br /&gt;
We will try to give below the principal guides that influenced our choice.&lt;br /&gt;
&lt;br /&gt;
Software engineering is the principal guide in the conception and the choices made concerning the Eiffel language.&amp;lt;br&amp;gt;&lt;br /&gt;
The following fundamental points flow from this guideline:&lt;br /&gt;
* Eiffel is designed especially for large and even '''very large programs''',&lt;br /&gt;
* Eiffel should facilitate working on a team, '''communication and documentation''',&lt;br /&gt;
* Eiffel should facilitate '''maintenance and test''' of software components.&lt;br /&gt;
&lt;br /&gt;
Of course, the '''security''' aspect is also one of our primary concerns. &lt;br /&gt;
Moreover, as for the software engineering aspect, we propose to set the bar even higher: to put forth a language capable of fully exploiting all machine resources, a language and set of tools to truly generate [[Performance|'''high performance programs''']].&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=User:Tybor&amp;diff=1721</id>
		<title>User:Tybor</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=User:Tybor&amp;diff=1721"/>
		<updated>2013-04-04T22:31:28Z</updated>

		<summary type="html">&lt;p&gt;Tybor: Created page with &amp;quot;I'm Paolo Redaelli, who began programming on a Commodore 64 and then on Amiga.  I discovered GNU and freedom in information technology when I bought GeekGadgets for Amiga, a port…&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I'm Paolo Redaelli, who began programming on a Commodore 64 and then on Amiga. &lt;br /&gt;
I discovered GNU and freedom in information technology when I bought GeekGadgets for Amiga, a port of the most popular development tools and utilities from the Free Software Foundation (FSF), BSD and other sources.  &lt;br /&gt;
During IPISA (Incontro Programmatori Italiani Sistemi Amiga, italian amiga programmers meeting) in 1997 I met Richard Stallman; with his talk he taught us what means to seek freedom in IT&lt;br /&gt;
Rudi Chiarito was working on the Amiga port of SmallEiffel; at MIPSA he suggested me to study Eiffel and Meyer's &amp;quot;Object Oriented Software Construction&amp;quot;. &lt;br /&gt;
I'm now a structural civil engineer with a strong toward Quality Management Systems so I found the cleanness of Eiffel and its Design by contract tecnique really useful to write bugfree correct software.&lt;br /&gt;
My efforts in Liberty are to provide access to the widest possible set of wrappers and binding to widespread libraries: one of the main reasons Eiffel didn't become widespread is that there weren't enought libraries.&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
	<entry>
		<id>https://wiki.liberty-eiffel.org/index.php?title=Generated_c_code&amp;diff=1720</id>
		<title>Generated c code</title>
		<link rel="alternate" type="text/html" href="https://wiki.liberty-eiffel.org/index.php?title=Generated_c_code&amp;diff=1720"/>
		<updated>2013-04-04T19:49:11Z</updated>

		<summary type="html">&lt;p&gt;Tybor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Smarteiffel]]&lt;br /&gt;
 *** I have partially updated the examples here: the hello_world.id file was generated by se2.2beta5 and I&lt;br /&gt;
 *** have noted some statements that are now obsolete in view of recent compiler changes.&lt;br /&gt;
 *** This article and its French counterpart need revising by the development team.&lt;br /&gt;
&lt;br /&gt;
 *** You can also use [http://SmartEiffel.loria.fr/man/c_code.html the original article]&lt;br /&gt;
&lt;br /&gt;
People who want to interface with applications and/or libraries written in C should as far as possible limit themselves to the interfaces provided by [[Cecil]], [[externals|external]] and [[plugins]]. This page gives details about the generated C code, but these details ought not to be of any use to you. ;-)&lt;br /&gt;
&lt;br /&gt;
== The type identifiers ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
SmartEiffel generates one unique identifying number for each active type in the Eiffel code&amp;lt;sup&amp;gt;[[Generated c code#note1|1]]&amp;lt;/sup&amp;gt;. A lot of symbols in the generated C code depend on that identifier.&lt;br /&gt;
&lt;br /&gt;
'''Don't depend on those identifiers!''' The mangling table is only valid for one specific compilation of one specific application with one specific compiler version, for one compiler [[compile_to_c]] in one specific version and libraries in one specific version... We do not guarantee the stabbility of these identifiers.&lt;br /&gt;
&lt;br /&gt;
If ''27'' is an identifier, then:&lt;br /&gt;
&lt;br /&gt;
* The C type of an Eiffel object is '''T27''';&lt;br /&gt;
* The corresponding C structure is '''struct&amp;amp;nbsp;S27'''; in that structure, the names of the attributes are prefixed with an underscore (there may be some other fields used by SmartEiffel, in particular, the &amp;lt;TT&amp;gt;id&amp;lt;/TT&amp;gt; field, which in this case has the value 27). &amp;lt;br&amp;gt; Each reference type can be cast to &amp;lt;TT&amp;gt;T0&amp;lt;/TT&amp;gt; (although some reference types may not have the &amp;lt;TT&amp;gt;id&amp;lt;/TT&amp;gt; field).&lt;br /&gt;
* Each method is called '''r27''method_name''()'''&lt;br /&gt;
* Each prefix method is called '''r27_px_''method_name''()'''&lt;br /&gt;
* Each infix method is called '''r27_ix_''method_name''()'''&lt;br /&gt;
* Each late-binding method is called '''X27''method_name''()'''&lt;br /&gt;
* The object's creation method (when the [[Garbage collector|garbage collector]] is used) is called '''new27()'''&lt;br /&gt;
* The type model is a variable called '''M27'''. Models are used for initialisation. For example:&lt;br /&gt;
 T27 M27 = {27,NULL,NULL,0,0};&lt;br /&gt;
 ...&lt;br /&gt;
 {T27*n=((T27*)se_malloc(sizeof(*n)));&lt;br /&gt;
  *n=M27;&lt;br /&gt;
  r27make(n);&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Some characters in method names, such as &amp;lt;TT&amp;gt;&amp;quot;&amp;amp;lt;&amp;quot;&amp;lt;/TT&amp;gt; or &amp;lt;TT&amp;gt;&amp;quot;+&amp;quot;&amp;lt;/TT&amp;gt;, will be replaced by their corresponding ASCII code in decimal.&lt;br /&gt;
&lt;br /&gt;
=== An example ===&lt;br /&gt;
&lt;br /&gt;
For example: [[library_class:STRING|&amp;lt;TT&amp;gt;STRING&amp;lt;/TT&amp;gt;]] has the identifier '''7'''&amp;lt;sup&amp;gt;[[Generated c code#note2|2]]&amp;lt;/sup&amp;gt;. So:&lt;br /&gt;
&lt;br /&gt;
* The object type is '''T7'''.&lt;br /&gt;
 typedef struct S7 T7;&lt;br /&gt;
* The structure is defined in '''struct&amp;amp;nbsp;S7'''.&lt;br /&gt;
 struct S7{Tid id;T9 _storage;t2 _count;t2 _capacity;};&lt;br /&gt;
* The &amp;lt;TT&amp;gt;append&amp;lt;/TT&amp;gt; method becomes:&lt;br /&gt;
 void r7append(se_dump_stack*caller,T7* C,T0* a1)&lt;br /&gt;
(See below for details on the ''dump stack'' execution stack.)&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;TT&amp;gt;.id&amp;lt;/TT&amp;gt; file ===&lt;br /&gt;
&lt;br /&gt;
When the application is compiled, the list of identifiers is stored in a file whose name is suffixed &amp;lt;TT&amp;gt;.id&amp;lt;/TT&amp;gt;.  The file is reread in incremental compilations (which allows some stability in the identifiers, so long as the whole project is not recompiled).&lt;br /&gt;
&lt;br /&gt;
This file is structured in ''entries'', each entry being separated from others by a hash character (&amp;lt;TT&amp;gt;#&amp;lt;/TT&amp;gt;). This file looks like this:&lt;br /&gt;
&lt;br /&gt;
 5 &amp;quot;REAL&amp;quot;&lt;br /&gt;
 class-path: &amp;quot;/SmartEiffel/lib/numeric/real.e&amp;quot;&lt;br /&gt;
 class-name: REAL&lt;br /&gt;
 assertion-level: all&lt;br /&gt;
 parent-count: 1 inherit: 49&lt;br /&gt;
 #&lt;br /&gt;
 72 &amp;quot;FAST_ARRAY&amp;quot;&lt;br /&gt;
 class-path: &amp;quot;/SmartEiffel/lib/storage/collection/fast_array.e&amp;quot;&lt;br /&gt;
 class-name: FAST_ARRAY&lt;br /&gt;
 assertion-level: all&lt;br /&gt;
 parent-count: 1 inherit: 58&lt;br /&gt;
 #&lt;br /&gt;
 62 &amp;quot;STD_ERROR&amp;quot;&lt;br /&gt;
 class-path: &amp;quot;/SmartEiffel/lib/io/terminal/std_error.e&amp;quot;&lt;br /&gt;
 class-name: STD_ERROR&lt;br /&gt;
 assertion-level: all&lt;br /&gt;
 parent-count: 1 inherit: 39&lt;br /&gt;
 c-type: T62 reference: yes&lt;br /&gt;
 ref-status: live id-field: yes&lt;br /&gt;
 destination-graph-nodes: -&amp;gt;OUTPUT_STREAM&lt;br /&gt;
 run-time-set-count: 1&lt;br /&gt;
 run-time-set:&lt;br /&gt;
         STD_ERROR (62)&lt;br /&gt;
 #&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
You should never depend on these identifiers. In any case, when an identifier is computed, collisions may occur, and affect the process. Thus, the identifier and  name of each type depends not only on the type name, but also on the order in which the types are compiled. That is, on the order of ''application'' and ''library'' types combined... They also depend on the compilation mode used (since that can change the list of active types), and the version of the compiler you're using. So what is &amp;lt;TT&amp;gt;T145&amp;lt;/TT&amp;gt; today may be  &amp;lt;TT&amp;gt;T234&amp;lt;/TT&amp;gt; tomorrow&amp;lt;sup&amp;gt;[[Generated c code#note3|3]]&amp;lt;/sup&amp;gt;!&lt;br /&gt;
&lt;br /&gt;
Consequently, '''do not ever rely on the generated identifiers, because they are not constant!'''  Do not try to write in your own C code horrible things like &amp;lt;TT&amp;gt;new123&amp;lt;/TT&amp;gt; or &amp;lt;TT&amp;gt;T456&amp;lt;/TT&amp;gt;, because the only thing we can guarantee is that this code will not work.&lt;br /&gt;
&lt;br /&gt;
== Naming convention ==&lt;br /&gt;
&lt;br /&gt;
The preceding section has explained how methods are generated.&lt;br /&gt;
&lt;br /&gt;
The function prototype &amp;lt;TT&amp;gt;r7append()&amp;lt;/TT&amp;gt; from the example above is presented as&lt;br /&gt;
 v7append(se_dump_stack*caller,T7* C,T0* a1);&lt;br /&gt;
This shows how ''Current'' and the arguments are passed.  The rules are as follows:&lt;br /&gt;
&lt;br /&gt;
* ''Current'' is called &amp;lt;TT&amp;gt;C&amp;lt;/TT&amp;gt; and is always strongly typed (with its own exact type).  This parameter may be omitted if Current is not used by the method. In some cases (when code is inlined), ''Current'' can be copied in local variables named  &amp;lt;TT&amp;gt;C1&amp;lt;/TT&amp;gt;, &amp;lt;TT&amp;gt;C2&amp;lt;/TT&amp;gt;...&lt;br /&gt;
* The arguments are called &amp;lt;TT&amp;gt;a1&amp;lt;/TT&amp;gt;, &amp;lt;TT&amp;gt;a2&amp;lt;/TT&amp;gt;... and are typed &amp;lt;TT&amp;gt;T0*&amp;lt;/TT&amp;gt; for reference types or given their exact type for expanded types (e.g. &amp;lt;TT&amp;gt;T2&amp;lt;/TT&amp;gt; for an integer)&lt;br /&gt;
* Inside functions, a local variable &amp;lt;TT&amp;gt;R&amp;lt;/TT&amp;gt; is defined. This is ''Result''.&lt;br /&gt;
* Local variable keep their Eiffel name, prefixed by an underscore.&lt;br /&gt;
&lt;br /&gt;
=== Agent routines ===&lt;br /&gt;
&lt;br /&gt;
Functions of the form _T111C222l333c444 are agent creations.&lt;br /&gt;
&lt;br /&gt;
222 is the id of the class where the agent creation was written (look it up in &lt;br /&gt;
the .id file);&lt;br /&gt;
333 is the line number;&lt;br /&gt;
444 is the column number.&lt;br /&gt;
&lt;br /&gt;
111 is a little more difficult to explain. It is the id of the type from which &lt;br /&gt;
this agent creation will be executed. It can be the same as 222, but it will &lt;br /&gt;
be different if 222 corresponds to a generic class, and it can also be &lt;br /&gt;
different if a class inherits from 222.&lt;br /&gt;
&lt;br /&gt;
For example, function _T832C832l1362c106&lt;br /&gt;
was declared in class #832, on&lt;br /&gt;
line 1362 column 106.&lt;br /&gt;
&lt;br /&gt;
== The mangling table ==&lt;br /&gt;
&lt;br /&gt;
OK, now you understand why you cannot use type numbers, but you still want to know what those fields in the mangling table mean (in the &amp;lt;TT&amp;gt;.id&amp;lt;/TT&amp;gt; file)&amp;gt;..&lt;br /&gt;
&lt;br /&gt;
First, a big caveat. Although it may have been very stable for quite some time now, '''the mangling table coding may change'''! We currently have no plans to change it, and we prefer keeping it the way it is. But once again, we do not commit ourselves to the current representation.&lt;br /&gt;
&lt;br /&gt;
Let's look again at the extract of a &amp;lt;TT&amp;gt;.id&amp;lt;/TT&amp;gt; file. The part shown covers nearly all the possible cases:&lt;br /&gt;
&lt;br /&gt;
 5 &amp;quot;REAL&amp;quot;&lt;br /&gt;
 class-path: &amp;quot;/SmartEiffel/lib/numeric/real.e&amp;quot;&lt;br /&gt;
 class-name: REAL&lt;br /&gt;
 assertion-level: all&lt;br /&gt;
 parent-count: 1 inherit: 49&lt;br /&gt;
 #&lt;br /&gt;
 72 &amp;quot;FAST_ARRAY&amp;quot;&lt;br /&gt;
 class-path: &amp;quot;/SmartEiffel/lib/storage/collection/fast_array.e&amp;quot;&lt;br /&gt;
 class-name: FAST_ARRAY&lt;br /&gt;
 assertion-level: all&lt;br /&gt;
 parent-count: 1 inherit: 58&lt;br /&gt;
 #&lt;br /&gt;
 62 &amp;quot;STD_ERROR&amp;quot;&lt;br /&gt;
 class-path: &amp;quot;/SmartEiffel/lib/io/terminal/std_error.e&amp;quot;&lt;br /&gt;
 class-name: STD_ERROR&lt;br /&gt;
 assertion-level: all&lt;br /&gt;
 parent-count: 1 inherit: 39&lt;br /&gt;
 c-type: T62 reference: yes&lt;br /&gt;
 ref-status: live id-field: yes&lt;br /&gt;
 destination-graph-nodes: -&amp;gt;OUTPUT_STREAM&lt;br /&gt;
 run-time-set-count: 1&lt;br /&gt;
 run-time-set:&lt;br /&gt;
        STD_ERROR (62)&lt;br /&gt;
 #&lt;br /&gt;
 . . .&lt;br /&gt;
&lt;br /&gt;
There is one entry per type (active or not); each entry spans many lines and is terminated by a hash symbol (&amp;lt;TT&amp;gt;#&amp;lt;/TT&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Each entry contains a lot of information. Not all of it is always present; missing entries take default values.&lt;br /&gt;
&lt;br /&gt;
Only the first line is compulsory.  It contains the type identifier, and its name (as would be returned by  &amp;lt;TT&amp;gt;generating_type&amp;lt;/TT&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
The following lines contain different fields, marked by a keyword, a colon and a value. There may be one or more fields on a single line. Those fields are: &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| '''class-path'''&lt;br /&gt;
| The path to the file containing the source code. May be omitted if the class has no associated file (uncommon).&lt;br /&gt;
|-&lt;br /&gt;
| '''class-name'''&lt;br /&gt;
| The name of the class, as returned by &amp;lt;TT&amp;gt;generator&amp;lt;/TT&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| '''parent-count'''&lt;br /&gt;
| Le number of parents.&lt;br /&gt;
|-&lt;br /&gt;
| '''inherit'''&lt;br /&gt;
| On the same line as '''parent-count''' if the latter is not null; it gives the list of parent class identifiers.&lt;br /&gt;
|-&lt;br /&gt;
| '''c-type'''&lt;br /&gt;
| The C type, usually in the form '''T27'''. If it is omitted, the class has no runnable type.&lt;br /&gt;
In that case, the following fields do not appear either.&lt;br /&gt;
|-&lt;br /&gt;
| '''reference'''&lt;br /&gt;
| On the same line as '''c-type''', &amp;lt;TT&amp;gt;yes&amp;lt;/TT&amp;gt; for a reference type or &amp;lt;TT&amp;gt;no&amp;lt;/TT&amp;gt; for an expanded type.&lt;br /&gt;
|-&lt;br /&gt;
| '''ref-status'''&lt;br /&gt;
| Either &amp;lt;TT&amp;gt;live&amp;lt;/TT&amp;gt; for an active type (i.e. instances of this type are  created at run-time), or &amp;lt;TT&amp;gt;dead&amp;lt;/TT&amp;gt;  otherwise.&lt;br /&gt;
|-&lt;br /&gt;
| '''id-field'''&lt;br /&gt;
| On the same line as '''ref-status''', &amp;lt;TT&amp;gt;yes&amp;lt;/TT&amp;gt; if the &amp;lt;TT&amp;gt;id&amp;lt;/TT&amp;gt; field has to be generated in the C structure (as its first element), &amp;lt;TT&amp;gt;no&amp;lt;/TT&amp;gt; otherwise. This field is present if one of these confitions is true:&lt;br /&gt;
* some late binding may occur on targets of that type,&lt;br /&gt;
* or the structure may be accessed by an [[external]] or by [[cecil]].&lt;br /&gt;
Note that a lot of calls are statically computed; the type inference algorithm used in SmartEiffel increases the number of such types that do not need the id field.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| '''destination-graph-nodes'''&lt;br /&gt;
| ????? &amp;lt;!-- someone please write an explanation for this --&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| '''run-time-set-count'''&lt;br /&gt;
| The number of concrete, active descendants of the type (including itself). This is the number of items in '''run-time-set''' below.&lt;br /&gt;
|-&lt;br /&gt;
| '''run-time-set'''&lt;br /&gt;
| The concrete, active heirs of this type (including itself). One  class per line, tab-indented.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== The dump stack ==&lt;br /&gt;
&lt;br /&gt;
'''When not in boost mode''', a stack is managed by the runtime environment generated by SmartEiffel. This stack is displayed when an uncaught exception is raised. It is also used by the debugger [[sedb]].&lt;br /&gt;
&lt;br /&gt;
Technically, the SmartEiffel stack is built upon the native (C) stack. Each stack element is a &amp;lt;TT&amp;gt;se_dump_stack&amp;lt;/TT&amp;gt;&amp;lt;sup&amp;gt;[[Generated c code#note4|4]]&amp;lt;/sup&amp;gt; usually allocated on the stack&amp;lt;sup&amp;gt;[[Generated c code#note5|5]]&amp;lt;/sup&amp;gt;. It is made up of several parts:&lt;br /&gt;
&lt;br /&gt;
* a frame descriptor, of type &amp;lt;TT&amp;gt;se_frame_descriptor&amp;lt;/TT&amp;gt;&amp;lt;sup&amp;gt;[[Generated c code#note4|4]]&amp;lt;/sup&amp;gt; which is a static description of the feature, as follows:&lt;br /&gt;
** run type,&lt;br /&gt;
** does it use Current,&lt;br /&gt;
** number and type of the local variables, and&lt;br /&gt;
** an anti-recursion flag (for contracts)...&lt;br /&gt;
* a dynamic part:&lt;br /&gt;
** a pointer to ''Current'' (i.e. either a pointer to an expanded object, or else a pointer to a reference object, it being a pointer to the object itself). That is why the type of the &amp;lt;TT&amp;gt;current&amp;lt;/TT&amp;gt; field is &amp;lt;TT&amp;gt;Void**&amp;lt;/TT&amp;gt;. This field will be &amp;lt;TT&amp;gt;NULL&amp;lt;/TT&amp;gt; if ''Current'' is not used by the ''feature'',o&lt;br /&gt;
** the position (used mainly by [[sedb]]),&lt;br /&gt;
** a pointer to the caller (i.e. the &amp;lt;TT&amp;gt;se_dump_stack&amp;lt;/TT&amp;gt; of the calling function),&lt;br /&gt;
** a pointer to the exception origin: if not &amp;lt;TT&amp;gt;NULL&amp;lt;/TT&amp;gt;, it means that this &amp;lt;TT&amp;gt;se_dump_stack&amp;lt;/TT&amp;gt; ''is not'' in the stack, but was malloc'ed to preserve the exception stack trace,&lt;br /&gt;
** an array of local variables (with double indirection as for ''Current''), hence the type void***.&lt;br /&gt;
&lt;br /&gt;
Macros handle the linking between the &amp;lt;TT&amp;gt;se_dump_stack&amp;lt;/TT&amp;gt; frames.&lt;br /&gt;
&lt;br /&gt;
* Normally, the top of the dump stack is the global variable &amp;lt;TT&amp;gt;se_dst&amp;lt;/TT&amp;gt; defined in &amp;lt;TT&amp;gt;SmartEiffel/sys/runtime/no_check.c&amp;lt;/TT&amp;gt;. The macro &amp;lt;TT&amp;gt;set_dump_stack_top&amp;lt;/TT&amp;gt; accomplishes the assignment of its argument in this variable.&lt;br /&gt;
* In [[SCOOP]] mode, each processor has its own stack. So the &amp;lt;TT&amp;gt;set_dump_stack_top&amp;lt;/TT&amp;gt; macro has two arguments: the processor and the new dump stack top.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;div id=&amp;quot;note1&amp;quot;&amp;gt;1. There is a bijection (a one to one relationship) between the number and the ''name'' of the type (including the value of its generic parameters in the case of generic types). &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;note2&amp;quot;&amp;gt;2. There are some identifiers that are reserved for &amp;quot;basic&amp;quot; types. They are:&lt;br /&gt;
&lt;br /&gt;
* '''0''': the type any other can be cast to&lt;br /&gt;
* '''1''': [[library_class:INTEGER_8|&amp;lt;TT&amp;gt;INTEGER_8&amp;lt;/TT&amp;gt;]]&lt;br /&gt;
* '''2''': [[library_class:INTEGER|&amp;lt;TT&amp;gt;INTEGER&amp;lt;/TT&amp;gt;]] (or [[library_class:INTEGER_32|&amp;lt;TT&amp;gt;INTEGER_32&amp;lt;/TT&amp;gt;]])&lt;br /&gt;
* '''3''': [[library_class:CHARACTER|&amp;lt;TT&amp;gt;CHARACTER&amp;lt;/TT&amp;gt;]]&lt;br /&gt;
* '''4''': [[library_class:REAL_32|&amp;lt;TT&amp;gt;REAL_32&amp;lt;/TT&amp;gt;]]&lt;br /&gt;
* '''5''': [[library_class:REAL_64|&amp;lt;TT&amp;gt;REAL_64&amp;lt;/TT&amp;gt;]] (or [[library_class:REAL|&amp;lt;TT&amp;gt;REAL&amp;lt;/TT&amp;gt;]])&lt;br /&gt;
* '''6''': [[library_class:BOOLEAN|&amp;lt;TT&amp;gt;BOOLEAN&amp;lt;/TT&amp;gt;]]&lt;br /&gt;
* '''7''': [[library_class:STRING|&amp;lt;TT&amp;gt;STRING&amp;lt;/TT&amp;gt;]]&lt;br /&gt;
* '''8''': [[library_class:POINTER|&amp;lt;TT&amp;gt;POINTER&amp;lt;/TT&amp;gt;]]&lt;br /&gt;
* '''9''': [[library_class:NATIVE_ARRAY|&amp;lt;TT&amp;gt;NATIVE_ARRAY&amp;lt;/TT&amp;gt;]]&amp;lt;TT&amp;gt;[&amp;lt;/TT&amp;gt;[[library_class:CHARACTER|&amp;lt;TT&amp;gt;CHARACTER&amp;lt;/TT&amp;gt;]]&amp;lt;TT&amp;gt;]&amp;lt;/TT&amp;gt;&lt;br /&gt;
* '''10''': [[library_class:INTEGER_16|&amp;lt;TT&amp;gt;INTEGER_16&amp;lt;/TT&amp;gt;]]&lt;br /&gt;
* '''11''': [[library_class:INTEGER_64|&amp;lt;TT&amp;gt;INTEGER_64&amp;lt;/TT&amp;gt;]]&lt;br /&gt;
* '''12''': [[library_class:REAL_EXTENDED|&amp;lt;TT&amp;gt;REAL_EXTENDED&amp;lt;/TT&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So it is likely that the root class of the system may have the identifier '''12'''. But do not rely on that too much (before all the changes to INTEGERs, it was '''11''').&lt;br /&gt;
&lt;br /&gt;
All [[liberty_class:NATURAL|&amp;lt;tt&amp;gt;NATURAL&amp;lt;/TT&amp;gt;]] classes (NATURAL, NATURAL_8, NATURAL_16, NATURAL_32, NATURAL_64 and NATURAL_GENERAL) does not have a fixed id.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;note3&amp;quot;&amp;gt;3. The compiler will do its best not to change the identifiers uselessly. The &amp;lt;TT&amp;gt;.id&amp;lt;/TT&amp;gt; file is loaded at the beginning of the compilation process, and saved again at its end. But [[clean]], for example, erases that file.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;note4&amp;quot;&amp;gt;4.  You can find the definition of these structures in the &amp;lt;TT&amp;gt;SmartEiffel/sys/runtime/c/no_check.h&amp;lt;/TT&amp;gt; file.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;note5&amp;quot;&amp;gt;5. The exception is when an exception is raised: in that case, part of the stack is allocated onto the heap before the &amp;lt;TT&amp;gt;longjmp&amp;lt;/TT&amp;gt;. &amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tybor</name></author>
	</entry>
</feed>