Merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12976 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
02d58e0125
99 changed files with 1847 additions and 418 deletions
|
|
@ -5,6 +5,52 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
Version 2.0.5 (in progress)
|
||||
===========================
|
||||
|
||||
2012-04-05: olly
|
||||
[Lua] Add support for Lua 5.2 (patch SF#3514593 from Miles Bader)
|
||||
|
||||
2012-03-26: xavier98
|
||||
[octave] Apply patch #3425993 from jgillis: add extra logic to the octave_swig_type::dims(void) method: it checks if the user has defined a __dims__ method and uses this in stead of returning (1,1)
|
||||
[octave] Apply patch #3424833 from jgillis: make is_object return true for swig types
|
||||
|
||||
2012-03-24: wsfulton
|
||||
[D] Apply #3502431 to fix duplicate symbols in multiple modules and compiler errors due to lack
|
||||
of const in some methods taking char*.
|
||||
|
||||
2012-03-21: wsfulton
|
||||
Fix #3494791 - %$isglobal for %rename matching.
|
||||
|
||||
2012-03-20: wsfulton
|
||||
Fix #3487706 and #3391906 - missing stddef.h include for ptrdiff_t when using %import
|
||||
for STL containers and compiling with g++-4.6. An include of stddef.h is now only
|
||||
generated when SWIG generates STL helper templates which require ptrdiff_t. If you
|
||||
were previously relying on "#include <stddef.h>" always being generated when using a
|
||||
%include of an STL header, you may now need to add this in manually.
|
||||
|
||||
2012-03-16: wsfulton
|
||||
Apply patch #3392264 from Sebastien Bine to parse (unsigned) long long types in enum value assignment.
|
||||
|
||||
2012-03-16: wsfulton
|
||||
Apply patch #3505530 from Karl Wette to allow custom allocators in STL string classes for the UTL languages.
|
||||
|
||||
2012-03-13: wsfulton
|
||||
Apply patch #3468362 from Karl Wette to fix %include inside %define.
|
||||
|
||||
2012-03-13: wsfulton
|
||||
[Python, Ruby, Octave] Fix #3475492 - iterating through std::vector wrappers of enumerations.
|
||||
|
||||
2012-02-27: xavier98 (patches from Karl Wette)
|
||||
[Octave] Use -globals . to load global variables in module namespace
|
||||
[Octave] Comment declaration of unimplemented function swig_register_director
|
||||
[Octave] Fix OCTAVE_PATH in octave Makefiles
|
||||
[Octave] Add support for nspace feature - fix director_nspace test
|
||||
[Octave] Add support for std::list - fix li_std_containers_int test
|
||||
[Octave] Fix imports test
|
||||
|
||||
2012-02-16: wsfulton
|
||||
[Java] Make generated support functions in arrays_java.i static so that generated code
|
||||
from multiple instances of SWIG can be compiled and linked together - problem reported by
|
||||
Evan Krause.
|
||||
|
||||
2012-01-24: wsfulton
|
||||
Fix crash with bad regex - bug #3474250.
|
||||
|
||||
|
|
@ -271,12 +317,6 @@ Version 2.0.5 (in progress)
|
|||
the module table into the global namespace. Require call also returns the module table instead
|
||||
of a string.
|
||||
|
||||
2011-08-12: wsfulton
|
||||
SF bug # 3333549 - %shared_ptr fixes when the type is a template using template parameters
|
||||
that are typedef'd to another type.
|
||||
|
||||
Also fixed %shared_ptr when template parameters have default values.
|
||||
|
||||
2011-08-09: xavier98
|
||||
Fix bug 3387394; Octave patches for 3.4.0 compatibility, etc. (from Karl Wette)
|
||||
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@
|
|||
<li><a href="SWIG.html#SWIG_nn29">Simple renaming of specific identifiers</a>
|
||||
<li><a href="SWIG.html#SWIG_advanced_renaming">Advanced renaming support</a>
|
||||
<li><a href="SWIG.html#SWIG_limiting_renaming">Limiting global renaming rules</a>
|
||||
<li><a href="SWIG.html#SWIG_chosen_unignore">Ignoring everything then wrapping a few selected symbols</a>
|
||||
</ul>
|
||||
<li><a href="SWIG.html#SWIG_default_args">Default/optional arguments</a>
|
||||
<li><a href="SWIG.html#SWIG_nn30">Pointers to functions and callbacks</a>
|
||||
|
|
|
|||
|
|
@ -99,6 +99,19 @@ swig -go -help
|
|||
6g/8g/5g.</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>-gccgo-46</td>
|
||||
<td>Generate code for gccgo 4.6. The default is set by the configure
|
||||
script.</td> This generates code that does not use some facilities
|
||||
that are only available in gccgo 4.7 and later.
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>-no-gccgo-46</td>
|
||||
<td>Turn off <code>-gccgo-46</code>, whether set by default or earlier
|
||||
on the command line.
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>-package <name></td>
|
||||
<td>Set the name of the Go package to <name>. The default
|
||||
|
|
|
|||
|
|
@ -75,12 +75,11 @@ eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers t
|
|||
|
||||
<H2><a name="Lua_nn2"></a>26.1 Preliminaries</H2>
|
||||
|
||||
|
||||
<p>
|
||||
The current SWIG implementation is designed to work with Lua 5.0.x and Lua 5.1.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. ((Currently SWIG generated code has only been tested on Windows with MingW, though given the nature of Lua, is should not have problems on other OS's)). It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms). SWIG also supports eLua and works with eLua 0.8. SWIG generated code for eLua has been tested on Stellaris ARM Cortex-M3 LM3S and Infineon TriCore.
|
||||
The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms). SWIG also supports eLua and works with eLua 0.8. SWIG generated code for eLua has been tested on Stellaris ARM Cortex-M3 LM3S and Infineon TriCore.
|
||||
</p>
|
||||
<H2><a name="Lua_nn3"></a>26.2 Running SWIG</H2>
|
||||
|
||||
<H2><a name="Lua_nn3"></a>26.2 Running SWIG</H2>
|
||||
|
||||
<p>
|
||||
Suppose that you defined a SWIG module such as the following:
|
||||
|
|
@ -245,7 +244,7 @@ $ gcc -c example.c -o example.o
|
|||
$ gcc -shared -I/usr/include/lua -L/usr/lib/lua example_wrap.o example.o -o example.so
|
||||
</pre></div>
|
||||
<p>
|
||||
The wrappers produced by SWIG can be compiled and linked with Lua 5.1.x. The loading is extremely simple.
|
||||
The wrappers produced by SWIG can be compiled and linked with Lua 5.1.x and later. The loading is extremely simple.
|
||||
</p>
|
||||
<div class="targetlang"><pre>
|
||||
require("example")
|
||||
|
|
@ -256,7 +255,7 @@ For those using Lua 5.0.x, you will also need an interpreter with the loadlib fu
|
|||
<div class="targetlang"><pre>
|
||||
my_init=loadlib("example.so","luaopen_example") -- for Unix/Linux
|
||||
--my_init=loadlib("example.dll","luaopen_example") -- for Windows
|
||||
assert(my_init) -- name sure its not nil
|
||||
assert(my_init) -- make sure it's not nil
|
||||
my_init() -- call the init fn of the lib
|
||||
</pre></div>
|
||||
<p>
|
||||
|
|
@ -664,7 +663,7 @@ Stout
|
|||
>
|
||||
</pre></div>
|
||||
<p>
|
||||
(Note: for calling methods of a class, you use <tt>class:method(args)</tt>, not <tt>class.method(args)</tt>, its an easy mistake to make. However for data attributes it is <tt>class.attribute</tt>)
|
||||
(Note: for calling methods of a class, you use <tt>class:method(args)</tt>, not <tt>class.method(args)</tt>, it's an easy mistake to make. However for data attributes it is <tt>class.attribute</tt>)
|
||||
</p>
|
||||
<p>
|
||||
Class data members are accessed in the same manner as C structures. Static class members present a special problem for Lua, as Lua doesn't have support for such features. Therefore, SWIG generates wrappers that try to work around some of these issues. To illustrate, suppose you have a class like this:
|
||||
|
|
@ -673,7 +672,6 @@ Class data members are accessed in the same manner as C structures. Static class
|
|||
public:
|
||||
static void foo();
|
||||
static int bar;
|
||||
|
||||
};
|
||||
</pre></div>
|
||||
<p>
|
||||
|
|
@ -1168,10 +1166,10 @@ stack traceback:
|
|||
<p>
|
||||
SWIG is able to throw numeric types, enums, chars, char*'s and std::string's without problem. It has also written typemaps for std::exception and its derived classes, which convert the exception into an error string. </p>
|
||||
<p>
|
||||
However its not so simple for to throw other types of objects.
|
||||
However it's not so simple to throw other types of objects.
|
||||
Thrown objects are not valid outside the 'catch' block. Therefore they cannot be
|
||||
returned to the interpreter.
|
||||
The obvious ways to overcome this would be to either return a copy of the object, or so convert the object to a string and
|
||||
The obvious ways to overcome this would be to either return a copy of the object, or to convert the object to a string and
|
||||
return that. Though it seems obvious to perform the former, in some cases this is not possible, most notably when
|
||||
SWIG has no information about the object, or the object is not copyable/creatable.
|
||||
</p>
|
||||
|
|
@ -1185,7 +1183,7 @@ void throw_A() throw(A*) {
|
|||
}
|
||||
</pre></div>
|
||||
<p>
|
||||
SWIG will just convert it (poorly) to a string and use that as its error. (Yes its not that useful, but it always works).
|
||||
SWIG will just convert it (poorly) to a string and use that as its error. (This is not that useful, but it always works).
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
|
|
@ -1212,8 +1210,8 @@ If you have your own class which you want output as a string you will need to ad
|
|||
%}
|
||||
</pre></div>
|
||||
<p>
|
||||
If you wish your exception to be returned to the interpreter, it must firstly be copyable. Then you must have and additional
|
||||
<tt>%apply</tt> statement, to inform SWIG to return a copy of this object to the interpreter. For example:
|
||||
If you wish your exception to be returned to the interpreter, it must firstly be copyable. Then you must have an additional
|
||||
<tt>%apply</tt> statement, to tell SWIG to return a copy of this object to the interpreter. For example:
|
||||
</p>
|
||||
<div class="code"><pre>
|
||||
%apply SWIGTYPE EXCEPTION_BY_VAL {Exc}; // tell SWIG to return Exc by value to interpreter
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ Options specific to the Octave module are:
|
|||
Octave Options (available with -octave)
|
||||
-global - Load all symbols into the global namespace [default]
|
||||
-globals <em>name</em> - Set <em>name</em> used to access C global variables [default: 'cvar']
|
||||
- Use '.' to load C global variables into module namespace
|
||||
-noglobal - Do not load all symbols into the global namespace
|
||||
-opprefix <em>str</em> - Prefix <em>str</em> for global operator functions [default: 'op_']
|
||||
</pre></div>
|
||||
|
|
@ -119,6 +120,7 @@ Octave Options (available with -octave)
|
|||
<p>
|
||||
The <em>-global</em> and <em>-noglobal</em> options determine whether the Octave module will load all symbols into the global namespace in addition to the global namespace.
|
||||
The <em>-globals</em> option sets the name of the variable which is the namespace for C global variables exported by the module.
|
||||
The special name "." loads C global variables into the module namespace, i.e. alongside C functions and structs exported by the module.
|
||||
The <em>-opprefix</em> options sets the prefix of the names of global/friend <a href="#Octave_nn18">operator</a> functions.
|
||||
</p>
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ options are found near the end of the chapter.
|
|||
|
||||
<p>
|
||||
To build a Perl5 module, run SWIG using the <tt>-perl</tt> option as
|
||||
follows :
|
||||
follows:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -137,7 +137,7 @@ To build the module, you will need to compile the file
|
|||
|
||||
|
||||
<p>
|
||||
In order to compile, SWIG extensions need the following Perl5 header files :</p>
|
||||
In order to compile, SWIG extensions need the following Perl5 header files:</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
#include "Extern.h"
|
||||
|
|
@ -149,19 +149,19 @@ In order to compile, SWIG extensions need the following Perl5 header files :</p>
|
|||
These are typically located in a directory like this</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
/usr/lib/perl5/5.00503/i386-linux/CORE
|
||||
/usr/lib/perl/5.14/CORE
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
The SWIG configuration script automatically tries to locate this directory so
|
||||
that it can compile examples. However, if you need to find out where the directory is
|
||||
loaded, an easy way to find out is to run Perl itself.
|
||||
located, an easy way to find out is to ask Perl itself:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
% perl -e 'use Config; print $Config{archlib};'
|
||||
/usr/lib/perl5/5.00503/i386-linux
|
||||
$ perl -e 'use Config; print "$Config{archlib}\n";'
|
||||
/usr/lib/perl/5.14
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -176,9 +176,9 @@ using commands like this (shown for Linux):
|
|||
|
||||
<div class="code"><pre>
|
||||
$ swig -perl example.i
|
||||
% gcc example.c
|
||||
% gcc -c example_wrap.c -I/usr/lib/perl5/5.00503/i386-linux/CORE -Dbool=char
|
||||
% gcc -shared example.o example_wrap.o -o example.so
|
||||
$ gcc -fPIC example.c
|
||||
$ gcc -fPIC -c example_wrap.c -I/usr/lib/perl/5.14/CORE -Dbool=char
|
||||
$ gcc -shared example.o example_wrap.o -o example.so
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -204,7 +204,7 @@ the target should be named `<tt>example.so</tt>',
|
|||
<p>
|
||||
It is also possible to use Perl to build dynamically loadable modules
|
||||
for you using the MakeMaker utility. To do this, write a Perl
|
||||
script such as the following :</p>
|
||||
script such as the following:</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
# File : Makefile.PL
|
||||
|
|
@ -218,12 +218,12 @@ WriteMakefile(
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
Now, to build a module, simply follow these steps :</p>
|
||||
Now, to build a module, simply follow these steps:</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
% perl Makefile.PL
|
||||
% make
|
||||
% make install
|
||||
$ perl Makefile.PL
|
||||
$ make
|
||||
$ make install
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -239,10 +239,10 @@ and Randal Schwartz.</p>
|
|||
If you machine does not support dynamic loading or if you've tried to
|
||||
use it without success, you can build a new version of the Perl
|
||||
interpreter with your SWIG extensions added to it. To build a static
|
||||
extension, you first need to invoke SWIG as follows :</p>
|
||||
extension, you first need to invoke SWIG as follows:</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
% swig -perl -static example.i
|
||||
$ swig -perl -static example.i
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -253,7 +253,7 @@ By default SWIG includes code for dynamic loading, but the
|
|||
Next, you will need to supply a <tt>main()</tt> function that
|
||||
initializes your extension and starts the Perl interpreter. While,
|
||||
this may sound daunting, SWIG can do this for you automatically as
|
||||
follows :</p>
|
||||
follows:</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
%module example
|
||||
|
|
@ -268,10 +268,10 @@ extern int fact(int);
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
The same thing can be accomplished by running SWIG as follows :</p>
|
||||
The same thing can be accomplished by running SWIG as follows:</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
% swig -perl -static -lperlmain.i example.i
|
||||
$ swig -perl -static -lperlmain.i example.i
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -290,7 +290,7 @@ for a dynamic module, but change the link line to something like this:
|
|||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
% gcc example.o example_wrap.o -L/usr/lib/perl5/5.00503/i386-linux/CORE \
|
||||
$ gcc example.o example_wrap.o -L/usr/lib/perl/5.14/CORE \
|
||||
-lperl -lsocket -lnsl -lm -o myperl
|
||||
</pre></div>
|
||||
|
||||
|
|
@ -323,9 +323,7 @@ A common error received by first-time users is the following:
|
|||
<div class="targetlang">
|
||||
<pre>
|
||||
use example;
|
||||
Can't locate example.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i386-lin
|
||||
ux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/pe
|
||||
rl5/site_perl/5.005 .) at - line 1.
|
||||
Can't locate example.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at - line 1.
|
||||
BEGIN failed--compilation aborted at - line 1.
|
||||
</pre>
|
||||
</div>
|
||||
|
|
@ -363,7 +361,7 @@ Another common error is the following:
|
|||
<pre>
|
||||
use example;
|
||||
Can't load './example.so' for module example: ./example.so:
|
||||
undefined symbol: Foo at /usr/lib/perl5/5.00503/i386-linux/DynaLoader.pm line 169.
|
||||
undefined symbol: Foo at /usr/lib/perl/5.14/i386-linux/DynaLoader.pm line 169.
|
||||
|
||||
at - line 1
|
||||
BEGIN failed--compilation aborted at - line 1.
|
||||
|
|
@ -409,7 +407,7 @@ error when you try to use your module:
|
|||
<pre>
|
||||
use example;
|
||||
Can't load './example.so' for module example: libfoo.so: cannot open shared object file:
|
||||
No such file or directory at /usr/lib/perl5/5.00503/i386-linux/DynaLoader.pm line 169.
|
||||
No such file or directory at /usr/lib/perl/5.14/i386-linux/DynaLoader.pm line 169.
|
||||
|
||||
at - line 1
|
||||
BEGIN failed--compilation aborted at - line 1.
|
||||
|
|
@ -472,10 +470,10 @@ compiler. For example:
|
|||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
% swig -c++ -perl example.i
|
||||
% g++ -c example.cxx
|
||||
% g++ -c example_wrap.cxx -I/usr/lib/perl5/5.00503/i386-linux/CORE
|
||||
% <b>g++ -shared example.o example_wrap.o -o example.so</b>
|
||||
$ swig -c++ -perl example.i
|
||||
$ g++ -fPIC -c example.cxx
|
||||
$ g++ -fPIC -c example_wrap.cxx -I/usr/lib/perl/5.14/i386-linux/CORE
|
||||
$ <b>g++ -shared example.o example_wrap.o -o example.so</b>
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -485,10 +483,10 @@ Solaris, you often need to add an extra library <tt>-lCrun</tt> like this:
|
|||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
% swig -c++ -perl example.i
|
||||
% g++ -c example.cxx
|
||||
% g++ -c example_wrap.cxx -I/usr/lib/perl5/5.00503/i386-linux/CORE
|
||||
% g++ -shared example.o example_wrap.o -o example.so <b>-lCrun</b>
|
||||
$ swig -c++ -perl example.i
|
||||
$ CC -c example.cxx
|
||||
$ CC -c example_wrap.cxx -I/usr/lib/perl/5.14/i386-linux/CORE
|
||||
$ CC -shared example.o example_wrap.o -o example.so <b>-lCrun</b>
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -503,7 +501,7 @@ it needs to be. So you should compile the wrapper like:
|
|||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
% g++ -c example_wrap.cxx -I/usr/lib/perl/5.8.0/CORE -D_GNU_SOURCE
|
||||
$ g++ -fPIC -c example_wrap.cxx -I/usr/lib/perl/5.8.0/CORE -D_GNU_SOURCE
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -511,7 +509,7 @@ it needs to be. So you should compile the wrapper like:
|
|||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
% perl -e 'use Config; print $Config{ccflags};'
|
||||
$ perl -e 'use Config; print "$Config{ccflags}\n";'
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -519,8 +517,8 @@ So you could also compile the wrapper like
|
|||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
% g++ -c example_wrap.cxx -I/usr/lib/perl/5.8.0/CORE \
|
||||
`perl -e 'use Config; print $Config{ccflags}'`
|
||||
$ g++ -fPIC -c example_wrap.cxx -I/usr/lib/perl/5.8.0/CORE \
|
||||
`perl -MConfig -e 'print $Config{ccflags}'`
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -568,8 +566,8 @@ can behave strangely when working with multiple modules.
|
|||
|
||||
<p>
|
||||
It should be noted that you may get a lot of error messages
|
||||
about the `<tt>bool</tt>' datatype when compiling a C++ Perl module. If
|
||||
you experience this problem, you can try the following :</p>
|
||||
about the '<tt>bool</tt>' datatype when compiling a C++ Perl module. If
|
||||
you experience this problem, you can try the following:</p>
|
||||
|
||||
<ul>
|
||||
<li>Use <tt>-DHAS_BOOL</tt> when compiling the SWIG wrapper code
|
||||
|
|
@ -643,7 +641,7 @@ although the procedure may be similar with other compilers.
|
|||
<p>
|
||||
If you are developing your application within Microsoft developer
|
||||
studio, SWIG can be invoked as a custom build option. The process
|
||||
roughly requires these steps :</p>
|
||||
roughly requires these steps:</p>
|
||||
|
||||
<ul>
|
||||
<li>Open up a new workspace and use the AppWizard to select a DLL
|
||||
|
|
@ -651,7 +649,7 @@ project.
|
|||
|
||||
<li>Add both the SWIG interface file (the .i file), any supporting C
|
||||
files, and the name of the wrapper file that will be created by SWIG
|
||||
(ie. <tt>example_wrap.c</tt>). Note : If using C++, choose a
|
||||
(ie. <tt>example_wrap.c</tt>). Note: If using C++, choose a
|
||||
different suffix for the wrapper file such as
|
||||
<tt>example_wrap.cxx</tt>. Don't worry if the wrapper file doesn't
|
||||
exist yet--Developer studio will keep a reference to it around.
|
||||
|
|
@ -689,7 +687,7 @@ Now, assuming you made it this far, SWIG will be automatically invoked when
|
|||
you build your project. Any changes made to the interface file will
|
||||
result in SWIG being automatically invoked to produce a new version of
|
||||
the wrapper file. To run your new Perl extension, simply run Perl and
|
||||
use the use command as normal. For example :
|
||||
use the use command as normal. For example:
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
|
|
@ -758,7 +756,7 @@ double Spam;
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
is accessed as follows :</p>
|
||||
is accessed as follows:</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
use example;
|
||||
|
|
@ -858,7 +856,7 @@ print example::FOO,"\n";
|
|||
SWIG represents pointers as blessed references. A blessed reference
|
||||
is the same as a Perl reference except that it has additional
|
||||
information attached to it indicating what kind of reference it
|
||||
is. That is, if you have a C declaration like this :</p>
|
||||
is. That is, if you have a C declaration like this:</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
Matrix *new_Matrix(int n, int m);
|
||||
|
|
@ -880,7 +878,7 @@ generated.</p>
|
|||
|
||||
<p>
|
||||
To check to see if a value is the NULL pointer, use the
|
||||
<tt>defined()</tt> command :</p>
|
||||
<tt>defined()</tt> command:</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
if (defined($ptr)) {
|
||||
|
|
@ -904,7 +902,7 @@ In general, <tt>$a</tt> and <tt>$b</tt> will be different--since they
|
|||
are different references. Thus, it is a mistake to check the equality
|
||||
of <tt>$a</tt> and <tt>$b</tt> to check the equality of two C
|
||||
pointers. The correct method to check equality of C pointers is to
|
||||
dereference them as follows :
|
||||
dereference them as follows:
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
|
|
@ -1099,7 +1097,7 @@ void Bar_f_set(Bar *b, Foo *val) {
|
|||
|
||||
<p>
|
||||
C++ classes are wrapped by building a set of low level accessor functions.
|
||||
Consider the following class :
|
||||
Consider the following class:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -1117,7 +1115,7 @@ static void print(List *l);
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
When wrapped by SWIG, the following functions are created :
|
||||
When wrapped by SWIG, the following functions are created:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -1272,11 +1270,11 @@ The following C++ operators are currently supported by the Perl module:
|
|||
<p>
|
||||
When you create a SWIG extension, everything gets placed into
|
||||
a single Perl module. The name of the module is determined by the
|
||||
<tt>%module</tt> directive. To use the module, do the following :
|
||||
<tt>%module</tt> directive. To use the module, do the following:
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
% perl5
|
||||
$ perl5
|
||||
use example; # load the example module
|
||||
print example::fact(4),"\n" # Call a function in it
|
||||
24
|
||||
|
|
@ -1342,17 +1340,17 @@ nested namespace simply provide the fully qualified name in your
|
|||
<!--
|
||||
<p>
|
||||
This can be changed by giving SWIG the -package
|
||||
option :
|
||||
option:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
% swig -perl -package Foo example.i
|
||||
$ swig -perl -package Foo example.i
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
In this case, you still create a module called `<tt>example</tt>' exactly as before, but
|
||||
all of the functions in that module will be installed into the package
|
||||
`<tt>Foo</tt>.' For example :
|
||||
`<tt>Foo</tt>.' For example:
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
|
|
@ -1588,7 +1586,7 @@ The SWIG <tt>%exception</tt> directive can be used to create a
|
|||
user-definable exception handler for converting exceptions in your
|
||||
C/C++ program into Perl exceptions. The chapter on customization features
|
||||
contains more details, but suppose you have a C++ class like the
|
||||
following :
|
||||
following:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -1796,7 +1794,7 @@ The <tt>$input</tt> variable is the input object (usually a <tt>SV *</tt>).
|
|||
</p>
|
||||
|
||||
<p>
|
||||
When this example is used in Perl5, it will operate as follows :
|
||||
When this example is used in Perl5, it will operate as follows:
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
|
|
@ -1805,7 +1803,7 @@ $n = example::fact(6);
|
|||
print "$n\n";
|
||||
...
|
||||
|
||||
Output :
|
||||
Output:
|
||||
Received an integer : 6
|
||||
720
|
||||
</pre></div>
|
||||
|
|
@ -2200,7 +2198,7 @@ char **get_args() {
|
|||
|
||||
<p>
|
||||
When this module is compiled, the wrapped C functions can be used in a
|
||||
Perl script as follows :
|
||||
Perl script as follows:
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
|
|
@ -2227,7 +2225,7 @@ number of output values.
|
|||
<p>
|
||||
The total number of return values should not exceed the number of
|
||||
input values unless you explicitly extend the argument stack. This
|
||||
can be done using the <tt>EXTEND()</tt> macro as in :
|
||||
can be done using the <tt>EXTEND()</tt> macro as in:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -2286,7 +2284,7 @@ int multout(double a, double b, double *OUTPUT, double *OUTPUT);
|
|||
<p>
|
||||
When this function is called, the output arguments are appended to the stack used
|
||||
to return results. This shows up an array in Perl.
|
||||
For example :
|
||||
For example:
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
|
|
@ -2299,7 +2297,7 @@ print "multout(7,13) = @r\n";
|
|||
|
||||
|
||||
<p>
|
||||
Consider the following data structure :
|
||||
Consider the following data structure:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -2364,7 +2362,7 @@ to copy the converted array into a C data structure.
|
|||
<p>
|
||||
A frequent confusion on the SWIG mailing list is errors caused by the
|
||||
mixing of Perl references and C pointers. For example, suppose you
|
||||
have a C function that modifies its arguments like this :
|
||||
have a C function that modifies its arguments like this:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -2374,7 +2372,7 @@ void add(double a, double b, double *c) {
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
A common misinterpretation of this function is the following Perl script :
|
||||
A common misinterpretation of this function is the following Perl script:
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
|
|
@ -2411,7 +2409,7 @@ To make this work with a reference, you can use a typemap such as this:
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
Now, if you place this before the add function, you can do this :
|
||||
Now, if you place this before the add function, you can do this:
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
|
|
@ -2544,7 +2542,7 @@ high level wrappers. The wrappers, in turn, interact with the low-level procedu
|
|||
|
||||
|
||||
<p>
|
||||
Suppose you have the following SWIG interface file :
|
||||
Suppose you have the following SWIG interface file:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -2672,7 +2670,7 @@ $v->DESTROY();
|
|||
<p>
|
||||
In order for proxy classes to work properly, it is necessary for Perl
|
||||
to manage some mechanism of object ownership. Here's the crux of the
|
||||
problem---suppose you had a function like this :
|
||||
problem---suppose you had a function like this:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -2685,7 +2683,7 @@ Vector *Vector_get(Vector *v, int index) {
|
|||
This function takes a Vector pointer and returns a pointer to another
|
||||
Vector. Such a function might be used to manage arrays or lists of
|
||||
vectors (in C). Now contrast this function with the constructor for a
|
||||
Vector object :
|
||||
Vector object:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -2757,7 +2755,7 @@ sophisticated languages.
|
|||
|
||||
|
||||
<p>
|
||||
Suppose that we have a new object that looks like this :
|
||||
Suppose that we have a new object that looks like this:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -2774,7 +2772,7 @@ struct Particle {
|
|||
In this case, the members of the structure are complex objects that
|
||||
have already been encapsulated in a Perl proxy class. To handle
|
||||
these correctly, we use the <tt>%BLESSEDMEMBERS</tt> hash which would
|
||||
look like this (along with some supporting code) :
|
||||
look like this (along with some supporting code):
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
|
|
@ -2796,7 +2794,7 @@ unmodified.
|
|||
</p>
|
||||
|
||||
<p>
|
||||
This implementation allows us to operate on nested structures as follows :
|
||||
This implementation allows us to operate on nested structures as follows:
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
|
|
@ -2811,7 +2809,7 @@ $p->{f}->{x} = 0.0;
|
|||
|
||||
<p>
|
||||
When functions take arguments involving a complex object, it is
|
||||
sometimes necessary to write a proxy function. For example :
|
||||
sometimes necessary to write a proxy function. For example:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -2822,7 +2820,7 @@ double dot_product(Vector *v1, Vector *v2);
|
|||
Since Vector is an object already wrapped into a proxy class, we need
|
||||
to modify this function to accept arguments that are given in the form
|
||||
of tied hash tables. This is done by creating a Perl function like
|
||||
this :
|
||||
this:
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
|
|
@ -2846,7 +2844,7 @@ identical manner.
|
|||
<p>
|
||||
Simple C++ inheritance is handled using the Perl <tt>@ISA</tt> array
|
||||
in each class package. For example, if you have the following
|
||||
interface file :
|
||||
interface file:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -2881,7 +2879,7 @@ public:
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
The resulting, Perl wrapper class will create the following code :
|
||||
The resulting, Perl wrapper class will create the following code:
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
<li><a href="#SWIG_nn29">Simple renaming of specific identifiers</a>
|
||||
<li><a href="#SWIG_advanced_renaming">Advanced renaming support</a>
|
||||
<li><a href="#SWIG_limiting_renaming">Limiting global renaming rules</a>
|
||||
<li><a href="#SWIG_chosen_unignore">Ignoring everything then wrapping a few selected symbols</a>
|
||||
</ul>
|
||||
<li><a href="#SWIG_default_args">Default/optional arguments</a>
|
||||
<li><a href="#SWIG_nn30">Pointers to functions and callbacks</a>
|
||||
|
|
@ -1996,9 +1997,10 @@ such match expressions, for example
|
|||
</div>
|
||||
<p>
|
||||
will capitalize the names of all the enum elements but not change the case of
|
||||
the other declarations. Similarly, <tt>%$isclass</tt>, <tt>%$isfunction</tt>
|
||||
the other declarations. Similarly, <tt>%$isclass</tt>, <tt>%$isfunction</tt>,
|
||||
<tt>%$isconstructor</tt>, <tt>%$isunion</tt>, <tt>%$istemplate</tt>,
|
||||
and <tt>%$isvariable</tt> can be used. Many other checks are possible and this
|
||||
documentation is not exhaustive, see "%rename predicates" section of
|
||||
documentation is not exhaustive, see the "%rename predicates" section in
|
||||
<tt>swig.swg</tt> for the full list of supported match expressions.
|
||||
</p>
|
||||
|
||||
|
|
@ -2023,9 +2025,13 @@ declaration name directly can be preferable and can also be done using
|
|||
%rename("$ignore", regextarget=1) "Old$";
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Notice that the check is done only against the name of the declaration
|
||||
itself, if you need to match the full name of a C++ declaration you
|
||||
must use <tt>fullname</tt> attribute:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%rename("$ignore", regextarget=1, fullname=1) "NameSpace::ClassName::.*Old$";
|
||||
|
|
@ -2050,6 +2056,48 @@ wrap C++ overloaded functions and methods or C++ methods which use default argum
|
|||
</p>
|
||||
|
||||
|
||||
<H4><a name="SWIG_chosen_unignore"></a>5.4.7.4 Ignoring everything then wrapping a few selected symbols</H4>
|
||||
|
||||
|
||||
<p>
|
||||
Using the techniques described above it is possible to ignore everything in a header and then
|
||||
selectively wrap a few chosen methods or classes. For example, consider a header, <tt>myheader.h</tt>
|
||||
which has many classes in it and just the one class called <tt>Star</tt> is wanted within this header,
|
||||
the following approach could be taken:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%ignore ""; // Ignore everything
|
||||
|
||||
// Unignore chosen class 'Star'
|
||||
%rename("%s") Star;
|
||||
|
||||
// As the ignore everything will include the constructor, destructor, methods etc
|
||||
// in the class, these have to be explicitly unignored too:
|
||||
%rename("%s") Star::Star;
|
||||
%rename("%s") Star::~Star;
|
||||
%rename("%s") Star::shine; // named method
|
||||
|
||||
%include "myheader.h"
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Another approach which might be more suitable as it does not require naming all the methods in the
|
||||
chosen class is to begin by ignoring just the classes. This does not add an explicit ignore to any
|
||||
members of the class, so when the chosen class is unignored, all of its methods will be wrapped.
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%rename($ignore, %$isclass) ""; // Only ignore all classes
|
||||
%rename("%s") Star; // Unignore 'Star'
|
||||
%include "myheader.h"
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
<H3><a name="SWIG_default_args"></a>5.4.8 Default/optional arguments</H3>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ OCTSCRIPT = runme.m
|
|||
|
||||
octave_run: $(OCTSCRIPT)
|
||||
for file in $(OCTSCRIPT); do \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVEPATH=$(srcdir):$$OCTAVEPATH $(OCTAVE) $$file >/dev/null || break; \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(OCTAVE) $$file >/dev/null || break; \
|
||||
done
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
|
|
@ -1138,14 +1138,24 @@ uffi_clean:
|
|||
R = R
|
||||
RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system as it does not understand _wrap.cxx
|
||||
RRSRC = $(INTERFACE:.i=.R)
|
||||
R_CFLAGS=-fPIC
|
||||
|
||||
# need to compile .cxx files outside of R build system to make sure that
|
||||
# we get -fPIC
|
||||
|
||||
r: $(SRCS)
|
||||
$(SWIG) -r $(SWIGOPT) $(INTERFACEPATH)
|
||||
+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(SRCS) )
|
||||
ifneq ($(SRCS),)
|
||||
$(CXX) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES)
|
||||
endif
|
||||
+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) )
|
||||
|
||||
r_cpp: $(CXXSRCS)
|
||||
$(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
|
||||
+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(SRCS) $(CXXSRCS))
|
||||
ifneq ($(CXXSRCS),)
|
||||
$(CXX) -g -c $(CFLAGS) $(R_CFLAGS) $(CXXSRCS) $(INCLUDES)
|
||||
endif
|
||||
+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) )
|
||||
|
||||
r_clean:
|
||||
rm -f *_wrap* *~ .~*
|
||||
|
|
@ -1226,19 +1236,22 @@ scilab_clean:
|
|||
|
||||
GO = @GO@
|
||||
GOGCC = @GOGCC@
|
||||
GO1 = @GO1@
|
||||
GOC = @GOC@
|
||||
|
||||
GOSWIGARG = `if $(GOGCC) ; then echo -gccgo; fi`
|
||||
GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; fi`
|
||||
GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi`
|
||||
|
||||
GOSRCS = $(INTERFACE:.i=.go)
|
||||
GOCSRCS = $(INTERFACE:.i=_gc.c)
|
||||
|
||||
GOC = $(GO:g=c)
|
||||
GOLD = $(GO:g=l)
|
||||
GOLD = $(GOC:c=l)
|
||||
GOTOOL = `if $(GO1) ; then echo go tool; fi`
|
||||
GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi`
|
||||
|
||||
GOPACKAGE = $(INTERFACE:.i=.a)
|
||||
|
||||
GOOBJEXT = $(GO:g=)
|
||||
GOOBJEXT = $(GOC:c=)
|
||||
GOGCOBJS = $(GOSRCS:.go=.$(GOOBJEXT))
|
||||
GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@)
|
||||
|
||||
|
|
@ -1250,10 +1263,10 @@ go: $(SRCS)
|
|||
$(SWIG) -go $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH)
|
||||
$(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES)
|
||||
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
|
||||
$(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(GOSRCS)
|
||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS)
|
||||
if ! $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GOC) -I $${GOROOT}/pkg/$${GOOS}_$${GOARCH} $(GOCSRCS) && \
|
||||
$(COMPILETOOL) gopack grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT}/pkg/$${GOOS}_$${GOARCH} $(GOCSRCS) && \
|
||||
$(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
|
||||
fi
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
|
@ -1264,10 +1277,10 @@ go_cpp: $(SRCS)
|
|||
$(SWIG) -go -c++ $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH)
|
||||
$(CXX) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
|
||||
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
|
||||
$(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(GOSRCS)
|
||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS)
|
||||
if ! $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GOC) -I $${GOROOT}/pkg/$${GOOS}_$${GOARCH} $(GOCSRCS) && \
|
||||
$(COMPILETOOL) gopack grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT}/pkg/$${GOOS}_$${GOARCH} $(GOCSRCS) && \
|
||||
$(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
|
|
@ -1279,7 +1292,7 @@ go_run: runme.go
|
|||
if $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GO) -o runme runme.@OBJEXT@ $(GOGCCOBJS) $(LIBPREFIX)$(TARGET)$(SO); \
|
||||
else \
|
||||
$(COMPILETOOL) $(GOLD) -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o runme runme.$(GOOBJEXT); \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o runme runme.$(GOOBJEXT); \
|
||||
fi
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme
|
||||
|
||||
|
|
|
|||
|
|
@ -38,3 +38,11 @@ example -globals mycvar
|
|||
assert(!isglobal("cvar"))
|
||||
assert(mycvar.ivar == example.ifunc())
|
||||
##### END TEST #####
|
||||
|
||||
clear all;
|
||||
|
||||
##### BEGIN TEST #####
|
||||
# load module with root-level cvar
|
||||
example -globals .
|
||||
assert(example.ivar == example.ifunc())
|
||||
##### END TEST #####
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ CPP_TEST_BROKEN += \
|
|||
exception_partial_info \
|
||||
extend_variable \
|
||||
li_std_vector_ptr \
|
||||
li_boost_shared_ptr_template \
|
||||
overload_complicated \
|
||||
template_default_pointer \
|
||||
template_expr
|
||||
|
|
@ -472,6 +473,7 @@ CPP_STD_TEST_CASES += \
|
|||
li_std_pair \
|
||||
li_std_string \
|
||||
li_std_vector \
|
||||
li_std_vector_enum \
|
||||
naturalvar \
|
||||
smart_pointer_inherit \
|
||||
template_typedef_fnc \
|
||||
|
|
|
|||
27
Examples/test-suite/csharp/li_std_vector_enum_runme.cs
Normal file
27
Examples/test-suite/csharp/li_std_vector_enum_runme.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// This test tests all the methods in the C# collection wrapper
|
||||
|
||||
using System;
|
||||
using li_std_vector_enumNamespace;
|
||||
|
||||
public class li_std_vector_enum_runme {
|
||||
|
||||
public static void Main() {
|
||||
EnumVector ev = new EnumVector();
|
||||
|
||||
check((int)ev.nums[0], 10);
|
||||
check((int)ev.nums[1], 20);
|
||||
check((int)ev.nums[2], 30);
|
||||
|
||||
int expected = 10;
|
||||
foreach (EnumVector.numbers val in ev.nums) {
|
||||
check((int)val, expected);
|
||||
expected += 10;
|
||||
}
|
||||
}
|
||||
|
||||
private static void check(int a, int b) {
|
||||
if (a != b)
|
||||
throw new ApplicationException("values don't match");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ namespace Bar
|
|||
virtual Foo makeFoo() { return Foo(); }
|
||||
virtual FooBar makeFooBar() { return FooBar(); }
|
||||
|
||||
static Foo* get_self(Foo *self) {return self;}
|
||||
static Foo* get_self(Foo *self_) {return self_;}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -63,6 +63,6 @@ namespace Bar
|
|||
virtual Foo makeFoo();
|
||||
virtual FooBar makeFooBar();
|
||||
|
||||
static Foo* get_self(Foo *self);
|
||||
static Foo* get_self(Foo *self_);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,17 @@
|
|||
|
||||
LANGUAGE = go
|
||||
GO = @GO@
|
||||
GOGCC = false
|
||||
GOGCC = @GOGCC@
|
||||
GO1 = @GO1@
|
||||
GOC = @GOC@
|
||||
SCRIPTSUFFIX = _runme.go
|
||||
|
||||
GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; fi`
|
||||
GOC = $(GO:g=c)
|
||||
GOLD = $(GO:g=l)
|
||||
GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi`
|
||||
GOLD = $(GOC:c=l)
|
||||
GOTOOL = `if $(GO1) ; then echo go tool; fi`
|
||||
GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi`
|
||||
|
||||
GOOBJEXT = $(GO:g=)
|
||||
GOOBJEXT = $(GOC:c=)
|
||||
|
||||
SO = @SO@
|
||||
|
||||
|
|
@ -53,23 +56,23 @@ multi_import.multicpptest:
|
|||
# Runs the testcase.
|
||||
run_testcase = \
|
||||
if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
|
||||
$(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
if $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*$(SO); \
|
||||
else \
|
||||
$(COMPILETOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
fi && \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
|
||||
fi
|
||||
|
||||
run_multi_testcase = \
|
||||
if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
|
||||
$(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
if $(GOGCC) ; then \
|
||||
files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \
|
||||
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.@OBJEXT@ $$f$(SO); done`; \
|
||||
else \
|
||||
$(COMPILETOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
fi && \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
LANGUAGE = java
|
||||
JAVA = java
|
||||
JAVAC = javac
|
||||
JAVAFLAGS = -Xcheck:jni
|
||||
SCRIPTSUFFIX = _runme.java
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = ../@top_srcdir@
|
||||
|
|
@ -79,7 +80,7 @@ run_testcase = \
|
|||
cd $(JAVA_PACKAGE) && $(COMPILETOOL) $(JAVAC) -classpath . `find . -name "*.java"` && cd .. && \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
$(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme; \
|
||||
env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) $(JAVAFLAGS) -classpath . $*_runme; \
|
||||
fi
|
||||
|
||||
# Clean: remove testcase directories
|
||||
|
|
|
|||
27
Examples/test-suite/java/li_std_vector_enum_runme.java
Normal file
27
Examples/test-suite/java/li_std_vector_enum_runme.java
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import li_std_vector_enum.*;
|
||||
|
||||
public class li_std_vector_enum_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("li_std_vector_enum");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) throws Throwable
|
||||
{
|
||||
EnumVector ev = new EnumVector();
|
||||
|
||||
check(ev.getNums().get(0).swigValue(), 10);
|
||||
check(ev.getNums().get(1).swigValue(), 20);
|
||||
check(ev.getNums().get(2).swigValue(), 30);
|
||||
}
|
||||
|
||||
private static void check(int a, int b) {
|
||||
if (a != b)
|
||||
throw new RuntimeException("values don't match");
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,11 @@
|
|||
%{
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#ifdef SWIGR
|
||||
// remove naming conflict with R symbol
|
||||
#define INTEGER MYINTEGER
|
||||
#endif
|
||||
|
||||
typedef int INTEGER;
|
||||
|
||||
template <class T>
|
||||
|
|
|
|||
23
Examples/test-suite/li_std_vector_enum.i
Normal file
23
Examples/test-suite/li_std_vector_enum.i
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
%module li_std_vector_enum
|
||||
|
||||
%include "std_vector.i"
|
||||
|
||||
%inline %{
|
||||
class EnumVector {
|
||||
public:
|
||||
EnumVector() { fill_numbers(); }
|
||||
|
||||
enum numbers {ten=10, twenty=20, thirty=30};
|
||||
|
||||
std::vector<numbers> nums;
|
||||
|
||||
void fill_numbers() {
|
||||
nums.push_back(ten);
|
||||
nums.push_back(twenty);
|
||||
nums.push_back(thirty);
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
%template(vector_numbers) std::vector<EnumVector::numbers>;
|
||||
|
||||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("abstract_access") -- import code
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
-- trying to instantiate pure virual classes
|
||||
-- should fail
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ import("cpp_basic") -- import code
|
|||
cb=cpp_basic -- renaming import
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
f=cb.Foo(4)
|
||||
assert(f.num==4)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("disown") -- import code
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
for x=0,100 do
|
||||
a=disown.A()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("enums") -- import lib
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
-- check values
|
||||
assert(enums.CSP_ITERATION_FWD==0)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import("exception_order") -- import lib into global
|
|||
eo=exception_order --alias
|
||||
|
||||
-- catching undefined variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
a = eo.A()
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("import_nomodule") -- import code
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
f = import_nomodule.create_Foo()
|
||||
import_nomodule.test1(f,42)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ import("li_carrays") -- import code
|
|||
for k,v in pairs(li_carrays) do _G[k]=v end
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
-- Testing for %array_functions(int,intArray)
|
||||
ary = new_intArray(2)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import("li_std_string") -- import lib
|
|||
for k,v in pairs(li_std_string) do _G[k]=v end -- move to global
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
-- helper to check type
|
||||
function is_std_string(s)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("li_typemaps") -- import code
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
-- Check double INPUT typemaps
|
||||
assert(li_typemaps.in_double(22.22) == 22.22)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ for k,v in pairs(operator_overload) do _G[k]=v end -- move to global
|
|||
Op_sanity_check()
|
||||
|
||||
-- catching undefined variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
-- test routine:
|
||||
a=Op()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ top_builddir = @top_builddir@
|
|||
CPP_TEST_CASES += \
|
||||
li_std_pair_extra \
|
||||
li_std_string_extra \
|
||||
octave_cell_deref
|
||||
octave_cell_deref\
|
||||
octave_dim
|
||||
|
||||
CPP_TEST_BROKEN += \
|
||||
implicittest \
|
||||
|
|
@ -57,7 +58,7 @@ CSRCS = octave_empty.c
|
|||
# a file is found which has _runme.m appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVEPATH=$(srcdir):OCTAVEPATH $(RUNTOOL) $(OCTAVE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(RUNTOOL) $(OCTAVE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean: remove the generated .m file
|
||||
|
|
|
|||
27
Examples/test-suite/octave/li_std_vector_enum_runme.m
Normal file
27
Examples/test-suite/octave/li_std_vector_enum_runme.m
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
li_std_vector_enum
|
||||
|
||||
function check(a, b)
|
||||
if (a != b)
|
||||
error("incorrect match");
|
||||
endif
|
||||
end
|
||||
|
||||
ev = EnumVector();
|
||||
|
||||
check(ev.nums(0), 10);
|
||||
check(ev.nums(1), 20);
|
||||
check(ev.nums(2), 30);
|
||||
|
||||
it = ev.nums.begin();
|
||||
v = it.value();
|
||||
check(v, 10);
|
||||
it.next();
|
||||
v = it.value();
|
||||
check(v, 20);
|
||||
|
||||
#expected = 10
|
||||
#ev.nums.each do|val|
|
||||
# swig_assert(val == expected)
|
||||
# expected += 10
|
||||
#end
|
||||
|
||||
18
Examples/test-suite/octave/octave_dim_runme.m
Normal file
18
Examples/test-suite/octave/octave_dim_runme.m
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
octave_dim
|
||||
|
||||
assert(all(size(Foo45a())==[4 5]));
|
||||
assert(all(size(Foo456a())==[4 5 6]));
|
||||
assert(all(size(Foo4a())==[4 1]));
|
||||
assert(all(size(Foo4b())==[4 1]));
|
||||
assert(all(size(Foo())==[1 1]));
|
||||
assert(all(size(Bar1())==[1 1]));
|
||||
assert(all(size(Bar2())==[1 1]));
|
||||
assert(all(size(Baz1())==[3 4]));
|
||||
assert(all(size(Baz2())==[3 4]));
|
||||
assert(all(size(Baz3())==[3 4]));
|
||||
assert(all(size(Baz4())==[3 4]));
|
||||
|
||||
% Assertions will not work, but kept for future reference.
|
||||
%assert(all(size(Baz5())==[3 4]));
|
||||
%assert(all(size(Baz6())==[3 4]));
|
||||
%assert(all(size(Baz7())==[3 4]));
|
||||
160
Examples/test-suite/octave_dim.i
Normal file
160
Examples/test-suite/octave_dim.i
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
%module octave_dim
|
||||
|
||||
%include "std_vector.i"
|
||||
|
||||
namespace std {
|
||||
%template(IntVector) vector<int>;
|
||||
}
|
||||
|
||||
|
||||
%typemap(out) Matrix {
|
||||
$result = $1;
|
||||
}
|
||||
|
||||
// Code below will not work. Kept for future reference.
|
||||
// Reason: there is no octave_value(Array<octave_idx_type>) constructor
|
||||
//%typemap(out) Array<octave_idx_type> {
|
||||
// $result = octave_value($1,true);
|
||||
//}
|
||||
|
||||
|
||||
%inline %{
|
||||
|
||||
class Foo45a {
|
||||
public:
|
||||
std::vector<int> __dims__() const {
|
||||
std::vector<int> ret(2);
|
||||
ret[0] = 4;
|
||||
ret[1] = 5;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
// doubles are not converted to ints.
|
||||
class Bar1 {
|
||||
public:
|
||||
std::vector<double> __dims__() const {
|
||||
std::vector<double> ret(2);
|
||||
ret[0] = 4;
|
||||
ret[1] = 5;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
class Bar2 {
|
||||
public:
|
||||
std::string __dims__() const {
|
||||
return "foo";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Foo4a {
|
||||
public:
|
||||
std::vector<int> __dims__() const {
|
||||
std::vector<int> ret(1);
|
||||
ret[0] = 4;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
class Foo4b {
|
||||
public:
|
||||
int __dims__() const {
|
||||
return 4;
|
||||
}
|
||||
};
|
||||
|
||||
class Foo456a {
|
||||
public:
|
||||
std::vector<int> __dims__() const {
|
||||
std::vector<int> ret(3);
|
||||
ret[0] = 4;
|
||||
ret[1] = 5;
|
||||
ret[2] = 6;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class Foo {
|
||||
|
||||
};
|
||||
|
||||
|
||||
class Baz1 {
|
||||
public:
|
||||
Cell __dims__() const {
|
||||
Cell c(1,2);
|
||||
c(0) = 3;
|
||||
c(1) = 4;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
class Baz2 {
|
||||
public:
|
||||
Cell __dims__() const {
|
||||
Cell c(2,1);
|
||||
c(0) = 3;
|
||||
c(1) = 4;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
class Baz3 {
|
||||
public:
|
||||
Matrix __dims__() const {
|
||||
Matrix c(2,1);
|
||||
c(0) = 3;
|
||||
c(1) = 4;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
class Baz4 {
|
||||
public:
|
||||
Matrix __dims__() const {
|
||||
Matrix c(1,2);
|
||||
c(0) = 3;
|
||||
c(1) = 4;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
class Baz5 {
|
||||
public:
|
||||
Array<octave_idx_type> __dims__() const {
|
||||
Array<octave_idx_type> c(2,1);
|
||||
c(0) = 3;
|
||||
c(1) = 4;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
class Baz6 {
|
||||
public:
|
||||
Array<octave_idx_type> __dims__() const {
|
||||
Array<octave_idx_type> c(1,2);
|
||||
c(0) = 3;
|
||||
c(1) = 4;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
// Code below will not work. Kept for future reference.
|
||||
// Reason: there is no octave_value(dim_vector) constructor
|
||||
// class Baz7 {
|
||||
//public:
|
||||
// dim_vector __dims__() const {
|
||||
// octave_value v = dim_vector(3,4);
|
||||
// Array<int> a = v.int_vector_value();
|
||||
// if (error_state) return dim_vector(1,1);
|
||||
// int mysize = a.numel();
|
||||
// return dim_vector(3,4);
|
||||
// }
|
||||
//};
|
||||
|
||||
%}
|
||||
|
|
@ -80,3 +80,22 @@
|
|||
#define EXPR_LOR 0xFF || 1
|
||||
#define EXPR_CONDITIONAL true ? 2 : 2.2
|
||||
|
||||
|
||||
/// constant assignment in enum
|
||||
#if defined(SWIGCSHARP)
|
||||
%csconstvalue("1<<2") kValue;
|
||||
#endif
|
||||
|
||||
%{
|
||||
#define BIT(n) (1ULL << (n))
|
||||
|
||||
enum MyEnum {
|
||||
kValue = BIT(2)
|
||||
};
|
||||
%}
|
||||
|
||||
#define BIT(n) (1ULL << (n))
|
||||
|
||||
enum MyEnum {
|
||||
kValue = BIT(2)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35,3 +35,18 @@ int multiply60(int a) { return a*60; }
|
|||
int multiply70(int a) { return a*70; }
|
||||
%}
|
||||
|
||||
%define nested_include_1(HEADER)
|
||||
%include <HEADER>
|
||||
%enddef
|
||||
|
||||
%define nested_include_2(HEADER)
|
||||
nested_include_1(HEADER);
|
||||
%enddef
|
||||
|
||||
%define nested_include_3(HEADER)
|
||||
nested_include_2(HEADER);
|
||||
%enddef
|
||||
|
||||
nested_include_1(preproc_include_h1.i);
|
||||
nested_include_2(preproc_include_h2.i);
|
||||
nested_include_3(preproc_include_h3.i);
|
||||
|
|
|
|||
1
Examples/test-suite/preproc_include_h1.i
Normal file
1
Examples/test-suite/preproc_include_h1.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
#define const1 1
|
||||
1
Examples/test-suite/preproc_include_h2.i
Normal file
1
Examples/test-suite/preproc_include_h2.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
#define const2 2
|
||||
1
Examples/test-suite/preproc_include_h3.i
Normal file
1
Examples/test-suite/preproc_include_h3.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
#define const3 3
|
||||
24
Examples/test-suite/python/li_std_vector_enum_runme.py
Normal file
24
Examples/test-suite/python/li_std_vector_enum_runme.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import li_std_vector_enum
|
||||
|
||||
def check(a, b):
|
||||
if (a != b):
|
||||
raise RuntimeError("Not equal: ", a, b)
|
||||
|
||||
ev = li_std_vector_enum.EnumVector()
|
||||
|
||||
check(ev.nums[0], 10)
|
||||
check(ev.nums[1], 20)
|
||||
check(ev.nums[2], 30)
|
||||
|
||||
it = ev.nums.iterator()
|
||||
v = it.value()
|
||||
check(v, 10)
|
||||
it.next()
|
||||
v = it.value()
|
||||
check(v, 20)
|
||||
|
||||
expected = 10
|
||||
for val in ev.nums:
|
||||
check(val, expected)
|
||||
expected += 10
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ top_srcdir = @top_srcdir@
|
|||
top_builddir = @top_builddir@
|
||||
|
||||
C_TEST_CASES = r_copy_struct r_legacy
|
||||
CPP_TEST_CASES = r_double_delete
|
||||
CPP_TEST_CASES = r_double_delete r_overload_array
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
|
|
|
|||
20
Examples/test-suite/r_overload_array.i
Normal file
20
Examples/test-suite/r_overload_array.i
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
%module r_overload_array
|
||||
%include "stl.i"
|
||||
# this tests the situation in which there is a scalar function
|
||||
# corresponding with a vector one
|
||||
|
||||
%inline %{
|
||||
class Foo {
|
||||
public:
|
||||
double bar(double w) {return w;};
|
||||
double bar(double *w) {return w[0];}
|
||||
double bar(std::vector<double> w) {return w[0];}
|
||||
|
||||
int bar_int(int w) {return w;}
|
||||
int bar_int(int *w) {return w[0];}
|
||||
int bar_int(std::vector<int> w) {return w[0];}
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
|
||||
25
Examples/test-suite/ruby/li_std_vector_enum_runme.rb
Executable file
25
Examples/test-suite/ruby/li_std_vector_enum_runme.rb
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'swig_assert'
|
||||
require 'li_std_vector_enum'
|
||||
include Li_std_vector_enum
|
||||
|
||||
ev = EnumVector.new()
|
||||
|
||||
swig_assert(ev.nums[0] == 10)
|
||||
swig_assert(ev.nums[1] == 20)
|
||||
swig_assert(ev.nums[2] == 30)
|
||||
|
||||
it = ev.nums.begin
|
||||
v = it.value()
|
||||
swig_assert(v == 10)
|
||||
it.next()
|
||||
v = it.value()
|
||||
swig_assert(v == 20)
|
||||
|
||||
expected = 10
|
||||
ev.nums.each do|val|
|
||||
swig_assert(val == expected)
|
||||
expected += 10
|
||||
end
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
%module template_typedef_virtual
|
||||
%module template_typedef_inherit
|
||||
|
||||
// Bug 3378145
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ template<class Key, class T, class J = int> class Multimap {
|
|||
namespace Standard {
|
||||
template<> class Multimap<A, int> {
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
typedef A key_type;
|
||||
typedef int mapped_type;
|
||||
|
||||
class iterator;
|
||||
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ template<class Key, class T, class J = int> class Multimap {
|
|||
namespace Standard {
|
||||
template<> class Multimap<A, int> {
|
||||
public:
|
||||
typedef Key key_type;
|
||||
typedef T mapped_type;
|
||||
typedef A key_type;
|
||||
typedef int mapped_type;
|
||||
|
||||
class iterator;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,12 +17,6 @@
|
|||
|
||||
%{
|
||||
#include <string>
|
||||
// #include <vector>
|
||||
// using std::vector;
|
||||
|
||||
using std::string;
|
||||
|
||||
|
||||
%}
|
||||
|
||||
// %include <std_vector.i>
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ static import tango.stdc.stringz;
|
|||
%pragma(d) imdmodulecode=%{
|
||||
private class SwigExceptionHelper {
|
||||
static this() {
|
||||
swigRegisterExceptionCallbacks(
|
||||
swigRegisterExceptionCallbacks$module(
|
||||
&setException,
|
||||
&setIllegalArgumentException,
|
||||
&setIllegalElementException,
|
||||
|
|
@ -91,31 +91,31 @@ private class SwigExceptionHelper {
|
|||
&setNoSuchElementException);
|
||||
}
|
||||
|
||||
static void setException(char* message) {
|
||||
static void setException(const char* message) {
|
||||
auto exception = new object.Exception(tango.stdc.stringz.fromStringz(message).dup);
|
||||
exception.next = SwigPendingException.retrieve();
|
||||
SwigPendingException.set(exception);
|
||||
}
|
||||
|
||||
static void setIllegalArgumentException(char* message) {
|
||||
static void setIllegalArgumentException(const char* message) {
|
||||
auto exception = new tango.core.Exception.IllegalArgumentException(tango.stdc.stringz.fromStringz(message).dup);
|
||||
exception.next = SwigPendingException.retrieve();
|
||||
SwigPendingException.set(exception);
|
||||
}
|
||||
|
||||
static void setIllegalElementException(char* message) {
|
||||
static void setIllegalElementException(const char* message) {
|
||||
auto exception = new tango.core.Exception.IllegalElementException(tango.stdc.stringz.fromStringz(message).dup);
|
||||
exception.next = SwigPendingException.retrieve();
|
||||
SwigPendingException.set(exception);
|
||||
}
|
||||
|
||||
static void setIOException(char* message) {
|
||||
static void setIOException(const char* message) {
|
||||
auto exception = new tango.core.Exception.IOException(tango.stdc.stringz.fromStringz(message).dup);
|
||||
exception.next = SwigPendingException.retrieve();
|
||||
SwigPendingException.set(exception);
|
||||
}
|
||||
|
||||
static void setNoSuchElementException(char* message) {
|
||||
static void setNoSuchElementException(const char* message) {
|
||||
auto exception = new tango.core.Exception.NoSuchElementException(tango.stdc.stringz.fromStringz(message).dup);
|
||||
exception.next = SwigPendingException.retrieve();
|
||||
SwigPendingException.set(exception);
|
||||
|
|
@ -174,7 +174,7 @@ private:
|
|||
alias tango.core.Thread.ThreadLocal!(object.Exception) ThreadLocalData;
|
||||
static ThreadLocalData m_sPendingException;
|
||||
}
|
||||
alias void function(char* message) SwigExceptionCallback;
|
||||
alias void function(const char* message) SwigExceptionCallback;
|
||||
%}
|
||||
#else
|
||||
%pragma(d) imdmoduleimports=%{
|
||||
|
|
@ -185,7 +185,7 @@ static import std.conv;
|
|||
private class SwigExceptionHelper {
|
||||
static this() {
|
||||
// The D1/Tango version maps C++ exceptions to multiple exception types.
|
||||
swigRegisterExceptionCallbacks(
|
||||
swigRegisterExceptionCallbacks$module(
|
||||
&setException,
|
||||
&setException,
|
||||
&setException,
|
||||
|
|
@ -283,7 +283,7 @@ SWIGEXPORT void SWIGRegisterStringCallback_$module(SWIG_DStringHelperCallback ca
|
|||
%pragma(d) imdmodulecode = %{
|
||||
private class SwigStringHelper {
|
||||
static this() {
|
||||
swigRegisterStringCallback(&createString);
|
||||
swigRegisterStringCallback$module(&createString);
|
||||
}
|
||||
|
||||
static char* createString(char* cString) {
|
||||
|
|
@ -302,7 +302,7 @@ static import std.string;
|
|||
%pragma(d) imdmodulecode = %{
|
||||
private class SwigStringHelper {
|
||||
static this() {
|
||||
swigRegisterStringCallback(&createString);
|
||||
swigRegisterStringCallback$module(&createString);
|
||||
}
|
||||
|
||||
static const(char)* createString(const(char*) cString) {
|
||||
|
|
|
|||
|
|
@ -282,10 +282,10 @@ static this() {
|
|||
}
|
||||
|
||||
//#if !defined(SWIG_D_NO_EXCEPTION_HELPER)
|
||||
mixin(bindCode("swigRegisterExceptionCallbacks", "SWIGRegisterExceptionCallbacks_$module"));
|
||||
mixin(bindCode("swigRegisterExceptionCallbacks$module", "SWIGRegisterExceptionCallbacks_$module"));
|
||||
//#endif // SWIG_D_NO_EXCEPTION_HELPER
|
||||
//#if !defined(SWIG_D_NO_STRING_HELPER)
|
||||
mixin(bindCode("swigRegisterStringCallback", "SWIGRegisterStringCallback_$module"));
|
||||
mixin(bindCode("swigRegisterStringCallback$module", "SWIGRegisterStringCallback_$module"));
|
||||
//#endif // SWIG_D_NO_STRING_HELPER
|
||||
$wrapperloaderbindcode
|
||||
}
|
||||
|
|
@ -296,11 +296,11 @@ extern(C) void function(
|
|||
SwigExceptionCallback illegalArgumentCallback,
|
||||
SwigExceptionCallback illegalElementCallback,
|
||||
SwigExceptionCallback ioCallback,
|
||||
SwigExceptionCallback noSuchElementCallback) swigRegisterExceptionCallbacks;
|
||||
SwigExceptionCallback noSuchElementCallback) swigRegisterExceptionCallbacks$module;
|
||||
//#endif // SWIG_D_NO_EXCEPTION_HELPER
|
||||
|
||||
//#if !defined(SWIG_D_NO_STRING_HELPER)
|
||||
extern(C) void function(SwigStringCallback callback) swigRegisterStringCallback;
|
||||
extern(C) void function(SwigStringCallback callback) swigRegisterStringCallback$module;
|
||||
//#endif // SWIG_D_NO_STRING_HELPER
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,6 +117,16 @@ import _ "runtime/cgo"
|
|||
|
||||
%}
|
||||
|
||||
#else
|
||||
|
||||
%insert(go_header) %{
|
||||
|
||||
import "syscall"
|
||||
|
||||
type _ syscall.Sockaddr
|
||||
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
/* Function pointers are translated by the code in go.cxx into
|
||||
|
|
|
|||
40
Lib/go/std_list.i
Normal file
40
Lib/go/std_list.i
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_vector.i
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <list>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T, class Alloc = allocator<T> >
|
||||
class list {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef Alloc allocator_type;
|
||||
|
||||
list();
|
||||
size_type size() const;
|
||||
bool empty() const;
|
||||
%rename(isEmpty) empty;
|
||||
void clear();
|
||||
void push_front(const value_type& x);
|
||||
void pop_front();
|
||||
void push_back(const value_type& x);
|
||||
void pop_back();
|
||||
void remove(value_type x);
|
||||
void reverse();
|
||||
void unique();
|
||||
void sort();
|
||||
void merge(list& x);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -28,9 +28,9 @@
|
|||
/* Array support functions declarations macro */
|
||||
%define JAVA_ARRAYS_DECL(CTYPE, JNITYPE, JAVATYPE, JFUNCNAME)
|
||||
%{
|
||||
int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNITYPE##Array input);
|
||||
void SWIG_JavaArrayArgout##JFUNCNAME (JNIEnv *jenv, JNITYPE *jarr, CTYPE *carr, JNITYPE##Array input);
|
||||
JNITYPE##Array SWIG_JavaArrayOut##JFUNCNAME (JNIEnv *jenv, CTYPE *result, jsize sz);
|
||||
static int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNITYPE##Array input);
|
||||
static void SWIG_JavaArrayArgout##JFUNCNAME (JNIEnv *jenv, JNITYPE *jarr, CTYPE *carr, JNITYPE##Array input);
|
||||
static JNITYPE##Array SWIG_JavaArrayOut##JFUNCNAME (JNIEnv *jenv, CTYPE *result, jsize sz);
|
||||
%}
|
||||
%enddef
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ JNITYPE##Array SWIG_JavaArrayOut##JFUNCNAME (JNIEnv *jenv, CTYPE *result, jsize
|
|||
%define JAVA_ARRAYS_IMPL(CTYPE, JNITYPE, JAVATYPE, JFUNCNAME)
|
||||
%{
|
||||
/* CTYPE[] support */
|
||||
int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNITYPE##Array input) {
|
||||
static int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNITYPE##Array input) {
|
||||
int i;
|
||||
jsize sz;
|
||||
if (!input) {
|
||||
|
|
@ -63,7 +63,7 @@ int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNI
|
|||
return 1;
|
||||
}
|
||||
|
||||
void SWIG_JavaArrayArgout##JFUNCNAME (JNIEnv *jenv, JNITYPE *jarr, CTYPE *carr, JNITYPE##Array input) {
|
||||
static void SWIG_JavaArrayArgout##JFUNCNAME (JNIEnv *jenv, JNITYPE *jarr, CTYPE *carr, JNITYPE##Array input) {
|
||||
int i;
|
||||
jsize sz = JCALL1(GetArrayLength, jenv, input);
|
||||
for (i=0; i<sz; i++)
|
||||
|
|
@ -71,7 +71,7 @@ void SWIG_JavaArrayArgout##JFUNCNAME (JNIEnv *jenv, JNITYPE *jarr, CTYPE *carr,
|
|||
JCALL3(Release##JAVATYPE##ArrayElements, jenv, input, jarr, 0);
|
||||
}
|
||||
|
||||
JNITYPE##Array SWIG_JavaArrayOut##JFUNCNAME (JNIEnv *jenv, CTYPE *result, jsize sz) {
|
||||
static JNITYPE##Array SWIG_JavaArrayOut##JFUNCNAME (JNIEnv *jenv, CTYPE *result, jsize sz) {
|
||||
JNITYPE *arr;
|
||||
int i;
|
||||
JNITYPE##Array jresult = JCALL1(New##JAVATYPE##Array, jenv, sz);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,24 @@ extern "C" {
|
|||
#include <stdlib.h> /* for malloc */
|
||||
#include <assert.h> /* for a few sanity tests */
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* compatibility defines
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* History of Lua C API length functions: In Lua 5.0 (and before?)
|
||||
there was "lua_strlen". In Lua 5.1, this was renamed "lua_objlen",
|
||||
but a compatibility define of "lua_strlen" was added. In Lua 5.2,
|
||||
this function was again renamed, to "lua_rawlen" (to emphasize that
|
||||
it doesn't call the "__len" metamethod), and the compatibility
|
||||
define of lua_strlen was removed. All SWIG uses have been updated
|
||||
to "lua_rawlen", and we add our own defines of that here for older
|
||||
versions of Lua. */
|
||||
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501
|
||||
# define lua_rawlen lua_strlen
|
||||
#elif LUA_VERSION_NUM == 501
|
||||
# define lua_rawlen lua_objlen
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* global swig types
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -30,7 +30,11 @@ SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */
|
|||
#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */
|
||||
int i;
|
||||
/* start with global table */
|
||||
#ifdef LUA_RIDX_GLOBALS
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS);
|
||||
#else
|
||||
lua_pushvalue(L,LUA_GLOBALSINDEX);
|
||||
#endif
|
||||
/* SWIG's internal initalisation */
|
||||
SWIG_InitializeModule((void*)L);
|
||||
SWIG_PropagateClientData();
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ parmeters match which function
|
|||
|
||||
// special check for a char (string of length 1)
|
||||
%typecheck(SWIG_TYPECHECK_CHAR,fragment="SWIG_lua_isnilstring") char, const char& {
|
||||
$1 = SWIG_lua_isnilstring(L,$input) && (lua_strlen(L,$input)==1);
|
||||
$1 = SWIG_lua_isnilstring(L,$input) && (lua_rawlen(L,$input)==1);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_STRING,fragment="SWIG_lua_isnilstring") char *, char[] {
|
||||
|
|
|
|||
|
|
@ -41,18 +41,18 @@ but
|
|||
Similarly for getting the string
|
||||
$1 = (char*)lua_tostring(L, $input);
|
||||
becomes
|
||||
$1.assign(lua_tostring(L,$input),lua_strlen(L,$input));
|
||||
$1.assign(lua_tostring(L,$input),lua_rawlen(L,$input));
|
||||
|
||||
Not using: lua_tolstring() as this is only found in Lua 5.1 & not 5.0.2
|
||||
*/
|
||||
|
||||
%typemap(in,checkfn="lua_isstring") std::string
|
||||
%{$1.assign(lua_tostring(L,$input),lua_strlen(L,$input));%}
|
||||
%{$1.assign(lua_tostring(L,$input),lua_rawlen(L,$input));%}
|
||||
%typemap(out) std::string
|
||||
%{ lua_pushlstring(L,$1.data(),$1.size()); SWIG_arg++;%}
|
||||
|
||||
%typemap(in,checkfn="lua_isstring") const std::string& (std::string temp)
|
||||
%{temp.assign(lua_tostring(L,$input),lua_strlen(L,$input)); $1=&temp;%}
|
||||
%{temp.assign(lua_tostring(L,$input),lua_rawlen(L,$input)); $1=&temp;%}
|
||||
|
||||
%typemap(out) const std::string&
|
||||
%{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_arg++;%}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ wchar_t* str2wstr(const char *str, int len)
|
|||
|
||||
%typemap(in, checkfn="SWIG_lua_isnilstring", fragment="SWIG_lua_isnilstring") wchar_t *
|
||||
%{
|
||||
$1 = str2wstr(lua_tostring( L, $input ),lua_strlen( L, $input ));
|
||||
$1 = str2wstr(lua_tostring( L, $input ),lua_rawlen( L, $input ));
|
||||
if ($1==0) {lua_pushfstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;}
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace swig {
|
|||
}
|
||||
}
|
||||
|
||||
%fragment("OctSequence_Base","header")
|
||||
%fragment("OctSequence_Base","header",fragment="<stddef.h>")
|
||||
{
|
||||
%#include <functional>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
%include <std_common.i>
|
||||
|
||||
%fragment("OctSwigIterator","header") {
|
||||
%fragment("OctSwigIterator","header",fragment="<stddef.h>") {
|
||||
namespace swig {
|
||||
struct stop_iteration {
|
||||
};
|
||||
|
|
@ -113,7 +113,7 @@ namespace swig {
|
|||
}
|
||||
}
|
||||
|
||||
%fragment("OctSwigIterator_T","header",fragment="OctSwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
|
||||
%fragment("OctSwigIterator_T","header",fragment="<stddef.h>",fragment="OctSwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
|
||||
namespace swig {
|
||||
template<typename OutIterator>
|
||||
class OctSwigIterator_T : public OctSwigIterator
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class octave_swig_type;
|
|||
namespace Swig {
|
||||
class Director;
|
||||
|
||||
SWIGRUNTIME void swig_register_director(octave_swig_type *self, void *ptr, Director *d);
|
||||
//SWIGRUNTIME void swig_register_director(octave_swig_type *self, void *ptr, Director *d);
|
||||
SWIGRUNTIME void swig_director_destroyed(octave_swig_type *self, Director *d);
|
||||
SWIGRUNTIME void swig_director_set_self(Director *d, octave_swig_type *self);
|
||||
|
||||
|
|
@ -400,7 +400,57 @@ namespace Swig {
|
|||
}
|
||||
|
||||
dim_vector dims(void) const {
|
||||
return dim_vector(1,1);
|
||||
octave_swig_type *nc_this = const_cast < octave_swig_type *>(this);
|
||||
|
||||
// Find the __dims__ method of this object
|
||||
member_value_pair *m = nc_this->find_member("__dims__", false);
|
||||
|
||||
if (!m) return dim_vector(1,1);
|
||||
|
||||
// Call the __dims__ method of this object
|
||||
octave_value_list inarg;
|
||||
inarg.append(nc_this->as_value());
|
||||
octave_value_list outarg = nc_this->member_invoke(m, inarg, 1);
|
||||
|
||||
// __dims__ should return (at least) one output argument
|
||||
if (outarg.length() < 1) return dim_vector(1,1);
|
||||
|
||||
octave_value & out = outarg(0);
|
||||
|
||||
// Return value should be cell or matrix of integers
|
||||
if (out.is_cell()) {
|
||||
const Cell & c=out.cell_value();
|
||||
int ndim = c.rows();
|
||||
if (ndim==1 && c.columns()!=1) ndim = c.columns();
|
||||
|
||||
dim_vector d;
|
||||
d.resize(ndim);
|
||||
|
||||
// Fill in dim_vector
|
||||
for (int k=0;k<ndim;k++) {
|
||||
const octave_value& obj = c(k);
|
||||
d.elem(k) = obj.int_value();
|
||||
|
||||
// __dims__ should return a cell filled with integers
|
||||
if (error_state) return dim_vector(1,1);
|
||||
}
|
||||
return d;
|
||||
} else if (out.is_matrix_type() || out.is_real_nd_array() || out.is_numeric_type() ) {
|
||||
if (out.rows()==1 || out.columns()==1) {
|
||||
Array<int> a = out.int_vector_value();
|
||||
if (error_state) return dim_vector(1,1);
|
||||
dim_vector d;
|
||||
d.resize(a.numel());
|
||||
for (int k=0;k<a.numel();k++) {
|
||||
d.elem(k) = a(k);
|
||||
}
|
||||
return d;
|
||||
} else {
|
||||
return dim_vector(1,1);
|
||||
}
|
||||
} else {
|
||||
return dim_vector(1,1);
|
||||
}
|
||||
}
|
||||
|
||||
octave_value as_value() {
|
||||
|
|
@ -703,6 +753,10 @@ namespace Swig {
|
|||
return as_value();
|
||||
}
|
||||
|
||||
virtual bool is_object() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool is_string() const {
|
||||
octave_swig_type *nc_this = const_cast < octave_swig_type *>(this);
|
||||
return !!nc_this->find_member("__str__", false);
|
||||
|
|
@ -950,6 +1004,9 @@ namespace Swig {
|
|||
octave_value subsasgn(const std::string &ops, const std::list < octave_value_list > &idx, const octave_value &rhs)
|
||||
{ return ptr->subsasgn(ops, idx, rhs); }
|
||||
|
||||
virtual bool is_object() const
|
||||
{ return ptr->is_object(); }
|
||||
|
||||
virtual bool is_string() const
|
||||
{ return ptr->is_string(); }
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@
|
|||
|
||||
static void SWIG_init_user(octave_swig_type* module_ns);
|
||||
|
||||
#if OCTAVE_API_VERSION_NUMBER>=37
|
||||
octave_value_list SWIG_atexit_func(const octave_value_list &args, int nargout);
|
||||
#endif
|
||||
|
||||
DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
|
||||
|
||||
// determine if module is already loaded
|
||||
|
|
@ -33,7 +37,7 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
|
|||
if (!already_load) {
|
||||
|
||||
// parse command line
|
||||
const char* usage="usage: " SWIG_name_d " [-global|-noglobal] [-globals <name>]";
|
||||
const char* usage="usage: " SWIG_name_d " [-global|-noglobal] [-globals {<name>|.}]";
|
||||
bool global_load=SWIG_global_load;
|
||||
std::string global_name=SWIG_global_name;
|
||||
for (int j=0;j<args.length();++j)
|
||||
|
|
@ -65,7 +69,7 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
|
|||
return octave_value_list();
|
||||
}
|
||||
|
||||
if (!valid_identifier(global_name)) {
|
||||
if (global_name != "." && !valid_identifier(global_name)) {
|
||||
std::cerr << "error: " SWIG_name_d ": '" << global_name << "' is not a valid Octave identifier." << std::endl;
|
||||
return octave_value_list();
|
||||
}
|
||||
|
|
@ -88,13 +92,23 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
|
|||
install_builtin_function(swig_this,"swig_this",std::string());
|
||||
install_builtin_function(swig_subclass,"subclass",std::string());
|
||||
|
||||
octave_swig_type* cvar_ns=new octave_swig_type;
|
||||
for (int j=0;swig_globals[j].name;++j)
|
||||
if (swig_globals[j].get_method)
|
||||
cvar_ns->assign(swig_globals[j].name,&swig_globals[j]);
|
||||
octave_swig_type* cvar_ns=0;
|
||||
if (global_name != ".") {
|
||||
cvar_ns=new octave_swig_type;
|
||||
for (int j=0;swig_globals[j].name;++j)
|
||||
if (swig_globals[j].get_method)
|
||||
cvar_ns->assign(swig_globals[j].name,&swig_globals[j]);
|
||||
}
|
||||
|
||||
octave_swig_type* module_ns=new octave_swig_type(0, 0, 0, true);
|
||||
module_ns->assign(global_name,Swig::swig_value_ref(cvar_ns));
|
||||
if (global_name != ".") {
|
||||
module_ns->assign(global_name,Swig::swig_value_ref(cvar_ns));
|
||||
}
|
||||
else {
|
||||
for (int j=0;swig_globals[j].name;++j)
|
||||
if (swig_globals[j].get_method)
|
||||
module_ns->assign(swig_globals[j].name,&swig_globals[j]);
|
||||
}
|
||||
for (int j=0;swig_globals[j].name;++j)
|
||||
if (swig_globals[j].method)
|
||||
module_ns->assign(swig_globals[j].name,&swig_globals[j]);
|
||||
|
|
@ -123,6 +137,12 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
|
|||
// create global variable containing module
|
||||
set_global_value(SWIG_name_d,Swig::swig_value_ref(module_ns));
|
||||
|
||||
#if OCTAVE_API_VERSION_NUMBER>=37
|
||||
install_builtin_function(SWIG_atexit_func,"__swig_atexit_" SWIG_name_d "__",std::string());
|
||||
octave_add_atexit_function("__swig_atexit_" SWIG_name_d "__");
|
||||
octave_remove_atexit_function("__finish__");
|
||||
#endif
|
||||
|
||||
// return from base frame
|
||||
#if OCTAVE_API_VERSION_NUMBER<37
|
||||
curr_sym_tab = prev_sym_tab;
|
||||
|
|
@ -150,14 +170,11 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
|
|||
// workaround bug in octave where installing global variable of custom type and then
|
||||
// exiting without explicitly clearing the variable causes octave to segfault.
|
||||
#if OCTAVE_API_VERSION_NUMBER>=37
|
||||
struct oct_file_unload {
|
||||
~oct_file_unload() {
|
||||
string_vector vars = symbol_table::global_variable_names();
|
||||
for (int i = 0; i < vars.length(); i++)
|
||||
symbol_table::clear_global(vars[i]);
|
||||
}
|
||||
};
|
||||
static oct_file_unload __unload;
|
||||
octave_value_list SWIG_atexit_func(const octave_value_list &args, int nargout) {
|
||||
symbol_table::clear_global_pattern("*");
|
||||
symbol_table::clear_functions();
|
||||
return octave_value();
|
||||
}
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,37 @@ namespace swig {
|
|||
}
|
||||
%enddef
|
||||
|
||||
/* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums
|
||||
is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit
|
||||
instantiations required using %template). The STL containers define the 'front' method and the typemap
|
||||
below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the
|
||||
standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from
|
||||
required in the generated code for enums. */
|
||||
|
||||
%define %traits_enum(Type...)
|
||||
%fragment("SWIG_Traits_enum_"{Type},"header",
|
||||
fragment=SWIG_AsVal_frag(int),
|
||||
fragment=SWIG_From_frag(int),
|
||||
fragment="StdTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits_asval<Type > {
|
||||
typedef Type value_type;
|
||||
static int asval(octave_value obj, value_type *val) {
|
||||
return SWIG_AsVal(int)(obj, (int *)val);
|
||||
}
|
||||
};
|
||||
template <> struct traits_from<Type > {
|
||||
typedef Type value_type;
|
||||
static octave_value from(const value_type& val) {
|
||||
return SWIG_From(int)((int)val);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
%typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%}
|
||||
%enddef
|
||||
|
||||
|
||||
%include <std/std_common.i>
|
||||
|
||||
//
|
||||
|
|
|
|||
26
Lib/octave/std_list.i
Normal file
26
Lib/octave/std_list.i
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// Lists
|
||||
|
||||
%fragment("StdListTraits","header",fragment="StdSequenceTraits")
|
||||
%{
|
||||
namespace swig {
|
||||
template <class T >
|
||||
struct traits_asptr<std::list<T> > {
|
||||
static int asptr(const octave_value& obj, std::list<T> **lis) {
|
||||
return traits_asptr_stdseq<std::list<T> >::asptr(obj, lis);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct traits_from<std::list<T> > {
|
||||
static octave_value *from(const std::list<T> & vec) {
|
||||
return traits_from_stdseq<std::list<T> >::from(vec);
|
||||
}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
#define %swig_list_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
%include <std/std_list.i>
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ namespace swig {
|
|||
}
|
||||
}
|
||||
|
||||
%fragment("SwigPySequence_Base","header")
|
||||
%fragment("SwigPySequence_Base","header",fragment="<stddef.h>")
|
||||
{
|
||||
%#include <functional>
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
%include <std_common.i>
|
||||
|
||||
%fragment("SwigPyIterator","header") {
|
||||
%fragment("SwigPyIterator","header",fragment="<stddef.h>") {
|
||||
namespace swig {
|
||||
struct stop_iteration {
|
||||
};
|
||||
|
|
@ -139,7 +139,7 @@ namespace swig {
|
|||
}
|
||||
}
|
||||
|
||||
%fragment("SwigPyIterator_T","header",fragment="SwigPyIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
|
||||
%fragment("SwigPyIterator_T","header",fragment="<stddef.h>",fragment="SwigPyIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
|
||||
namespace swig {
|
||||
template<typename OutIterator>
|
||||
class SwigPyIterator_T : public SwigPyIterator
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args)
|
|||
#endif
|
||||
{
|
||||
const char *name = SWIG_TypePrettyName(v->ty);
|
||||
PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", name, (void *)v);
|
||||
PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v);
|
||||
if (v->next) {
|
||||
# ifdef METH_NOARGS
|
||||
PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,36 @@ namespace swig {
|
|||
}
|
||||
%enddef
|
||||
|
||||
/* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums
|
||||
is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit
|
||||
instantiations required using %template). The STL containers define the 'front' method and the typemap
|
||||
below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the
|
||||
standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from
|
||||
required in the generated code for enums. */
|
||||
|
||||
%define %traits_enum(Type...)
|
||||
%fragment("SWIG_Traits_enum_"{Type},"header",
|
||||
fragment=SWIG_AsVal_frag(int),
|
||||
fragment=SWIG_From_frag(int),
|
||||
fragment="StdTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits_asval<Type > {
|
||||
typedef Type value_type;
|
||||
static int asval(PyObject *obj, value_type *val) {
|
||||
return SWIG_AsVal(int)(obj, (int *)val);
|
||||
}
|
||||
};
|
||||
template <> struct traits_from<Type > {
|
||||
typedef Type value_type;
|
||||
static PyObject *from(const value_type& val) {
|
||||
return SWIG_From(int)((int)val);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
%typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%}
|
||||
%enddef
|
||||
|
||||
|
||||
%include <std/std_common.i>
|
||||
|
||||
|
|
|
|||
15
Lib/r/r.swg
15
Lib/r/r.swg
|
|
@ -109,10 +109,21 @@ SWIG_InitializeModule(0);
|
|||
free($1);
|
||||
%}
|
||||
|
||||
%typemap(freearg, noblock=1) int *OUTPUT,
|
||||
signed int *OUTPUT,
|
||||
unsigned int *OUTPUT,
|
||||
short *OUTPUT,
|
||||
signed short *OUTPUT,
|
||||
long *OUTPUT,
|
||||
signed long *OUTPUT,
|
||||
long long *OUTPUT,
|
||||
unsigned long long *OUTPUT,
|
||||
float *OUTPUT,
|
||||
double *OUTPUT {}
|
||||
|
||||
|
||||
|
||||
/* Shoul dwe recycle to make the length correct.
|
||||
/* Should we recycle to make the length correct.
|
||||
And warn if length() > the dimension.
|
||||
*/
|
||||
%typemap(scheck) SWIGTYPE [ANY] %{
|
||||
|
|
@ -132,8 +143,6 @@ SWIG_InitializeModule(0);
|
|||
};
|
||||
%}
|
||||
|
||||
|
||||
%include <typemaps/swigmacros.swg>
|
||||
%include <typemaps/fragments.swg>
|
||||
%include <rfragments.swg>
|
||||
%include <ropers.swg>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
|
||||
|
||||
%fragment("RSequence_Base","header")
|
||||
%fragment("StdSequenceTraits","header",fragment="<stddef.h>")
|
||||
{
|
||||
%#include <functional>
|
||||
namespace swig {
|
||||
|
|
@ -133,7 +133,7 @@ namespace swig {
|
|||
// %swig_sequence_iterator(%arg(Sequence))
|
||||
%swig_container_methods(%arg(Sequence))
|
||||
|
||||
%fragment("RSequence_Base");
|
||||
%fragment("StdSequenceTraits");
|
||||
|
||||
%extend {
|
||||
value_type pop() throw (std::out_of_range) {
|
||||
|
|
|
|||
|
|
@ -361,6 +361,13 @@ SWIG_R_ConvertPacked(SEXP obj, void *ptr, size_t sz, swig_type_info *ty) {
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <exception>
|
||||
#define SWIG_exception_noreturn(code, msg) do { throw std::runtime_error(msg); } while(0)
|
||||
#else
|
||||
#define SWIG_exception_noreturn(code, msg) do { return result; } while(0)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -36,8 +36,45 @@
|
|||
%typemap("rtype") SWIGTYPE & "$R_class";
|
||||
%typemap("rtype") SWIGTYPE "$&R_class";
|
||||
|
||||
%typemap("rtypecheck") int, int &, long, long &,
|
||||
unsigned char, unsigned char &
|
||||
%{ (is.integer($arg) || is.numeric($arg)) && length($arg) == 1 %}
|
||||
%typemap("rtypecheck") int *, long *, unsigned char *
|
||||
%{ is.integer($arg) || is.numeric($arg) %}
|
||||
|
||||
|
||||
%typemap("rtypecheck") double, double &, float, float &
|
||||
%{ is.numeric($arg) && length($arg) == 1 %}
|
||||
%typemap("rtypecheck") double*, float *
|
||||
%{ is.numeric($arg) %}
|
||||
|
||||
%typemap("rtypecheck") bool, bool &
|
||||
%{ is.logical($arg) && length($arg) == 1 %}
|
||||
%typemap("rtypecheck") bool *
|
||||
%{ is.logical($arg) %}
|
||||
|
||||
/*
|
||||
Set up type checks to insure overloading precedence.
|
||||
We would like non pointer items to shadow pointer items, so that
|
||||
they get called if length = 1
|
||||
*/
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_BOOL) bool {}
|
||||
%typecheck(SWIG_TYPECHECK_UINT32) unsigned int {}
|
||||
%typecheck(SWIG_TYPECHECK_INTEGER) int {}
|
||||
%typecheck(SWIG_TYPECHECK_FLOAT) float {}
|
||||
%typecheck(SWIG_TYPECHECK_DOUBLE) double {}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_BOOL_PTR) bool * {}
|
||||
%typecheck(SWIG_TYPECHECK_INT32_PTR) int * {}
|
||||
%typecheck(SWIG_TYPECHECK_FLOAT_PTR) float * {}
|
||||
%typecheck(SWIG_TYPECHECK_DOUBLE_PTR) double * {}
|
||||
%typecheck(SWIG_TYPECHECK_CHAR_PTR) char * {}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT32_ARRAY) int[ANY] {}
|
||||
%typecheck(SWIG_TYPECHECK_FLOAT_ARRAY) float[ANY] {}
|
||||
%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY) double [ANY] {}
|
||||
|
||||
/* Have to be careful that as(x, "numeric") is different from as.numeric(x).
|
||||
The latter makes a REALSXP, whereas the former leaves an INTSXP as an
|
||||
INTSXP.
|
||||
|
|
@ -170,10 +207,11 @@ string &, std::string &
|
|||
signed long,
|
||||
signed long &,
|
||||
unsigned long,
|
||||
unsigned long &
|
||||
unsigned long &,
|
||||
unsigned char *,
|
||||
unsigned char &
|
||||
%{ %}
|
||||
|
||||
|
||||
#if 0
|
||||
Just examining the values for a SWIGTYPE.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,35 @@
|
|||
%include <rstdcommon.swg>
|
||||
%include <std/std_common.i>
|
||||
|
||||
%define %traits_ptypen(Type...)
|
||||
%fragment(SWIG_Traits_frag(Type),"header",
|
||||
fragment=SWIG_AsVal_frag(Type),
|
||||
fragment=SWIG_From_frag(Type),
|
||||
fragment="StdTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<Type > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() { return #Type; }
|
||||
};
|
||||
template <> struct traits_asval<Type > {
|
||||
typedef Type value_type;
|
||||
static int asval(SEXP obj, value_type *val) {
|
||||
return SWIG_AsVal(Type)(obj, val);
|
||||
}
|
||||
};
|
||||
template <> struct traits_from<Type > {
|
||||
typedef Type value_type;
|
||||
static SEXP from(const value_type& val) {
|
||||
return SWIG_From(Type)(val);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
//
|
||||
// Generates the traits for all the known primitive
|
||||
// C++ types (int, double, ...)
|
||||
//
|
||||
%apply_cpptypes(%traits_ptypen);
|
||||
|
||||
|
|
|
|||
5
Lib/r/std_list.i
Normal file
5
Lib/r/std_list.i
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#define %swig_list_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
%include <std/std_list.i>
|
||||
|
||||
|
|
@ -1,10 +1,269 @@
|
|||
%fragment("StdVectorTraits","header")
|
||||
// R specific swig components
|
||||
/*
|
||||
Vectors
|
||||
Thanks to Richard Beare - richard.beare@ieee.org for StdVectorTraits
|
||||
*/
|
||||
|
||||
%fragment("StdVectorTraits","header",fragment="StdSequenceTraits")
|
||||
%{
|
||||
namespace swig {
|
||||
// vectors of doubles
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<double> > {
|
||||
static SEXP from (std::vector<double > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(REALSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
NUMERIC_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
// vectors of floats
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<float> > {
|
||||
static SEXP from (std::vector<float > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(REALSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
NUMERIC_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
// vectors of unsigned int
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<unsigned int> > {
|
||||
static SEXP from (std::vector<unsigned int > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(INTSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
INTEGER_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
// vectors of int
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<int> > {
|
||||
static SEXP from (std::vector<int > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(INTSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
INTEGER_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
// vectors of bool
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<bool> > {
|
||||
static SEXP from (std::vector<bool> *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(LGLSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
LOGICAL_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
//return SWIG_R_NewPointerObj(val, type_info< std::vector<T > >(), owner);
|
||||
}
|
||||
};
|
||||
// vectors of strings
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<std::basic_string<char> > > {
|
||||
static SEXP from (std::vector<std::basic_string<char> > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(STRSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
CHARACTER_POINTER(result)[pos] = Rf_mkChar(((*val)[pos]).c_str());
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
//return SWIG_R_NewPointerObj(val, type_info< std::vector<T > >(), owner);
|
||||
}
|
||||
};
|
||||
|
||||
// catch all that does everything with vectors
|
||||
template <typename T>
|
||||
struct traits_from_ptr< std::vector< T > > {
|
||||
static SEXP from (std::vector< T > *val, int owner = 0) {
|
||||
return SWIG_R_NewPointerObj(val, type_info< std::vector< T > >(), owner);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<double> > {
|
||||
static int asptr(SEXP obj, std::vector<double> **val) {
|
||||
std::vector<double> *p;
|
||||
// not sure how to check the size of the SEXP obj is correct
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector<double>(sexpsz);
|
||||
double *S = NUMERIC_POINTER(obj);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<double>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<float> > {
|
||||
static int asptr(SEXP obj, std::vector<float> **val) {
|
||||
std::vector<float> *p;
|
||||
// not sure how to check the size of the SEXP obj is correct
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector<float>(sexpsz);
|
||||
double *S = NUMERIC_POINTER(obj);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<double>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<unsigned int> > {
|
||||
static int asptr(SEXP obj, std::vector<unsigned int> **val) {
|
||||
std::vector<unsigned int> *p;
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector<unsigned int>(sexpsz);
|
||||
SEXP coerced;
|
||||
PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
|
||||
int *S = INTEGER_POINTER(coerced);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<unsigned int>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<int> > {
|
||||
static int asptr(SEXP obj, std::vector<int> **val) {
|
||||
std::vector<int> *p;
|
||||
// not sure how to check the size of the SEXP obj is correct
|
||||
int sexpsz = Rf_length(obj);
|
||||
p = new std::vector<int>(sexpsz);
|
||||
SEXP coerced;
|
||||
PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
|
||||
int *S = INTEGER_POINTER(coerced);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<int>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
// catchall for R to vector conversion
|
||||
template <typename T>
|
||||
struct traits_asptr < std::vector<T> > {
|
||||
static int asptr(SEXP obj, std::vector<T> **val) {
|
||||
std::vector<T> *p;
|
||||
Rprintf("my asptr\n");
|
||||
int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector<T> >(), 0);
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
%}
|
||||
|
||||
#define %swig_vector_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
%define %traits_type_name(Type...)
|
||||
%fragment(SWIG_Traits_frag(Type), "header",
|
||||
fragment="StdTraits",fragment="StdVectorTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits< Type > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return #Type;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%include <std/std_vector.i>
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<double>)
|
||||
%traits_type_name(std::vector<double>)
|
||||
%typemap("rtypecheck") std::vector<double> %{ is.numeric($arg) %}
|
||||
%typemap("rtype") std::vector<double> "numeric"
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<float>)
|
||||
%traits_type_name(std::vector<float>)
|
||||
%typemap("rtypecheck") std::vector<float> %{ is.numeric($arg) %}
|
||||
%typemap("rtype") std::vector<float> "numeric"
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<bool>);
|
||||
%traits_type_name(std::vector<bool>);
|
||||
%typemap("rtypecheck") std::vector<bool> %{ is.logical($arg) %}
|
||||
%typemap("rtype") std::vector<bool> "logical"
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<int>);
|
||||
%traits_type_name(std::vector<int>);
|
||||
%typemap("rtypecheck") std::vector<int>
|
||||
%{ is.integer($arg) || is.numeric($arg) %}
|
||||
%typemap("rtype") std::vector<int> "integer"
|
||||
%typemap("scoercein") std::vector<int> "$input = as.integer($input);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<unsigned int>);
|
||||
%traits_type_name(std::vector<unsigned int>);
|
||||
%typemap("rtypecheck") std::vector<unsigned int>
|
||||
%{ is.integer($arg) || is.numeric($arg) %}
|
||||
%typemap("rtype") std::vector<unsigned int> "integer"
|
||||
%typemap("scoercein") std::vector<unsigned int> "$input = as.integer($input);";
|
||||
|
||||
// we don't want these to be given R classes as they
|
||||
// have already been turned into R vectors.
|
||||
%typemap(scoerceout) std::vector<double>,
|
||||
std::vector<double> *,
|
||||
std::vector<double> &,
|
||||
std::vector<bool>,
|
||||
std::vector<bool> *,
|
||||
std::vector<bool> &,
|
||||
std::vector<unsigned int>,
|
||||
std::vector<unsigned int> *,
|
||||
std::vector<unsigned int> &
|
||||
%{ %}
|
||||
|
||||
|
||||
%include <std/std_vector.i>
|
||||
|
|
@ -153,6 +153,7 @@ namespace swig {
|
|||
}
|
||||
|
||||
%fragment("RubySequence_Cont","header",
|
||||
fragment="<stddef.h>",
|
||||
fragment="StdTraits",
|
||||
fragment="RubySequence_Base",
|
||||
fragment="ConstIterator_T")
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
%include <std_common.i>
|
||||
|
||||
|
||||
%fragment("ConstIterator","header",fragment="GC_VALUE_definition") {
|
||||
%fragment("ConstIterator","header",fragment="<stddef.h>",fragment="GC_VALUE_definition") {
|
||||
namespace swig {
|
||||
struct stop_iteration {
|
||||
};
|
||||
|
|
@ -270,7 +270,7 @@ namespace swig {
|
|||
}
|
||||
|
||||
|
||||
%fragment("ConstIterator_T","header",fragment="ConstIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
|
||||
%fragment("ConstIterator_T","header",fragment="<stddef.h>",fragment="ConstIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
|
||||
namespace swig {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -34,6 +34,36 @@ namespace swig {
|
|||
}
|
||||
%enddef
|
||||
|
||||
/* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums
|
||||
is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit
|
||||
instantiations required using %template). The STL containers define the 'front' method and the typemap
|
||||
below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the
|
||||
standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from
|
||||
required in the generated code for enums. */
|
||||
|
||||
%define %traits_enum(Type...)
|
||||
%fragment("SWIG_Traits_enum_"{Type},"header",
|
||||
fragment=SWIG_AsVal_frag(int),
|
||||
fragment=SWIG_From_frag(int),
|
||||
fragment="StdTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits_asval<Type > {
|
||||
typedef Type value_type;
|
||||
static int asval(VALUE obj, value_type *val) {
|
||||
return SWIG_AsVal(int)(obj, (int *)val);
|
||||
}
|
||||
};
|
||||
template <> struct traits_from<Type > {
|
||||
typedef Type value_type;
|
||||
static VALUE from(const value_type& val) {
|
||||
return SWIG_From(int)((int)val);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
%typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%}
|
||||
%enddef
|
||||
|
||||
|
||||
%include <std/std_common.i>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Sets
|
||||
*/
|
||||
|
||||
%fragment("StdSetTraits","header",fragment="StdSequenceTraits")
|
||||
%fragment("StdSetTraits","header",fragment="<stddef.h>",fragment="StdSequenceTraits")
|
||||
%{
|
||||
namespace swig {
|
||||
template <class RubySeq, class T>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
%}
|
||||
|
||||
|
||||
%fragment("StdIteratorTraits","header") %{
|
||||
%fragment("StdIteratorTraits","header",fragment="<stddef.h>") %{
|
||||
#if defined(__SUNPRO_CC) && defined(_RWSTD_VER)
|
||||
# if !defined(SWIG_NO_STD_NOITERATOR_TRAITS_STL)
|
||||
# define SWIG_STD_NOITERATOR_TRAITS_STL
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ namespace std {
|
|||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(_Tp);
|
||||
%traits_enum(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::vector<_Tp, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ static int NAME(TYPE x) {
|
|||
%define %$isextern "match$storage"="extern" %enddef
|
||||
|
||||
%define %$ismember "match$ismember"="1" %enddef
|
||||
%define %$isglobal %not %ismember %enddef
|
||||
%define %$isglobal %$not %$ismember %enddef
|
||||
%define %$innamespace "match$parentNode$nodeType"="namespace" %enddef
|
||||
|
||||
%define %$ispublic "match$access"="public" %enddef
|
||||
|
|
@ -301,7 +301,7 @@ static int NAME(TYPE x) {
|
|||
%define %$ismemberget "match$memberget"="1" %enddef
|
||||
%define %$ismemberset "match$memberset"="1" %enddef
|
||||
|
||||
%define %$classname %ismember,match$parentNode$name %enddef
|
||||
%define %$classname %$ismember,"match$parentNode$name" %enddef
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Include all the warnings labels and macros
|
||||
|
|
|
|||
|
|
@ -149,6 +149,10 @@
|
|||
#endif
|
||||
%}
|
||||
|
||||
%fragment("<stddef.h>", "header") %{
|
||||
#include <stddef.h>
|
||||
%}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* special macros for fragments
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@
|
|||
SWIG_CharPtrLen,
|
||||
SWIG_AsCharPtr,
|
||||
SWIG_FromCharPtr,
|
||||
SWIG_AsCharArray)
|
||||
SWIG_AsCharArray,
|
||||
SWIG_NewCopyCharArray,
|
||||
SWIG_DeleteCharArray)
|
||||
|
||||
/* in */
|
||||
|
||||
|
|
@ -38,7 +40,7 @@
|
|||
$1 = %reinterpret_cast(buf, $1_ltype);
|
||||
}
|
||||
%typemap(freearg,noblock=1,match="in") Char *, const Char * {
|
||||
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
|
||||
if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum);
|
||||
}
|
||||
|
||||
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr) Char const*& (int res, Char *buf = 0, int alloc = 0) {
|
||||
|
|
@ -49,7 +51,7 @@
|
|||
$1 = &buf;
|
||||
}
|
||||
%typemap(freearg, noblock=1,match="in") Char const*& {
|
||||
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
|
||||
if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum);
|
||||
}
|
||||
|
||||
/* out */
|
||||
|
|
@ -64,7 +66,7 @@
|
|||
}
|
||||
|
||||
%typemap(newfree,noblock=1) Char * {
|
||||
%delete_array($1);
|
||||
SWIG_DeleteCharArray($1);
|
||||
}
|
||||
|
||||
/* varin */
|
||||
|
|
@ -75,11 +77,11 @@
|
|||
if (!SWIG_IsOK(res)) {
|
||||
%variable_fail(res,"$type","$name");
|
||||
}
|
||||
if ($1) %delete_array($1);
|
||||
if ($1) SWIG_DeleteCharArray($1);
|
||||
if (alloc == SWIG_NEWOBJ) {
|
||||
$1 = cptr;
|
||||
} else {
|
||||
$1 = csize ? ($1_type)%new_copy_array(cptr, csize, Char) : 0;
|
||||
$1 = csize ? ($1_type)SWIG_NewCopyCharArray(cptr, csize, Char) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +94,7 @@
|
|||
if (alloc == SWIG_NEWOBJ) {
|
||||
$1 = cptr;
|
||||
} else {
|
||||
$1 = csize ? ($1_type)%new_copy_array(cptr, csize, Char) : 0;
|
||||
$1 = csize ? ($1_type)SWIG_NewCopyCharArray(cptr, csize, Char) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -105,10 +107,10 @@
|
|||
/* memberin */
|
||||
|
||||
%typemap(memberin,noblock=1) Char * {
|
||||
if ($1) %delete_array($1);
|
||||
if ($1) SWIG_DeleteCharArray($1);
|
||||
if ($input) {
|
||||
size_t size = SWIG_CharPtrLen(%reinterpret_cast($input, const Char *)) + 1;
|
||||
$1 = ($1_type)%new_copy_array(%reinterpret_cast($input, const Char *), size, Char);
|
||||
$1 = ($1_type)SWIG_NewCopyCharArray(%reinterpret_cast($input, const Char *), size, Char);
|
||||
} else {
|
||||
$1 = 0;
|
||||
}
|
||||
|
|
@ -117,7 +119,7 @@
|
|||
%typemap(memberin,noblock=1,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * {
|
||||
if ($input) {
|
||||
size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1;
|
||||
$1 = ($1_type)%new_copy_array($input, size, Char);
|
||||
$1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char);
|
||||
} else {
|
||||
$1 = 0;
|
||||
}
|
||||
|
|
@ -126,10 +128,10 @@
|
|||
/* globalin */
|
||||
|
||||
%typemap(globalin,noblock=1) Char * {
|
||||
if ($1) %delete_array($1);
|
||||
if ($1) SWIG_DeleteCharArray($1);
|
||||
if ($input) {
|
||||
size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1;
|
||||
$1 = ($1_type)%new_copy_array($input, size, Char);
|
||||
$1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char);
|
||||
} else {
|
||||
$1 = 0;
|
||||
}
|
||||
|
|
@ -138,7 +140,7 @@
|
|||
%typemap(globalin,noblock=1,warning=SWIGWARN_TYPEMAP_CHARLEAK_MSG) const Char * {
|
||||
if ($input) {
|
||||
size_t size = SWIG_CharPtrLen($input) + 1;
|
||||
$1 = ($1_type)%new_copy_array($input, size, Char);
|
||||
$1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char);
|
||||
} else {
|
||||
$1 = 0;
|
||||
}
|
||||
|
|
@ -416,7 +418,7 @@
|
|||
$2 = %numeric_cast(size - 1, $2_ltype);
|
||||
}
|
||||
%typemap(freearg,noblock=1,match="in") (Char *STRING, size_t LENGTH) {
|
||||
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
|
||||
if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum);
|
||||
}
|
||||
/* old 'int' form */
|
||||
%typemap(in) (Char *STRING, int LENGTH) = (Char *STRING, size_t LENGTH);
|
||||
|
|
@ -436,7 +438,7 @@
|
|||
$2 = %numeric_cast(size, $2_ltype);
|
||||
}
|
||||
%typemap(freearg,noblock=1,match="in") (Char *STRING, size_t SIZE) {
|
||||
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
|
||||
if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum);
|
||||
}
|
||||
/* old 'int' form */
|
||||
%typemap(in) (Char *STRING, int SIZE) = (Char *STRING, size_t SIZE);
|
||||
|
|
@ -458,7 +460,7 @@
|
|||
$1 = %numeric_cast(size - 1, $1_ltype) ;
|
||||
}
|
||||
%typemap(freearg, noblock=1, match="in") (size_t LENGTH, Char *STRING) {
|
||||
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
|
||||
if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum);
|
||||
}
|
||||
/* old 'int' form */
|
||||
%typemap(in) (int LENGTH, Char *STRING) = (size_t LENGTH, Char *STRING);
|
||||
|
|
@ -477,7 +479,7 @@
|
|||
$1 = %numeric_cast(size, $1_ltype) ;
|
||||
}
|
||||
%typemap(freearg, noblock=1, match="in") (size_t SIZE, Char *STRING) {
|
||||
if (alloc$argnum == SWIG_NEWOBJ) %delete_array(buf$argnum);
|
||||
if (alloc$argnum == SWIG_NEWOBJ) SWIG_DeleteCharArray(buf$argnum);
|
||||
}
|
||||
/* old 'int' form */
|
||||
%typemap(in) (int SIZE, Char *STRING) = (size_t SIZE, Char *STRING);
|
||||
|
|
@ -492,11 +494,13 @@
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
|
||||
%define %typemaps_string(StringCode, CharCode,
|
||||
%define %_typemap2_string(StringCode, CharCode,
|
||||
Char, CharName,
|
||||
SWIG_AsCharPtrAndSize,
|
||||
SWIG_FromCharPtrAndSize,
|
||||
SWIG_CharPtrLen,
|
||||
SWIG_NewCopyCharArray,
|
||||
SWIG_DeleteCharArray,
|
||||
FragLimits, CHAR_MIN, CHAR_MAX)
|
||||
|
||||
%fragment("SWIG_From"#CharName"Ptr","header",fragment=#SWIG_FromCharPtrAndSize) {
|
||||
|
|
@ -533,12 +537,12 @@ SWIG_As##CharName##Array(SWIG_Object obj, Char *val, size_t size)
|
|||
if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(Char));
|
||||
}
|
||||
if (alloc == SWIG_NEWOBJ) {
|
||||
%delete_array(cptr);
|
||||
SWIG_DeleteCharArray(cptr);
|
||||
res = SWIG_DelNewMask(res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
if (alloc == SWIG_NEWOBJ) %delete_array(cptr);
|
||||
if (alloc == SWIG_NEWOBJ) SWIG_DeleteCharArray(cptr);
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
|
@ -584,6 +588,51 @@ SWIG_AsVal_dec(Char)(SWIG_Object obj, Char *val)
|
|||
SWIG_CharPtrLen,
|
||||
SWIG_As##CharName##Ptr,
|
||||
SWIG_From##CharName##Ptr,
|
||||
SWIG_As##CharName##Array)
|
||||
SWIG_As##CharName##Array,
|
||||
SWIG_NewCopyCharArray,
|
||||
SWIG_DeleteCharArray)
|
||||
|
||||
%enddef
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* String typemaps and fragments, with default allocators
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%define %typemaps_string(StringCode, CharCode,
|
||||
Char, CharName,
|
||||
SWIG_AsCharPtrAndSize,
|
||||
SWIG_FromCharPtrAndSize,
|
||||
SWIG_CharPtrLen,
|
||||
FragLimits, CHAR_MIN, CHAR_MAX)
|
||||
%_typemap2_string(StringCode, CharCode,
|
||||
Char, CharName,
|
||||
SWIG_AsCharPtrAndSize,
|
||||
SWIG_FromCharPtrAndSize,
|
||||
SWIG_CharPtrLen,
|
||||
%new_copy_array,
|
||||
%delete_array,
|
||||
FragLimits, CHAR_MIN, CHAR_MAX)
|
||||
%enddef
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* String typemaps and fragments, with custom allocators
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%define %typemaps_string_alloc(StringCode, CharCode,
|
||||
Char, CharName,
|
||||
SWIG_AsCharPtrAndSize,
|
||||
SWIG_FromCharPtrAndSize,
|
||||
SWIG_CharPtrLen,
|
||||
SWIG_NewCopyCharArray,
|
||||
SWIG_DeleteCharArray,
|
||||
FragLimits, CHAR_MIN, CHAR_MAX)
|
||||
%_typemap2_string(StringCode, CharCode,
|
||||
Char, CharName,
|
||||
SWIG_AsCharPtrAndSize,
|
||||
SWIG_FromCharPtrAndSize,
|
||||
SWIG_CharPtrLen,
|
||||
SWIG_NewCopyCharArray,
|
||||
SWIG_DeleteCharArray,
|
||||
FragLimits, CHAR_MIN, CHAR_MAX)
|
||||
%enddef
|
||||
|
|
|
|||
|
|
@ -498,7 +498,7 @@ dd = @PACKAGE_NAME@-@PACKAGE_VERSION@
|
|||
srpm = @PACKAGE_NAME@-@PACKAGE_VERSION@
|
||||
|
||||
dist:
|
||||
@echo "not implemented"
|
||||
@echo "not implemented - use Tools/makedist.py instead."
|
||||
false
|
||||
|
||||
srcrpm:
|
||||
|
|
|
|||
|
|
@ -767,6 +767,10 @@ int yylex(void) {
|
|||
}
|
||||
if (strcmp(yytext, "%includefile") == 0)
|
||||
return (INCLUDE);
|
||||
if (strcmp(yytext, "%beginfile") == 0)
|
||||
return (BEGINFILE);
|
||||
if (strcmp(yytext, "%endoffile") == 0)
|
||||
return (ENDOFFILE);
|
||||
if (strcmp(yytext, "%val") == 0) {
|
||||
Swig_warning(WARN_DEPRECATED_VAL, cparse_file, cparse_line, "%%val directive deprecated (ignored).\n");
|
||||
return (yylex());
|
||||
|
|
|
|||
|
|
@ -1644,6 +1644,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
|
|||
%token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64
|
||||
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD
|
||||
%token CONST_QUAL VOLATILE REGISTER STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET
|
||||
%token BEGINFILE ENDOFFILE
|
||||
%token ILLEGAL CONSTANT
|
||||
%token NAME RENAME NAMEWARN EXTEND PRAGMA FEATURE VARARGS
|
||||
%token ENUM
|
||||
|
|
@ -2110,7 +2111,7 @@ fragment_directive: FRAGMENT LPAREN fname COMMA kwargs RPAREN HBLOCK {
|
|||
%importfile(option1="xyz", ...) "filename" [ declarations ]
|
||||
------------------------------------------------------------ */
|
||||
|
||||
include_directive: includetype options string LBRACKET {
|
||||
include_directive: includetype options string BEGINFILE {
|
||||
$1.filename = Copy(cparse_file);
|
||||
$1.line = cparse_line;
|
||||
scanner_set_location(NewString($3),1);
|
||||
|
|
@ -2119,7 +2120,7 @@ include_directive: includetype options string LBRACKET {
|
|||
if (maininput)
|
||||
scanner_set_main_input_file(NewString(maininput));
|
||||
}
|
||||
} interface RBRACKET {
|
||||
} interface ENDOFFILE {
|
||||
String *mname = 0;
|
||||
$$ = $6;
|
||||
scanner_set_location($1.filename,$1.line+1);
|
||||
|
|
@ -5637,6 +5638,7 @@ etype : expr {
|
|||
$$ = $1;
|
||||
if (($$.type != T_INT) && ($$.type != T_UINT) &&
|
||||
($$.type != T_LONG) && ($$.type != T_ULONG) &&
|
||||
($$.type != T_LONGLONG) && ($$.type != T_ULONGLONG) &&
|
||||
($$.type != T_SHORT) && ($$.type != T_USHORT) &&
|
||||
($$.type != T_SCHAR) && ($$.type != T_UCHAR) &&
|
||||
($$.type != T_CHAR) && ($$.type != T_BOOL)) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,12 @@ char cvsroot_go_cxx[] = "$Id";
|
|||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_GCCGO_46
|
||||
#define GCCGO_46_DEFAULT true
|
||||
#else
|
||||
#define GCCGO_46_DEFAULT false
|
||||
#endif
|
||||
|
||||
class GO:public Language {
|
||||
static const char *const usage;
|
||||
|
||||
|
|
@ -20,6 +26,8 @@ class GO:public Language {
|
|||
String *package;
|
||||
// Flag for generating gccgo output.
|
||||
bool gccgo_flag;
|
||||
// Flag for generating gccgo 4.6 output.
|
||||
bool gccgo_46_flag;
|
||||
// Prefix to use with gccgo.
|
||||
String *go_prefix;
|
||||
// Name of shared library to import.
|
||||
|
|
@ -82,6 +90,7 @@ class GO:public Language {
|
|||
public:
|
||||
GO():package(NULL),
|
||||
gccgo_flag(false),
|
||||
gccgo_46_flag(GCCGO_46_DEFAULT),
|
||||
go_prefix(NULL),
|
||||
soname(NULL),
|
||||
long_type_size(32),
|
||||
|
|
@ -139,6 +148,12 @@ private:
|
|||
} else if (strcmp(argv[i], "-gccgo") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
gccgo_flag = true;
|
||||
} else if (strcmp(argv[i], "-gccgo-46") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
gccgo_46_flag = true;
|
||||
} else if (strcmp(argv[i], "-no-gccgo-46") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
gccgo_46_flag = false;
|
||||
} else if (strcmp(argv[i], "-go-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
go_prefix = NewString(argv[i + 1]);
|
||||
|
|
@ -779,6 +794,10 @@ private:
|
|||
if (needs_wrapper) {
|
||||
wrapper_name = buildGoWrapperName(name, overname);
|
||||
|
||||
if (gccgo_flag && !gccgo_46_flag) {
|
||||
Printv(f_go_wrappers, "//extern ", go_prefix, "_", wname, "\n", NULL);
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, "func ", wrapper_name, "(", NULL);
|
||||
if (parm_count > required_count) {
|
||||
Printv(f_go_wrappers, "int", NULL);
|
||||
|
|
@ -826,7 +845,7 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
if (gccgo_flag) {
|
||||
if (gccgo_flag && gccgo_46_flag) {
|
||||
Printv(f_go_wrappers, " __asm__ (\"", go_prefix, "_", wname, "\")", NULL);
|
||||
}
|
||||
|
||||
|
|
@ -835,6 +854,10 @@ private:
|
|||
|
||||
// Start defining the Go function.
|
||||
|
||||
if (!needs_wrapper && gccgo_flag && !gccgo_46_flag) {
|
||||
Printv(f_go_wrappers, "//extern ", go_prefix, "_", wname, "\n", NULL);
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, "func ", NULL);
|
||||
|
||||
Parm *p = parms;
|
||||
|
|
@ -936,6 +959,11 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
if (gccgo_flag && !gccgo_46_flag) {
|
||||
Printv(f_go_wrappers, "\tsyscall.Entersyscall()\n", NULL);
|
||||
Printv(f_go_wrappers, "\tdefer syscall.Exitsyscall()\n", NULL);
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, "\t", NULL);
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
Printv(f_go_wrappers, "return ", NULL);
|
||||
|
|
@ -976,7 +1004,7 @@ private:
|
|||
Printv(f_go_wrappers, ")\n", NULL);
|
||||
Printv(f_go_wrappers, "}\n", NULL);
|
||||
} else {
|
||||
if (gccgo_flag) {
|
||||
if (gccgo_flag && gccgo_46_flag) {
|
||||
Printv(f_go_wrappers, " __asm__ (\"", go_prefix, "_", wname, "\")\n", NULL);
|
||||
}
|
||||
}
|
||||
|
|
@ -2493,6 +2521,11 @@ private:
|
|||
|
||||
if (!is_ignored) {
|
||||
// Declare the C++ wrapper.
|
||||
|
||||
if (gccgo_flag && !gccgo_46_flag) {
|
||||
Printv(f_go_wrappers, "//extern ", go_prefix, "_", wname, "\n", NULL);
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, "func ", fn_name, NULL);
|
||||
if (overname) {
|
||||
Printv(f_go_wrappers, overname, NULL);
|
||||
|
|
@ -2510,7 +2543,7 @@ private:
|
|||
|
||||
Printv(f_go_wrappers, ") ", go_type_name, NULL);
|
||||
|
||||
if (gccgo_flag) {
|
||||
if (gccgo_flag && gccgo_46_flag) {
|
||||
Printv(f_go_wrappers, " __asm__(\"", go_prefix, "_", wname, "\")", NULL);
|
||||
}
|
||||
|
||||
|
|
@ -2532,6 +2565,12 @@ private:
|
|||
Printv(f_go_wrappers, ") ", cn, " {\n", NULL);
|
||||
|
||||
Printv(f_go_wrappers, "\tp := &", director_struct_name, "{0, v}\n", NULL);
|
||||
|
||||
if (gccgo_flag && !gccgo_46_flag) {
|
||||
Printv(f_go_wrappers, "\tsyscall.Entersyscall()\n", NULL);
|
||||
Printv(f_go_wrappers, "\tdefer syscall.Exitsyscall()\n", NULL);
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, "\tp.", class_receiver, " = ", fn_name, NULL);
|
||||
if (overname) {
|
||||
Printv(f_go_wrappers, overname, NULL);
|
||||
|
|
@ -2987,6 +3026,10 @@ private:
|
|||
|
||||
String *upcall_gc_name = buildGoWrapperName(upcall_name, overname);
|
||||
|
||||
if (gccgo_flag && !gccgo_46_flag) {
|
||||
Printv(f_go_wrappers, "//extern ", go_prefix, "_", upcall_wname, "\n", NULL);
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, "func ", upcall_gc_name, "(", go_type_name, NULL);
|
||||
|
||||
p = parms;
|
||||
|
|
@ -3006,7 +3049,7 @@ private:
|
|||
Delete(tm);
|
||||
}
|
||||
|
||||
if (gccgo_flag) {
|
||||
if (gccgo_flag && gccgo_46_flag) {
|
||||
Printv(f_go_wrappers, " __asm__(\"", go_prefix, "_", upcall_wname, "\")", NULL);
|
||||
}
|
||||
|
||||
|
|
@ -3039,6 +3082,11 @@ private:
|
|||
|
||||
Printv(f_go_wrappers, " {\n", NULL);
|
||||
|
||||
if (gccgo_flag && !gccgo_46_flag) {
|
||||
Printv(f_go_wrappers, "\tsyscall.Entersyscall()\n", NULL);
|
||||
Printv(f_go_wrappers, "\tdefer syscall.Exitsyscall()\n", NULL);
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, "\tif swig_g, swig_ok := swig_p.v.(", interface_name, "); swig_ok {\n", NULL);
|
||||
Printv(f_go_wrappers, "\t\t", NULL);
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
|
|
@ -3131,22 +3179,27 @@ private:
|
|||
Printv(action, Swig_cparm_name(NULL, 0), "->", upcall_method_name, "(", NULL);
|
||||
|
||||
p = parms;
|
||||
for (int i = 0; i < parm_count; ++i) {
|
||||
p = getParm(p);
|
||||
String *pname = Swig_cparm_name(NULL, i + 1);
|
||||
if (i > 0) {
|
||||
Printv(action, ", ", NULL);
|
||||
int i = 0;
|
||||
while (p != NULL) {
|
||||
if (SwigType_type(Getattr(p, "type")) != T_VOID) {
|
||||
String *pname = Swig_cparm_name(NULL, i + 1);
|
||||
if (i > 0) {
|
||||
Printv(action, ", ", NULL);
|
||||
}
|
||||
|
||||
// A parameter whose type is a reference is converted into a
|
||||
// pointer type by gcCTypeForGoValue. We are calling a
|
||||
// function which expects a reference so we need to convert
|
||||
// back.
|
||||
if (SwigType_isreference(Getattr(p, "type"))) {
|
||||
Printv(action, "*", NULL);
|
||||
}
|
||||
|
||||
Printv(action, pname, NULL);
|
||||
Delete(pname);
|
||||
i++;
|
||||
}
|
||||
// A parameter whose type is a reference is converted into a
|
||||
// pointer type by gcCTypeForGoValue. We are calling a
|
||||
// function which expects a reference so we need to convert
|
||||
// back.
|
||||
if (SwigType_isreference(Getattr(p, "type"))) {
|
||||
Printv(action, "*", NULL);
|
||||
}
|
||||
Printv(action, pname, NULL);
|
||||
Delete(pname);
|
||||
p = nextParm(p);
|
||||
p = nextSibling(p);
|
||||
}
|
||||
Printv(action, ");", NULL);
|
||||
Setattr(n, "wrap:action", action);
|
||||
|
|
@ -3201,6 +3254,11 @@ private:
|
|||
|
||||
Printv(f_go_wrappers, " {\n", NULL);
|
||||
|
||||
if (gccgo_flag && !gccgo_46_flag) {
|
||||
Printv(f_go_wrappers, "\tsyscall.Entersyscall()\n", NULL);
|
||||
Printv(f_go_wrappers, "\tdefer syscall.Exitsyscall()\n", NULL);
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, "\t", NULL);
|
||||
if (SwigType_type(result) != T_VOID) {
|
||||
Printv(f_go_wrappers, "return ", NULL);
|
||||
|
|
@ -3242,6 +3300,12 @@ private:
|
|||
Printv(f_go_wrappers, "(swig_result ", result_wrapper, ") ", NULL);
|
||||
}
|
||||
Printv(f_go_wrappers, "{\n", NULL);
|
||||
|
||||
if (gccgo_flag && !gccgo_46_flag) {
|
||||
Printv(f_go_wrappers, "\tsyscall.Exitsyscall()\n", NULL);
|
||||
Printv(f_go_wrappers, "\tdefer syscall.Entersyscall()\n", NULL);
|
||||
}
|
||||
|
||||
Printv(f_go_wrappers, "\t", NULL);
|
||||
|
||||
if (is_ignored) {
|
||||
|
|
@ -3546,8 +3610,8 @@ private:
|
|||
|
||||
Printv(w->code, "}", NULL);
|
||||
|
||||
Wrapper_print(w, f_c_directors);
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_c_directors);
|
||||
|
||||
DelWrapper(w);
|
||||
}
|
||||
|
|
@ -4636,7 +4700,7 @@ private:
|
|||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* gcCTypeForGoValue()
|
||||
* gccgoCTypeForGoValue()
|
||||
*
|
||||
* Given a type, return the C/C++ type which will be used to catch
|
||||
* the value in Go. This is the gccgo version.
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ public:
|
|||
Printf(s_dot_set, "\nconst LUA_REG_TYPE dot_set[] = {\n");
|
||||
}
|
||||
} else {
|
||||
Printf(s_cmd_tab, "\nstatic const struct luaL_reg swig_commands[] = {\n");
|
||||
Printf(s_cmd_tab, "\nstatic const struct luaL_Reg swig_commands[] = {\n");
|
||||
Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n");
|
||||
Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ static const char *usage = (char *) "\
|
|||
Octave Options (available with -octave)\n\
|
||||
-global - Load all symbols into the global namespace [default]\n\
|
||||
-globals <name> - Set <name> used to access C global variables [default: 'cvar']\n\
|
||||
- Use '.' to load C global variables into module namespace\n\
|
||||
-noglobal - Do not load all symbols into the global namespace\n\
|
||||
-opprefix <str> - Prefix <str> for global operator functions [default: 'op_']\n\
|
||||
\n";
|
||||
|
|
@ -171,6 +172,7 @@ public:
|
|||
Printf(f_runtime, "#define SWIG_global_load %s\n", global_load ? "true" : "false");
|
||||
Printf(f_runtime, "#define SWIG_global_name \"%s\"\n", global_name);
|
||||
Printf(f_runtime, "#define SWIG_op_prefix \"%s\"\n", op_prefix);
|
||||
Printf(f_runtime, "#define SWIG_atexit_func swig_atexit_%s\n", module);
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
|
|
@ -932,18 +934,23 @@ public:
|
|||
|
||||
int use_director = Swig_directorclass(n);
|
||||
if (use_director) {
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *cname = Swig_name_disown(nspace, class_name);
|
||||
String *wcname = Swig_name_wrapper(cname);
|
||||
String *disown_shadow = NewString("");
|
||||
Printf(disown_shadow, "static octave_value_list _wrap_disown_%s_shadow " "(const octave_value_list& args, int nargout) {\n", class_name);
|
||||
Printf(disown_shadow, "static octave_value_list %s_shadow " "(const octave_value_list& args, int nargout) {\n", wcname);
|
||||
Printf(disown_shadow, " if (args.length()!=1) {\n");
|
||||
Printf(disown_shadow, " error(\"disown takes no arguments\");\n");
|
||||
Printf(disown_shadow, " return octave_value_list();\n");
|
||||
Printf(disown_shadow, " }\n");
|
||||
Printf(disown_shadow, " _wrap_disown_%s (args, nargout);\n", class_name);
|
||||
Printf(disown_shadow, " %s (args, nargout);\n", wcname);
|
||||
Printf(disown_shadow, " return args;\n");
|
||||
Printf(disown_shadow, "}\n");
|
||||
Printv(f_wrappers, disown_shadow, NIL);
|
||||
Delete(disown_shadow);
|
||||
Printf(s_members_tab, "{\"__disown\",_wrap_disown_%s_shadow,0,0,0,0},\n", class_name);
|
||||
Printf(s_members_tab, "{\"__disown\",%s_shadow,0,0,0,0},\n", wcname);
|
||||
Delete(wcname);
|
||||
Delete(cname);
|
||||
}
|
||||
|
||||
Printf(s_members_tab, "{0,0,0,0}\n};\n");
|
||||
|
|
@ -977,7 +984,8 @@ public:
|
|||
Printv(f_wrappers, "static swig_octave_class _wrap_class_", class_name, " = {\"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
|
||||
Printv(f_wrappers, Swig_directorclass(n) ? "1," : "0,", NIL);
|
||||
if (have_constructor) {
|
||||
String *cname = Swig_name_construct(NSPACE_TODO, constructor_name);
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *cname = Swig_name_construct(nspace, constructor_name);
|
||||
String *wcname = Swig_name_wrapper(cname);
|
||||
String *tname = texinfo_name(n);
|
||||
Printf(f_wrappers, "%s,%s,", wcname, tname);
|
||||
|
|
@ -986,9 +994,14 @@ public:
|
|||
Delete(cname);
|
||||
} else
|
||||
Printv(f_wrappers, "0,0,", NIL);
|
||||
if (have_destructor)
|
||||
Printv(f_wrappers, "_wrap_delete_", class_name, ",", NIL);
|
||||
else
|
||||
if (have_destructor) {
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *cname = Swig_name_destroy(nspace, class_name);
|
||||
String *wcname = Swig_name_wrapper(cname);
|
||||
Printf(f_wrappers, "%s,", wcname);
|
||||
Delete(wcname);
|
||||
Delete(cname);
|
||||
} else
|
||||
Printv(f_wrappers, "0", ",", NIL);
|
||||
Printf(f_wrappers, "swig_%s_members,swig_%s_base_names,swig_%s_base };\n\n", class_name, class_name, class_name);
|
||||
|
||||
|
|
@ -1010,16 +1023,21 @@ public:
|
|||
String *name = Getattr(n, "name");
|
||||
String *iname = GetChar(n, "sym:name");
|
||||
String *realname = iname ? iname : name;
|
||||
String *rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
String *wname = Getattr(n, "wrap:name");
|
||||
assert(wname);
|
||||
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
String *tname = texinfo_name(n);
|
||||
String *rname = Copy(wname);
|
||||
bool overloaded = !!Getattr(n, "sym:overloaded");
|
||||
if (overloaded)
|
||||
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
|
||||
Printf(s_members_tab, "{\"%s\",%s,0,0,0,%s},\n",
|
||||
realname, rname, tname);
|
||||
Delete(rname);
|
||||
Delete(tname);
|
||||
}
|
||||
|
||||
Delete(rname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1083,16 +1101,21 @@ public:
|
|||
String *name = Getattr(n, "name");
|
||||
String *iname = GetChar(n, "sym:name");
|
||||
String *realname = iname ? iname : name;
|
||||
String *rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
String *wname = Getattr(n, "wrap:name");
|
||||
assert(wname);
|
||||
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
String *tname = texinfo_name(n);
|
||||
String *rname = Copy(wname);
|
||||
bool overloaded = !!Getattr(n, "sym:overloaded");
|
||||
if (overloaded)
|
||||
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
|
||||
Printf(s_members_tab, "{\"%s\",%s,0,0,1,%s},\n",
|
||||
realname, rname, tname);
|
||||
Delete(rname);
|
||||
Delete(tname);
|
||||
}
|
||||
|
||||
Delete(rname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3102,7 +3102,7 @@ public:
|
|||
Printf(f_directors_h, " Swig::DirectorMethodException::raise(msg.c_str());\n");
|
||||
Printf(f_directors_h, " }\n");
|
||||
Printf(f_directors_h, " vtable[method_index] = method;\n");
|
||||
Printf(f_directors_h, " };\n");
|
||||
Printf(f_directors_h, " }\n");
|
||||
Printf(f_directors_h, " return method;\n");
|
||||
Printf(f_directors_h, " }\n");
|
||||
Printf(f_directors_h, "private:\n");
|
||||
|
|
@ -4839,7 +4839,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
if (use_parse || !modernargs) {
|
||||
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", Swig_cresult_name(), pyname, parse_args, arglist);
|
||||
} else {
|
||||
Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", Swig_cresult_name(), pyname);
|
||||
Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname);
|
||||
Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", Swig_cresult_name(), arglist);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) {
|
|||
if(Strncmp(b, "struct ", 7) == 0)
|
||||
Replace(b, "struct ", "", DOH_REPLACE_FIRST);
|
||||
|
||||
/* Printf(stderr, "<getRTypeName> %s,base = %s\n", t, b);
|
||||
/* Printf(stdout, "<getRTypeName> %s,base = %s\n", t, b);
|
||||
for(i = 0; i < Len(els); i++)
|
||||
Printf(stderr, "%d) %s, ", i, Getitem(els,i));
|
||||
Printf(stderr, "\n"); */
|
||||
Printf(stdout, "%d) %s, ", i, Getitem(els,i));
|
||||
Printf(stdout, "\n"); */
|
||||
|
||||
for(i = 0; i < Len(els); i++) {
|
||||
String *el = Getitem(els, i);
|
||||
|
|
@ -92,7 +92,7 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) {
|
|||
if(!l || n == 0) {
|
||||
#ifdef R_SWIG_VERBOSE
|
||||
if (debugMode)
|
||||
Printf(stderr, "SwigType_split return an empty list for %s\n",
|
||||
Printf(stdout, "SwigType_split return an empty list for %s\n",
|
||||
retType);
|
||||
#endif
|
||||
return(tmp);
|
||||
|
|
@ -148,7 +148,7 @@ static String * getRClassNameCopyStruct(String *retType, int addRef) {
|
|||
int n = Len(l);
|
||||
if(!l || n == 0) {
|
||||
#ifdef R_SWIG_VERBOSE
|
||||
Printf(stderr, "SwigType_split return an empty list for %s\n", retType);
|
||||
Printf(stdout, "SwigType_split return an empty list for %s\n", retType);
|
||||
#endif
|
||||
return(tmp);
|
||||
}
|
||||
|
|
@ -292,10 +292,12 @@ public:
|
|||
int membervariableHandler(Node *n);
|
||||
|
||||
int typedefHandler(Node *n);
|
||||
static List *Swig_overload_rank(Node *n,
|
||||
bool script_lang_wrapping);
|
||||
|
||||
int memberfunctionHandler(Node *n) {
|
||||
if (debugMode)
|
||||
Printf(stderr, "<memberfunctionHandler> %s %s\n",
|
||||
Printf(stdout, "<memberfunctionHandler> %s %s\n",
|
||||
Getattr(n, "name"),
|
||||
Getattr(n, "type"));
|
||||
member_name = Getattr(n, "sym:name");
|
||||
|
|
@ -497,11 +499,11 @@ int R::getFunctionPointerNumArgs(Node *n, SwigType *tt) {
|
|||
(void) tt;
|
||||
n = Getattr(n, "type");
|
||||
if (debugMode)
|
||||
Printf(stderr, "type: %s\n", n);
|
||||
Printf(stdout, "type: %s\n", n);
|
||||
|
||||
ParmList *parms = Getattr(n, "parms");
|
||||
if (debugMode)
|
||||
Printf(stderr, "parms = %p\n", parms);
|
||||
Printf(stdout, "parms = %p\n", parms);
|
||||
return ParmList_len(parms);
|
||||
}
|
||||
|
||||
|
|
@ -512,7 +514,7 @@ void R::addSMethodInfo(String *name, String *argType, int nargs) {
|
|||
if(!SMethodInfo)
|
||||
SMethodInfo = NewHash();
|
||||
if (debugMode)
|
||||
Printf(stderr, "[addMethodInfo] %s\n", name);
|
||||
Printf(stdout, "[addMethodInfo] %s\n", name);
|
||||
|
||||
Hash *tb = Getattr(SMethodInfo, name);
|
||||
|
||||
|
|
@ -543,7 +545,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
return funName;
|
||||
|
||||
if (debugMode)
|
||||
Printf(stderr, "<createFunctionPointerHandler> Defining %s\n", t);
|
||||
Printf(stdout, "<createFunctionPointerHandler> Defining %s\n", t);
|
||||
|
||||
SwigType *rettype = Copy(Getattr(n, "type"));
|
||||
SwigType *funcparams = SwigType_functionpointer_decompose(rettype);
|
||||
|
|
@ -555,13 +557,13 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
|
||||
|
||||
if (debugMode) {
|
||||
Printf(stderr, "Type: %s\n", t);
|
||||
Printf(stderr, "Return type: %s\n", SwigType_base(t));
|
||||
Printf(stdout, "Type: %s\n", t);
|
||||
Printf(stdout, "Return type: %s\n", SwigType_base(t));
|
||||
}
|
||||
|
||||
bool isVoidType = Strcmp(rettype, "void") == 0;
|
||||
if (debugMode)
|
||||
Printf(stderr, "%s is void ? %s (%s)\n", funName, isVoidType ? "yes" : "no", rettype);
|
||||
Printf(stdout, "%s is void ? %s (%s)\n", funName, isVoidType ? "yes" : "no", rettype);
|
||||
|
||||
Wrapper *f = NewWrapper();
|
||||
|
||||
|
|
@ -608,7 +610,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
if(numArgs) {
|
||||
*numArgs = nargs;
|
||||
if (debugMode)
|
||||
Printf(stderr, "Setting number of parameters to %d\n", *numArgs);
|
||||
Printf(stdout, "Setting number of parameters to %d\n", *numArgs);
|
||||
}
|
||||
String *setExprElements = NewString("");
|
||||
|
||||
|
|
@ -616,11 +618,16 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
for(i = 0; p; i++) {
|
||||
SwigType *tt = Getattr(p, "type");
|
||||
SwigType *name = Getattr(p, "name");
|
||||
// String *lname = Getattr(p,"lname");
|
||||
Printf(f->def, "%s %s", SwigType_str(tt, 0), name);
|
||||
String *tm = Getattr(p, "tmap:out");
|
||||
if(tm) {
|
||||
Printf(f->def, "%s %s", SwigType_str(tt, 0), name);
|
||||
if(tm) {
|
||||
Replaceall(tm, "$1", name);
|
||||
if (SwigType_isreference(tt)) {
|
||||
String *tmp = NewString("");
|
||||
Append(tmp, "*");
|
||||
Append(tmp, name);
|
||||
Replaceall(tm, tmp, name);
|
||||
}
|
||||
Replaceall(tm, "$result", "r_tmp");
|
||||
replaceRClass(tm, Getattr(p,"type"));
|
||||
Replaceall(tm,"$owner", "R_SWIG_EXTERNAL");
|
||||
|
|
@ -691,11 +698,14 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
|
||||
Printv(f->code, "R_SWIG_popCallbackFunctionData(1);\n", NIL);
|
||||
Printv(f->code, "\n", UnProtectWrapupCode, NIL);
|
||||
|
||||
if(!isVoidType)
|
||||
|
||||
if (SwigType_isreference(rettype)) {
|
||||
Printv(f->code, "return *", Swig_cresult_name(), ";\n", NIL);
|
||||
} else if(!isVoidType)
|
||||
Printv(f->code, "return ", Swig_cresult_name(), ";\n", NIL);
|
||||
|
||||
Printv(f->code, "\n}\n", NIL);
|
||||
Replaceall(f->code, "SWIG_exception_fail", "SWIG_exception_noreturn");
|
||||
|
||||
/* To coerce correctly in S, we really want to have an extra/intermediate
|
||||
function that handles the scoerceout.
|
||||
|
|
@ -744,7 +754,7 @@ int R::cDeclaration(Node *n) {
|
|||
SwigType *t = Getattr(n, "type");
|
||||
SwigType *name = Getattr(n, "name");
|
||||
if (debugMode)
|
||||
Printf(stderr, "cDeclaration (%s): %s\n", name, SwigType_lstr(t, 0));
|
||||
Printf(stdout, "cDeclaration (%s): %s\n", name, SwigType_lstr(t, 0));
|
||||
return Language::cDeclaration(n);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -846,7 +856,7 @@ int R::DumpCode(Node *n) {
|
|||
Printf(output_filename, "%s%s.R", SWIG_output_directory(), Rpackage);
|
||||
|
||||
#ifdef R_SWIG_VERBOSE
|
||||
Printf(stderr, "Writing S code to %s\n", output_filename);
|
||||
Printf(stdout, "Writing S code to %s\n", output_filename);
|
||||
#endif
|
||||
|
||||
File *scode = NewFile(output_filename, "w", SWIG_output_files());
|
||||
|
|
@ -935,15 +945,15 @@ int R::OutputClassMethodsTable(File *) {
|
|||
if (debugMode) {
|
||||
for(i = 0; i < n ; i++ ) {
|
||||
key = Getitem(keys, i);
|
||||
Printf(stderr, "%d) %s\n", i, key);
|
||||
Printf(stdout, "%d) %s\n", i, key);
|
||||
List *els = Getattr(tb, key);
|
||||
int nels = Len(els);
|
||||
Printf(stderr, "\t");
|
||||
Printf(stdout, "\t");
|
||||
for(int j = 0; j < nels; j+=2) {
|
||||
Printf(stderr, "%s%s", Getitem(els, j), j < nels - 1 ? ", " : "");
|
||||
Printf(stderr, "%s\n", Getitem(els, j+1));
|
||||
Printf(stdout, "%s%s", Getitem(els, j), j < nels - 1 ? ", " : "");
|
||||
Printf(stdout, "%s\n", Getitem(els, j+1));
|
||||
}
|
||||
Printf(stderr, "\n");
|
||||
Printf(stdout, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1097,12 +1107,11 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
|
|||
Printv(f->code, tab8, "f(x, value);\n", NIL);
|
||||
Printv(f->code, tab8, "x;\n", NIL); // make certain to return the S value.
|
||||
} else {
|
||||
Printv(f->code, tab8, "formals(f)[[1]] = x;\n", NIL);
|
||||
if (varaccessor) {
|
||||
Printv(f->code, tab8,
|
||||
"if (is.na(match(name, vaccessors))) f else f(x);\n", NIL);
|
||||
"if (is.na(match(name, vaccessors))) function(...){f(x, ...)} else f(x);\n", NIL);
|
||||
} else {
|
||||
Printv(f->code, tab8, "f;\n", NIL);
|
||||
Printv(f->code, tab8, "function(...){f(x, ...)};\n", NIL);
|
||||
}
|
||||
}
|
||||
Printf(f->code, "}\n");
|
||||
|
|
@ -1289,11 +1298,9 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
|
|||
Append(l, tmp);
|
||||
// if we could put the wrapper in directly: Append(l, Copy(sfun));
|
||||
if (debugMode)
|
||||
Printf(stderr, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp);
|
||||
Printf(stdout, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp);
|
||||
}
|
||||
|
||||
#define Swig_overload_rank R_swig_overload_rank
|
||||
|
||||
#define MAX_OVERLOAD 256
|
||||
|
||||
struct Overloaded {
|
||||
|
|
@ -1304,7 +1311,7 @@ struct Overloaded {
|
|||
};
|
||||
|
||||
|
||||
static List * Swig_overload_rank(Node *n,
|
||||
List * R::Swig_overload_rank(Node *n,
|
||||
bool script_lang_wrapping) {
|
||||
Overloaded nodes[MAX_OVERLOAD];
|
||||
int nnodes = 0;
|
||||
|
|
@ -1362,7 +1369,9 @@ static List * Swig_overload_rank(Node *n,
|
|||
int differ = 0;
|
||||
int num_checked = 0;
|
||||
while (p1 && p2 && (num_checked < nodes[i].argc)) {
|
||||
// Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type"));
|
||||
if (debugMode) {
|
||||
Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type"));
|
||||
}
|
||||
if (checkAttribute(p1,"tmap:in:numinputs","0")) {
|
||||
p1 = Getattr(p1,"tmap:in:next");
|
||||
continue;
|
||||
|
|
@ -1373,6 +1382,9 @@ static List * Swig_overload_rank(Node *n,
|
|||
}
|
||||
String *t1 = Getattr(p1,"tmap:typecheck:precedence");
|
||||
String *t2 = Getattr(p2,"tmap:typecheck:precedence");
|
||||
if (debugMode) {
|
||||
Printf(stdout,"t1 = '%s', t2 = '%s'\n", t1, t2);
|
||||
}
|
||||
if ((!t1) && (!nodes[i].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"Overloaded method %s not supported (no type checking rule for '%s').\n",
|
||||
|
|
@ -1553,6 +1565,9 @@ void R::dispatchFunction(Node *n) {
|
|||
|
||||
Printf(f->def,
|
||||
"`%s` <- function(...) {", sfname);
|
||||
if (debugMode) {
|
||||
Swig_print_node(n);
|
||||
}
|
||||
List *dispatch = Swig_overload_rank(n, true);
|
||||
int nfunc = Len(dispatch);
|
||||
Printv(f->code,
|
||||
|
|
@ -1587,31 +1602,59 @@ void R::dispatchFunction(Node *n) {
|
|||
}
|
||||
Printv(f->code, "if (", NIL);
|
||||
for (p =pi, j = 0 ; j < num_arguments ; j++) {
|
||||
if (debugMode) {
|
||||
Swig_print_node(p);
|
||||
}
|
||||
String *tm = Swig_typemap_lookup("rtype", p, "", 0);
|
||||
if(tm) {
|
||||
replaceRClass(tm, Getattr(p, "type"));
|
||||
}
|
||||
|
||||
String *tmcheck = Swig_typemap_lookup("rtypecheck", p, "", 0);
|
||||
if (tmcheck) {
|
||||
|
||||
String *tmp = NewString("");
|
||||
Printf(tmp, "argv[[%d]]", j+1);
|
||||
Replaceall(tmcheck, "$arg", tmp);
|
||||
Printf(tmp, "argtype[%d]", j+1);
|
||||
Replaceall(tmcheck, "$argtype", tmp);
|
||||
if (tm) {
|
||||
Replaceall(tmcheck, "$rtype", tm);
|
||||
}
|
||||
if (debugMode) {
|
||||
Printf(stdout, "<rtypecheck>%s\n", tmcheck);
|
||||
}
|
||||
Printf(f->code, "%s(%s)",
|
||||
j == 0? "" : " && ",
|
||||
tmcheck);
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
if (DohStrcmp(tm,"numeric")==0) {
|
||||
Printf(f->code, "%sis.numeric(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
}
|
||||
else if (DohStrcmp(tm,"integer")==0) {
|
||||
Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1, j+1);
|
||||
}
|
||||
else if (DohStrcmp(tm,"character")==0) {
|
||||
Printf(f->code, "%sis.character(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
}
|
||||
else {
|
||||
Printf(f->code, "%sextends(argtypes[%d], '%s')",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1,
|
||||
tm);
|
||||
}
|
||||
Printf(f->code, "%sis.numeric(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
}
|
||||
else if (DohStrcmp(tm,"integer")==0) {
|
||||
Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1, j+1);
|
||||
}
|
||||
else if (DohStrcmp(tm,"character")==0) {
|
||||
Printf(f->code, "%sis.character(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
}
|
||||
else {
|
||||
Printf(f->code, "%sextends(argtypes[%d], '%s')",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1,
|
||||
tm);
|
||||
}
|
||||
if (!SwigType_ispointer(Getattr(p, "type"))) {
|
||||
Printf(f->code, " && length(argv[[%d]]) == 1",
|
||||
j+1);
|
||||
}
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
}
|
||||
Printf(f->code, ") { f <- %s%s; }\n", sfname, overname);
|
||||
|
|
@ -1641,7 +1684,7 @@ int R::functionWrapper(Node *n) {
|
|||
String *type = Getattr(n, "type");
|
||||
|
||||
if (debugMode) {
|
||||
Printf(stderr,
|
||||
Printf(stdout,
|
||||
"<functionWrapper> %s %s %s\n", fname, iname, type);
|
||||
}
|
||||
String *overname = 0;
|
||||
|
|
@ -1660,7 +1703,7 @@ int R::functionWrapper(Node *n) {
|
|||
}
|
||||
|
||||
if (debugMode)
|
||||
Printf(stderr,
|
||||
Printf(stdout,
|
||||
"<functionWrapper> processing parameters\n");
|
||||
|
||||
|
||||
|
|
@ -1694,11 +1737,11 @@ int R::functionWrapper(Node *n) {
|
|||
}
|
||||
}
|
||||
if (debugMode)
|
||||
Printf(stderr, "<functionWrapper> unresolved_return_type %s\n",
|
||||
Printf(stdout, "<functionWrapper> unresolved_return_type %s\n",
|
||||
unresolved_return_type);
|
||||
if(processing_member_access_function) {
|
||||
if (debugMode)
|
||||
Printf(stderr, "<functionWrapper memberAccess> '%s' '%s' '%s' '%s'\n",
|
||||
Printf(stdout, "<functionWrapper memberAccess> '%s' '%s' '%s' '%s'\n",
|
||||
fname, iname, member_name, class_name);
|
||||
|
||||
if(opaqueClassDeclaration)
|
||||
|
|
@ -1757,7 +1800,7 @@ int R::functionWrapper(Node *n) {
|
|||
|
||||
// if(addCopyParam)
|
||||
if (debugMode)
|
||||
Printf(stderr, "Adding a .copy argument to %s for %s = %s\n",
|
||||
Printf(stdout, "Adding a .copy argument to %s for %s = %s\n",
|
||||
iname, type, addCopyParam ? "yes" : "no");
|
||||
|
||||
Printv(f->def, "SWIGEXPORT SEXP\n", wname, " ( ", NIL);
|
||||
|
|
@ -1814,7 +1857,7 @@ int R::functionWrapper(Node *n) {
|
|||
//XXX need to free.
|
||||
name = NewStringf("%s", Strchr(name, ':') + 2);
|
||||
if (debugMode)
|
||||
Printf(stderr, "+++ parameter name with :: in it %s\n", name);
|
||||
Printf(stdout, "+++ parameter name with :: in it %s\n", name);
|
||||
}
|
||||
if (Len(name) == 0)
|
||||
name = NewStringf("s_arg%d", i+1);
|
||||
|
|
@ -1977,7 +2020,7 @@ int R::functionWrapper(Node *n) {
|
|||
/* Deal with the explicit return value. */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
SwigType *retType = Getattr(n, "type");
|
||||
//Printf(stderr, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no");
|
||||
//Printf(stdout, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no");
|
||||
/* if(SwigType_isarray(retType)) {
|
||||
defineArrayAccessors(retType);
|
||||
} */
|
||||
|
|
@ -2258,7 +2301,7 @@ int R::classDeclaration(Node *n) {
|
|||
if(Getattr(n, "unnamed") && Strcmp(Getattr(n, "storage"), "typedef") == 0
|
||||
&& Getattr(n, "tdname") && Strcmp(Getattr(n, "tdname"), name) == 0) {
|
||||
if (debugMode)
|
||||
Printf(stderr, "Typedef in the class declaration for %s\n", name);
|
||||
Printf(stdout, "Typedef in the class declaration for %s\n", name);
|
||||
// typedefHandler(n);
|
||||
}
|
||||
|
||||
|
|
@ -2340,7 +2383,7 @@ int R::classDeclaration(Node *n) {
|
|||
|
||||
|
||||
// returns "" tp = processType(elType, c, NULL);
|
||||
// Printf(stderr, "<classDeclaration> elType %p\n", elType);
|
||||
// Printf(stdout, "<classDeclaration> elType %p\n", elType);
|
||||
// tp = getRClassNameCopyStruct(Getattr(c, "type"), 1);
|
||||
#endif
|
||||
String *elNameT = replaceInitialDash(elName);
|
||||
|
|
@ -2392,7 +2435,7 @@ int R::generateCopyRoutines(Node *n) {
|
|||
String *mangledName = SwigType_manglestr(name);
|
||||
|
||||
if (debugMode)
|
||||
Printf(stderr, "generateCopyRoutines: name = %s, %s\n", name, type);
|
||||
Printf(stdout, "generateCopyRoutines: name = %s, %s\n", name, type);
|
||||
|
||||
Printf(copyToR->def, "CopyToR%s = function(value, obj = new(\"%s\"))\n{\n",
|
||||
mangledName, name);
|
||||
|
|
@ -2475,7 +2518,7 @@ int R::typedefHandler(Node *n) {
|
|||
SwigType *tp = Getattr(n, "type");
|
||||
String *type = Getattr(n, "type");
|
||||
if (debugMode)
|
||||
Printf(stderr, "<typedefHandler> %s\n", Getattr(n, "name"));
|
||||
Printf(stdout, "<typedefHandler> %s\n", Getattr(n, "name"));
|
||||
|
||||
processType(tp, n);
|
||||
|
||||
|
|
@ -2484,7 +2527,7 @@ int R::typedefHandler(Node *n) {
|
|||
char *trueName = Char(type);
|
||||
trueName += 7;
|
||||
if (debugMode)
|
||||
Printf(stderr, "<typedefHandler> Defining S class %s\n", trueName);
|
||||
Printf(stdout, "<typedefHandler> Defining S class %s\n", trueName);
|
||||
Printf(s_classes, "setClass('_p%s', contains = 'ExternalReference')\n",
|
||||
SwigType_manglestr(name));
|
||||
}
|
||||
|
|
@ -2506,13 +2549,13 @@ int R::membervariableHandler(Node *n) {
|
|||
processing_member_access_function = 1;
|
||||
member_name = Getattr(n,"sym:name");
|
||||
if (debugMode)
|
||||
Printf(stderr, "<membervariableHandler> name = %s, sym:name = %s\n",
|
||||
Printf(stdout, "<membervariableHandler> name = %s, sym:name = %s\n",
|
||||
Getattr(n, "name"), member_name);
|
||||
|
||||
int status(Language::membervariableHandler(n));
|
||||
|
||||
if(!opaqueClassDeclaration && debugMode)
|
||||
Printf(stderr, "<membervariableHandler> %s %s\n", Getattr(n, "name"), Getattr(n, "type"));
|
||||
Printf(stdout, "<membervariableHandler> %s %s\n", Getattr(n, "name"), Getattr(n, "type"));
|
||||
|
||||
processing_member_access_function = 0;
|
||||
member_name = NULL;
|
||||
|
|
@ -2527,7 +2570,7 @@ int R::membervariableHandler(Node *n) {
|
|||
String * R::runtimeCode() {
|
||||
String *s = Swig_include_sys("rrun.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'rrun.swg'\n");
|
||||
Printf(stdout, "*** Unable to open 'rrun.swg'\n");
|
||||
s = NewString("");
|
||||
}
|
||||
return s;
|
||||
|
|
@ -2614,6 +2657,13 @@ void R::main(int argc, char *argv[]) {
|
|||
if (cppcast) {
|
||||
Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
|
||||
}
|
||||
|
||||
if (debugMode) {
|
||||
Swig_typemap_search_debug_set();
|
||||
Swig_typemap_used_debug_set();
|
||||
Swig_typemap_register_debug_set();
|
||||
Swig_file_debug_set();
|
||||
}
|
||||
/// copyToR copyToC functions.
|
||||
|
||||
}
|
||||
|
|
@ -2659,7 +2709,7 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
|
|||
|
||||
SwigType *tmp = Getattr(n, "tdname");
|
||||
if (debugMode)
|
||||
Printf(stderr, "processType %s (tdname = %s)\n", Getattr(n, "name"), tmp);
|
||||
Printf(stdout, "processType %s (tdname = %s)\n", Getattr(n, "name"), tmp);
|
||||
|
||||
SwigType *td = t;
|
||||
if (expandTypedef(t) &&
|
||||
|
|
@ -2676,7 +2726,7 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
|
|||
String *b = getRTypeName(t, &count);
|
||||
if(count && b && !Getattr(SClassDefs, b)) {
|
||||
if (debugMode)
|
||||
Printf(stderr, "<processType> Defining class %s\n", b);
|
||||
Printf(stdout, "<processType> Defining class %s\n", b);
|
||||
|
||||
Printf(s_classes, "setClass('%s', contains = 'ExternalReference')\n", b);
|
||||
Setattr(SClassDefs, b, b);
|
||||
|
|
@ -2690,7 +2740,7 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
|
|||
|
||||
if(SwigType_isfunctionpointer(t)) {
|
||||
if (debugMode)
|
||||
Printf(stderr,
|
||||
Printf(stdout,
|
||||
"<processType> Defining pointer handler %s\n", t);
|
||||
|
||||
String *tmp = createFunctionPointerHandler(t, n, nargs);
|
||||
|
|
|
|||
|
|
@ -227,64 +227,51 @@ class TypePass:private Dispatcher {
|
|||
for (i = 0; i < len; i++) {
|
||||
Node *n = Getitem(ilist, i);
|
||||
String *bname = Getattr(n, "name");
|
||||
Node *bclass = n;
|
||||
Node *bclass = n; /* Getattr(n,"class"); */
|
||||
Hash *scopes = Getattr(bclass, "typescope");
|
||||
SwigType_inherit(clsname, bname, cast, 0);
|
||||
String *smartptr = Getattr(first, "feature:smartptr");
|
||||
if (smartptr) {
|
||||
SwigType *smart = 0;
|
||||
SwigType *spt = Swig_cparse_type(smartptr);
|
||||
if (spt) {
|
||||
smart = SwigType_typedef_resolve_all(spt);
|
||||
Delete(spt);
|
||||
/* Record a (fake) inheritance relationship between smart pointer
|
||||
and smart pointer to base class, so that smart pointer upcasts
|
||||
are automatically generated. */
|
||||
SwigType *bsmart = Copy(smart);
|
||||
SwigType *rclsname = SwigType_typedef_resolve_all(clsname);
|
||||
SwigType *rbname = SwigType_typedef_resolve_all(bname);
|
||||
Replaceall(bsmart, rclsname, rbname);
|
||||
Delete(rclsname);
|
||||
Delete(rbname);
|
||||
String *smartnamestr = SwigType_namestr(smart);
|
||||
String *bsmartnamestr = SwigType_namestr(bsmart);
|
||||
/* construct casting code */
|
||||
String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr);
|
||||
Delete(bsmartnamestr);
|
||||
Delete(smartnamestr);
|
||||
/* setup inheritance relationship between smart pointer templates */
|
||||
SwigType_inherit(smart, bsmart, 0, convcode);
|
||||
if (!GetFlag(bclass, "feature:smartptr"))
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name")));
|
||||
Delete(convcode);
|
||||
Delete(bsmart);
|
||||
Delete(smart);
|
||||
} else {
|
||||
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname));
|
||||
}
|
||||
} else {
|
||||
if (GetFlag(bclass, "feature:smartptr"))
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name")));
|
||||
}
|
||||
if (!importmode) {
|
||||
String *btype = Copy(bname);
|
||||
SwigType_add_pointer(btype);
|
||||
SwigType_remember(btype);
|
||||
Delete(btype);
|
||||
}
|
||||
|
||||
String *smartptr = Getattr(first, "feature:smartptr");
|
||||
String *base_smartptr = Getattr(bclass, "feature:smartptr");
|
||||
if (smartptr) {
|
||||
SwigType *spt = Swig_cparse_type(smartptr);
|
||||
if (spt) {
|
||||
if (base_smartptr) {
|
||||
SwigType *base_spt = Swig_cparse_type(base_smartptr);
|
||||
if (base_spt) {
|
||||
/* Record a (fake) inheritance relationship between smart pointer
|
||||
and smart pointer to base class, so that smart pointer upcasts
|
||||
are automatically generated. */
|
||||
SwigType *smart = SwigType_typedef_resolve_all(spt);
|
||||
SwigType *bsmart = SwigType_typedef_resolve_all(base_spt);
|
||||
String *smartnamestr = SwigType_namestr(smart);
|
||||
String *bsmartnamestr = SwigType_namestr(bsmart);
|
||||
|
||||
/* Construct casting code */
|
||||
String *convcode = NewStringf("\n *newmemory = SWIG_CAST_NEW_MEMORY;\n return (void *) new %s(*(%s *)$from);\n", bsmartnamestr, smartnamestr);
|
||||
|
||||
/* Setup inheritance relationship between smart pointers */
|
||||
SwigType_inherit(smart, bsmart, 0, convcode);
|
||||
if (!importmode) {
|
||||
String *btype = Copy(bsmart);
|
||||
SwigType_add_pointer(btype);
|
||||
SwigType_remember(btype);
|
||||
Delete(btype);
|
||||
}
|
||||
Delete(convcode);
|
||||
Delete(bsmartnamestr);
|
||||
Delete(smartnamestr);
|
||||
Delete(bsmart);
|
||||
Delete(smart);
|
||||
Delete(base_spt);
|
||||
} else {
|
||||
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(base_smartptr), SwigType_namestr(bname));
|
||||
}
|
||||
Delete(spt);
|
||||
} else {
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name")));
|
||||
}
|
||||
} else {
|
||||
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname));
|
||||
}
|
||||
} else {
|
||||
if (base_smartptr)
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name")));
|
||||
}
|
||||
|
||||
if (scopes) {
|
||||
SwigType_inherit_scope(scopes);
|
||||
}
|
||||
|
|
@ -442,10 +429,6 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
} else {
|
||||
Swig_symbol_cadd(fname, n);
|
||||
/* needed?
|
||||
if (template_default_expanded)
|
||||
Swig_symbol_cadd(template_default_expanded, n);
|
||||
*/
|
||||
SwigType_typedef_class(fname);
|
||||
scopename = Copy(fname);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ static String *kpp_dline = 0;
|
|||
static String *kpp_ddefine = 0;
|
||||
static String *kpp_dinclude = 0;
|
||||
static String *kpp_dimport = 0;
|
||||
static String *kpp_dbeginfile = 0;
|
||||
static String *kpp_dextern = 0;
|
||||
|
||||
static String *kpp_LINE = 0;
|
||||
|
|
@ -181,6 +182,7 @@ void Preprocessor_init(void) {
|
|||
|
||||
kpp_dinclude = NewString("%include");
|
||||
kpp_dimport = NewString("%import");
|
||||
kpp_dbeginfile = NewString("%beginfile");
|
||||
kpp_dextern = NewString("%extern");
|
||||
kpp_ddefine = NewString("%define");
|
||||
kpp_dline = NewString("%line");
|
||||
|
|
@ -229,6 +231,7 @@ void Preprocessor_delete(void) {
|
|||
|
||||
Delete(kpp_dinclude);
|
||||
Delete(kpp_dimport);
|
||||
Delete(kpp_dbeginfile);
|
||||
Delete(kpp_dextern);
|
||||
Delete(kpp_ddefine);
|
||||
Delete(kpp_dline);
|
||||
|
|
@ -1327,6 +1330,7 @@ String *Preprocessor_parse(String *s) {
|
|||
int allow = 1;
|
||||
int level = 0;
|
||||
int dlevel = 0;
|
||||
int filelevel = 0;
|
||||
int mask = 0;
|
||||
int start_level = 0;
|
||||
int cpp_lines = 0;
|
||||
|
|
@ -1715,9 +1719,9 @@ String *Preprocessor_parse(String *s) {
|
|||
s1 = cpp_include(fn, sysfile);
|
||||
if (s1) {
|
||||
if (include_all)
|
||||
Printf(ns, "%%includefile \"%s\" [\n", Swig_filename_escape(Swig_last_file()));
|
||||
Printf(ns, "%%includefile \"%s\" %%beginfile\n", Swig_filename_escape(Swig_last_file()));
|
||||
else if (import_all) {
|
||||
Printf(ns, "%%importfile \"%s\" [\n", Swig_filename_escape(Swig_last_file()));
|
||||
Printf(ns, "%%importfile \"%s\" %%beginfile\n", Swig_filename_escape(Swig_last_file()));
|
||||
push_imported();
|
||||
}
|
||||
|
||||
|
|
@ -1731,7 +1735,7 @@ String *Preprocessor_parse(String *s) {
|
|||
}
|
||||
s2 = Preprocessor_parse(s1);
|
||||
addline(ns, s2, allow);
|
||||
Append(ns, "]");
|
||||
Append(ns, "%endoffile");
|
||||
if (dirname) {
|
||||
Swig_pop_directory();
|
||||
}
|
||||
|
|
@ -1859,7 +1863,7 @@ String *Preprocessor_parse(String *s) {
|
|||
char *dirname;
|
||||
copy_location(s, chunk);
|
||||
add_chunk(ns, chunk, allow);
|
||||
Printf(ns, "%sfile%s%s%s\"%s\" [\n", decl, options_whitespace, opt, filename_whitespace, Swig_filename_escape(Swig_last_file()));
|
||||
Printf(ns, "%sfile%s%s%s\"%s\" %%beginfile\n", decl, options_whitespace, opt, filename_whitespace, Swig_filename_escape(Swig_last_file()));
|
||||
if (Equal(decl, kpp_dimport)) {
|
||||
push_imported();
|
||||
}
|
||||
|
|
@ -1878,7 +1882,7 @@ String *Preprocessor_parse(String *s) {
|
|||
pop_imported();
|
||||
}
|
||||
addline(ns, s2, allow);
|
||||
Append(ns, "]");
|
||||
Append(ns, "%endoffile");
|
||||
Delete(s2);
|
||||
Delete(s1);
|
||||
}
|
||||
|
|
@ -1887,6 +1891,14 @@ String *Preprocessor_parse(String *s) {
|
|||
Delete(options_whitespace);
|
||||
}
|
||||
state = 1;
|
||||
} else if (Equal(decl, kpp_dbeginfile)) {
|
||||
/* Got an internal directive marking the beginning of an included file: %beginfile ... %endoffile */
|
||||
filelevel++;
|
||||
start_line = Getline(s);
|
||||
copy_location(s, chunk);
|
||||
add_chunk(ns, chunk, allow);
|
||||
Append(chunk, decl);
|
||||
state = 120;
|
||||
} else if (Equal(decl, kpp_dline)) {
|
||||
/* Got a line directive */
|
||||
state = 1;
|
||||
|
|
@ -1907,6 +1919,40 @@ String *Preprocessor_parse(String *s) {
|
|||
}
|
||||
break;
|
||||
|
||||
/* Searching for the end of a %beginfile block */
|
||||
case 120:
|
||||
Putc(c, chunk);
|
||||
if (c == '%') {
|
||||
const char *bf = "beginfile";
|
||||
const char *ef = "endoffile";
|
||||
char statement[10];
|
||||
int i = 0;
|
||||
for (i = 0; i < 9;) {
|
||||
c = Getc(s);
|
||||
Putc(c, chunk);
|
||||
statement[i++] = (char)c;
|
||||
if (strncmp(statement, bf, i) && strncmp(statement, ef, i))
|
||||
break;
|
||||
}
|
||||
c = Getc(s);
|
||||
Ungetc(c, s);
|
||||
if ((i == 9) && (isspace(c))) {
|
||||
if (strncmp(statement, bf, i) == 0) {
|
||||
++filelevel;
|
||||
} else if (strncmp(statement, ef, i) == 0) {
|
||||
--filelevel;
|
||||
if (!filelevel) {
|
||||
/* Reached end of included file */
|
||||
addline(ns, chunk, allow);
|
||||
Clear(chunk);
|
||||
copy_location(s, chunk);
|
||||
state = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* Searching for the end of a %define statement */
|
||||
case 150:
|
||||
Putc(c, value);
|
||||
|
|
@ -1957,6 +2003,9 @@ String *Preprocessor_parse(String *s) {
|
|||
Swig_error(Getfile(s), -1, "Missing #endif for conditional starting on line %d\n", cond_lines[level - 1]);
|
||||
level--;
|
||||
}
|
||||
if (state == 120) {
|
||||
Swig_error(Getfile(s), -1, "Missing %%endoffile for file inclusion block starting on line %d\n", start_line);
|
||||
}
|
||||
if (state == 150) {
|
||||
Seek(value, 0, SEEK_SET);
|
||||
Swig_error(Getfile(s), -1, "Missing %%enddef for macro starting on line %d\n", Getline(value));
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ void Swig_fragment_register(Node *fragment) {
|
|||
if (kwargs) {
|
||||
Setmeta(ccode, "kwargs", kwargs);
|
||||
}
|
||||
Setfile(ccode, Getfile(fragment));
|
||||
Setline(ccode, Getline(fragment));
|
||||
Setattr(fragments, name, ccode);
|
||||
if (debug)
|
||||
Printf(stdout, "registering fragment %s %s\n", name, section);
|
||||
|
|
@ -142,7 +144,7 @@ void Swig_fragment_emit(Node *n) {
|
|||
if (section) {
|
||||
File *f = Swig_filebyname(section);
|
||||
if (!f) {
|
||||
Swig_error(Getfile(code), Getline(code), "Bad section '%s' for code fragment '%s'\n", section, name);
|
||||
Swig_error(Getfile(code), Getline(code), "Bad section '%s' in %%fragment declaration for code fragment '%s'\n", section, name);
|
||||
} else {
|
||||
if (debug)
|
||||
Printf(stdout, "emitting subfragment %s %s\n", name, section);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ static List *directories = 0; /* List of include directories */
|
|||
static String *lastpath = 0; /* Last file that was included */
|
||||
static List *pdirectories = 0; /* List of pushed directories */
|
||||
static int dopush = 1; /* Whether to push directories */
|
||||
static int file_debug = 0;
|
||||
|
||||
/* This functions determine whether to push/pop dirs in the preprocessor */
|
||||
void Swig_set_push_dir(int push) {
|
||||
|
|
@ -173,6 +174,9 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_
|
|||
cname = Char(name);
|
||||
filename = NewString(cname);
|
||||
assert(filename);
|
||||
if (file_debug) {
|
||||
Printf(stdout, " Open: %s\n", filename);
|
||||
}
|
||||
f = fopen(Char(filename), "r");
|
||||
if (!f && use_include_path) {
|
||||
spath = Swig_search_path_any(sysfile);
|
||||
|
|
@ -386,3 +390,10 @@ char *Swig_file_dirname(const_String_or_char_ptr filename) {
|
|||
*(++c) = 0;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Swig_file_debug()
|
||||
*/
|
||||
void Swig_file_debug_set() {
|
||||
file_debug = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -747,7 +747,6 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
|||
int firstarray = 1;
|
||||
int isreference = 0;
|
||||
int isfunction = 0;
|
||||
int isarray = 0;
|
||||
|
||||
result = NewStringEmpty();
|
||||
|
||||
|
|
@ -838,7 +837,6 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
|||
Delete(size);
|
||||
clear = 0;
|
||||
}
|
||||
isarray = 1;
|
||||
} else if (SwigType_isfunction(element)) {
|
||||
DOH *parms, *p;
|
||||
int j, plen;
|
||||
|
|
|
|||
|
|
@ -388,6 +388,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern void Swig_typemap_debug(void);
|
||||
extern void Swig_typemap_search_debug_set(void);
|
||||
extern void Swig_typemap_used_debug_set(void);
|
||||
extern void Swig_typemap_register_debug_set(void);
|
||||
|
||||
extern String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f);
|
||||
extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ extern char *Swig_file_suffix(const_String_or_char_ptr filename);
|
|||
extern char *Swig_file_basename(const_String_or_char_ptr filename);
|
||||
extern char *Swig_file_filename(const_String_or_char_ptr filename);
|
||||
extern char *Swig_file_dirname(const_String_or_char_ptr filename);
|
||||
extern void Swig_file_debug_set();
|
||||
|
||||
/* Delimiter used in accessing files and directories */
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ char cvsroot_typemap_c[] = "$Id$";
|
|||
|
||||
static int typemap_search_debug = 0;
|
||||
static int typemaps_used_debug = 0;
|
||||
static int typemap_register_debug = 0;
|
||||
static int in_typemap_search_multi = 0;
|
||||
|
||||
static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f, Node *file_line_node);
|
||||
|
|
@ -191,9 +192,14 @@ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *par
|
|||
String *tm_method;
|
||||
SwigType *type;
|
||||
String *pname;
|
||||
|
||||
if (!parms)
|
||||
return;
|
||||
|
||||
if (typemap_register_debug) {
|
||||
Printf(stdout, "Registering - %s\n", tmap_method);
|
||||
Swig_print_node(parms);
|
||||
}
|
||||
|
||||
tm_method = typemap_method_name(tmap_method);
|
||||
|
||||
/* Register the first type in the parameter list */
|
||||
|
|
@ -2064,3 +2070,13 @@ void Swig_typemap_used_debug_set(void) {
|
|||
typemaps_used_debug = 1;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_typemap_register_debug_set()
|
||||
*
|
||||
* Turn on typemaps used debug display
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_typemap_register_debug_set(void) {
|
||||
typemap_register_debug = 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,19 +22,19 @@ AC_DEFUN([AC_COMPARE_VERSION], [
|
|||
isolate_b_regex='\([[0-9]]\+\).*'
|
||||
for ver_part in $nodots_a ; do
|
||||
b_ver_part=`echo "$ver_b" | sed -e 's/'"$isolate_b_regex"'/\1/'`
|
||||
if test \( "$ver_part" -lt "$b_ver_part" \) -a \( "x$condition" == "xequal" \) ; then
|
||||
if test \( "$ver_part" -lt "$b_ver_part" \) -a \( "x$condition" = "xequal" \) ; then
|
||||
condition=less
|
||||
elif test \( "$ver_part" -gt "$b_ver_part" \) -a \( "x$condition" == "xequal" \) ; then
|
||||
elif test \( "$ver_part" -gt "$b_ver_part" \) -a \( "x$condition" = "xequal" \) ; then
|
||||
condition=greater
|
||||
fi
|
||||
isolate_b_regex='[[0-9]]\+\.'"$isolate_b_regex"
|
||||
done
|
||||
|
||||
if test "x$condition" == "xequal" ; then
|
||||
if test "x$condition" = "xequal" ; then
|
||||
[$4]
|
||||
elif test "x$condition" == "xless" ; then
|
||||
elif test "x$condition" = "xless" ; then
|
||||
[$3]
|
||||
elif test "x$condition" == "xgreater" ; then
|
||||
elif test "x$condition" = "xgreater" ; then
|
||||
[$5]
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
|
|
|||
|
|
@ -110,19 +110,19 @@ AC_DEFUN([AX_PATH_GENERIC],[
|
|||
])
|
||||
|
||||
AC_PATH_PROGS(UP[]_CONFIG,[$6 DOWN-config],[no])
|
||||
AS_IF([test "$UP[]_CONFIG" == "no"],[
|
||||
AS_IF([test "$UP[]_CONFIG" = "no"],[
|
||||
:
|
||||
$5
|
||||
],[
|
||||
dnl Get the CFLAGS from LIBRARY-config script
|
||||
AS_IF([test x"$7" == x],[
|
||||
AS_IF([test x"$7" = x],[
|
||||
UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`"
|
||||
],[
|
||||
UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args $7`"
|
||||
])
|
||||
|
||||
dnl Get the LIBS from LIBRARY-config script
|
||||
AS_IF([test x"$8" == x],[
|
||||
AS_IF([test x"$8" = x],[
|
||||
UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`"
|
||||
],[
|
||||
UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args $8`"
|
||||
|
|
|
|||
37
configure.in
37
configure.in
|
|
@ -1954,7 +1954,12 @@ else
|
|||
|
||||
# can we find lua?
|
||||
if test "x$LUABIN" = xyes; then
|
||||
AC_PATH_PROG(LUABIN, lua)
|
||||
# We look for a versioned Lua binary first, as there can be
|
||||
# multiple versions of Lua installed on some systems (like Debian).
|
||||
# The search order should match the include-file and library search
|
||||
# orders below (a Lua shared library built for one version may not
|
||||
# work with a Lua binary of a different version).
|
||||
AC_PATH_PROGS(LUABIN, [lua5.2 lua5.1 lua])
|
||||
fi
|
||||
|
||||
# check version: we need Lua 5.x
|
||||
|
|
@ -2002,8 +2007,11 @@ else
|
|||
# if we didn't get it, going to have to look elsewhere (the hard way)
|
||||
if test -z "$LUA_OK"; then
|
||||
AC_MSG_CHECKING(for lua.h in other locations)
|
||||
# note: ubuntu seems to like /usr/include/lua5.1/lua.h
|
||||
dirs="/usr/include/lua* /usr/local/include"
|
||||
# note: Debian/Ubuntu seem to like /usr/include/lua5.1/lua.h
|
||||
# The ordering of the include directories to search should match
|
||||
# the ordering of libraries to search in the library test below.
|
||||
inc=/usr/include
|
||||
dirs="$inc/lua5.2 $inc/lua5.1 $inc/lua51 $inc/lua5.0 $inc/lua50 /usr/local/include"
|
||||
for i in $dirs; do
|
||||
#echo "$i"
|
||||
if test -r $i/lua.h; then
|
||||
|
|
@ -2026,7 +2034,7 @@ lua_save_LIBS=$LIBS # the code seems to disrupt LIBS, so saving
|
|||
if test -n "$LUALIB"; then
|
||||
AC_CHECK_FILE($LUALIB/liblua.a,[LUALINK="-L$LUALIB -llua"],[LUABIN=])
|
||||
else
|
||||
AC_SEARCH_LIBS(lua_close, [lua lua51 lua5.1 lua50 lua5.0], [LUALINK="-l$ac_lib"],[LUABIN=])
|
||||
AC_SEARCH_LIBS(lua_close, [lua lua5.2 lua5.1 lua51 lua5.0 lua50], [LUALINK="-l$ac_lib"],[LUABIN=])
|
||||
fi
|
||||
|
||||
# adding lualib for lua 5.0
|
||||
|
|
@ -2122,24 +2130,35 @@ AS_HELP_STRING([--with-go=path], [Set location of Go compiler]),[GOBIN="$withval
|
|||
if test x"${GOBIN}" = xno -o x"${with_alllang}" = xno ; then
|
||||
AC_MSG_NOTICE([Disabling Go])
|
||||
GO=
|
||||
GOC=
|
||||
GO1=false
|
||||
GOGCC=false
|
||||
else
|
||||
|
||||
if test "x$GOBIN" = xyes; then
|
||||
AC_CHECK_PROGS(GO, 6g 8g gccgo)
|
||||
AC_CHECK_PROGS(GO, go 6g 8g gccgo)
|
||||
else
|
||||
GO="$GOBIN"
|
||||
fi
|
||||
|
||||
GOGCC=false
|
||||
GO1=false
|
||||
if test -n "$GO" ; then
|
||||
GOGCC=false
|
||||
if $GO --help 2>/dev/null | grep gccgo >/dev/null 2>&1 ; then
|
||||
GOGCC=true
|
||||
go_version=`$GO --version | sed -e 's/[^0-9]* \([0-9.]*\) .*$/\1/' -e 's/[.]//g'`
|
||||
if test "$go_version" -lt 470; then
|
||||
AC_DEFINE(HAVE_GCCGO_46, 1, [Define if using gccgo before 4.7.0])
|
||||
fi
|
||||
elif test "`echo $GO | sed -e 's|.*/||'`" = "go"; then
|
||||
GO1=true
|
||||
GOC=$(sh -c "$(go env) && echo \$GOCHAR")c
|
||||
else
|
||||
GOC=`echo $GO | sed -e 's/g/c/'`
|
||||
AC_MSG_CHECKING([whether Go ($GO) version is too old])
|
||||
go_version=`$GO -V | sed -e 's/.*version.* \([[0-9]]*\).*/\1/'`
|
||||
go_version=`$GO -V 2>/dev/null | sed -e 's/.*version.* \([[0-9]]*\).*/\1/'`
|
||||
go_min_version=7077
|
||||
if test "$go_version" -lt $go_min_version; then
|
||||
if test "$go_version" != "" -a "$go_version" -lt $go_min_version; then
|
||||
AC_MSG_RESULT([yes - minimum version is $go_min_version])
|
||||
GO=
|
||||
else
|
||||
|
|
@ -2151,6 +2170,8 @@ fi
|
|||
|
||||
AC_SUBST(GOGCC)
|
||||
AC_SUBST(GO)
|
||||
AC_SUBST(GOC)
|
||||
AC_SUBST(GO1)
|
||||
|
||||
#----------------------------------------------------------------
|
||||
# Look for D
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue