Merge remote-tracking branch 'origin/master' into gsoc2012-scilab
This commit is contained in:
commit
9c5bac9887
83 changed files with 2913 additions and 7441 deletions
|
|
@ -15,6 +15,7 @@ matrix:
|
|||
before_install:
|
||||
- lsb_release -a
|
||||
- uname -a
|
||||
- sudo apt-get -qq update
|
||||
- time sudo apt-get -qq install libboost-dev
|
||||
- if test "$SWIGLANG" = "csharp"; then sudo apt-get -qq install mono-devel; fi
|
||||
- if test "$SWIGLANG" = "go"; then go env | sed -e 's/^/export /' > goenvsetup && source goenvsetup && rm -f goenvsetup; fi # Until configure.ac is fixed
|
||||
|
|
|
|||
125
CHANGES.current
125
CHANGES.current
|
|
@ -5,3 +5,128 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
Version 2.0.11 (in progress)
|
||||
============================
|
||||
|
||||
2013-09-12: wsfulton
|
||||
[Lua] Pull Git patch #62.
|
||||
1) Static members and static functions inside class can be accessed as
|
||||
ModuleName.ClassName.FunctionName (MemberName respectively). Old way such as
|
||||
ModuleName.ClassName_FunctionName still works.
|
||||
2) Same goes for enums inside classes: ModuleName.ClassName.EnumValue1 etc.
|
||||
|
||||
2013-09-12: wsfulton
|
||||
[UTL] Infinity is now by default an acceptable value for type 'float'. This fix makes
|
||||
the handling of type 'float' and 'double' the same. The implementation requires the
|
||||
C99 isfinite() macro, or otherwise some platform dependent equivalents, to be available.
|
||||
|
||||
Users requiring the old behaviour of not accepting infinity, can define a 'check' typemap
|
||||
wherever a float is used, such as:
|
||||
|
||||
%typemap(check,fragment="<float.h>") float, const float & %{
|
||||
if ($1 < -FLT_MAX || $1 > FLT_MAX) {
|
||||
SWIG_exception_fail(SWIG_TypeError, "Overflow in type float");
|
||||
}
|
||||
%}
|
||||
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2013-08-30: wsfulton
|
||||
[Lua] Pull Git patch #81: Include Lua error locus in SWIG error messages.
|
||||
This is standard information in Lua error messages, and makes it much
|
||||
easier to find bugs.
|
||||
|
||||
2013-08-29: wsfulton
|
||||
Pull Git patch #75: Handle UTF-8 files with BOM at beginning of file. Was giving an
|
||||
'Illegal token' syntax error.
|
||||
|
||||
2013-08-29: wsfulton
|
||||
[C#] Pull Git patch #77: Allow exporting std::map using non-default comparison function.
|
||||
|
||||
2013-08-28: wsfulton
|
||||
[Python] %implicitconv is improved for overloaded functions. Like in C++, the methods
|
||||
with the actual types are considered before trying implicit conversions. Example:
|
||||
|
||||
%implicitconv A;
|
||||
struct A {
|
||||
A(int i);
|
||||
};
|
||||
class CCC {
|
||||
public:
|
||||
int xx(int i) { return 11; }
|
||||
int xx(const A& i) { return 22; }
|
||||
};
|
||||
|
||||
The following python code:
|
||||
|
||||
CCC().xx(-1)
|
||||
|
||||
will now return 11 instead of 22 - the implicit conversion is not done.
|
||||
|
||||
2013-08-23: olly
|
||||
[Python] Fix clang++ warning in generated wrapper code.
|
||||
|
||||
2013-08-16: wsfulton
|
||||
[Python] %implicitconv will now accept None where the implicit conversion takes a C/C++ pointer.
|
||||
Problem highlighted by Bo Peng. Closes SF patch #230.
|
||||
|
||||
2013-08-07: wsfulton
|
||||
[Python] SF Patch #326 from Kris Thielemans - Remove SwigPyObject_print and SwigPyObject_str and
|
||||
make the generated wrapper use the default python implementations, which will fall back to repr
|
||||
(for -builtin option).
|
||||
|
||||
Advantages:
|
||||
- it avoids the swig user having to jump through hoops to get print to work as expected when
|
||||
redefining repr/str slots.
|
||||
- typing the name of a variable on the python prompt now prints the result of a (possibly redefined)
|
||||
repr, without the swig user having to do any extra work.
|
||||
- when redefining repr, the swig user doesn't necessarily have to redefine str as it will call the
|
||||
redefined repr
|
||||
- the behaviour is exactly the same as without the -builtin option while requiring no extra work
|
||||
by the user (aside from adding the %feature("python:slot...) statements of course)
|
||||
|
||||
Disadvantage:
|
||||
- default str() will give different (but clearer?) output on swigged classes
|
||||
|
||||
2013-07-30: wsfulton
|
||||
[Python, Ruby] Fix #64 #65: Missing code in std::multimap wrappers. Previously an instantiation
|
||||
of a std::map was erroneously required in addition to an instantiation of std::multimap with the
|
||||
same template parameters to prevent compilation errors for the wrappers of a std::multimap.
|
||||
|
||||
2013-07-14: joequant
|
||||
[R] Change types file to allow for SEXP return values
|
||||
|
||||
2013-07-05: wsfulton
|
||||
[Python] Add %pythonbegin directive which works like %pythoncode, except the specified code is
|
||||
added at the beginning of the generated .py file. This is primarily needed for importing from
|
||||
__future__ statements required to be at the very beginning of the file. Example:
|
||||
|
||||
%pythonbegin %{
|
||||
from __future__ import print_function
|
||||
print("Loading", "Whizz", "Bang", sep=' ... ')
|
||||
%}
|
||||
|
||||
2013-07-01: wsfulton
|
||||
[Python] Apply SF patch #340 - Uninitialized variable fix in SWIG_Python_NonDynamicSetAttr
|
||||
when using -builtin.
|
||||
|
||||
2013-07-01: wsfulton
|
||||
[Python, Ruby, Ocaml] Apply SF patch #341 - fix a const_cast in generated code that was generating
|
||||
a <:: digraph when using the unary scope operator (::) (global scope) in a template type.
|
||||
|
||||
2013-07-01: wsfulton
|
||||
[Python] Add SF patch #342 from Christian Delbaere to fix some director classes crashing on
|
||||
object deletion when using -builtin. Fixes SF bug #1301.
|
||||
|
||||
2013-06-11: wsfulton
|
||||
[Python] Add SWIG_PYTHON_INTERPRETER_NO_DEBUG macro which can be defined to use the Release version
|
||||
of the Python interpreter in Debug builds of the wrappers. The Visual Studio .dsp example
|
||||
files have been modified to use this so that Debug builds will now work without having
|
||||
to install or build a Debug build of the interpreter.
|
||||
|
||||
2013-06-07: wsfulton
|
||||
[Ruby] Git issue #52. Fix regression with missing rb_complex_new function for Ruby
|
||||
versions prior to 1.9 using std::complex wrappers if just using std::complex as an output type.
|
||||
Also fix the Complex helper functions external visibility (to static by default).
|
||||
|
||||
2013-06-04: olly
|
||||
[PHP] Fix SWIG_ZTS_ConvertResourcePtr() not to dereference NULL
|
||||
if the type lookup fails.
|
||||
|
||||
|
|
|
|||
|
|
@ -1528,9 +1528,9 @@
|
|||
<li><a href="Ruby.html#Ruby_Placement_of_typemaps">Placement of typemaps</a>
|
||||
<li><a href="Ruby.html#Ruby_nn39">Ruby typemaps</a>
|
||||
<ul>
|
||||
<li><a href="Ruby.html#Ruby_in_typemap"> "in" typemap</a>
|
||||
<li><a href="Ruby.html#Ruby_in_typemap">"in" typemap</a>
|
||||
<li><a href="Ruby.html#Ruby_typecheck_typemap">"typecheck" typemap</a>
|
||||
<li><a href="Ruby.html#Ruby_out_typemap"> "out" typemap</a>
|
||||
<li><a href="Ruby.html#Ruby_out_typemap">"out" typemap</a>
|
||||
<li><a href="Ruby.html#Ruby_arginit_typemap">"arginit" typemap</a>
|
||||
<li><a href="Ruby.html#Ruby_default_typemap">"default" typemap</a>
|
||||
<li><a href="Ruby.html#Ruby_check_typemap">"check" typemap</a>
|
||||
|
|
|
|||
|
|
@ -795,7 +795,9 @@ If you need to build it on your own, the following notes are provided:
|
|||
You will need to create a DLL that can be loaded into the interpreter.
|
||||
This section briefly describes the use of SWIG with Microsoft Visual
|
||||
C++. As a starting point, many of SWIG's examples include project
|
||||
files. You might want to take a quick look at these in addition to
|
||||
files (.dsp files) for Visual C++ 6. These can be opened by more
|
||||
recent versions of Visual Studio.
|
||||
You might want to take a quick look at these examples in addition to
|
||||
reading this section.
|
||||
</p>
|
||||
|
||||
|
|
@ -868,6 +870,24 @@ set of Win32 debug or thread libraries. You will have to fiddle around with
|
|||
the build options of project to try and track this down.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A 'Debug' build of the wrappers requires a debug build of the Python interpreter.
|
||||
This normally requires building the Python interpreter from source, which is not a
|
||||
job for the feint-hearted. Alternatively you can use the 'Release' build of the
|
||||
Python interpreter with a 'Debug' build of your wrappers by defining the <tt>SWIG_PYTHON_INTERPRETER_NO_DEBUG</tt>
|
||||
symbol under the preprocessor options. Or you can ensure this macro is defined at the beginning
|
||||
of the wrapper code using the following in your interface file, where <tt>_MSC_VER</tt> ensures it is
|
||||
only used by the Visual Studio compiler:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
%begin %{
|
||||
#ifdef _MSC_VER
|
||||
#define SWIG_PYTHON_INTERPRETER_NO_DEBUG
|
||||
#endif
|
||||
%}
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
Some users have reported success in building extension modules using Cygwin
|
||||
and other compilers. However, the problem of building usable DLLs with these
|
||||
|
|
@ -3294,6 +3314,53 @@ what can be done without having to rely on any of the more advanced
|
|||
customization features.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
There is also <tt>%pythonbegin</tt> which is another directive very similar to <tt>%pythoncode</tt>,
|
||||
but generates the given Python code at the beginning of the <tt>.py</tt> file.
|
||||
This directive works in the same way as <tt>%pythoncode</tt>, except the code is copied
|
||||
just after the SWIG banner (comment) at the top of the file, before any real code.
|
||||
This provides an opportunity to add your own description in a comment near the top of the file as well
|
||||
as Python imports that have to appear at the top of the file, such as "<tt>from __future__ import</tt>"
|
||||
statements.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The following shows example usage for Python 2.6 to use <tt>print</tt> as it can in Python 3, that is, as a function instead of a statement:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%pythonbegin %{
|
||||
# This module provides wrappers to the Whizz Bang library
|
||||
%}
|
||||
|
||||
%pythonbegin %{
|
||||
from __future__ import print_function
|
||||
print("Loading", "Whizz", "Bang", sep=' ... ')
|
||||
%}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
which can be seen when viewing the first few lines of the generated <tt>.py</tt> file:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
# This file was automatically generated by SWIG (http://www.swig.org).
|
||||
# Version 2.0.11
|
||||
#
|
||||
# Do not make changes to this file unless you know what you are doing--modify
|
||||
# the SWIG interface file instead.
|
||||
|
||||
# This module provides wrappers to the Whizz Bang library
|
||||
|
||||
from __future__ import print_function
|
||||
print("Loading", "Whizz", "Bang", sep=' ... ')
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>Sometimes you may want to replace or modify the wrapper function
|
||||
that SWIG creates in the proxy <tt>.py</tt> file. The Python module
|
||||
in SWIG provides some features that enable you to do this. First, to
|
||||
|
|
|
|||
8701
Doc/Manual/Ruby.html
8701
Doc/Manual/Ruby.html
File diff suppressed because it is too large
Load diff
|
|
@ -4433,7 +4433,7 @@ around some other class. For example:
|
|||
template<class T> class SmartPtr {
|
||||
T *pointee;
|
||||
public:
|
||||
...
|
||||
SmartPtr(T *p) : pointee(p) { ... }
|
||||
T *operator->() {
|
||||
return pointee;
|
||||
}
|
||||
|
|
@ -4453,7 +4453,7 @@ typedef SmartPtr<Foo_Impl> Foo;
|
|||
|
||||
// Create smart pointer Foo
|
||||
Foo make_Foo() {
|
||||
return SmartPtr(new Foo_Impl());
|
||||
return SmartPtr<Foo_Impl>(new Foo_Impl());
|
||||
}
|
||||
|
||||
// Do something with smart pointer Foo
|
||||
|
|
@ -4461,6 +4461,9 @@ void do_something(Foo f) {
|
|||
printf("x = %d\n", f->x);
|
||||
f->bar();
|
||||
}
|
||||
|
||||
// Call the wrapped smart pointer proxy class in the target language 'Foo'
|
||||
%template(Foo) SmartPtr<Foo_Impl>;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ PERL5_LIB: D:\nsPerl5.004_04\lib\CORE\perl.lib<br>
|
|||
|
||||
|
||||
<p>
|
||||
<b><tt>PYTHON_INCLUDE</tt></b> : Set this to the directory that contains python.h<br>
|
||||
<b><tt>PYTHON_INCLUDE</tt></b> : Set this to the directory that contains Python.h<br>
|
||||
<b><tt>PYTHON_LIB</tt></b> : Set this to the python library including path for linking<p>
|
||||
Example using Python 2.1.1:<br>
|
||||
<tt>
|
||||
|
|
|
|||
|
|
@ -398,7 +398,7 @@ python_clean:
|
|||
##################################################################
|
||||
|
||||
# Make sure these locate your Octave installation
|
||||
OCTAVE = OCTAVE_HISTFILE=/dev/null @OCTAVE@ -qfH
|
||||
OCTAVE = OCTAVE_HISTFILE=/dev/null @OCTAVE@
|
||||
OCTAVE_CXX = $(DEFS) @OCTAVE_CPPFLAGS@ @OCTAVE_CXXFLAGS@
|
||||
|
||||
# Extra Octave specific dynamic linking options
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "./example"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "./example"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"./example"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "./example"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "./example"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type CEO struct{}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "./example"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "./example"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "./example"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "./example"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"./example"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
. "./example"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"./example"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ RSC=rc.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ RSC=rc.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ RSC=rc.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BAR_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ RSC=rc.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BASE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ RSC=rc.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ RSC=rc.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GR /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SPAM_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ RSC=rc.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ RSC=rc.exe
|
|||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
|
|
|
|||
9
Examples/test-suite/bom_utf8.i
Normal file
9
Examples/test-suite/bom_utf8.i
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
%module bom_utf8
|
||||
|
||||
/* Test for UTF8 BOM at start of file */
|
||||
%inline %{
|
||||
struct NotALotHere {
|
||||
int n;
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
@ -285,8 +285,9 @@ CPP_TEST_CASES += \
|
|||
operbool \
|
||||
ordering \
|
||||
overload_copy \
|
||||
overload_method \
|
||||
overload_extend \
|
||||
overload_method \
|
||||
overload_numeric \
|
||||
overload_rename \
|
||||
overload_return_type \
|
||||
overload_simple \
|
||||
|
|
@ -511,6 +512,7 @@ endif
|
|||
# C test cases. (Can be run individually using: make testcase.ctest)
|
||||
C_TEST_CASES += \
|
||||
arrays \
|
||||
bom_utf8 \
|
||||
char_constant \
|
||||
const_const \
|
||||
constant_expr \
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"./constover"
|
||||
"fmt"
|
||||
"os"
|
||||
"./constover"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import . "./template_typedef_cplx3"
|
|||
func main() {
|
||||
// this is OK
|
||||
|
||||
|
||||
s := NewSin()
|
||||
s.Get_base_value()
|
||||
s.Get_value()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import . "./template_typedef_cplx4"
|
|||
func main() {
|
||||
// this is OK
|
||||
|
||||
|
||||
s := NewSin()
|
||||
s.Get_base_value()
|
||||
s.Get_value()
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import "template_typedef_import"
|
|||
func main() {
|
||||
// this is OK
|
||||
|
||||
|
||||
s := template_typedef_import.NewSin()
|
||||
s.Get_base_value()
|
||||
s.Get_value()
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@
|
|||
Foo(double){ ii = 2;}
|
||||
explicit Foo(char *s){ii = 3;}
|
||||
Foo(const Foo& f){ ii = f.ii;}
|
||||
|
||||
};
|
||||
|
||||
struct Bar
|
||||
|
|
@ -57,11 +56,61 @@
|
|||
Bar(const Foo& ff){ ii = ff.ii;}
|
||||
};
|
||||
|
||||
|
||||
int get_b(const Bar&b) { return b.ii; }
|
||||
|
||||
Foo foo;
|
||||
|
||||
}
|
||||
|
||||
%template(A_int) A_T<int>;
|
||||
|
||||
|
||||
/****************** None handling *********************/
|
||||
|
||||
%inline
|
||||
{
|
||||
struct BB {};
|
||||
struct AA
|
||||
{
|
||||
int ii;
|
||||
AA(int i) { ii = 1; }
|
||||
AA(double d) { ii = 2; }
|
||||
AA(const B* b) { ii = 3; }
|
||||
explicit AA(char *s) { ii = 4; }
|
||||
AA(const BB& b) { ii = 5; }
|
||||
|
||||
int get() const { return ii; }
|
||||
};
|
||||
|
||||
int get_AA_val(AA a) { return a.ii; }
|
||||
int get_AA_ref(const AA& a) { return a.ii; }
|
||||
}
|
||||
|
||||
|
||||
/****************** Overloading priority *********************/
|
||||
|
||||
%inline %{
|
||||
class BBB {
|
||||
public:
|
||||
BBB(const B &) {}
|
||||
};
|
||||
|
||||
class CCC {
|
||||
public:
|
||||
CCC(const BBB &) : checkvalue(0) {}
|
||||
int xx(int i) { return 11; }
|
||||
int xx(const A& i) { return 22; }
|
||||
int yy(int i, int j) { return 111; }
|
||||
int yy(const A& i, const A& j) { return 222; }
|
||||
int checkvalue;
|
||||
};
|
||||
%}
|
||||
|
||||
// CCC(const BBB &) was being called instead of this constructor (independent of being added via %extend)
|
||||
%extend CCC {
|
||||
CCC(const B& b) {
|
||||
CCC* ccc = new CCC(b);
|
||||
ccc->checkvalue = 10;
|
||||
return ccc;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
%feature("trackobjects");
|
||||
|
||||
%include std_pair.i
|
||||
%include std_map.i
|
||||
%include std_multimap.i
|
||||
|
||||
%inline %{
|
||||
|
|
@ -20,6 +19,5 @@ struct A{
|
|||
namespace std
|
||||
{
|
||||
%template(pairA) pair<int, A*>;
|
||||
%template(mapA) map<int, A*>;
|
||||
%template(multimapA) multimap<int, A*>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,14 @@ wchar_t* test_cvalue(wchar_t* x) {
|
|||
}
|
||||
|
||||
|
||||
wchar_t* test_wchar_overload() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
wchar_t* test_wchar_overload(wchar_t *x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
std::wstring test_value(std::wstring x) {
|
||||
return x;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,16 +42,22 @@ assert(f3.num==32)
|
|||
f4=cb.Foo(6)
|
||||
cb.Bar_global_fptr=f4
|
||||
assert(cb.Bar_global_fptr.num==6)
|
||||
assert(cb.Bar.global_fptr.num==6)
|
||||
f4.num=8
|
||||
assert(cb.Bar_global_fptr.num==8)
|
||||
assert(cb.Bar.global_fptr.num==8)
|
||||
|
||||
assert(cb.Bar_global_fref.num==23)
|
||||
assert(cb.Bar.global_fref.num==23)
|
||||
cb.Bar_global_fref=cb.Foo(-7) -- this will set the value
|
||||
assert(cb.Bar_global_fref.num==-7)
|
||||
assert(cb.Bar.global_fref.num==-7)
|
||||
|
||||
assert(cb.Bar_global_fval.num==3)
|
||||
assert(cb.Bar.global_fval.num==3)
|
||||
cb.Bar_global_fval=cb.Foo(-34)
|
||||
assert(cb.Bar_global_fval.num==-34)
|
||||
assert(cb.Bar.global_fval.num==-34)
|
||||
|
||||
-- Now test member function pointers
|
||||
func1_ptr=cb.get_func1_ptr()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#######################################################################
|
||||
|
||||
LANGUAGE = octave
|
||||
OCTAVE = @OCTAVE@ -qf
|
||||
OCTAVE = @OCTAVE@
|
||||
SCRIPTSUFFIX = _runme.m
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
|
|
|||
51
Examples/test-suite/overload_numeric.i
Normal file
51
Examples/test-suite/overload_numeric.i
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
%module overload_numeric
|
||||
|
||||
// Tests overloading of integral and floating point types to verify the range checking required
|
||||
// for dispatch to the correct overloaded method
|
||||
|
||||
#ifdef SWIGLUA
|
||||
// lua only has one numeric type, so most of the overloads shadow each other creating warnings
|
||||
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Nums::over;
|
||||
#endif
|
||||
|
||||
%{
|
||||
#include <iostream>
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
struct Limits {
|
||||
signed char schar_min() { return SCHAR_MIN; }
|
||||
signed char schar_max() { return SCHAR_MAX; }
|
||||
short shrt_min() { return SHRT_MIN; }
|
||||
short shrt_max() { return SHRT_MAX; }
|
||||
int int_min() { return INT_MIN; }
|
||||
int int_max() { return INT_MAX; }
|
||||
float flt_min() { return FLT_MIN; }
|
||||
float flt_max() { return FLT_MAX; }
|
||||
double dbl_max() { return DBL_MAX; }
|
||||
};
|
||||
|
||||
struct Nums {
|
||||
const char * over(signed char v) {
|
||||
return "signed char";
|
||||
}
|
||||
const char * over(short v) {
|
||||
return "short";
|
||||
}
|
||||
const char * over(int v) {
|
||||
return "int";
|
||||
}
|
||||
const char * over(float v) {
|
||||
return "float";
|
||||
}
|
||||
const char * over(double v) {
|
||||
return "double";
|
||||
}
|
||||
double doublebounce(double v) {
|
||||
return v;
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ CPP_TEST_CASES += \
|
|||
li_std_wstream \
|
||||
li_std_wstring \
|
||||
primitive_types \
|
||||
python_abstractbase \
|
||||
python_abstractbase \
|
||||
python_append \
|
||||
python_director \
|
||||
python_nondynamic \
|
||||
|
|
@ -165,6 +165,9 @@ endif
|
|||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean
|
||||
rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
|
||||
rm -f clientdata_prop_a.py clientdata_prop_b.py import_stl_a.py import_stl_b.py
|
||||
rm -f imports_a.py imports_b.py mod_a.py mod_b.py multi_import_a.py
|
||||
rm -f multi_import_b.py packageoption_a.py packageoption_b.py packageoption_c.py
|
||||
|
||||
cvsignore:
|
||||
@echo '*wrap* *.pyc *.so *.dll *.exp *.lib'
|
||||
|
|
|
|||
|
|
@ -11,6 +11,14 @@ check(1, A(1).get())
|
|||
check(2, A(1.0).get())
|
||||
check(3, A(B()).get())
|
||||
check(4, A("hello").get())
|
||||
try:
|
||||
check(3, A(None).get())
|
||||
raise RuntimeError
|
||||
except ValueError:
|
||||
# ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &'
|
||||
# Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value,
|
||||
# references and pointers to different types, where pointers ought to be given a slightly higher precedence.
|
||||
pass
|
||||
|
||||
check(1, get(1))
|
||||
check(2, get(1.0))
|
||||
|
|
@ -71,3 +79,47 @@ try:
|
|||
except TypeError:
|
||||
pass
|
||||
|
||||
#### Class testing None ####
|
||||
|
||||
# No implicit conversion
|
||||
check(1, AA(1).get())
|
||||
check(2, AA(1.0).get())
|
||||
check(3, AA(B()).get())
|
||||
check(3, AA(None).get())
|
||||
check(4, AA("hello").get())
|
||||
check(5, AA(BB()).get())
|
||||
|
||||
check(1, get_AA_val(1))
|
||||
check(2, get_AA_val(1.0))
|
||||
check(3, get_AA_val(B()))
|
||||
check(3, get_AA_val(None))
|
||||
check(5, get_AA_val(BB()))
|
||||
|
||||
# Explicit constructor:
|
||||
try:
|
||||
check(4, get_AA_val("hello"))
|
||||
raise RuntimeError
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
check(1, get_AA_ref(1))
|
||||
check(2, get_AA_ref(1.0))
|
||||
check(3, get_AA_ref(B()))
|
||||
check(3, get_AA_ref(None))
|
||||
check(5, get_AA_ref(BB()))
|
||||
|
||||
# Explicit constructor:
|
||||
try:
|
||||
check(4, get_AA_ref("hello"))
|
||||
raise RuntimeError
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
|
||||
### overloading priority test ###
|
||||
|
||||
ccc = CCC(B())
|
||||
check(ccc.checkvalue, 10)
|
||||
check(ccc.xx(123), 11)
|
||||
check(ccc.yy(123, 123), 111)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,12 @@ if li_std_wstring.test_ccvalue(x) != x:
|
|||
if li_std_wstring.test_cvalue(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring.test_wchar_overload(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring.test_wchar_overload("not unicode") != "not unicode":
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
if li_std_wstring.test_value(x) != x:
|
||||
print x, li_std_wstring.test_value(x)
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
|
|
|||
43
Examples/test-suite/python/overload_numeric_runme.py
Normal file
43
Examples/test-suite/python/overload_numeric_runme.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
from overload_numeric import *
|
||||
import math
|
||||
|
||||
nums = Nums()
|
||||
limits = Limits()
|
||||
|
||||
def check(got, expected):
|
||||
if got != expected:
|
||||
raise RuntimeError("got: " + got + " expected: " + expected)
|
||||
|
||||
check(nums.over(0), "signed char")
|
||||
check(nums.over(0.0), "float")
|
||||
|
||||
check(nums.over(limits.schar_min()), "signed char")
|
||||
check(nums.over(limits.schar_max()), "signed char")
|
||||
|
||||
check(nums.over(limits.schar_min()-1), "short")
|
||||
check(nums.over(limits.schar_max()+1), "short")
|
||||
check(nums.over(limits.shrt_min()), "short")
|
||||
check(nums.over(limits.shrt_max()), "short")
|
||||
|
||||
check(nums.over(limits.shrt_min()-1), "int")
|
||||
check(nums.over(limits.shrt_max()+1), "int")
|
||||
check(nums.over(limits.int_min()), "int")
|
||||
check(nums.over(limits.int_max()), "int")
|
||||
|
||||
check(nums.over(limits.flt_min()), "float")
|
||||
check(nums.over(limits.flt_max()), "float")
|
||||
|
||||
check(nums.over(limits.flt_max()*10), "double")
|
||||
check(nums.over(-limits.flt_max()*10), "double")
|
||||
check(nums.over(limits.dbl_max()), "double")
|
||||
check(nums.over(-limits.dbl_max()), "double")
|
||||
|
||||
check(nums.over(float("inf")), "float")
|
||||
check(nums.over(float("-inf")), "float")
|
||||
check(nums.over(float("nan")), "float")
|
||||
|
||||
# Just check if the following are accepted without exceptions being thrown
|
||||
nums.doublebounce(float("inf"))
|
||||
nums.doublebounce(float("-inf"))
|
||||
nums.doublebounce(float("nan"))
|
||||
|
|
@ -2,3 +2,10 @@ from python_append import *
|
|||
t=Test()
|
||||
t.func()
|
||||
t.static_func()
|
||||
|
||||
if grabpath() != os.path.dirname(mypath):
|
||||
raise RuntimeError
|
||||
|
||||
if grabstaticpath() != os.path.basename(mypath):
|
||||
raise RuntimeError
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,43 @@
|
|||
/*
|
||||
Testcase to test %pythonprepend and %pythonappend
|
||||
Testcase to test %pythonprepend and %pythonappend %pythoncode %pythonbegin
|
||||
*/
|
||||
|
||||
%module python_append
|
||||
|
||||
%pythoncode %{
|
||||
mypath = os.path.dirname("/a/b/c/d.txt")
|
||||
funcpath = None
|
||||
staticfuncpath = None
|
||||
def grabpath():
|
||||
return funcpath
|
||||
def grabstaticpath():
|
||||
return staticfuncpath
|
||||
%}
|
||||
|
||||
%pythonappend Test::func %{
|
||||
pass
|
||||
funcpath = os.path.dirname(funcpath)
|
||||
%}
|
||||
|
||||
%pythonprepend Test::func %{
|
||||
pass
|
||||
global funcpath
|
||||
funcpath = mypath
|
||||
%}
|
||||
|
||||
%pythonappend Test::static_func %{
|
||||
staticfuncpath = os.path.basename(staticfuncpath)
|
||||
pass
|
||||
%}
|
||||
|
||||
%pythonprepend Test::static_func {
|
||||
global staticfuncpath
|
||||
staticfuncpath = mypath
|
||||
pass
|
||||
}
|
||||
|
||||
%pythonbegin %{
|
||||
import os.path
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
class Test {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ C_TEST_CASES += \
|
|||
|
||||
CPP_TEST_CASES += \
|
||||
r_double_delete \
|
||||
r_overload_array
|
||||
r_overload_array \
|
||||
r_sexp
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
|
|
|
|||
7
Examples/test-suite/r/r_sexp_runme.R
Normal file
7
Examples/test-suite/r/r_sexp_runme.R
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
source("unittest.R")
|
||||
dyn.load(paste("r_sexp", .Platform$dynlib.ext, sep=""))
|
||||
source("r_sexp.R")
|
||||
cacheMetaData(1)
|
||||
|
||||
obj <- return_sexp(1);
|
||||
unittest(obj, 1)
|
||||
10
Examples/test-suite/r_sexp.i
Normal file
10
Examples/test-suite/r_sexp.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
%module r_sexp
|
||||
|
||||
extern "C" SEXP return_sexp(SEXP x);
|
||||
|
||||
%inline %{
|
||||
SEXP return_sexp(SEXP x) {
|
||||
return x; //Rcpp NumericVector is automatically casted to SEXP
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_map.i
|
||||
*
|
||||
* SWIG typemaps for std::map< K, T >
|
||||
* SWIG typemaps for std::map< K, T, C >
|
||||
*
|
||||
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.IDictionary<>.
|
||||
*
|
||||
|
|
@ -26,10 +26,10 @@
|
|||
%}
|
||||
|
||||
/* K is the C++ key type, T is the C++ value type */
|
||||
%define SWIG_STD_MAP_INTERNAL(K, T)
|
||||
%define SWIG_STD_MAP_INTERNAL(K, T, C)
|
||||
|
||||
%typemap(csinterfaces) std::map< K, T > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n#endif\n";
|
||||
%typemap(cscode) std::map<K, T > %{
|
||||
%typemap(csinterfaces) std::map< K, T, C > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n#endif\n";
|
||||
%typemap(cscode) std::map<K, T, C > %{
|
||||
|
||||
public $typemap(cstype, T) this[$typemap(cstype, K) key] {
|
||||
get {
|
||||
|
|
@ -221,14 +221,14 @@
|
|||
typedef T mapped_type;
|
||||
|
||||
map();
|
||||
map(const map< K, T > &other);
|
||||
map(const map< K, T, C > &other);
|
||||
size_type size() const;
|
||||
bool empty() const;
|
||||
%rename(Clear) clear;
|
||||
void clear();
|
||||
%extend {
|
||||
const mapped_type& getitem(const key_type& key) throw (std::out_of_range) {
|
||||
std::map< K,T >::iterator iter = $self->find(key);
|
||||
std::map< K, T, C >::iterator iter = $self->find(key);
|
||||
if (iter != $self->end())
|
||||
return iter->second;
|
||||
else
|
||||
|
|
@ -240,19 +240,19 @@
|
|||
}
|
||||
|
||||
bool ContainsKey(const key_type& key) {
|
||||
std::map< K, T >::iterator iter = $self->find(key);
|
||||
std::map< K, T, C >::iterator iter = $self->find(key);
|
||||
return iter != $self->end();
|
||||
}
|
||||
|
||||
void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) {
|
||||
std::map< K, T >::iterator iter = $self->find(key);
|
||||
std::map< K, T, C >::iterator iter = $self->find(key);
|
||||
if (iter != $self->end())
|
||||
throw std::out_of_range("key already exists");
|
||||
$self->insert(std::pair< K, T >(key, val));
|
||||
}
|
||||
|
||||
bool Remove(const key_type& key) {
|
||||
std::map< K, T >::iterator iter = $self->find(key);
|
||||
std::map< K, T, C >::iterator iter = $self->find(key);
|
||||
if (iter != $self->end()) {
|
||||
$self->erase(iter);
|
||||
return true;
|
||||
|
|
@ -261,20 +261,20 @@
|
|||
}
|
||||
|
||||
// create_iterator_begin(), get_next_key() and destroy_iterator work together to provide a collection of keys to C#
|
||||
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *create_iterator_begin }
|
||||
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *swigiterator }
|
||||
%apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *create_iterator_begin }
|
||||
%apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *swigiterator }
|
||||
|
||||
std::map< K, T >::iterator *create_iterator_begin() {
|
||||
return new std::map< K, T >::iterator($self->begin());
|
||||
std::map< K, T, C >::iterator *create_iterator_begin() {
|
||||
return new std::map< K, T, C >::iterator($self->begin());
|
||||
}
|
||||
|
||||
const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) {
|
||||
std::map< K, T >::iterator iter = *swigiterator;
|
||||
const key_type& get_next_key(std::map< K, T, C >::iterator *swigiterator) {
|
||||
std::map< K, T, C >::iterator iter = *swigiterator;
|
||||
(*swigiterator)++;
|
||||
return (*iter).first;
|
||||
}
|
||||
|
||||
void destroy_iterator(std::map< K, T >::iterator *swigiterator) {
|
||||
void destroy_iterator(std::map< K, T, C >::iterator *swigiterator) {
|
||||
delete swigiterator;
|
||||
}
|
||||
}
|
||||
|
|
@ -291,8 +291,8 @@
|
|||
|
||||
// Default implementation
|
||||
namespace std {
|
||||
template<class K, class T> class map {
|
||||
SWIG_STD_MAP_INTERNAL(K, T)
|
||||
template<class K, class T, class C = std::less<K> > class map {
|
||||
SWIG_STD_MAP_INTERNAL(K, T, C)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,36 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Helper functions for error handling
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
/* Push the string STR on the Lua stack, like lua_pushstring, but
|
||||
prefixed with the the location of the innermost Lua call-point
|
||||
(as formated by luaL_where). */
|
||||
SWIGRUNTIME void
|
||||
SWIG_Lua_pusherrstring (lua_State *L, const char *str)
|
||||
{
|
||||
luaL_where (L, 1);
|
||||
lua_pushstring (L, str);
|
||||
lua_concat (L, 2);
|
||||
}
|
||||
|
||||
/* Push a formatted string generated from FMT and following args on
|
||||
the Lua stack, like lua_pushfstring, but prefixed with the the
|
||||
location of the innermost Lua call-point (as formated by luaL_where). */
|
||||
SWIGRUNTIME void
|
||||
SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...)
|
||||
{
|
||||
va_list argp;
|
||||
va_start(argp, fmt);
|
||||
luaL_where(L, 1);
|
||||
lua_pushvfstring(L, fmt, argp);
|
||||
va_end(argp);
|
||||
lua_concat(L, 2);
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* global swig types
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -110,6 +140,15 @@ typedef struct {
|
|||
lua_CFunction setmethod;
|
||||
} swig_lua_attribute;
|
||||
|
||||
// Can be used to create namespaces. Currently used to
|
||||
// wrap class static methods/variables/constants
|
||||
typedef struct {
|
||||
const char *name;
|
||||
swig_lua_method *ns_methods;
|
||||
swig_lua_attribute *ns_attributes;
|
||||
swig_lua_const_info *ns_constants;
|
||||
} swig_lua_namespace;
|
||||
|
||||
typedef struct swig_lua_class {
|
||||
const char *name;
|
||||
swig_type_info **type;
|
||||
|
|
@ -117,6 +156,7 @@ typedef struct swig_lua_class {
|
|||
void (*destructor)(void *);
|
||||
swig_lua_method *methods;
|
||||
swig_lua_attribute *attributes;
|
||||
swig_lua_namespace cls_static;
|
||||
struct swig_lua_class **bases;
|
||||
const char **base_names;
|
||||
} swig_lua_class;
|
||||
|
|
@ -155,19 +195,20 @@ typedef struct {
|
|||
|
||||
/* Contract support */
|
||||
#define SWIG_contract_assert(expr, msg) \
|
||||
if (!(expr)) { lua_pushstring(L, (char *) msg); goto fail; } else
|
||||
if (!(expr)) { SWIG_Lua_pusherrstring(L, (char *) msg); goto fail; } else
|
||||
|
||||
|
||||
/* helper #defines */
|
||||
#define SWIG_fail {goto fail;}
|
||||
#define SWIG_fail_arg(func_name,argnum,type) \
|
||||
{lua_pushfstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\
|
||||
{SWIG_Lua_pushferrstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\
|
||||
func_name,argnum,type,SWIG_Lua_typename(L,argnum));\
|
||||
goto fail;}
|
||||
#define SWIG_fail_ptr(func_name,argnum,type) \
|
||||
SWIG_fail_arg(func_name,argnum,(type && type->str)?type->str:"void*")
|
||||
#define SWIG_check_num_args(func_name,a,b) \
|
||||
if (lua_gettop(L)<a || lua_gettop(L)>b) \
|
||||
{lua_pushfstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\
|
||||
{SWIG_Lua_pushferrstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\
|
||||
goto fail;}
|
||||
|
||||
|
||||
|
|
@ -220,8 +261,7 @@ SWIGINTERN int SWIG_Lua_set_immutable(lua_State* L)
|
|||
/* there should be 1 param passed in: the new value */
|
||||
#ifndef SWIGLUA_IGNORE_SET_IMMUTABLE
|
||||
lua_pop(L,1); /* remove it */
|
||||
lua_pushstring(L,"This variable is immutable");
|
||||
lua_error(L);
|
||||
luaL_error(L,"This variable is immutable");
|
||||
#endif
|
||||
return 0; /* should not return anything */
|
||||
}
|
||||
|
|
@ -385,6 +425,137 @@ SWIGINTERN void SWIG_Lua_module_add_function(lua_State* L,const char* name,lua_
|
|||
SWIG_Lua_add_function(L,name,fn);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* global variable support code: namespaces
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SWIGINTERN int SWIG_Lua_namespace_get(lua_State* L)
|
||||
{
|
||||
/* there should be 2 params passed in
|
||||
(1) table (not the meta table)
|
||||
(2) string name of the attribute
|
||||
*/
|
||||
assert(lua_istable(L,-2)); /* just in case */
|
||||
lua_getmetatable(L,-2);
|
||||
assert(lua_istable(L,-1));
|
||||
SWIG_Lua_get_table(L,".get"); /* find the .get table */
|
||||
assert(lua_istable(L,-1));
|
||||
/* look for the key in the .get table */
|
||||
lua_pushvalue(L,2); /* key */
|
||||
lua_rawget(L,-2);
|
||||
lua_remove(L,-2); /* stack tidy, remove .get table */
|
||||
if (lua_iscfunction(L,-1))
|
||||
{ /* found it so call the fn & return its value */
|
||||
lua_call(L,0,1); /* 1 value in (userdata),1 out (result) */
|
||||
lua_remove(L,-2); /* stack tidy, remove metatable */
|
||||
return 1;
|
||||
}
|
||||
lua_pop(L,1); /* remove whatever was there */
|
||||
/* ok, so try the .fn table */
|
||||
SWIG_Lua_get_table(L,".fn"); /* find the .get table */
|
||||
assert(lua_istable(L,-1)); /* just in case */
|
||||
lua_pushvalue(L,2); /* key */
|
||||
lua_rawget(L,-2); /* look for the fn */
|
||||
lua_remove(L,-2); /* stack tidy, remove .fn table */
|
||||
if (lua_isfunction(L,-1)) /* note: whether it's a C function or lua function */
|
||||
{ /* found it so return the fn & let lua call it */
|
||||
lua_remove(L,-2); /* stack tidy, remove metatable */
|
||||
return 1;
|
||||
}
|
||||
lua_pop(L,1); /* remove whatever was there */
|
||||
return 0;
|
||||
}
|
||||
|
||||
SWIGINTERN int SWIG_Lua_namespace_set(lua_State* L)
|
||||
{
|
||||
/* there should be 3 params passed in
|
||||
(1) table (not the meta table)
|
||||
(2) string name of the attribute
|
||||
(3) any for the new value
|
||||
*/
|
||||
|
||||
assert(lua_istable(L,1));
|
||||
lua_getmetatable(L,1); /* get the meta table */
|
||||
assert(lua_istable(L,-1));
|
||||
|
||||
SWIG_Lua_get_table(L,".set"); /* find the .set table */
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
/* look for the key in the .set table */
|
||||
lua_pushvalue(L,2); /* key */
|
||||
lua_rawget(L,-2);
|
||||
if (lua_iscfunction(L,-1))
|
||||
{ /* found it so call the fn & return its value */
|
||||
lua_pushvalue(L,3); /* value */
|
||||
lua_call(L,1,0);
|
||||
return 0;
|
||||
}
|
||||
lua_pop(L,1); /* remove the value */
|
||||
}
|
||||
lua_pop(L,1); /* remove the value .set table */
|
||||
return 0;
|
||||
}
|
||||
|
||||
SWIGINTERN void SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]); // forward declaration
|
||||
SWIGINTERN void SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn); // forward declaration
|
||||
|
||||
/* helper function - register namespace methods and attributes into namespace */
|
||||
SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State* L, swig_lua_namespace* ns)
|
||||
{
|
||||
int i = 0;
|
||||
assert(lua_istable(L,-1));
|
||||
/* There must be table at the top of the stack */
|
||||
SWIG_Lua_InstallConstants(L, ns->ns_constants);
|
||||
|
||||
lua_getmetatable(L,-1);
|
||||
|
||||
/* add fns */
|
||||
for(i=0;ns->ns_attributes[i].name;i++){
|
||||
SWIG_Lua_add_class_variable(L,ns->ns_attributes[i].name,ns->ns_attributes[i].getmethod,ns->ns_attributes[i].setmethod);
|
||||
}
|
||||
|
||||
/* add methods to the metatable */
|
||||
SWIG_Lua_get_table(L,".fn"); /* find the .fn table */
|
||||
assert(lua_istable(L,-1)); /* just in case */
|
||||
for(i=0;ns->ns_methods[i].name;i++){
|
||||
SWIG_Lua_add_function(L,ns->ns_methods[i].name,ns->ns_methods[i].method);
|
||||
}
|
||||
lua_pop(L,1);
|
||||
|
||||
/* clear stack - remove metatble */
|
||||
lua_pop(L,1);
|
||||
|
||||
}
|
||||
|
||||
/* helper function. creates namespace table and add it to module table */
|
||||
SWIGINTERN int SWIG_Lua_namespace_register(lua_State* L, swig_lua_namespace* ns)
|
||||
{
|
||||
assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table */
|
||||
lua_checkstack(L,5);
|
||||
lua_pushstring(L, ns->name);
|
||||
lua_newtable(L); /* namespace itself */
|
||||
lua_newtable(L); /* metatable for namespace */
|
||||
|
||||
/* add a table called ".get" */
|
||||
lua_pushstring(L,".get");
|
||||
lua_newtable(L);
|
||||
lua_rawset(L,-3);
|
||||
/* add a table called ".set" */
|
||||
lua_pushstring(L,".set");
|
||||
lua_newtable(L);
|
||||
lua_rawset(L,-3);
|
||||
/* add a table called ".fn" */
|
||||
lua_pushstring(L,".fn");
|
||||
lua_newtable(L);
|
||||
lua_rawset(L,-3);
|
||||
|
||||
/* add accessor fns for using the .get,.set&.fn */
|
||||
SWIG_Lua_add_function(L,"__index",SWIG_Lua_namespace_get);
|
||||
SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_namespace_set);
|
||||
|
||||
lua_setmetatable(L,-2); /* set metatable */
|
||||
lua_rawset(L,-3); /* add namespace to module table */
|
||||
}
|
||||
/* -----------------------------------------------------------------------------
|
||||
* global variable support code: classes
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -540,6 +711,23 @@ SWIGINTERN int SWIG_Lua_class_disown(lua_State* L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Constructor proxy. Used when class name entry in module is not class constructor,
|
||||
but special table instead. */
|
||||
SWIGINTERN int SWIG_Lua_constructor_proxy(lua_State* L)
|
||||
{
|
||||
/* unlimited number of parameters
|
||||
First one is our proxy table and we should remove it
|
||||
Other we should pass to real constructor
|
||||
*/
|
||||
assert(lua_istable(L,1));
|
||||
lua_pushstring(L,".constructor");
|
||||
lua_rawget(L,1);
|
||||
assert(!lua_isnil(L,-1));
|
||||
lua_replace(L,1); /* replace our table with real constructor */
|
||||
lua_call(L,lua_gettop(L)-1,1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* gets the swig class registry (or creates it) */
|
||||
SWIGINTERN void SWIG_Lua_get_class_registry(lua_State* L)
|
||||
{
|
||||
|
|
@ -584,6 +772,21 @@ SWIGINTERN void SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_C
|
|||
}
|
||||
}
|
||||
|
||||
/* helper to recursively add class static details (static attributes, operations and constants) */
|
||||
SWIGINTERN void SWIG_Lua_add_class_static_details(lua_State* L, swig_lua_class* clss)
|
||||
{
|
||||
int i = 0;
|
||||
/* The class namespace table must be on the top of the stack */
|
||||
assert(lua_istable(L,-1));
|
||||
/* call all the base classes first: we can then override these later: */
|
||||
for(i=0;clss->bases[i];i++)
|
||||
{
|
||||
SWIG_Lua_add_class_static_details(L,clss->bases[i]);
|
||||
}
|
||||
|
||||
SWIG_Lua_add_namespace_details(L, &clss->cls_static);
|
||||
}
|
||||
|
||||
/* helper to recursively add class details (attributes & operations) */
|
||||
SWIGINTERN void SWIG_Lua_add_class_details(lua_State* L,swig_lua_class* clss)
|
||||
{
|
||||
|
|
@ -637,15 +840,42 @@ SWIGINTERN void SWIG_Lua_init_base_class(lua_State* L,swig_lua_class* clss)
|
|||
}
|
||||
}
|
||||
|
||||
/* performs the entire class registration process */
|
||||
SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss)
|
||||
/* Register class static methods,attributes etc as well as constructor proxy */
|
||||
SWIGINTERN void SWIG_Lua_class_register_static(lua_State* L, swig_lua_class* clss)
|
||||
{
|
||||
lua_checkstack(L,5); /* just in case */
|
||||
assert(lua_istable(L,-1)); /* just in case */
|
||||
assert(strcmp(clss->name, clss->cls_static.name) == 0); /* in class those 2 must be equal */
|
||||
|
||||
SWIG_Lua_namespace_register(L,&clss->cls_static);
|
||||
|
||||
SWIG_Lua_get_table(L,clss->name); // Get namespace table back
|
||||
assert(lua_istable(L,-1)); /* just in case */
|
||||
|
||||
/* add its constructor to module with the name of the class
|
||||
so you can do MyClass(...) as well as new_MyClass(...)
|
||||
BUT only if a constructor is defined
|
||||
(this overcomes the problem of pure virtual classes without constructors)*/
|
||||
if (clss->constructor)
|
||||
SWIG_Lua_add_function(L,clss->name,clss->constructor);
|
||||
{
|
||||
SWIG_Lua_add_function(L,".constructor", clss->constructor);
|
||||
lua_getmetatable(L,-1);
|
||||
assert(lua_istable(L,-1)); /* just in case */
|
||||
SWIG_Lua_add_function(L,"__call", SWIG_Lua_constructor_proxy);
|
||||
lua_pop(L,1);
|
||||
}
|
||||
|
||||
assert(lua_istable(L,-1)); /* just in case */
|
||||
SWIG_Lua_add_class_static_details(L, clss);
|
||||
|
||||
/* clear stack */
|
||||
lua_pop(L,1);
|
||||
}
|
||||
|
||||
/* performs the entire class registration process */
|
||||
SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss)
|
||||
{
|
||||
SWIG_Lua_class_register_static(L,clss);
|
||||
|
||||
SWIG_Lua_get_class_registry(L); /* get the registry */
|
||||
lua_pushstring(L,clss->name); /* get the name */
|
||||
|
|
@ -756,9 +986,8 @@ SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State* L,int index,swig_type_info *typ
|
|||
int argnum,const char* func_name){
|
||||
void* result;
|
||||
if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){
|
||||
lua_pushfstring(L,"Error in %s, expected a %s at argument number %d\n",
|
||||
func_name,(type && type->str)?type->str:"void*",argnum);
|
||||
lua_error(L);
|
||||
luaL_error (L,"Error in %s, expected a %s at argument number %d\n",
|
||||
func_name,(type && type->str)?type->str:"void*",argnum);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,12 +250,12 @@ SWIGINTERN int SWIG_table_size(lua_State* L, int index)
|
|||
SWIGINTERN TYPE* SWIG_get_##NAME##_num_array_fixed(lua_State* L, int index, int size){\
|
||||
TYPE *array;\
|
||||
if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) {\
|
||||
lua_pushfstring(L,"expected a table of size %d",size);\
|
||||
SWIG_Lua_pushferrstring(L,"expected a table of size %d",size);\
|
||||
return 0;\
|
||||
}\
|
||||
array=SWIG_ALLOC_ARRAY(TYPE,size);\
|
||||
if (!SWIG_read_##NAME##_num_array(L,index,array,size)){\
|
||||
lua_pushstring(L,"table must contain numbers");\
|
||||
SWIG_Lua_pusherrstring(L,"table must contain numbers");\
|
||||
SWIG_FREE_ARRAY(array);\
|
||||
return 0;\
|
||||
}\
|
||||
|
|
@ -265,17 +265,17 @@ SWIGINTERN int SWIG_table_size(lua_State* L, int index)
|
|||
{\
|
||||
TYPE *array;\
|
||||
if (!lua_istable(L,index)) {\
|
||||
lua_pushstring(L,"expected a table");\
|
||||
SWIG_Lua_pusherrstring(L,"expected a table");\
|
||||
return 0;\
|
||||
}\
|
||||
*size=SWIG_itable_size(L,index);\
|
||||
if (*size<1){\
|
||||
lua_pushstring(L,"table appears to be empty");\
|
||||
SWIG_Lua_pusherrstring(L,"table appears to be empty");\
|
||||
return 0;\
|
||||
}\
|
||||
array=SWIG_ALLOC_ARRAY(TYPE,*size);\
|
||||
if (!SWIG_read_##NAME##_num_array(L,index,array,*size)){\
|
||||
lua_pushstring(L,"table must contain numbers");\
|
||||
SWIG_Lua_pusherrstring(L,"table must contain numbers");\
|
||||
SWIG_FREE_ARRAY(array);\
|
||||
return 0;\
|
||||
}\
|
||||
|
|
@ -451,12 +451,12 @@ SWIGINTERN int SWIG_read_ptr_array(lua_State* L,int index,void **array,int size,
|
|||
SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swig_type_info *type){
|
||||
void **array;
|
||||
if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) {
|
||||
lua_pushfstring(L,"expected a table of size %d",size);
|
||||
SWIG_Lua_pushferrstring(L,"expected a table of size %d",size);
|
||||
return 0;
|
||||
}
|
||||
array=SWIG_ALLOC_ARRAY(void*,size);
|
||||
if (!SWIG_read_ptr_array(L,index,array,size,type)){
|
||||
lua_pushfstring(L,"table must contain pointers of type %s",type->name);
|
||||
SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name);
|
||||
SWIG_FREE_ARRAY(array);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -465,17 +465,17 @@ SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swi
|
|||
SWIGINTERN void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info *type){
|
||||
void **array;
|
||||
if (!lua_istable(L,index)) {
|
||||
lua_pushstring(L,"expected a table");
|
||||
SWIG_Lua_pusherrstring(L,"expected a table");
|
||||
return 0;
|
||||
}
|
||||
*size=SWIG_itable_size(L,index);
|
||||
if (*size<1){
|
||||
lua_pushstring(L,"table appears to be empty");
|
||||
SWIG_Lua_pusherrstring(L,"table appears to be empty");
|
||||
return 0;
|
||||
}
|
||||
array=SWIG_ALLOC_ARRAY(void*,*size);
|
||||
if (!SWIG_read_ptr_array(L,index,array,*size,type)){
|
||||
lua_pushfstring(L,"table must contain pointers of type %s",type->name);
|
||||
SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name);
|
||||
SWIG_FREE_ARRAY(array);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,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_rawlen( L, $input ));
|
||||
if ($1==0) {lua_pushfstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;}
|
||||
if ($1==0) {SWIG_Lua_pushferrstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;}
|
||||
%}
|
||||
|
||||
%typemap(freearg) wchar_t *
|
||||
|
|
|
|||
|
|
@ -1280,7 +1280,7 @@ SWIGRUNTIME int SWIG_Octave_ConvertPacked(const octave_value &ov, void *ptr, siz
|
|||
return ost->copy(type, (char *) ptr, sz) ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
|
||||
void SWIG_Octave_SetConstant(octave_swig_type *module_ns, const std::string &name, const octave_value &ov) {
|
||||
SWIGRUNTIMEINLINE void SWIG_Octave_SetConstant(octave_swig_type *module_ns, const std::string &name, const octave_value &ov) {
|
||||
module_ns->assign(name, ov);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,73 +2,9 @@
|
|||
|
||||
%include <octcontainer.swg>
|
||||
|
||||
%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
|
||||
%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits")
|
||||
{
|
||||
namespace swig {
|
||||
template <class OctSeq, class K, class T >
|
||||
inline void
|
||||
assign(const OctSeq& octseq, std::map<K,T > *map) {
|
||||
typedef typename std::map<K,T>::value_type value_type;
|
||||
typename OctSeq::const_iterator it = octseq.begin();
|
||||
for (;it != octseq.end(); ++it) {
|
||||
map->insert(value_type(it->first, it->second));
|
||||
}
|
||||
}
|
||||
|
||||
template <class K, class T>
|
||||
struct traits_asptr<std::map<K,T> > {
|
||||
typedef std::map<K,T> map_type;
|
||||
static int asptr(octave_value obj, map_type **val) {
|
||||
/*
|
||||
int res = SWIG_ERROR;
|
||||
if (PyDict_Check(obj)) {
|
||||
SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
|
||||
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
|
||||
} else {
|
||||
map_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
|
||||
if (SWIG_IsOK(res) && val) *val = p;
|
||||
}
|
||||
return res;
|
||||
*/
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
};
|
||||
|
||||
template <class K, class T >
|
||||
struct traits_from<std::map<K,T> > {
|
||||
typedef std::map<K,T> map_type;
|
||||
typedef typename map_type::const_iterator const_iterator;
|
||||
typedef typename map_type::size_type size_type;
|
||||
|
||||
static octave_value from(const map_type& map) {
|
||||
/*
|
||||
swig_type_info *desc = swig::type_info<map_type>();
|
||||
if (desc && desc->clientdata) {
|
||||
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
|
||||
} else {
|
||||
size_type size = map.size();
|
||||
int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
|
||||
if (pysize < 0) {
|
||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"map size not valid in python");
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
return NULL;
|
||||
}
|
||||
PyObject *obj = PyDict_New();
|
||||
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
|
||||
swig::SwigVar_PyObject key = swig::from(i->first);
|
||||
swig::SwigVar_PyObject val = swig::from(i->second);
|
||||
PyDict_SetItem(obj, key, val);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
*/
|
||||
return octave_value();
|
||||
}
|
||||
};
|
||||
|
||||
template <class ValueType>
|
||||
struct from_key_oper
|
||||
{
|
||||
|
|
@ -138,6 +74,75 @@
|
|||
}
|
||||
}
|
||||
|
||||
%fragment("StdMapTraits","header",fragment="StdMapCommonTraits")
|
||||
{
|
||||
namespace swig {
|
||||
template <class OctSeq, class K, class T >
|
||||
inline void
|
||||
assign(const OctSeq& octseq, std::map<K,T > *map) {
|
||||
typedef typename std::map<K,T>::value_type value_type;
|
||||
typename OctSeq::const_iterator it = octseq.begin();
|
||||
for (;it != octseq.end(); ++it) {
|
||||
map->insert(value_type(it->first, it->second));
|
||||
}
|
||||
}
|
||||
|
||||
template <class K, class T>
|
||||
struct traits_asptr<std::map<K,T> > {
|
||||
typedef std::map<K,T> map_type;
|
||||
static int asptr(octave_value obj, map_type **val) {
|
||||
/*
|
||||
int res = SWIG_ERROR;
|
||||
if (PyDict_Check(obj)) {
|
||||
SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
|
||||
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
|
||||
} else {
|
||||
map_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
|
||||
if (SWIG_IsOK(res) && val) *val = p;
|
||||
}
|
||||
return res;
|
||||
*/
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
};
|
||||
|
||||
template <class K, class T >
|
||||
struct traits_from<std::map<K,T> > {
|
||||
typedef std::map<K,T> map_type;
|
||||
typedef typename map_type::const_iterator const_iterator;
|
||||
typedef typename map_type::size_type size_type;
|
||||
|
||||
static octave_value from(const map_type& map) {
|
||||
/*
|
||||
swig_type_info *desc = swig::type_info<map_type>();
|
||||
if (desc && desc->clientdata) {
|
||||
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
|
||||
} else {
|
||||
size_type size = map.size();
|
||||
int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
|
||||
if (pysize < 0) {
|
||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"map size not valid in python");
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
return NULL;
|
||||
}
|
||||
PyObject *obj = PyDict_New();
|
||||
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
|
||||
swig::SwigVar_PyObject key = swig::from(i->first);
|
||||
swig::SwigVar_PyObject val = swig::from(i->second);
|
||||
PyDict_SetItem(obj, key, val);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
*/
|
||||
return octave_value();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%define %swig_map_common(Map...)
|
||||
%swig_sequence_iterator(Map);
|
||||
%swig_container_methods(Map);
|
||||
|
|
|
|||
|
|
@ -209,11 +209,11 @@ SWIG_ZTS_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags TSRMLS_DC) {
|
|||
const char *type_name;
|
||||
|
||||
value = (swig_object_wrapper *) zend_list_find(z->value.lval, &type);
|
||||
if ( flags & SWIG_POINTER_DISOWN ) {
|
||||
if (type==-1) return NULL;
|
||||
if (flags & SWIG_POINTER_DISOWN) {
|
||||
value->newobject = 0;
|
||||
}
|
||||
p = value->ptr;
|
||||
if (type==-1) return NULL;
|
||||
|
||||
type_name=zend_rsrc_list_get_rsrc_type(z->value.lval TSRMLS_CC);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,11 @@ wrapper##_closure(PyObject *a) { \
|
|||
PyObject *o = wrapper(a, NULL); \
|
||||
Py_XDECREF(o); \
|
||||
} \
|
||||
PyObject_Del(a); \
|
||||
if (PyType_IS_GC(a->ob_type)) { \
|
||||
PyObject_GC_Del(a); \
|
||||
} else { \
|
||||
PyObject_Del(a); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SWIGPY_INQUIRY_CLOSURE(wrapper) \
|
||||
|
|
|
|||
|
|
@ -67,10 +67,8 @@
|
|||
#define PySwigObject_next SwigPyObject_next
|
||||
#define PySwigObject_oct SwigPyObject_oct
|
||||
#define PySwigObject_own SwigPyObject_own
|
||||
#define PySwigObject_print SwigPyObject_print
|
||||
#define PySwigObject_repr SwigPyObject_repr
|
||||
#define PySwigObject_richcompare SwigPyObject_richcompare
|
||||
#define PySwigObject_str SwigPyObject_str
|
||||
#define PySwigObject_type SwigPyObject_type
|
||||
#define PySwigPacked SwigPyPacked
|
||||
#define PySwigPacked_Check SwigPyPacked_Check
|
||||
|
|
|
|||
|
|
@ -448,34 +448,6 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args)
|
|||
return repr;
|
||||
}
|
||||
|
||||
SWIGRUNTIME int
|
||||
SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
|
||||
{
|
||||
char *str;
|
||||
#ifdef METH_NOARGS
|
||||
PyObject *repr = SwigPyObject_repr(v);
|
||||
#else
|
||||
PyObject *repr = SwigPyObject_repr(v, NULL);
|
||||
#endif
|
||||
if (repr) {
|
||||
str = SWIG_Python_str_AsChar(repr);
|
||||
fputs(str, fp);
|
||||
SWIG_Python_str_DelForPy3(str);
|
||||
Py_DECREF(repr);
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
SWIGRUNTIME PyObject *
|
||||
SwigPyObject_str(SwigPyObject *v)
|
||||
{
|
||||
char result[SWIG_BUFFER_SIZE];
|
||||
return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
|
||||
SWIG_Python_str_FromChar(result) : 0;
|
||||
}
|
||||
|
||||
SWIGRUNTIME int
|
||||
SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
|
||||
{
|
||||
|
|
@ -761,7 +733,7 @@ SwigPyObject_TypeOnce(void) {
|
|||
sizeof(SwigPyObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor)SwigPyObject_dealloc, /* tp_dealloc */
|
||||
(printfunc)SwigPyObject_print, /* tp_print */
|
||||
0, /* tp_print */
|
||||
#if PY_VERSION_HEX < 0x02020000
|
||||
(getattrfunc)SwigPyObject_getattr, /* tp_getattr */
|
||||
#else
|
||||
|
|
@ -779,7 +751,7 @@ SwigPyObject_TypeOnce(void) {
|
|||
0, /* tp_as_mapping */
|
||||
(hashfunc)0, /* tp_hash */
|
||||
(ternaryfunc)0, /* tp_call */
|
||||
(reprfunc)SwigPyObject_str, /* tp_str */
|
||||
0, /* tp_str */
|
||||
PyObject_GenericGetAttr, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
|
|
@ -1156,10 +1128,11 @@ SWIGRUNTIME int
|
|||
SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
|
||||
int res;
|
||||
SwigPyObject *sobj;
|
||||
int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0;
|
||||
|
||||
if (!obj)
|
||||
return SWIG_ERROR;
|
||||
if (obj == Py_None) {
|
||||
if (obj == Py_None && !implicit_conv) {
|
||||
if (ptr)
|
||||
*ptr = 0;
|
||||
return SWIG_OK;
|
||||
|
|
@ -1208,7 +1181,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
|
|||
}
|
||||
res = SWIG_OK;
|
||||
} else {
|
||||
if (flags & SWIG_POINTER_IMPLICIT_CONV) {
|
||||
if (implicit_conv) {
|
||||
SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
|
||||
if (data && !data->implicitconv) {
|
||||
PyObject *klass = data->klass;
|
||||
|
|
@ -1243,6 +1216,13 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!SWIG_IsOK(res) && obj == Py_None) {
|
||||
if (ptr)
|
||||
*ptr = 0;
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Clear();
|
||||
res = SWIG_OK;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
@ -1742,7 +1722,7 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
|
|||
PyObject *descr;
|
||||
PyObject *encoded_name;
|
||||
descrsetfunc f;
|
||||
int res;
|
||||
int res = -1;
|
||||
|
||||
# ifdef Py_USING_UNICODE
|
||||
if (PyString_Check(name)) {
|
||||
|
|
@ -1765,7 +1745,6 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
|
|||
goto done;
|
||||
}
|
||||
|
||||
res = -1;
|
||||
descr = _PyType_Lookup(tp, name);
|
||||
f = NULL;
|
||||
if (descr != NULL)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
%insert(runtime) %{
|
||||
/* Python.h has to appear first */
|
||||
#include <Python.h>
|
||||
#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)
|
||||
/* Use debug wrappers with the Python release dll */
|
||||
# undef _DEBUG
|
||||
# include <Python.h>
|
||||
# define _DEBUG
|
||||
#else
|
||||
# include <Python.h>
|
||||
#endif
|
||||
%}
|
||||
|
||||
%insert(runtime) "swigrun.swg"; /* SWIG API */
|
||||
|
|
@ -13,4 +19,4 @@
|
|||
|
||||
#if defined(SWIGPYTHON_BUILTIN)
|
||||
%insert(runtime) "builtin.swg"; /* Specialization for classes with single inheritance */
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
/* shadow code */
|
||||
#define %shadow %insert("shadow")
|
||||
#define %pythoncode %insert("python")
|
||||
#define %pythonbegin %insert("pythonbegin")
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
|
|||
int isunicode = PyUnicode_Check(obj);
|
||||
%#if PY_VERSION_HEX < 0x03000000
|
||||
if (!isunicode && PyString_Check(obj)) {
|
||||
if (cptr) {
|
||||
obj = tmp = PyUnicode_FromObject(obj);
|
||||
}
|
||||
obj = tmp = PyUnicode_FromObject(obj);
|
||||
isunicode = 1;
|
||||
}
|
||||
%#endif
|
||||
|
|
|
|||
|
|
@ -2,7 +2,79 @@
|
|||
Maps
|
||||
*/
|
||||
|
||||
%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
|
||||
%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits")
|
||||
{
|
||||
namespace swig {
|
||||
template <class ValueType>
|
||||
struct from_key_oper
|
||||
{
|
||||
typedef const ValueType& argument_type;
|
||||
typedef PyObject *result_type;
|
||||
result_type operator()(argument_type v) const
|
||||
{
|
||||
return swig::from(v.first);
|
||||
}
|
||||
};
|
||||
|
||||
template <class ValueType>
|
||||
struct from_value_oper
|
||||
{
|
||||
typedef const ValueType& argument_type;
|
||||
typedef PyObject *result_type;
|
||||
result_type operator()(argument_type v) const
|
||||
{
|
||||
return swig::from(v.second);
|
||||
}
|
||||
};
|
||||
|
||||
template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
|
||||
struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
|
||||
{
|
||||
SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
|
||||
: SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class OutIterator,
|
||||
class FromOper = from_key_oper<typename OutIterator::value_type> >
|
||||
struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper>
|
||||
{
|
||||
SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
|
||||
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<typename OutIter>
|
||||
inline SwigPyIterator*
|
||||
make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
|
||||
{
|
||||
return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq);
|
||||
}
|
||||
|
||||
template<class OutIterator,
|
||||
class FromOper = from_value_oper<typename OutIterator::value_type> >
|
||||
struct SwigPyMapValueITerator_T : SwigPyMapIterator_T<OutIterator, FromOper>
|
||||
{
|
||||
SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
|
||||
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename OutIter>
|
||||
inline SwigPyIterator*
|
||||
make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
|
||||
{
|
||||
return new SwigPyMapValueITerator_T<OutIter>(current, begin, end, seq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("StdMapTraits","header",fragment="StdMapCommonTraits")
|
||||
{
|
||||
namespace swig {
|
||||
template <class SwigPySeq, class K, class T, class Compare, class Alloc >
|
||||
|
|
@ -73,74 +145,6 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class ValueType>
|
||||
struct from_key_oper
|
||||
{
|
||||
typedef const ValueType& argument_type;
|
||||
typedef PyObject *result_type;
|
||||
result_type operator()(argument_type v) const
|
||||
{
|
||||
return swig::from(v.first);
|
||||
}
|
||||
};
|
||||
|
||||
template <class ValueType>
|
||||
struct from_value_oper
|
||||
{
|
||||
typedef const ValueType& argument_type;
|
||||
typedef PyObject *result_type;
|
||||
result_type operator()(argument_type v) const
|
||||
{
|
||||
return swig::from(v.second);
|
||||
}
|
||||
};
|
||||
|
||||
template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
|
||||
struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
|
||||
{
|
||||
SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
|
||||
: SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class OutIterator,
|
||||
class FromOper = from_key_oper<typename OutIterator::value_type> >
|
||||
struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper>
|
||||
{
|
||||
SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
|
||||
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<typename OutIter>
|
||||
inline SwigPyIterator*
|
||||
make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
|
||||
{
|
||||
return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq);
|
||||
}
|
||||
|
||||
template<class OutIterator,
|
||||
class FromOper = from_value_oper<typename OutIterator::value_type> >
|
||||
struct SwigPyMapValueITerator_T : SwigPyMapIterator_T<OutIterator, FromOper>
|
||||
{
|
||||
SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
|
||||
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename OutIter>
|
||||
inline SwigPyIterator*
|
||||
make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
|
||||
{
|
||||
return new SwigPyMapValueITerator_T<OutIter>(current, begin, end, seq);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
%include <std_map.i>
|
||||
|
||||
%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits")
|
||||
%fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits")
|
||||
{
|
||||
namespace swig {
|
||||
template <class SwigPySeq, class K, class T >
|
||||
|
|
|
|||
|
|
@ -151,6 +151,8 @@ string &, std::string &
|
|||
#%typemap(scoerceout) SWIGTYPE *const
|
||||
# %{ class($result) <- "$R_class"; %}
|
||||
|
||||
%typemap(scoerceout) SEXP %{ %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE
|
||||
%{ $result <- new("$&R_class", ref=$result); %}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,34 +7,39 @@
|
|||
See the std_complex.i and ccomplex.i for concrete examples.
|
||||
*/
|
||||
|
||||
%fragment("SWIG_Complex_Numbers","header")
|
||||
%fragment("rb_complex_new","header")
|
||||
{
|
||||
%#if !defined(T_COMPLEX)
|
||||
/* Ruby versions prior to 1.9 did not have native complex numbers. They were an extension in the STD library. */
|
||||
VALUE rb_complex_new(VALUE x, VALUE y) {
|
||||
SWIGINTERN VALUE rb_complex_new(VALUE x, VALUE y) {
|
||||
static ID new_id = rb_intern("new");
|
||||
static VALUE cComplex = rb_const_get(rb_cObject, rb_intern("Complex"));
|
||||
return rb_funcall(cComplex, new_id, 2, x, y);
|
||||
}
|
||||
%#endif
|
||||
}
|
||||
|
||||
static int SWIG_Is_Complex( VALUE obj ) {
|
||||
%fragment("SWIG_Complex_Numbers","header")
|
||||
{
|
||||
%#if !defined(T_COMPLEX)
|
||||
SWIGINTERN int SWIG_Is_Complex( VALUE obj ) {
|
||||
static ID real_id = rb_intern("real");
|
||||
static ID imag_id = rb_intern("imag");
|
||||
return ( (rb_respond_to( obj, real_id ) ) &&
|
||||
(rb_respond_to( obj, imag_id ) ) );
|
||||
}
|
||||
%#else
|
||||
static int SWIG_Is_Complex( VALUE obj ) {
|
||||
SWIGINTERN int SWIG_Is_Complex( VALUE obj ) {
|
||||
return TYPE(obj) == T_COMPLEX;
|
||||
}
|
||||
%#endif
|
||||
|
||||
VALUE SWIG_Complex_Real(VALUE obj) {
|
||||
SWIGINTERN VALUE SWIG_Complex_Real(VALUE obj) {
|
||||
static ID real_id = rb_intern("real");
|
||||
return rb_funcall(obj, real_id, 0);
|
||||
}
|
||||
|
||||
VALUE SWIG_Complex_Imaginary(VALUE obj) {
|
||||
SWIGINTERN VALUE SWIG_Complex_Imaginary(VALUE obj) {
|
||||
static ID imag_id = rb_intern("imag");
|
||||
return rb_funcall(obj, imag_id, 0);
|
||||
}
|
||||
|
|
@ -48,7 +53,7 @@ VALUE SWIG_Complex_Imaginary(VALUE obj) {
|
|||
|
||||
/* the common from converter */
|
||||
%define %swig_fromcplx_conv(Type, Real, Imag)
|
||||
%fragment(SWIG_From_frag(Type),"header")
|
||||
%fragment(SWIG_From_frag(Type),"header",fragment="rb_complex_new")
|
||||
{
|
||||
SWIGINTERNINLINE VALUE
|
||||
SWIG_From(Type)(%ifcplusplus(const Type&, Type) c)
|
||||
|
|
|
|||
|
|
@ -1,67 +1,9 @@
|
|||
//
|
||||
// Maps
|
||||
//
|
||||
%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
|
||||
%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits")
|
||||
{
|
||||
namespace swig {
|
||||
template <class RubySeq, class K, class T >
|
||||
inline void
|
||||
assign(const RubySeq& rubyseq, std::map<K,T > *map) {
|
||||
typedef typename std::map<K,T>::value_type value_type;
|
||||
typename RubySeq::const_iterator it = rubyseq.begin();
|
||||
for (;it != rubyseq.end(); ++it) {
|
||||
map->insert(value_type(it->first, it->second));
|
||||
}
|
||||
}
|
||||
|
||||
template <class K, class T>
|
||||
struct traits_asptr<std::map<K,T> > {
|
||||
typedef std::map<K,T> map_type;
|
||||
static int asptr(VALUE obj, map_type **val) {
|
||||
int res = SWIG_ERROR;
|
||||
if ( TYPE(obj) == T_HASH ) {
|
||||
static ID id_to_a = rb_intern("to_a");
|
||||
VALUE items = rb_funcall(obj, id_to_a, 0);
|
||||
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
|
||||
} else {
|
||||
map_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
|
||||
if (SWIG_IsOK(res) && val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <class K, class T >
|
||||
struct traits_from<std::map<K,T> > {
|
||||
typedef std::map<K,T> map_type;
|
||||
typedef typename map_type::const_iterator const_iterator;
|
||||
typedef typename map_type::size_type size_type;
|
||||
|
||||
static VALUE from(const map_type& map) {
|
||||
swig_type_info *desc = swig::type_info<map_type>();
|
||||
if (desc && desc->clientdata) {
|
||||
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
|
||||
} else {
|
||||
size_type size = map.size();
|
||||
int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
|
||||
if (rubysize < 0) {
|
||||
SWIG_RUBY_THREAD_BEGIN_BLOCK;
|
||||
rb_raise( rb_eRuntimeError, "map size not valid in Ruby");
|
||||
SWIG_RUBY_THREAD_END_BLOCK;
|
||||
return Qnil;
|
||||
}
|
||||
VALUE obj = rb_hash_new();
|
||||
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
|
||||
VALUE key = swig::from(i->first);
|
||||
VALUE val = swig::from(i->second);
|
||||
rb_hash_aset(obj, key, val);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class ValueType>
|
||||
struct from_key_oper
|
||||
{
|
||||
|
|
@ -134,6 +76,69 @@
|
|||
}
|
||||
}
|
||||
|
||||
%fragment("StdMapTraits","header",fragment="StdMapCommonTraits")
|
||||
{
|
||||
namespace swig {
|
||||
template <class RubySeq, class K, class T >
|
||||
inline void
|
||||
assign(const RubySeq& rubyseq, std::map<K,T > *map) {
|
||||
typedef typename std::map<K,T>::value_type value_type;
|
||||
typename RubySeq::const_iterator it = rubyseq.begin();
|
||||
for (;it != rubyseq.end(); ++it) {
|
||||
map->insert(value_type(it->first, it->second));
|
||||
}
|
||||
}
|
||||
|
||||
template <class K, class T>
|
||||
struct traits_asptr<std::map<K,T> > {
|
||||
typedef std::map<K,T> map_type;
|
||||
static int asptr(VALUE obj, map_type **val) {
|
||||
int res = SWIG_ERROR;
|
||||
if ( TYPE(obj) == T_HASH ) {
|
||||
static ID id_to_a = rb_intern("to_a");
|
||||
VALUE items = rb_funcall(obj, id_to_a, 0);
|
||||
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
|
||||
} else {
|
||||
map_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
|
||||
if (SWIG_IsOK(res) && val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <class K, class T >
|
||||
struct traits_from<std::map<K,T> > {
|
||||
typedef std::map<K,T> map_type;
|
||||
typedef typename map_type::const_iterator const_iterator;
|
||||
typedef typename map_type::size_type size_type;
|
||||
|
||||
static VALUE from(const map_type& map) {
|
||||
swig_type_info *desc = swig::type_info<map_type>();
|
||||
if (desc && desc->clientdata) {
|
||||
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
|
||||
} else {
|
||||
size_type size = map.size();
|
||||
int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
|
||||
if (rubysize < 0) {
|
||||
SWIG_RUBY_THREAD_BEGIN_BLOCK;
|
||||
rb_raise( rb_eRuntimeError, "map size not valid in Ruby");
|
||||
SWIG_RUBY_THREAD_END_BLOCK;
|
||||
return Qnil;
|
||||
}
|
||||
VALUE obj = rb_hash_new();
|
||||
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
|
||||
VALUE key = swig::from(i->first);
|
||||
VALUE val = swig::from(i->second);
|
||||
rb_hash_aset(obj, key, val);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%define %swig_map_common(Map...)
|
||||
%swig_container_methods(%arg(Map));
|
||||
// %swig_sequence_iterator(%arg(Map));
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
%include <std_map.i>
|
||||
|
||||
%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits")
|
||||
%fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits")
|
||||
{
|
||||
namespace swig {
|
||||
template <class RubySeq, class K, class T >
|
||||
|
|
|
|||
|
|
@ -60,6 +60,20 @@ namespace std {
|
|||
%traits_swigtype(_Key);
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header",
|
||||
fragment=SWIG_Traits_frag(_Key),
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdPairTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::pair< _Key, _Tp > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::pair<" #_Key "," #_Tp " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::multimap<_Key, _Tp, _Compare, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >),
|
||||
fragment="StdMultimapTraits") {
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ SWIG_InitializeModule(void *clientdata) {
|
|||
module_head->next = &swig_module;
|
||||
}
|
||||
|
||||
/* When multiple interpeters are used, a module could have already been initialized in
|
||||
/* When multiple interpreters are used, a module could have already been initialized in
|
||||
a different interpreter, but not yet have a pointer in this interpreter.
|
||||
In this case, we do not want to continue adding types... everything should be
|
||||
set up already */
|
||||
|
|
|
|||
|
|
@ -153,6 +153,29 @@
|
|||
#include <stddef.h>
|
||||
%}
|
||||
|
||||
%fragment("SWIG_isfinite","header",fragment="<math.h>,<float.h>") %{
|
||||
/* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */
|
||||
#ifndef SWIG_isfinite
|
||||
# if defined(isfinite)
|
||||
# define SWIG_isfinite(X) (isfinite(X))
|
||||
# elif defined(_MSC_VER)
|
||||
# define SWIG_isfinite(X) (_finite(X))
|
||||
# elif defined(__sun) && defined(__SVR4)
|
||||
# include <ieeefp.h>
|
||||
# define SWIG_isfinite(X) (finite(X))
|
||||
# endif
|
||||
#endif
|
||||
%}
|
||||
|
||||
%fragment("SWIG_Float_Overflow_Check","header",fragment="<float.h>,SWIG_isfinite") %{
|
||||
/* Accept infinite as a valid float value unless we are unable to check if a value is finite */
|
||||
#ifdef SWIG_isfinite
|
||||
# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX) && SWIG_isfinite(X))
|
||||
#else
|
||||
# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX))
|
||||
#endif
|
||||
%}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* special macros for fragments
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -213,13 +236,20 @@ SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val)
|
|||
%enddef
|
||||
|
||||
|
||||
/* Macro for 'double' derived types */
|
||||
/* Macro for floating point derived types (original macro) */
|
||||
|
||||
%define %numeric_double(Type, Frag, Min, Max)
|
||||
%numeric_type_from(Type, double)
|
||||
%numeric_signed_type_asval(Type, double, Frag , Min, Max)
|
||||
%enddef
|
||||
|
||||
/* Macro for floating point derived types */
|
||||
|
||||
%define %numeric_float(Type, Frag, OverflowCond)
|
||||
%numeric_type_from(Type, double)
|
||||
%numeric_type_asval(Type, double, Frag, OverflowCond)
|
||||
%enddef
|
||||
|
||||
|
||||
/* Macros for missing fragments */
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ SWIG_AsVal_dec(bool)(SWIG_Object obj, bool *val)
|
|||
|
||||
/* float */
|
||||
|
||||
%numeric_double(float, "<float.h>", -FLT_MAX, FLT_MAX)
|
||||
%numeric_float(float, "SWIG_Float_Overflow_Check", SWIG_Float_Overflow_Check(v))
|
||||
|
||||
/* long/unsigned long */
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ static DOH *encodings = 0; /* Encoding hash */
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Writen()
|
||||
*
|
||||
* Write's N characters of output and retries until all characters are
|
||||
* Writes N characters of output and retries until all characters are
|
||||
* written. This is useful should a write operation encounter a spurious signal.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
|
|
|||
|
|
@ -4028,7 +4028,7 @@ public:
|
|||
Delete(director_ctor_code);
|
||||
director_ctor_code = NewString("$director_new");
|
||||
|
||||
Java_director_declaration(n);
|
||||
directorDeclaration(n);
|
||||
|
||||
Printf(f_directors_h, "%s {\n", Getattr(n, "director:decl"));
|
||||
Printf(f_directors_h, "\npublic:\n");
|
||||
|
|
@ -4148,13 +4148,13 @@ public:
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Java_director_declaration()
|
||||
* directorDeclaration()
|
||||
*
|
||||
* Generate the director class's declaration
|
||||
* e.g. "class SwigDirector_myclass : public myclass, public Swig::Director {"
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
void Java_director_declaration(Node *n) {
|
||||
void directorDeclaration(Node *n) {
|
||||
|
||||
String *base = Getattr(n, "classtype");
|
||||
String *class_ctor = NewString("Swig::Director()");
|
||||
|
|
|
|||
|
|
@ -4221,7 +4221,7 @@ public:
|
|||
Delete(director_ctor_code);
|
||||
director_ctor_code = NewString("$director_new");
|
||||
|
||||
Java_director_declaration(n);
|
||||
directorDeclaration(n);
|
||||
|
||||
Printf(f_directors_h, "%s {\n", Getattr(n, "director:decl"));
|
||||
Printf(f_directors_h, "\npublic:\n");
|
||||
|
|
@ -4405,13 +4405,13 @@ public:
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Java_director_declaration()
|
||||
* directorDeclaration()
|
||||
*
|
||||
* Generate the director class's declaration
|
||||
* e.g. "class SwigDirector_myclass : public myclass, public Swig::Director {"
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
void Java_director_declaration(Node *n) {
|
||||
void directorDeclaration(Node *n) {
|
||||
String *base = Getattr(n, "classtype");
|
||||
String *class_ctor = NewString("Swig::Director(jenv)");
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
*/
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
|
||||
/**** Diagnostics:
|
||||
With the #define REPORT(), you can change the amount of diagnostics given
|
||||
|
|
@ -111,6 +112,9 @@ private:
|
|||
String *s_const_tab; // table of global constants
|
||||
String *s_methods_tab; // table of class methods
|
||||
String *s_attr_tab; // table of class attributes
|
||||
String *s_cls_attr_tab; // table of class static attributes
|
||||
String *s_cls_methods_tab; // table of class static methods
|
||||
String *s_cls_const_tab; // tables of class constants(including enums)
|
||||
String *s_luacode; // luacode to be called during init
|
||||
String *s_dot_get; // table of variable 'get' functions
|
||||
String *s_dot_set; // table of variable 'set' functions
|
||||
|
|
@ -154,6 +158,9 @@ public:
|
|||
s_const_tab(0),
|
||||
s_methods_tab(0),
|
||||
s_attr_tab(0),
|
||||
s_cls_attr_tab(0),
|
||||
s_cls_methods_tab(0),
|
||||
s_cls_const_tab(0),
|
||||
s_luacode(0),
|
||||
s_dot_get(0),
|
||||
s_dot_set(0),
|
||||
|
|
@ -736,13 +743,18 @@ public:
|
|||
NEW LANGUAGE NOTE:END ************************************************/
|
||||
/* Now register the function with the interpreter. */
|
||||
if (!Getattr(n, "sym:overloaded")) {
|
||||
//REPORT("dispatchFunction", n);
|
||||
// add_method(n, iname, wname, description);
|
||||
if (current==NO_CPP || current==STATIC_FUNC) { // emit normal fns & static fns
|
||||
String *wrapname = Swig_name_wrapper(iname);
|
||||
if(elua_ltr || eluac_ltr)
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "\")", ", LFUNCVAL(", Swig_name_wrapper(iname), ")", "},\n", NIL);
|
||||
else
|
||||
Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
// Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
if (getCurrentClass()) {
|
||||
Setattr(n,"luaclassobj:wrap:name", wrapname);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
|
|
@ -775,6 +787,7 @@ public:
|
|||
look for %typecheck(SWIG_TYPECHECK_*) in the .swg file
|
||||
NEW LANGUAGE NOTE:END ************************************************/
|
||||
void dispatchFunction(Node *n) {
|
||||
//REPORT("dispatchFunction", n);
|
||||
/* Last node in overloaded chain */
|
||||
|
||||
int maxargs;
|
||||
|
|
@ -811,7 +824,7 @@ public:
|
|||
Printf(protoTypes, "\n\" %s\\n\"", fulldecl);
|
||||
Delete(fulldecl);
|
||||
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
|
||||
Printf(f->code, "lua_pushstring(L,\"Wrong arguments for overloaded function '%s'\\n\"\n"
|
||||
Printf(f->code, "SWIG_Lua_pusherrstring(L,\"Wrong arguments for overloaded function '%s'\\n\"\n"
|
||||
"\" Possible C/C++ prototypes are:\\n\"%s);\n",symname,protoTypes);
|
||||
Delete(protoTypes);
|
||||
|
||||
|
|
@ -822,10 +835,14 @@ public:
|
|||
if (current==NO_CPP || current==STATIC_FUNC) // emit normal fns & static fns
|
||||
Printv(s_cmd_tab, tab4, "{ \"", symname, "\",", wname, "},\n", NIL);
|
||||
|
||||
if (getCurrentClass())
|
||||
Setattr(n,"luaclassobj:wrap:name", wname);
|
||||
else
|
||||
Delete(wname);
|
||||
|
||||
DelWrapper(f);
|
||||
Delete(dispatch);
|
||||
Delete(tmp);
|
||||
Delete(wname);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -878,8 +895,13 @@ public:
|
|||
} else {
|
||||
Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName);
|
||||
}
|
||||
Delete(getName);
|
||||
Delete(setName);
|
||||
if (getCurrentClass()) {
|
||||
Setattr(n, "luaclassobj:wrap:get", getName);
|
||||
Setattr(n, "luaclassobj:wrap:set", setName);
|
||||
} else {
|
||||
Delete(getName);
|
||||
Delete(setName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -887,7 +909,7 @@ public:
|
|||
* constantWrapper()
|
||||
* ------------------------------------------------------------ */
|
||||
virtual int constantWrapper(Node *n) {
|
||||
// REPORT("constantWrapper", n);
|
||||
REPORT("constantWrapper", n);
|
||||
String *name = Getattr(n, "name");
|
||||
String *iname = Getattr(n, "sym:name");
|
||||
String *nsname = Copy(iname);
|
||||
|
|
@ -923,6 +945,20 @@ public:
|
|||
Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n");
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
if (cparse_cplusplus && getCurrentClass()) {
|
||||
// Additionally add to class constants
|
||||
Swig_require("luaclassobj_constantWrapper", n, "*sym:name", "luaclassobj:symname", NIL);
|
||||
Setattr(n, "sym:name", Getattr(n, "luaclassobj:symname"));
|
||||
String *cls_nsname = Getattr(n, "sym:name");
|
||||
if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) {
|
||||
Replaceall(tm, "$source", value);
|
||||
Replaceall(tm, "$target", name);
|
||||
Replaceall(tm, "$value", value);
|
||||
Replaceall(tm, "$nsname", cls_nsname);
|
||||
Printf(s_cls_const_tab, " %s,\n", tm);
|
||||
}
|
||||
Swig_restore(n);
|
||||
}
|
||||
Delete(nsname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1009,6 +1045,19 @@ public:
|
|||
Printf(s_methods_tab, "static swig_lua_method swig_");
|
||||
Printv(s_methods_tab, mangled_classname, "_methods[] = {\n", NIL);
|
||||
|
||||
s_cls_methods_tab = NewString("");
|
||||
Printf(s_cls_methods_tab, "static swig_lua_method swig_");
|
||||
Printv(s_cls_methods_tab, mangled_classname, "_cls_methods[] = {\n", NIL);
|
||||
|
||||
s_cls_attr_tab = NewString("");
|
||||
Printf(s_cls_attr_tab, "static swig_lua_attribute swig_");
|
||||
Printv(s_cls_attr_tab, mangled_classname, "_cls_attributes[] = {\n", NIL);
|
||||
|
||||
s_cls_const_tab = NewString("");
|
||||
Printf(s_cls_const_tab, "static swig_lua_const_info swig_");
|
||||
Printv(s_cls_const_tab, mangled_classname, "_cls_constants[] = {\n", NIL);
|
||||
|
||||
|
||||
// Generate normal wrappers
|
||||
Language::classHandler(n);
|
||||
|
||||
|
|
@ -1047,8 +1096,21 @@ public:
|
|||
Printf(s_attr_tab, " {0,0,0}\n};\n");
|
||||
Printv(f_wrappers, s_attr_tab, NIL);
|
||||
|
||||
Printf(s_cls_attr_tab, " {0,0,0}\n};\n");
|
||||
Printv(f_wrappers, s_cls_attr_tab, NIL);
|
||||
|
||||
Printf(s_cls_methods_tab, " {0,0}\n};\n");
|
||||
Printv(f_wrappers, s_cls_methods_tab, NIL);
|
||||
|
||||
Printf(s_cls_const_tab, " {0,0,0,0,0,0}\n};\n");
|
||||
Printv(f_wrappers, s_cls_const_tab, NIL);
|
||||
|
||||
|
||||
Delete(s_methods_tab);
|
||||
Delete(s_attr_tab);
|
||||
Delete(s_cls_methods_tab);
|
||||
Delete(s_cls_attr_tab);
|
||||
Delete(s_cls_const_tab);
|
||||
|
||||
// Handle inheritance
|
||||
// note: with the idea of class hierarchies spread over multiple modules
|
||||
|
|
@ -1122,7 +1184,10 @@ public:
|
|||
} else {
|
||||
Printf(f_wrappers, ",0");
|
||||
}
|
||||
Printf(f_wrappers, ", swig_%s_methods, swig_%s_attributes, swig_%s_bases, swig_%s_base_names };\n\n", mangled_classname, mangled_classname, mangled_classname, mangled_classname);
|
||||
Printf(f_wrappers, ", swig_%s_methods, swig_%s_attributes, { \"%s\", swig_%s_cls_methods, swig_%s_cls_attributes, swig_%s_cls_constants }, swig_%s_bases, swig_%s_base_names };\n\n",
|
||||
mangled_classname, mangled_classname,
|
||||
class_name, mangled_classname, mangled_classname, mangled_classname,
|
||||
mangled_classname, mangled_classname);
|
||||
|
||||
// Printv(f_wrappers, ", swig_", mangled_classname, "_methods, swig_", mangled_classname, "_attributes, swig_", mangled_classname, "_bases };\n\n", NIL);
|
||||
// Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", class_name, "\", (swig_wrapper_func) SWIG_ObjectConstructor, &_wrap_class_", mangled_classname, "},\n", NIL);
|
||||
|
|
@ -1232,8 +1297,30 @@ public:
|
|||
* ---------------------------------------------------------------------- */
|
||||
|
||||
virtual int staticmemberfunctionHandler(Node *n) {
|
||||
REPORT("staticmemberfunctionHandler", n);
|
||||
current = STATIC_FUNC;
|
||||
return Language::staticmemberfunctionHandler(n);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
int result = Language::staticmemberfunctionHandler(n);
|
||||
|
||||
if (cparse_cplusplus && getCurrentClass()) {
|
||||
Swig_restore(n);
|
||||
}
|
||||
current = NO_CPP;
|
||||
if (result != SWIG_OK)
|
||||
return result;
|
||||
|
||||
if (Getattr(n, "sym:nextSibling"))
|
||||
return SWIG_OK;
|
||||
|
||||
Swig_require("luaclassobj_staticmemberfunctionHandler", n, "luaclassobj:wrap:name", NIL);
|
||||
String *name = Getattr(n, "name");
|
||||
String *rname, *realname;
|
||||
realname = symname ? symname : name;
|
||||
rname = Getattr(n, "luaclassobj:wrap:name");
|
||||
Printv(s_cls_methods_tab, tab4, "{\"", realname, "\", ", rname, "}, \n", NIL);
|
||||
Swig_restore(n);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
|
|
@ -1243,8 +1330,17 @@ public:
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual int memberconstantHandler(Node *n) {
|
||||
// REPORT("memberconstantHandler",n);
|
||||
return Language::memberconstantHandler(n);
|
||||
REPORT("memberconstantHandler",n);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
if (cparse_cplusplus && getCurrentClass()) {
|
||||
Swig_save("luaclassobj_memberconstantHandler", n, "luaclassobj:symname", NIL);
|
||||
Setattr(n, "luaclassobj:symname", symname);
|
||||
}
|
||||
int result = Language::memberconstantHandler(n);
|
||||
if (cparse_cplusplus && getCurrentClass())
|
||||
Swig_restore(n);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
|
|
@ -1252,9 +1348,22 @@ public:
|
|||
* --------------------------------------------------------------------- */
|
||||
|
||||
virtual int staticmembervariableHandler(Node *n) {
|
||||
// REPORT("staticmembervariableHandler",n);
|
||||
REPORT("staticmembervariableHandler",n);
|
||||
current = STATIC_VAR;
|
||||
return Language::staticmembervariableHandler(n);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
int result = Language::staticmembervariableHandler(n);
|
||||
|
||||
if (result != SWIG_OK)
|
||||
return result;
|
||||
|
||||
|
||||
if (Getattr(n, "wrappedasconstant"))
|
||||
return SWIG_OK;
|
||||
|
||||
Swig_require("luaclassobj_staticmembervariableHandler", n, "luaclassobj:wrap:get", "luaclassobj:wrap:set", NIL);
|
||||
Printf(s_cls_attr_tab,"%s{ \"%s\", %s, %s},\n",tab4,symname,Getattr(n,"luaclassobj:wrap:get"), Getattr(n,"luaclassobj:wrap:set"));
|
||||
Swig_restore(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1503,7 +1503,7 @@ public:
|
|||
/* if necessary, cast away const since Python doesn't support it! */
|
||||
if (SwigType_isconst(nptype)) {
|
||||
nonconst = NewStringf("nc_tmp_%s", pname);
|
||||
String *nonconst_i = NewStringf("= const_cast<%s>(%s)", SwigType_lstr(ptype, 0), ppname);
|
||||
String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(ptype, 0), ppname);
|
||||
Wrapper_add_localv(w, nonconst, SwigType_lstr(ptype, 0), nonconst, nonconst_i, NIL);
|
||||
Delete(nonconst_i);
|
||||
Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number,
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ public:
|
|||
String *escaped_doc_str = texinfo_escape(doc_str);
|
||||
|
||||
if (Len(doc_str)>0) {
|
||||
Printf(f_doc,"const char* %s_texinfo = ",wrap_name);
|
||||
Printf(f_doc,"static const char* %s_texinfo = ",wrap_name);
|
||||
Printf(f_doc,"\"-*- texinfo -*-\\n\\\n%s", escaped_doc_str);
|
||||
if (Len(decl_info))
|
||||
Printf(f_doc,"\\n\\\n@end deftypefn");
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ struct Overloaded {
|
|||
int argc; /* Argument count */
|
||||
ParmList *parms; /* Parameters used for overload check */
|
||||
int error; /* Ambiguity error */
|
||||
bool implicitconv_function; /* For ordering implicitconv functions*/
|
||||
};
|
||||
|
||||
static int fast_dispatch_mode = 0;
|
||||
|
|
@ -40,6 +41,32 @@ void Wrapper_cast_dispatch_mode_set(int flag) {
|
|||
cast_dispatch_mode = flag;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* mark_implicitconv_function()
|
||||
*
|
||||
* Mark function if it contains an implicitconv type in the parameter list
|
||||
* ----------------------------------------------------------------------------- */
|
||||
static void mark_implicitconv_function(Overloaded& onode) {
|
||||
Parm *parms = onode.parms;
|
||||
if (parms) {
|
||||
bool is_implicitconv_function = false;
|
||||
Parm *p = parms;
|
||||
while (p) {
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
if (GetFlag(p, "implicitconv")) {
|
||||
is_implicitconv_function = true;
|
||||
break;
|
||||
}
|
||||
p = nextSibling(p);
|
||||
}
|
||||
if (is_implicitconv_function)
|
||||
onode.implicitconv_function = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_overload_rank()
|
||||
*
|
||||
|
|
@ -85,6 +112,9 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
nodes[nnodes].parms = Getattr(c, "wrap:parms");
|
||||
nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms);
|
||||
nodes[nnodes].error = 0;
|
||||
nodes[nnodes].implicitconv_function = false;
|
||||
|
||||
mark_implicitconv_function(nodes[nnodes]);
|
||||
nnodes++;
|
||||
}
|
||||
c = Getattr(c, "sym:nextSibling");
|
||||
|
|
@ -287,12 +317,30 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
List *result = NewList();
|
||||
{
|
||||
int i;
|
||||
int argc_changed_index = -1;
|
||||
for (i = 0; i < nnodes; i++) {
|
||||
if (nodes[i].error)
|
||||
Setattr(nodes[i].n, "overload:ignore", "1");
|
||||
Append(result, nodes[i].n);
|
||||
// Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms));
|
||||
// Swig_print_node(nodes[i].n);
|
||||
// Printf(stdout,"[ %d ] %d %s\n", i, nodes[i].implicitconv_function, ParmList_errorstr(nodes[i].parms));
|
||||
// Swig_print_node(nodes[i].n);
|
||||
if (i == nnodes-1 || nodes[i].argc != nodes[i+1].argc) {
|
||||
if (argc_changed_index+2 < nnodes && (nodes[argc_changed_index+1].argc == nodes[argc_changed_index+2].argc)) {
|
||||
// Add additional implicitconv functions in same order as already ranked.
|
||||
// Consider overloaded functions by argument count... only add additional implicitconv functions if
|
||||
// the number of functions with the same arg count > 1, ie, only if overloaded by same argument count.
|
||||
int j;
|
||||
for (j = argc_changed_index + 1; j <= i; j++) {
|
||||
if (nodes[j].implicitconv_function) {
|
||||
SetFlag(nodes[j].n, "implicitconvtypecheckoff");
|
||||
Append(result, nodes[j].n);
|
||||
// Printf(stdout,"[ %d ] %d + %s\n", j, nodes[j].implicitconv_function, ParmList_errorstr(nodes[j].parms));
|
||||
// Swig_print_node(nodes[j].n);
|
||||
}
|
||||
}
|
||||
}
|
||||
argc_changed_index = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
@ -302,20 +350,22 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
// * print_typecheck()
|
||||
// * ----------------------------------------------------------------------------- */
|
||||
|
||||
static bool print_typecheck(String *f, int j, Parm *pj) {
|
||||
static bool print_typecheck(String *f, int j, Parm *pj, bool implicitconvtypecheckoff) {
|
||||
char tmp[256];
|
||||
sprintf(tmp, Char(argv_template_string), j);
|
||||
String *tm = Getattr(pj, "tmap:typecheck");
|
||||
if (tm) {
|
||||
tm = Copy(tm);
|
||||
Replaceid(tm, Getattr(pj, "lname"), "_v");
|
||||
String *conv = Getattr(pj, "implicitconv");
|
||||
if (conv) {
|
||||
if (conv && !implicitconvtypecheckoff) {
|
||||
Replaceall(tm, "$implicitconv", conv);
|
||||
} else {
|
||||
Replaceall(tm, "$implicitconv", "0");
|
||||
}
|
||||
Replaceall(tm, "$input", tmp);
|
||||
Printv(f, tm, "\n", NIL);
|
||||
Delete(tm);
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
|
|
@ -715,6 +765,7 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
|
|||
for (i = 0; i < nfunc; i++) {
|
||||
Node *ni = Getitem(dispatch, i);
|
||||
Parm *pi = Getattr(ni, "wrap:parms");
|
||||
bool implicitconvtypecheckoff = GetFlag(ni, "implicitconvtypecheckoff") != 0;
|
||||
int num_required = emit_num_required(pi);
|
||||
int num_arguments = emit_num_arguments(pi);
|
||||
if (GetFlag(n, "wrap:this")) {
|
||||
|
|
@ -749,7 +800,7 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
|
|||
Printf(f, "}\n");
|
||||
Delete(lfmt);
|
||||
}
|
||||
if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj)) {
|
||||
if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj, implicitconvtypecheckoff)) {
|
||||
Printf(f, "if (_v) {\n");
|
||||
num_braces++;
|
||||
}
|
||||
|
|
@ -773,6 +824,8 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
|
|||
for ( /* empty */ ; num_braces > 0; num_braces--)
|
||||
Printf(f, "}\n");
|
||||
Printf(f, "}\n"); /* braces closes "if" for this method */
|
||||
if (implicitconvtypecheckoff)
|
||||
Delattr(ni, "implicitconvtypecheckoff");
|
||||
}
|
||||
Delete(dispatch);
|
||||
return f;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ static File *f_directors_h = 0;
|
|||
static File *f_init = 0;
|
||||
static File *f_shadow_py = 0;
|
||||
static String *f_shadow = 0;
|
||||
static String *f_shadow_begin = 0;
|
||||
static Hash *f_shadow_imports = 0;
|
||||
static String *f_shadow_builtin_imports = 0;
|
||||
static String *f_shadow_stubs = 0;
|
||||
|
|
@ -784,6 +785,7 @@ public:
|
|||
filen = NULL;
|
||||
|
||||
f_shadow = NewString("");
|
||||
f_shadow_begin = NewString("");
|
||||
f_shadow_imports = NewHash();
|
||||
f_shadow_builtin_imports = NewString("");
|
||||
f_shadow_stubs = NewString("");
|
||||
|
|
@ -977,6 +979,7 @@ public:
|
|||
if (!modern) {
|
||||
Printv(f_shadow, "# This file is compatible with both classic and new-style classes.\n", NIL);
|
||||
}
|
||||
Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL);
|
||||
Printv(f_shadow_py, "\n", f_shadow_builtin_imports, "\n", NIL);
|
||||
Printv(f_shadow_py, f_shadow, "\n", NIL);
|
||||
Printv(f_shadow_py, f_shadow_stubs, "\n", NIL);
|
||||
|
|
@ -3398,7 +3401,7 @@ public:
|
|||
printSlot(f, getSlot(n, "feature:python:tp_dict"), "tp_dict");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_descr_get"), "tp_descr_get", "descrgetfunc");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_descr_set"), "tp_descr_set", "descrsetfunc");
|
||||
Printf(f, " (size_t)(((char*)&((SwigPyObject *) 64L)->dict) - (char*) 64L), /* tp_dictoffset */\n");
|
||||
Printf(f, " (Py_ssize_t)offsetof(SwigPyObject, dict), /* tp_dictoffset */\n");
|
||||
printSlot(f, tp_init, "tp_init", "initproc");
|
||||
printSlot(f, getSlot(n, "feature:python:tp_alloc"), "tp_alloc", "allocfunc");
|
||||
printSlot(f, "0", "tp_new", "newfunc");
|
||||
|
|
@ -4451,12 +4454,16 @@ public:
|
|||
String *code = Getattr(n, "code");
|
||||
String *section = Getattr(n, "section");
|
||||
|
||||
if ((!ImportMode) && ((Cmp(section, "python") == 0) || (Cmp(section, "shadow") == 0))) {
|
||||
if (!ImportMode && (Cmp(section, "python") == 0 || Cmp(section, "shadow") == 0)) {
|
||||
if (shadow) {
|
||||
String *pycode = pythoncode(code, shadow_indent);
|
||||
Printv(f_shadow, pycode, NIL);
|
||||
Delete(pycode);
|
||||
}
|
||||
} else if (!ImportMode && (Cmp(section, "pythonbegin") == 0)) {
|
||||
String *pycode = pythoncode(code, "");
|
||||
Printv(f_shadow_begin, pycode, NIL);
|
||||
Delete(pycode);
|
||||
} else {
|
||||
Language::insertDirective(n);
|
||||
}
|
||||
|
|
@ -4724,7 +4731,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
|||
/* if necessary, cast away const since Python doesn't support it! */
|
||||
if (SwigType_isconst(nptype)) {
|
||||
nonconst = NewStringf("nc_tmp_%s", pname);
|
||||
String *nonconst_i = NewStringf("= const_cast<%s>(%s)", SwigType_lstr(ptype, 0), ppname);
|
||||
String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(ptype, 0), ppname);
|
||||
Wrapper_add_localv(w, nonconst, SwigType_lstr(ptype, 0), nonconst, nonconst_i, NIL);
|
||||
Delete(nonconst_i);
|
||||
Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number,
|
||||
|
|
|
|||
|
|
@ -3201,7 +3201,7 @@ public:
|
|||
/* if necessary, cast away const since Ruby doesn't support it! */
|
||||
if (SwigType_isconst(nptype)) {
|
||||
nonconst = NewStringf("nc_tmp_%s", parameterName);
|
||||
String *nonconst_i = NewStringf("= const_cast<%s>(%s)", SwigType_lstr(parameterType, 0), ppname);
|
||||
String *nonconst_i = NewStringf("= const_cast< %s >(%s)", SwigType_lstr(parameterType, 0), ppname);
|
||||
Wrapper_add_localv(w, nonconst, SwigType_lstr(parameterType, 0), nonconst, nonconst_i, NIL);
|
||||
Delete(nonconst_i);
|
||||
Swig_warning(WARN_LANG_DISCARD_CONST, input_file, line_number,
|
||||
|
|
|
|||
|
|
@ -163,7 +163,8 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_
|
|||
String *filename;
|
||||
List *spath = 0;
|
||||
char *cname;
|
||||
int i, ilen;
|
||||
int i, ilen, nbytes;
|
||||
char bom[3];
|
||||
|
||||
if (!directories)
|
||||
directories = NewList();
|
||||
|
|
@ -191,6 +192,14 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_
|
|||
if (f) {
|
||||
Delete(lastpath);
|
||||
lastpath = filename;
|
||||
|
||||
/* Skip the UTF-8 BOM if it's present */
|
||||
nbytes = fread(bom, 1, 3, f);
|
||||
if (nbytes == 3 && bom[0] == (char)0xEF && bom[1] == (char)0xBB && bom[2] == (char)0xBF) {
|
||||
/* skip */
|
||||
} else {
|
||||
fseek(f, 0, SEEK_SET);
|
||||
}
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,8 +205,8 @@ String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_filename_correct()
|
||||
*
|
||||
* Corrects filename paths by removing duplicate delimeters and on non-unix
|
||||
* systems use the correct delimeter across the whole name.
|
||||
* Corrects filename paths by removing duplicate delimiters and on non-unix
|
||||
* systems use the correct delimiter across the whole name.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_filename_correct(String *filename) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue