html validation fixes and chapter renumbering
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9206 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
56088f6b5a
commit
d8329a6c9e
7 changed files with 188 additions and 109 deletions
|
|
@ -6,7 +6,21 @@
|
|||
</head>
|
||||
|
||||
<body bgcolor="#ffffff">
|
||||
<H1>SWIG and R</H1>
|
||||
<H1><a name="R_nn1"></a>32 SWIG and R</H1>
|
||||
<!-- INDEX -->
|
||||
<div class="sectiontoc">
|
||||
<ul>
|
||||
<li><a href="#R_nn2">Bugs</a>
|
||||
<li><a href="#R_nn3">Using R and SWIG</a>
|
||||
<li><a href="#R_nn4">General policy</a>
|
||||
<li><a href="#R_nn5">Language conventions</a>
|
||||
<li><a href="#R_nn6">C++ classes</a>
|
||||
<li><a href="#R_nn7">Enumerations</a>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- INDEX -->
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
R is a GPL'ed open source statistical and plotting environment.
|
||||
|
|
@ -18,20 +32,27 @@ experimental. Not all features have been implemented and the API is
|
|||
not stable.
|
||||
</p>
|
||||
|
||||
<H2>Bugs</H2>
|
||||
<H2><a name="R_nn2"></a>32.1 Bugs</H2>
|
||||
|
||||
|
||||
<p>
|
||||
Currently the following features are not implemented or broken:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>Garbage collection of created objects
|
||||
<li>C Array wrappings
|
||||
<li>tested on UNIX only, how well or badly it works on windows is not known
|
||||
</ul>
|
||||
|
||||
<H2>Using R and SWIG</H2>
|
||||
<H2><a name="R_nn3"></a>32.2 Using R and SWIG</H2>
|
||||
|
||||
|
||||
<p>
|
||||
To use R and SWIG in C mode, execute the following commands where
|
||||
example_func.c is the name of the file with the functions in them
|
||||
</p>
|
||||
|
||||
<div class="shell">
|
||||
<pre>
|
||||
swig -r -o example,c example.i
|
||||
|
|
@ -39,7 +60,10 @@ PKG_LIBS="example_func.c" R CMD SHLIB example.c
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
The corresponding comments for C++ mode are
|
||||
</p>
|
||||
|
||||
<div class="shell">
|
||||
<pre>
|
||||
swig -c++ -r -o example.cpp example.i
|
||||
|
|
@ -47,6 +71,7 @@ PKG_LIBS="example_func.cxx" R CMD SHLIB example.cpp
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Note that R is sensitive to the name of the file and to the file
|
||||
extension in C and C++ mode. The name of the wrapper file must be the
|
||||
name of the library. Also in C++ mode, the file extension must be cpp
|
||||
|
|
@ -57,35 +82,57 @@ rather than cxx for the R compile command to recognize it.
|
|||
The commands produce two files. A dynamic shared object file called
|
||||
example.so and an R wrapper file called example_wrap.S. To load these
|
||||
files, start up R and type in the following commands
|
||||
</p>
|
||||
|
||||
<div class="shell">
|
||||
<pre>
|
||||
dyn.load('example.so')
|
||||
source('example_wrap.S')
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
These two files can be loaded in any order
|
||||
</p>
|
||||
|
||||
<h2>General policy</h2>
|
||||
<H2><a name="R_nn4"></a>32.3 General policy</H2>
|
||||
|
||||
|
||||
<p>
|
||||
The general policy of the module is to treat the C/C++ as a basic
|
||||
wrapping over the underlying functions and rely on the R type system
|
||||
to provide R syntax.
|
||||
</p>
|
||||
|
||||
<h2>Language conventions</h2>
|
||||
<H2><a name="R_nn5"></a>32.4 Language conventions</H2>
|
||||
|
||||
|
||||
<p>
|
||||
getitem and setitem use C++ conventions (i.e. zero based indices). [<-
|
||||
and [ are overloaded to allow for R syntax (one based indices and
|
||||
slices)
|
||||
</p>
|
||||
|
||||
<h2>C++ classes</h2>
|
||||
<H2><a name="R_nn6"></a>32.5 C++ classes</H2>
|
||||
|
||||
|
||||
<p>
|
||||
C++ objects are implemented as external pointer objects with the class
|
||||
being the mangled name of the class. The C++ classes are encapsulated
|
||||
as an SEXP with an external pointer type. The class is the mangled
|
||||
name of the class. The nice thing about R is that is allows you to
|
||||
keep track of the pointer object which removes the necessity for a lot
|
||||
of the proxy class baggage you see in other languages.
|
||||
</p>
|
||||
|
||||
<h2>Enumerations</h2>
|
||||
<H2><a name="R_nn7"></a>32.6 Enumerations</H2>
|
||||
|
||||
|
||||
<p>
|
||||
enumerations are characters which are then converted back and forth to
|
||||
ints before calling the C routines. All of the enumeration code is
|
||||
done in R.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue