Add support for the -external-runtime argument and update all language modules to use it

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6993 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
John Lenz 2005-02-23 22:40:51 +00:00
commit ef58056ffd
18 changed files with 233 additions and 46 deletions

View file

@ -75,44 +75,28 @@ languages provide. One solution is to load all modules before spawning any thre
the functions <tt>SWIG_TypeQuery</tt>, <tt>SWIG_NewPointerObj</tt>, and others sometimes need
to be called. Calling these functions from a typemap is supported, since the typemap code
is embedded into the <tt>_wrap.c</tt> file, which has those declerations available. If you need
to call the SWIG run-time functions from another C file, there are three headers you need
to include. They are located in the Lib directory in the SWIG source, or wherever the
SWIG Library was installed. You can see the current library path by running
<tt>swig -swiglib</tt>.</p>
to call the SWIG run-time functions from another C file, there is one header you need
to include. To generate the header that needs to be included, run the following command:
<blockquote><pre>
#include &lt;swigrun.swg&gt;
#include &lt;python/pyrun.swg&gt; /* Or other header, see below */
#include &lt;runtime.swg&gt;
$ swig -python -external-runtime &lt;filename&gt;
</pre></blockquote>
<p>After including these three headers, your code should be able to call <tt>SWIG_TypeQuery</tt>,
<p>The filename argument is optional and if it is not passed, then the default filename will
be something like <tt>swigpyrun.h</tt>, depending on the language. This header file should
be treated like any of the other _wrap.c output files, and should be regenerated when the
_wrap files are. After including this header, your code will be able to call <tt>SWIG_TypeQuery</tt>,
<tt>SWIG_NewPointerObj</tt>, <tt>SWIG_ConvertPtr</tt> and others. The exact argument paramaters
for these functions might differ between language modules; please check the language module chapters
for more information.</p>
<p>Inside these headers the functions are declared static and are included inline into the file,
<p>Inside this header the functions are declared static and are included inline into the file,
and thus the file does not need to be linked against any SWIG libraries or code (you might still
need to link against the language libraries like libpython-2.3). Data is shared between this
file and the _wrap.c files through a global variable in the wrapping language. It is also
possible to copy these three header files into your own package for distribution along with
the generated wrapper files, so that you can distribute a package that can be compiled
without SWIG installed (this works because the header files are self contained, and do not
need to link with anything).</p>
<p>The headers that should be included in place of the #include &lt;python/pyrun.swg&gt;
for the different language modules are:</p>
<ul>
<li>Chicken - &lt;chicken/chickenrun.swg&gt;</li>
<li>Guile (scm) - &lt;guile/guile_scm_run.swg&gt;</li>
<li>Guile (gh) - This does not work with the -gh API, use the -scm API</li>
<li>MzScheme - &lt;mzscheme/mzrun.swg&gt;</li>
<li>Ocaml - &lt;ocaml/ocaml.swg&gt;</li>
<li>Python - &lt;python/pyrun.swg&gt;</li>
<li>Perl5 - &lt;perl5/perlrun.swg&gt;</li>
<li>Ruby - &lt;ruby/rubydef.swg&gt;</li>
<li>Tcl - &lt;tcl/swigtcl8.swg&gt;</li>
</ul>
file and the _wrap.c files through a global variable in the scripting language. It is also
possible to copy this header file along with the generated wrapper files into your own package,
so that you can distribute a package that can be compiled without SWIG installed (this works
because the header file is self contained, and does not need to link with anything).</p>
<H2><a name="Modules_nn4"></a>15.3 A word of caution about static libraries</H2>