set the references right
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@10824 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a3ad15a6d6
commit
d0ae20ec39
1 changed files with 25 additions and 25 deletions
|
|
@ -9,24 +9,24 @@
|
|||
<!-- INDEX -->
|
||||
<div class="sectiontoc">
|
||||
<ul>
|
||||
<li><a href="#c_overview">Overview</a>
|
||||
<li><a href="#c_preliminaries">Preliminaries</a>
|
||||
<li><a href="#C_overview">Overview</a>
|
||||
<li><a href="#C_preliminaries">Preliminaries</a>
|
||||
<ul>
|
||||
<li><a href="#c_running_swig">Running SWIG</a>
|
||||
<li><a href="#c_commandline">Command line options</a>
|
||||
<li><a href="#c_dynamic">Compiling dynamic module</a>
|
||||
<li><a href="#c_using_module">Using generated module</a>
|
||||
<li><a href="#C_running_swig">Running SWIG</a>
|
||||
<li><a href="#C_commandline">Command line options</a>
|
||||
<li><a href="#C_dynamic">Compiling dynamic module</a>
|
||||
<li><a href="#C_using_module">Using generated module</a>
|
||||
</ul>
|
||||
<li><a href="#c_basic_c_wrapping">Basic C wrapping</a>
|
||||
<li><a href="#C_basic_c_wrapping">Basic C wrapping</a>
|
||||
<ul>
|
||||
<li><a href="#c_c_functions">Functions</a>
|
||||
<li><a href="#c_c_variables">Variables</a>
|
||||
<li><a href="#C_functions">Functions</a>
|
||||
<li><a href="#C_variables">Variables</a>
|
||||
</ul>
|
||||
<li><a href="#c_basic_cpp_wrapping">Basic C++ wrapping</a>
|
||||
<li><a href="#C_basic_cpp_wrapping">Basic C++ wrapping</a>
|
||||
<ul>
|
||||
<li><a href="#c_classes">Classes</a>
|
||||
<li><a href="#C_classes">Classes</a>
|
||||
</ul>
|
||||
<li><a href="#c_exceptions">Exception handling</a>
|
||||
<li><a href="#C_exceptions">Exception handling</a>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- INDEX -->
|
||||
|
|
@ -42,7 +42,7 @@ This chapter describes SWIG's support for creating ANSI C wrappers. This module
|
|||
</p>
|
||||
|
||||
|
||||
<H2><a name="c_overview"></a>36.1 Overview</H2>
|
||||
<H2><a name="C_overview"></a>36.1 Overview</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -60,10 +60,10 @@ With wrapper interfaces generated by SWIG, it is easy to use the functionality o
|
|||
Flattening C++ language constructs into a set of C-style functions obviously comes with many limitations and inconveniences. All data and functions become global. Manipulating objects requires explicit calls to special functions. We are losing the high level abstraction and have to work around it.
|
||||
</p>
|
||||
|
||||
<H2><a name="c_preliminaries"></a>36.2 Preliminaries</H2>
|
||||
<H2><a name="C_preliminaries"></a>36.2 Preliminaries</H2>
|
||||
|
||||
|
||||
<H3><a name="c_running_swig"></a>36.2.1 Running SWIG</H3>
|
||||
<H3><a name="C_running_swig"></a>36.2.1 Running SWIG</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -108,7 +108,7 @@ This will generate an <tt>example_wrap.c</tt> file or, in the latter case, <tt>e
|
|||
The <tt>wrap</tt> file contains the wrapper functions, which perform the main functionality of SWIG: it translates the input arguments from C to C++, makes calls to the original functions and marshalls C++ output back to C data. The <tt>proxy</tt> header file contains the interface we can use in C application code. The additional <tt>.c</tt> file contains calls to the wrapper functions, allowing us to preserve names of the original functions.
|
||||
</p>
|
||||
|
||||
<H3><a name="c_commandline"></a>36.2.2 Command line options</H3>
|
||||
<H3><a name="C_commandline"></a>36.2.2 Command line options</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -131,12 +131,12 @@ swig -c -help
|
|||
|
||||
<tr>
|
||||
<td>-noexcept</td>
|
||||
<td>generate wrappers with no support of exception handling; see <a href="#c_exceptions">Exceptions</a> chapter for more details </td>
|
||||
<td>generate wrappers with no support of exception handling; see <a href="#C_exceptions">Exceptions</a> chapter for more details </td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<H3><a name="c_dynamic"></a>36.2.3 Compiling a dynamic module</H3>
|
||||
<H3><a name="C_dynamic"></a>36.2.3 Compiling a dynamic module</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -163,7 +163,7 @@ $ g++ -shared example_wrap.o -o libexample.so
|
|||
Now the shared library module is ready to use. Note that the name of the generated module is important: is should be prefixed with <tt>lib</tt> on Unix, and have the specific extension, like <tt>.dll</tt> for Windows or <tt>.so</tt> for Unix systems.
|
||||
</p>
|
||||
|
||||
<H3><a name="c_using_module"></a>36.2.4 Using the generated module</H3>
|
||||
<H3><a name="C_using_module"></a>36.2.4 Using the generated module</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -178,14 +178,14 @@ $ gcc runme.c example_proxy.c -L. -lexample -o runme
|
|||
This will compile the application code (<tt>runme.c</tt>), along with the proxy code and link it against the generated shared module. Following the <tt>-L</tt> option is the path to the directory containing the shared module. The output executable is ready to use. The last thing to do is to supply to the operating system the information of location of our module. This is system dependant, for instance Unix systems look for shared modules in certain directories, like <tt>/usr/lib</tt>, and additionally we can set the environment variable <tt>LD_LIBRARY_PATH</tt> (Unix) or <tt>PATH</tt> (Windows) for other directories.
|
||||
</p>
|
||||
|
||||
<H2><a name="c_basic_c_wrapping"></a>36.3 Basic C wrapping</H2>
|
||||
<H2><a name="C_basic_c_wrapping"></a>36.3 Basic C wrapping</H2>
|
||||
|
||||
|
||||
<p>
|
||||
Wrapping C functions and variables is obviously performed in a straightforward way. There is no need to perform type conversions, and all language constructs can be preserved in their original form. However, SWIG allows you to enchance the code with some additional elements, for instance using <tt>check</tt> typemap or <tt>%extend</tt> directive.
|
||||
</p>
|
||||
|
||||
<H3><a name="c_c_functions"></a>36.3.1 Functions</H3>
|
||||
<H3><a name="C_functions"></a>36.3.1 Functions</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -259,7 +259,7 @@ int _wrap_gcd(int arg1, int arg2) {
|
|||
This time calling <tt>gcd</tt> with negative value argument will trigger an error message. This can save you time writing all the constraint checking code by hand.
|
||||
</p>
|
||||
|
||||
<H3><a name="c_c_variables"></a>36.3.2 Variables</H3>
|
||||
<H3><a name="C_variables"></a>36.3.2 Variables</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -297,14 +297,14 @@ ms.x = 123;
|
|||
ms.d = 123.123;
|
||||
</pre></div>
|
||||
|
||||
<H2><a name="c_basic_cpp_wrapping"></a>36.4 Basic C++ wrapping</H2>
|
||||
<H2><a name="C_basic_cpp_wrapping"></a>36.4 Basic C++ wrapping</H2>
|
||||
|
||||
|
||||
<p>
|
||||
The main reason of having the C module in SWIG is to be able to access C++ from C. In this chapter we will take a look at the rules of wrapping elements of the C++ language.
|
||||
</p>
|
||||
|
||||
<H3><a name="c_classes"></a>36.4.1 Classes</H3>
|
||||
<H3><a name="C_classes"></a>36.4.1 Classes</H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -382,7 +382,7 @@ radius: 1.500000
|
|||
area: 7.068583
|
||||
</pre></div>
|
||||
|
||||
<H2><a name="c_exceptions"></a>36.5 Exception handling</H2>
|
||||
<H2><a name="C_exceptions"></a>36.5 Exception handling</H2>
|
||||
|
||||
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue