-The table below has a few examples showing the resulting proxy and interface names.
+The table below has a few examples showing the resulting proxy and interface names for a C++ class called Base.
diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
index c7769dc97..fb5f67c06 100644
--- a/Doc/Manual/Makefile
+++ b/Doc/Manual/Makefile
@@ -41,6 +41,7 @@ check:
# 3) elements do not always select a fixed-width font - try installing the
# Courier font to fix - these have been added to style.css.
generate: SWIGDocumentation.html
+ wkhtmltopdf --version | grep "with patched qt" || (echo "wkhtmltopdf is not the patched qt version and so cannot be used - download it from http://wkhtmltopdf.org/downloads.html" && false)
wkhtmltopdf --margin-top 20mm --margin-bottom 20mm --margin-left 10mm --margin-right 10mm --header-font-size 6 --footer-font-size 6 --header-spacing 6 --footer-spacing 6 --header-center '[doctitle]' --footer-left '[subsection]' --footer-right '[page]' SWIGDocumentation.html SWIGDocumentation.pdf
SWIGDocumentation.html: swightml.book
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index 099d406bf..cf0f86024 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -51,7 +51,7 @@
Built-in Types
Memory management
Python 2.2 and classic classes
@@ -116,6 +116,14 @@
Absolute and relative imports
Enforcing absolute import semantics
Importing from __init__.py
+Implicit Namespace Packages
+Searching for the wrapper module
+
Python 3 Support
@@ -2434,7 +2442,7 @@ assert(issubclass(B.Derived, A.Base))
-
+
The entire justification for the -builtin option is improved
@@ -2486,52 +2494,110 @@ automatically converted to python slot operators, refer to the file
python/pyopers.swig in the SWIG library.
-There are other very useful python slots that you
-may explicitly define using %feature directives. For example,
-suppose you want to use instances of a wrapped class as keys in a native python
-dict. That will work as long as you define a hash function for
-instances of your class, and use it to define the python tp_hash
-slot:
+
+
+Read about all of the available python slots here:
+http://docs.python.org/c-api/typeobj.html
+
+
+There are two ways to define a python slot function: dispatch to a
+statically defined function; or dispatch to a method defined on the
+operand.
+
+
+
+To dispatch to a statically defined function, use %feature("python:<slot>"),
+where <slot> is the name of a field in a PyTypeObject, PyNumberMethods,
+PyMappingMethods, PySequenceMethods or PyBufferProcs.
+You may override (almost) all of these slots.
+
+
+
+
+Let's consider an example setting the tp_hash slot for the MyClass type.
+This is akin to providing a __hash__ method (for non-builtin types) to make a type hashable.
+The hashable type can then for example be added to a Python dict.
-%feature("python:slot", "tp_hash", functype="hashfunc") Cheese::cheeseHashFunc;
+%feature("python:tp_hash") MyClass "myHashFunc";
-class Cheese {
+class MyClass {
public:
- Cheese (const char *name);
- long cheeseHashFunc () const;
+ long field1;
+ long field2;
+ ...
+};
+
+%{
+#if PY_VERSION_HEX >= 0x03020000
+ static Py_hash_t myHashFunc(PyObject *pyobj)
+#else
+ static long myHashFunc(PyObject *pyobj)
+#endif
+ {
+ MyClass *cobj;
+ // Convert pyobj to cobj
+ return (cobj->field1 * (cobj->field2 << 7));
+ }
+%}
+
+
+
+
+If you examine the generated code, the supplied hash function will now be
+the function callback in the tp_hash slot for the builtin type for MyClass:
+
+
+
+
+static PyHeapTypeObject SwigPyBuiltin__MyClass_type = {
+ ...
+ (hashfunc) myHashFunc, /* tp_hash */
+ ...
+
+
+
+
+NOTE: It is the responsibility of the programmer (that's you!) to ensure
+that a statically defined slot function has the correct signature, the hashfunc
+typedef in this case.
+
+
+
+If, instead, you want to dispatch to an instance method, you can
+use %feature("python:slot"). For example:
+
+
+
+
+%feature("python:slot", "tp_hash", functype="hashfunc") MyClass::myHashFunc;
+
+#if PY_VERSION_HEX < 0x03020000
+ #define Py_hash_t long
+#endif
+
+class MyClass {
+ public:
+ Py_hash_t myHashFunc() const;
+ ...
};
-This will allow you to write python code like this:
+
+NOTE: Some python slots use a method signature which does not
+match the signature of SWIG-wrapped methods. For those slots,
+SWIG will automatically generate a "closure" function to re-marshal
+the arguments before dispatching to the wrapped method. Setting
+the "functype" attribute of the feature enables SWIG to generate
+the chosen closure function.
+
-
-
-from my MyPackage import Cheese
-
-inventory = {
- Cheese("cheddar") : 0,
- Cheese("gouda") : 0,
- Cheese("camembert") : 0
-}
-
-
-
-Because you defined the tp_hash slot, Cheese objects may
-be used as hash keys; and when the cheeseHashFunc method is invoked
-by a python dict, it will not go through named method dispatch.
-A more detailed discussion about %feature("python:slot") can be found
+
+There is further information on %feature("python:slot")
in the file python/pyopers.swig in the SWIG library.
-You can read about all of the available python slots here:
-
-http://docs.python.org/c-api/typeobj.html
-
-You may override (almost) all of the slots defined in the PyTypeObject,
-PyNumberMethods, PyMappingMethods, PySequenceMethods, and PyBufferProcs
-structs.
@@ -4186,7 +4252,7 @@ also be used to extra binary data from arbitrary pointers.
C++ default argument code generation is documented in the main
-Default arguments section.
+Default arguments section.
There is also an optional Python specific feature that can be used called the python:cdefaultargs
feature flag.
By default, SWIG attempts to convert C++ default argument values
@@ -4891,23 +4957,23 @@ A typemap can be used to handle this case as follows :
// is guaranteed to be a List object by SWIG.
%typemap(argout) double *OutValue {
- PyObject *o, *o2, *o3;
- o = PyFloat_FromDouble(*$1);
- if ((!$result) || ($result == Py_None)) {
- $result = o;
- } else {
- if (!PyTuple_Check($result)) {
- PyObject *o2 = $result;
- $result = PyTuple_New(1);
- PyTuple_SetItem(target,0,o2);
- }
- o3 = PyTuple_New(1);
- PyTuple_SetItem(o3,0,o);
- o2 = $result;
- $result = PySequence_Concat(o2,o3);
- Py_DECREF(o2);
- Py_DECREF(o3);
+ PyObject *o, *o2, *o3;
+ o = PyFloat_FromDouble(*$1);
+ if ((!$result) || ($result == Py_None)) {
+ $result = o;
+ } else {
+ if (!PyTuple_Check($result)) {
+ PyObject *o2 = $result;
+ $result = PyTuple_New(1);
+ PyTuple_SetItem($result,0,o2);
}
+ o3 = PyTuple_New(1);
+ PyTuple_SetItem(o3,0,o);
+ o2 = $result;
+ $result = PySequence_Concat(o2,o3);
+ Py_DECREF(o2);
+ Py_DECREF(o3);
+ }
}
int spam(double a, double b, double *OutValue, double *OutValue);
@@ -5520,6 +5586,23 @@ They should be created by other means. Both files (module *.py and
directories in order to obtain a desirable package/module hierarchy.
+
+Python3 adds another option for packages with
+PEP 0420 (implicit
+namespace packages). Implicit namespace packages no longer use
+__init__.py files. SWIG generated Python modules support implicit
+namespace packages. See
+36.11.5 Implicit Namespace
+Packages for more information.
+
+
+
+If you place a SWIG generated module into a Python package then there
+are details concerning the way SWIG
+searches for the wrapper module
+that you may want to familiarize yourself with.
+
+
The way Python defines its modules and packages impacts SWIG users. Some
users may need to use special features such as the package option in the
%module directive or import related command line options. These are
@@ -5679,8 +5762,9 @@ class M2(pkg2.mod3.M3): pass
By default, SWIG would generate mod2.py proxy file with
import directive as in point 1. This can be changed with the
-relativeimport command line option. The -relativeimport instructs
-SWIG to organize imports as in point 2 (for Python 2.x) or as in point 4 (for
-Python 3, that is when the -py3 command line option is enabled). In short, if you have
+SWIG to organize imports as in point 2 (for Python < 2.7.0) or as in point 4
+for Python 2.7.0 and newer. This is a check done at the time the module is
+imported. In short, if you have
mod2.i and mod3.i as above, then without
-relativeimport SWIG will write
@@ -5694,22 +5778,17 @@ import pkg1.pkg2.mod3
write
-
-import pkg2.mod3
+
+from sys import version_info
+if version_info >= (2, 7, 0):
+ from . import pkg2
+ import pkg1.pkg2.mod3
+else:
+ import pkg2.mod3
+del version_info
-if -py3 is not used, or
-
-
-
-from . import pkg2
-import pkg1.pkg2.mod3
-
-
-
-when -py3 is used.
-
You should avoid using relative imports and use absolute ones whenever
possible. There are some cases, however, when relative imports may be
necessary. The first example is, when some (legacy) Python code refers entities
@@ -5865,6 +5944,257 @@ class Bar(pkg3.foo.Foo): pass
effect (note, that the Python 2 case also needs the -relativeimport
workaround).
+
+
+
+ Python 3.3 introduced
+PEP 0420 which
+implements implicit namespace packages. In a nutshell, implicit namespace
+packages remove the requirement of an __init__.py file and allow packages
+to be split across multiple PATH elements. For example:
+
+
+
+
+/fragment1/pkg1/mod1.py
+/fragment2/pkg1/mod2.py
+/fragment3/pkg1/mod3.py
+
+
+
+If PYTHONPATH is set to "/fragment1:/fragment2:/fragment3", then mod1, mod2
+and mod3 will be part of pkg1. This allows for splitting of packages into
+separate pieces. This can be useful for SWIG generated wrappers in the
+following way.
+
+
+ Suppose you create a SWIG wrapper for a module called robin. The SWIG
+generated code consists of two files robin.py and _robin.so. You wish to
+make these modules part of a subpackage (brave.sir). With implicit namespace
+packages you can place these files in the following configurations:
+
+
+Using PYTHONPATH="/some/path"
+
+
+/some/path/brave/sir/robin.py
+/some/path/brave/sir/_robin.so
+
+
+
+Using PYTHONPATH="/some/path:/some/other/path"
+
+
+
+/some/path/brave/sir/robin.py
+/some/other/path/brave/sir/_robin.so
+
+
+
+ Finally suppose that your pure python code is stored in a .zip file or
+some other way (database, web service connection, etc). Python can load the
+robin.py module using a custom importer. But the _robin.so module will need
+to be located on a file system. Implicit namespace packages make this
+possible. For example, using PYTHONPATH="/some/path/foo.zip:/some/other/path"
+
+
Contents of foo.zip
+
+
+brave/
+brave/sir/
+brave/sir/robin.py
+
+
+
+ File system contents
+
+
+/some/other/path/brave/sir/_robin.so
+
+
+
+Support for implicit namespace packages was added to python-3.3. The
+zipimporter requires python-3.5.1 or newer to work with subpackages.
+
+
+
+Compatibility Note: Support for implicit namespace packages was added in SWIG-3.0.9.
+
+
+
+
+
+
+
+When SWIG creates wrappers from an interface file, say foo.i, two Python modules are
+created. There is a pure Python module module (foo.py) and C/C++ code which is
+built and linked into a dynamically (or statically) loaded module _foo
+(see the Preliminaries section for details). So, the interface
+file really defines two Python modules. How these two modules are loaded is
+covered next.
+
+
+
+The pure Python module needs to load the C/C++ module in order to link
+to the wrapped C/C++ methods. To do this it must make some assumptions
+about what package the C/C++ module may be located in. The approach the
+pure Python module uses to find the C/C++ module is as follows:
+
+
+
+ The pure Python module, foo.py, tries to load the C/C++ module, _foo, from the same package foo.py is
+ located in. The package name is determined from the __name__
+ attribute given to foo.py by the Python loader that imported
+ foo.py. If foo.py is not in a package then _foo is loaded
+ as a global module.
+
+ If the above import of _foo results in an ImportError
+ being thrown, then foo.py makes a final attempt to load _foo
+ as a global module.
+
+
+
+
+As an example suppose foo.i is compiled into foo.py and _foo.so. Assuming
+/dir is on PYTHONPATH, then the two modules can be installed and used in the
+following ways:
+
+
+
+
+
+
+Both modules are in one package:
+
+
+/dir/package/foo.py
+/dir/package/__init__.py
+/dir/package/_foo.so
+
+
+And imported with
+
+
+from package import foo
+
+
+
+
+
+
+
+The pure python module is in a package and the C/C++ module is global:
+
+
+/dir/package/foo.py
+/dir/package/__init__.py
+/dir/_foo.so
+
+
+And imported with
+
+
+from package import foo
+
+
+
+
+
+
+
+Both modules are global:
+
+
+/dir/foo.py
+/dir/_foo.so
+
+
+And imported with
+
+
+
+If _foo is statically linked into an embedded Python interpreter, then it may or
+may not be in a Python package. This depends in the exact way the module was
+loaded statically. The above search order will still be used for statically
+loaded modules. So, one may place the module either globally or in a package
+as desired.
+
+
+
+
+
+It is strongly recommended to use dynamically linked modules for the C
+portion of your pair of Python modules.
+If for some reason you still need
+to link the C module of the pair of Python modules generated by SWIG into
+your interpreter, then this section provides some details on how this impacts
+the pure Python modules ability to locate the other part of the pair.
+Please also see the Static Linking section.
+
+
+When Python is extended with C code the Python interpreter needs to be
+informed about details of the new C functions that have been linked into
+the executable. The code to do this is created by SWIG and is automatically
+called in the correct way when the module is dynamically loaded. However
+when the code is not dynamically loaded (because it is statically linked)
+Then the initialization method for the module created by SWIG is not
+called automatically and the Python interpreter has no idea that the
+new SWIG C module exists.
+
+
+Before Python 3, one could simply call the init method created by SWIG
+which would have normally been called when the shared object was dynamically
+loaded. The specific name of this method is not given here because statically
+linked modules are not encouraged with SWIG
+(Static Linking). However one can find this
+init function in the C file generated by SWIG.
+
+
+If you are really keen on static linking there are two ways
+to initialize the SWIG generated C module with the init method. Which way
+you use depends on what version of Python your module is being linked with.
+Python 2 and Python 3 treat this init function differently. And the way
+they treat it affects how the pure Python module will be able to
+locate the C module.
+
+
+The details concerning this are covered completly in the documentation
+for Python itself. Links to the relavent sections follow:
+
+
+
+
+There are two keys things to understand. The first is that in
+Python 2 the init() function returns void. In Python 3 the init() function
+returns a PyObject * which points to the new module. Secondly, when
+you call the init() method manually, you are the Python importer. So, you
+determine which package the C module will be located in.
+
+
+So, if you are using Python 3 it is important that you follow what is
+described in the Python documentation linked above. In particular, you can't
+simply call the init() function generated by SWIG and cast the PyObject
+pointer it returns over the side. If you do then Python 3 will have no
+idea that your C module exists and the pure Python half of your wrapper will
+not be able to find it. You need to register your module with the Python
+interpreter as described in the Python docs.
+
+
+With Python 2 things are somewhat more simple. In this case the init function
+returns void. Calling it will register your new C module as a global
+module. The pure Python part of the SWIG wrapper will be able to find it
+because it tries both the pure Python module it is part of and the global
+module. If you wish not to have the statically linked module be a global
+module then you will either need to refer to the Python documentation on how
+to do this (remember you are now the Python importer) or use dynamic linking.
+
diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html
index aa4a3e99f..0eaa61423 100644
--- a/Doc/Manual/Scilab.html
+++ b/Doc/Manual/Scilab.html
@@ -40,12 +40,12 @@
Pointers
Structures
C++ classes
C++ inheritance
-C++ overloading
+C++ overloading
Pointers, references, values, and arrays
C++ templates
C++ operators
@@ -56,7 +56,6 @@
Type mappings and libraries
- Default primitive type mappings
-
- Default type mappings for non-primitive types
- Arrays
- Pointer-to-pointers
- Matrices
@@ -764,11 +763,11 @@ Why a native pointer is not mapped to a Scilab pointer (type name: "pointer", ty
Notes:
+
- type tracking needs the SWIG runtime to be first initialized with the appropriate function (see the Module initialization section).
- for any reason, if a wrapped pointer type is unknown (or if the SWIG runtime is not initialized), SWIG maps it to a Scilab pointer. Also, a Scilab pointer is always accepted as a pointer argument of a wrapped function. The drawaback is that pointer type is lost.
-
Following is an example of the wrapping of the C FILE* pointer:
@@ -854,6 +853,7 @@ ans =
+
Using the previous SWIG_this() and SWIG_ptr(), it is possible to create and check null pointers:
@@ -904,6 +904,7 @@ Several functions are generated:
+
Usage example:
@@ -963,7 +964,7 @@ ans =
Note: the pointer to the struct works as described in Pointers. For example, the type of the struct pointer can be get with typeof, as following:
-
+
--> example_Init();
@@ -1027,7 +1028,7 @@ ans =
Note: like structs, class pointers are mapped as described in Pointers. Let's give an example which shows that each class pointer type is a new type in Scilab that can be used for example (through overloading) to implement a custom print for the Point class:
-
+
--> function %_p_Point_p(p)
@@ -1120,27 +1121,26 @@ But we can use either use the get_perimeter() function of the parent cl
+
-As explained in 6.15 SWIG provides support for overloaded functions and constructors.
+As explained in 6.15 SWIG provides support for overloaded functions and constructors.
As SWIG knows pointer types, the overloading works also with pointer types, here is is an example with a function magnify overloaded for the previous classes Shape and Circle:
+
-
%module example
void magnify(Square *square, double factor) {
- square->size *= factor;
+ square->size *= factor;
};
void magnify(Circle *circle, double factor) {
- square->radius *= factor;
+ square->radius *= factor;
};
-
-
--> example_Init();
--> c = new_Circle(3);
@@ -1157,7 +1157,6 @@ void magnify(Circle *circle, double factor) {
20;
-
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index bfa58f1ae..8417bec15 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -8,7 +8,7 @@
-Last update : SWIG-3.0.9 (in progress)
+Last update : SWIG-3.0.11 (in progress)
diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
index c365a879b..b074e9f94 100644
--- a/Doc/Manual/Typemaps.html
+++ b/Doc/Manual/Typemaps.html
@@ -750,7 +750,7 @@ code : { ... }
Note that the preprocessor will expand code within the {} delimiters, but not in the last two styles of delimiters,
-see Preprocessor and Typemaps.
+see Preprocessor and Typemaps.
Here are some examples of valid typemap specifications:
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index c489e0946..3e0d31c41 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -327,11 +327,11 @@ else
endif
PYTHON_SO = @PYTHON_SO@
-# SWIG option for Python
+# SWIG option for Python3
ifeq (,$(PY3))
- SWIGPYTHON = $(SWIG) -python
+ SWIGOPTPY3 =
else
- SWIGPYTHON = $(SWIG) -python -py3
+ SWIGOPTPY3 = -py3
endif
PEP8 = @PEP8@
@@ -342,7 +342,7 @@ PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391
# ----------------------------------------------------------------
python: $(SRCDIR_SRCS)
- $(SWIGPYTHON) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+ $(SWIG) -python $(SWIGOPTPY3) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(PYTHON_INCLUDE)
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
@@ -351,7 +351,7 @@ python: $(SRCDIR_SRCS)
# -----------------------------------------------------------------
python_cpp: $(SRCDIR_SRCS)
- $(SWIGPYTHON) -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+ $(SWIG) -python $(SWIGOPTPY3) -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE)
$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
@@ -367,12 +367,12 @@ TKINTER =
PYTHON_LIBOPTS = $(PYTHON_LINK) @LIBS@ $(TKINTER) $(SYSLIBS)
python_static: $(SRCDIR_SRCS)
- $(SWIGPYTHON) -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+ $(SWIG) -python $(SWIGOPTPY3) -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
python_static_cpp: $(SRCDIR_SRCS)
- $(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+ $(SWIG) -python $(SWIGOPTPY3) -c++ -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
@@ -429,7 +429,7 @@ python_clean:
##################################################################
# Make sure these locate your Octave installation
-OCTAVE = OCTAVE_HISTFILE=/dev/null @OCTAVE@
+OCTAVE = @OCTAVE@
OCTAVE_CXX = $(DEFS) @OCTAVE_CPPFLAGS@ @OCTAVE_CXXFLAGS@
# Extra Octave specific dynamic linking options
@@ -463,7 +463,7 @@ octave_cpp: $(SRCDIR_SRCS)
# -----------------------------------------------------------------
octave_run:
- $(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE)
+ OCTAVE_HISTFILE=/dev/null $(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE)
# -----------------------------------------------------------------
# Version display
@@ -587,6 +587,7 @@ JAVASO =@JAVASO@
JAVALDSHARED = @JAVALDSHARED@
JAVACXXSHARED = @JAVACXXSHARED@
JAVACFLAGS = @JAVACFLAGS@
+JAVAFLAGS = @JAVAFLAGS@
JAVA = @JAVA@
JAVAC = @JAVAC@ -d .
@@ -620,7 +621,7 @@ java_compile: $(SRCDIR_SRCS)
# -----------------------------------------------------------------
java_run:
- env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(JAVA) $(RUNME) $(RUNPIPE)
+ env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(JAVA) $(JAVAFLAGS) $(RUNME) $(RUNPIPE)
# -----------------------------------------------------------------
# Version display
@@ -1670,6 +1671,7 @@ R = R
RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system as it does not understand _wrap.cxx
RRSRC = $(INTERFACE:.i=.R)
R_CFLAGS=-fPIC
+R_OPT = --slave --quiet --no-save --no-restore
R_SCRIPT=$(SRCDIR)$(RUNME).R
# need to compile .cxx files outside of R build system to make sure that
@@ -1702,7 +1704,7 @@ endif
# -----------------------------------------------------------------
r_run:
- $(RUNTOOL) $(R) CMD BATCH $(R_SCRIPT) $(RUNPIPE)
+ $(RUNTOOL) $(R) $(R_OPT) -f $(R_SCRIPT) $(RUNPIPE)
# -----------------------------------------------------------------
# Version display
diff --git a/Examples/lua/arrays/example.i b/Examples/lua/arrays/example.i
index 3d5b60dc6..eafd8ff55 100644
--- a/Examples/lua/arrays/example.i
+++ b/Examples/lua/arrays/example.i
@@ -14,18 +14,19 @@ See the lua code for how they are called
// this adds some lua code directly into the module
// warning: you need the example. prefix if you want it added into the module
-// addmittedly this code is a bit tedious, but its a one off effort
+// admittedly this code is a bit tedious, but its a one off effort
%luacode {
function example.sort_int2(t)
- local len=table.maxn(t) -- the len
+-- local len=table.maxn(t) -- the len - maxn deprecated in 5.3
+ local len=0; for _ in pairs(t) do len=len+1 end
local arr=example.new_int(len)
for i=1,len do
- example.int_setitem(arr,i-1,t[i]) -- note: C index is one less then lua indea
+ example.int_setitem(arr,i-1,t[i]) -- note: C index is one less then lua index
end
example.sort_int(arr,len) -- call the fn
-- copy back
for i=1,len do
- t[i]=example.int_getitem(arr,i-1) -- note: C index is one less then lua indea
+ t[i]=example.int_getitem(arr,i-1) -- note: C index is one less then lua index
end
example.delete_int(arr) -- must delete it
end
diff --git a/Examples/python/import_packages/Makefile b/Examples/python/import_packages/Makefile
index 72b424a90..f428d6f5c 100644
--- a/Examples/python/import_packages/Makefile
+++ b/Examples/python/import_packages/Makefile
@@ -10,11 +10,15 @@ import_packages_subdirs = \
from_init3 \
relativeimport1 \
relativeimport2 \
- relativeimport3
+ relativeimport3 \
+ split_modules \
+ namespace_pkg
+
check: build
if test "x$(SRCDIR)" != x; then \
- for file in `cd $(SRCDIR) && find . -type f -name __init__.py`; do \
+ for file in `cd $(SRCDIR) && find . -type f -name "*.py"`; do \
+ mkdir -p `dirname $$file`; \
cp "${SRCDIR}$$file" "$$file" || exit 1; \
done; \
fi; \
@@ -35,7 +39,7 @@ static:
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
if test "x$(SRCDIR)" != x; then \
- for file in `cd $(SRCDIR) && find . -type f -name __init__.py`; do \
+ for file in `cd $(SRCDIR) && find . -type f -name "*.py"`; do \
rm -f "$$file" || exit 1; \
done; \
fi; \
diff --git a/Examples/python/import_packages/README b/Examples/python/import_packages/README
index 69fe3516e..187a5d64e 100644
--- a/Examples/python/import_packages/README
+++ b/Examples/python/import_packages/README
@@ -1,2 +1,4 @@
These are actually regression tests for SF bug #1297 (GH issue #7).
-See individual READMEs in subdirectories.
+The namespace_pkg is an example of python3's namespace packages.
+
+See individual READMEs in subdirectories.
\ No newline at end of file
diff --git a/Examples/python/import_packages/namespace_pkg/Makefile b/Examples/python/import_packages/namespace_pkg/Makefile
new file mode 100644
index 000000000..d86871344
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/Makefile
@@ -0,0 +1,17 @@
+TOP = ../../..
+SWIGEXE = $(TOP)/../swig
+SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
+TARGET = robin
+INTERFACE = robin.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
+ rm -rf path1 path2 path3 path4.zip
diff --git a/Examples/python/import_packages/namespace_pkg/README b/Examples/python/import_packages/namespace_pkg/README
new file mode 100644
index 000000000..8f7297a51
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/README
@@ -0,0 +1,25 @@
+ This is an example (and test) of using swig generated modules in the context
+of python3's namespace packages:
+
+https://www.python.org/dev/peps/pep-0420/
+
+ Consequently, this example requires python (3.3 or newer) to build and run.
+
+ This example creates a simple swig module named robin. The robin.py module
+has a companion C module named _robin.so. The robin module is tested in four
+ways:
+
+ 1) As a non-package module (tested by nonpkg.py)
+
+ 2) With robin.py and _robin.so in the brave package under the path1
+ subdirectory. (tested by normal.py)
+
+ 3) With robin.py in path2/brave and _robin.so in path3/brave
+ (tested by split.py)
+
+ 4) With robin.py contained in a zip file (path4.zip) as brave/robin.py and
+ _robin.so found on the filesystem under path3/brave (tested by zipsplit.py)
+
+Note: Using namespace packages with subpackages (such as brave.sir.robin) where
+ robin.py is located in a zipfile requires python-3.5.1 or newer as
+ python's zipimporter only worked with packages of depth 1 until then.
\ No newline at end of file
diff --git a/Examples/python/import_packages/namespace_pkg/nonpkg.py b/Examples/python/import_packages/namespace_pkg/nonpkg.py
new file mode 100644
index 000000000..acf0aedbd
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/nonpkg.py
@@ -0,0 +1,5 @@
+# import robin as a module in the global namespace
+
+import robin
+
+assert(robin.run() == "AWAY!")
diff --git a/Examples/python/import_packages/namespace_pkg/normal.py b/Examples/python/import_packages/namespace_pkg/normal.py
new file mode 100644
index 000000000..fc26c0216
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/normal.py
@@ -0,0 +1,7 @@
+import sys
+# Package brave found under one path
+sys.path.insert(0, 'path1')
+
+from brave import robin
+
+assert(robin.run() == "AWAY!")
diff --git a/Examples/python/import_packages/namespace_pkg/nstest.py b/Examples/python/import_packages/namespace_pkg/nstest.py
new file mode 100644
index 000000000..9b075ad8c
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/nstest.py
@@ -0,0 +1,45 @@
+import sys
+import os
+import shutil
+import zipfile
+
+
+def copyMods():
+ dirs = ['path1', 'path2', 'path3']
+
+ # Clean out any old package paths
+ for d in dirs:
+ if os.path.isdir(d):
+ shutil.rmtree(d)
+
+ for d in dirs:
+ os.mkdir(d)
+ os.mkdir(os.path.join(d, 'brave'))
+
+ shutil.copy('robin.py', os.path.join('path1', 'brave'))
+ os.system('cp _robin.* ' + os.path.join('path1', 'brave'))
+
+ shutil.copy('robin.py', os.path.join('path2', 'brave'))
+ os.system('cp _robin.* ' + os.path.join('path3', 'brave'))
+
+ mkzip()
+
+def mkzip():
+ zf = zipfile.ZipFile("path4.zip", "w")
+ zf.writestr("brave/", b'')
+ zf.write('robin.py', 'brave/robin.py')
+ zf.close()
+
+
+def main():
+ copyMods()
+
+ # Run each test with a separate interpreter
+ os.system(sys.executable + " nonpkg.py")
+ os.system(sys.executable + " normal.py")
+ os.system(sys.executable + " split.py")
+ os.system(sys.executable + " zipsplit.py")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/Examples/python/import_packages/namespace_pkg/robin.i b/Examples/python/import_packages/namespace_pkg/robin.i
new file mode 100644
index 000000000..394922130
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/robin.i
@@ -0,0 +1,7 @@
+%module robin
+
+%inline %{
+const char *run(void) {
+ return "AWAY!";
+}
+%}
diff --git a/Examples/python/import_packages/namespace_pkg/runme.py b/Examples/python/import_packages/namespace_pkg/runme.py
new file mode 100644
index 000000000..9c22d36fb
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/runme.py
@@ -0,0 +1,17 @@
+# These examples rely on namespace packages. Don't
+# run them for old python interpreters.
+import sys
+import os.path
+
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - namespace packages"
+
+if sys.version_info < (3, 3, 0):
+ print " Not importing nstest as Python version is < 3.3"
+ sys.exit(0)
+
+import nstest
+
+print " Finished importing nstest"
+
+nstest.main()
diff --git a/Examples/python/import_packages/namespace_pkg/split.py b/Examples/python/import_packages/namespace_pkg/split.py
new file mode 100644
index 000000000..1b66c2d49
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/split.py
@@ -0,0 +1,9 @@
+import sys
+# Package brave split into two paths.
+# path2/brave/robin.py and path3/brave/_robin.so
+sys.path.insert(0, 'path2')
+sys.path.insert(0, 'path3')
+
+from brave import robin
+
+assert(robin.run() == "AWAY!")
diff --git a/Examples/python/import_packages/namespace_pkg/zipsplit.py b/Examples/python/import_packages/namespace_pkg/zipsplit.py
new file mode 100644
index 000000000..9e35559e3
--- /dev/null
+++ b/Examples/python/import_packages/namespace_pkg/zipsplit.py
@@ -0,0 +1,9 @@
+import sys
+# Package brave split into two paths.
+# brave/robin.py (in path4.zip) and path3/brave/_robin.so
+sys.path.insert(0, 'path4.zip')
+sys.path.insert(0, 'path3')
+
+from brave import robin
+
+assert(robin.run() == "AWAY!")
diff --git a/Examples/python/import_packages/split_modules/Makefile b/Examples/python/import_packages/split_modules/Makefile
new file mode 100644
index 000000000..65d635bb7
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/Makefile
@@ -0,0 +1,26 @@
+TOP = ../../..
+LIBS =
+
+subdirs = vanilla vanilla_split
+
+
+check: build
+ for s in $(subdirs); do \
+ (cd $$s && $(MAKE) check); \
+ done
+
+build:
+ for s in $(subdirs); do \
+ (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build); \
+ done
+
+static:
+ for s in $(subdirs); do \
+ (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static); \
+ done
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
+ for s in $(subdirs); do \
+ (cd $$s && $(MAKE) clean); \
+ done
diff --git a/Examples/python/import_packages/split_modules/README b/Examples/python/import_packages/split_modules/README
new file mode 100644
index 000000000..0cb543e8a
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/README
@@ -0,0 +1,7 @@
+ These examples/tests are for when the SWIG generated wrapper module is split
+between two packages. Specifically the pure python part is part of a package
+and the C/C++ part is not in any package at all. Historically SWIG has
+supported this sort of thing.
+
+vanilla # "plane Jane" module both halves in pkg1
+vanilla_split # python 1/2 in pkg1 C 1/2 in global namespace
diff --git a/Examples/python/import_packages/split_modules/vanilla/Makefile b/Examples/python/import_packages/split_modules/vanilla/Makefile
new file mode 100644
index 000000000..b679d60a0
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla/Makefile
@@ -0,0 +1,18 @@
+TOP = ../../../..
+SWIGEXE = $(TOP)/../swig
+SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
+SWIGOPT =
+LIBS =
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
+
+build:
+ cd pkg1 && $(MAKE) build
+
+static:
+ cd pkg1 && $(MAKE) static
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
+ cd pkg1 && $(MAKE) -f $(TOP)/../Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/split_modules/vanilla/pkg1/Makefile b/Examples/python/import_packages/split_modules/vanilla/pkg1/Makefile
new file mode 100644
index 000000000..921bb9951
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla/pkg1/Makefile
@@ -0,0 +1,18 @@
+TOP = ../../../../..
+SWIGEXE = $(TOP)/../swig
+SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
+SWIGOPT =
+LIBS =
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
+
+static:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/split_modules/vanilla/pkg1/__init__.py b/Examples/python/import_packages/split_modules/vanilla/pkg1/__init__.py
new file mode 100644
index 000000000..7b1594cc8
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla/pkg1/__init__.py
@@ -0,0 +1 @@
+# killroy was here
diff --git a/Examples/python/import_packages/split_modules/vanilla/pkg1/foo.i b/Examples/python/import_packages/split_modules/vanilla/pkg1/foo.i
new file mode 100644
index 000000000..60ce16ec3
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla/pkg1/foo.i
@@ -0,0 +1,10 @@
+%module(package="pkg1") foo
+%{
+static unsigned count(void)
+{
+ return 3;
+}
+%}
+
+unsigned count(void);
+
diff --git a/Examples/python/import_packages/split_modules/vanilla/runme.py b/Examples/python/import_packages/split_modules/vanilla/runme.py
new file mode 100644
index 000000000..a188364f1
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla/runme.py
@@ -0,0 +1,10 @@
+import os.path
+
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - split modules"
+
+import pkg1.foo
+
+print " Finished importing pkg1.foo"
+
+assert(pkg1.foo.count() == 3)
diff --git a/Examples/python/import_packages/split_modules/vanilla_split/Makefile b/Examples/python/import_packages/split_modules/vanilla_split/Makefile
new file mode 100644
index 000000000..c322b5aec
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla_split/Makefile
@@ -0,0 +1,22 @@
+TOP = ../../../..
+SWIGEXE = $(TOP)/../swig
+SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
+SWIGOPT = -outdir pkg1
+LIBS =
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
+
+static:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
+ cd pkg1 && $(MAKE) -f $(TOP)/../Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/split_modules/vanilla_split/foo.i b/Examples/python/import_packages/split_modules/vanilla_split/foo.i
new file mode 100644
index 000000000..60ce16ec3
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla_split/foo.i
@@ -0,0 +1,10 @@
+%module(package="pkg1") foo
+%{
+static unsigned count(void)
+{
+ return 3;
+}
+%}
+
+unsigned count(void);
+
diff --git a/Examples/python/import_packages/split_modules/vanilla_split/pkg1/__init__.py b/Examples/python/import_packages/split_modules/vanilla_split/pkg1/__init__.py
new file mode 100644
index 000000000..7b1594cc8
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla_split/pkg1/__init__.py
@@ -0,0 +1 @@
+# killroy was here
diff --git a/Examples/python/import_packages/split_modules/vanilla_split/runme.py b/Examples/python/import_packages/split_modules/vanilla_split/runme.py
new file mode 100644
index 000000000..a188364f1
--- /dev/null
+++ b/Examples/python/import_packages/split_modules/vanilla_split/runme.py
@@ -0,0 +1,10 @@
+import os.path
+
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - split modules"
+
+import pkg1.foo
+
+print " Finished importing pkg1.foo"
+
+assert(pkg1.foo.count() == 3)
diff --git a/Examples/test-suite/apply_strings.i b/Examples/test-suite/apply_strings.i
index 62b578bf2..695dd068f 100644
--- a/Examples/test-suite/apply_strings.i
+++ b/Examples/test-suite/apply_strings.i
@@ -68,6 +68,10 @@ TAscii *DigitsGlobalC;
// Director test
%feature("director");
+#if defined(SWIGGO)
+%typemap(godirectorout) CharPtr, CCharPtr ""
+#endif
+
%inline %{
struct DirectorTest {
virtual UCharPtr UCharFunction(UCharPtr str) { return str; }
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index f87bdf311..10322b23b 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -87,7 +87,6 @@ CPP_TEST_BROKEN += \
director_nested_class \
exception_partial_info \
extend_variable \
- li_std_vector_ptr \
li_boost_shared_ptr_template \
nested_private \
overload_complicated \
@@ -174,7 +173,6 @@ CPP_TEST_CASES += \
director_abstract \
director_alternating \
director_basic \
- director_property \
director_binary_string \
director_classes \
director_classic \
@@ -189,12 +187,14 @@ CPP_TEST_CASES += \
director_ignore \
director_keywords \
director_namespace_clash \
+ director_nested \
director_nspace \
director_nspace_director_name_collision \
- director_nested \
director_overload \
director_overload2 \
+ director_pass_by_value \
director_primitives \
+ director_property \
director_protected \
director_protected_overloaded \
director_redefined \
@@ -307,6 +307,7 @@ CPP_TEST_CASES += \
nested_class \
nested_directors \
nested_comment \
+ nested_ignore \
nested_scope \
nested_template_base \
nested_workaround \
@@ -362,6 +363,7 @@ CPP_TEST_CASES += \
smart_pointer_const2 \
smart_pointer_const_overload \
smart_pointer_extend \
+ smart_pointer_ignore \
smart_pointer_member \
smart_pointer_multi \
smart_pointer_multi_typedef \
@@ -402,6 +404,7 @@ CPP_TEST_CASES += \
template_default2 \
template_default_arg \
template_default_arg_overloaded \
+ template_default_arg_overloaded_extend \
template_default_arg_virtual_destructor \
template_default_class_parms \
template_default_class_parms_typedef \
@@ -584,6 +587,7 @@ CPP_STD_TEST_CASES += \
li_std_vector \
li_std_vector_enum \
li_std_vector_member_var\
+ li_std_vector_ptr \
smart_pointer_inherit \
template_typedef_fnc \
template_type_namespace \
@@ -714,7 +718,7 @@ check-cpp: $(CPP_TEST_CASES:=.cpptest)
check-cpp11: $(CPP11_TEST_CASES:=.cpptest)
check-failing-test = \
- $(MAKE) -s $1.$2 >/dev/null 2>/dev/null && echo "Failing test $t passed."
+ $(MAKE) -s $1.$2 >/dev/null 2>/dev/null && echo "Failing test $1 passed."
check-failing:
+-$(foreach t,$(FAILING_C_TESTS),$(call check-failing-test,$t,ctest);)
diff --git a/Examples/test-suite/constant_directive.i b/Examples/test-suite/constant_directive.i
index fc6b6cd92..89f13cecc 100644
--- a/Examples/test-suite/constant_directive.i
+++ b/Examples/test-suite/constant_directive.i
@@ -3,6 +3,9 @@
// %constant and struct
%inline %{
+#if defined(_MSC_VER)
+ #pragma warning(disable : 4190) // warning C4190: 'result' has C-linkage specified, but returns UDT 'Type1' which is incompatible with C
+#endif
struct Type1 {
Type1(int val = 0) : val(val) {}
int val;
diff --git a/Examples/test-suite/cpp11_type_aliasing.i b/Examples/test-suite/cpp11_type_aliasing.i
index 87443633a..2f6ea3aa7 100644
--- a/Examples/test-suite/cpp11_type_aliasing.i
+++ b/Examples/test-suite/cpp11_type_aliasing.i
@@ -2,15 +2,6 @@
// Type aliasing seg fault : Github issue #424
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Target;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Int;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRef;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntPtrRef;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntRValueRef;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) IntArray;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr1;
-%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) HalideTargetPtr2;
-
%inline %{
namespace Halide {
@@ -53,14 +44,69 @@ public:
%inline %{
-using Int = int;
-using IntRef = int&;
-using IntPtrRef = int*&;
-using IntRValueRef = int&&;
-using IntArray = int[];
-
using HalideTargetPtr1 = Halide::Target*;
namespace Halide {
using HalideTargetPtr2 = Target*;
}
%}
+
+// Define some types
+
+%inline %{
+using Int = int;
+using IntPtr = Int*;
+using IntRef = Int&;
+using IntPtrRef = Int*&;
+using IntRValueRef = Int&&;
+using IntArray = Int[];
+%}
+
+// Test that SWIG understands these new types
+
+%callback("%s_cb");
+Int mult2(Int x);
+%nocallback;
+
+%inline %{
+Int mult2(Int x) { return x * 2; }
+IntPtr allocate_int() { return new Int(12); }
+void free_int(int* ptr) { delete ptr; }
+void inplace_mult2(IntRef x) { x *= 2; }
+Int read_int(IntPtr ptr) { return *ptr; }
+
+template class Pair {
+public:
+ using data_t = T;
+
+ data_t a, b;
+
+ Pair() : a(), b() { }
+ Pair(data_t a, data_t b) : a(a), b(b) { }
+ data_t first() { return a; }
+ data_t second() { return b; }
+};
+%}
+
+%template(int_pair) Pair;
+
+%inline %{
+using PairInt = Pair;
+
+class PairSubclass : public PairInt {
+public:
+ PairSubclass(data_t a, data_t b) : PairInt(a, b) { }
+
+ using const_ref_data_t = const data_t&;
+};
+
+PairSubclass::data_t plus1(PairSubclass::const_ref_data_t x) { return x + 1; }
+%}
+
+// Test function pointers
+
+%inline %{
+using callback_t = int(*)(int);
+
+callback_t get_callback() { return mult2; }
+int call(callback_t func, int param) { return func(param); }
+%}
diff --git a/Examples/test-suite/cpp_enum.i b/Examples/test-suite/cpp_enum.i
index cb212615a..548c65de4 100644
--- a/Examples/test-suite/cpp_enum.i
+++ b/Examples/test-suite/cpp_enum.i
@@ -6,6 +6,12 @@ The primary purpose of this testcase is to ensure that enums used along with the
%inline %{
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+/* for anonymous enums */
+/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif
+
enum SOME_ENUM {ENUM_ONE, ENUM_TWO};
struct StructWithEnums {
diff --git a/Examples/test-suite/csharp/director_pass_by_value_runme.cs b/Examples/test-suite/csharp/director_pass_by_value_runme.cs
new file mode 100644
index 000000000..ba6371590
--- /dev/null
+++ b/Examples/test-suite/csharp/director_pass_by_value_runme.cs
@@ -0,0 +1,43 @@
+using System;
+using director_pass_by_valueNamespace;
+
+public class runme
+{
+ private static void WaitForGC()
+ {
+ System.GC.Collect();
+ System.GC.WaitForPendingFinalizers();
+ System.Threading.Thread.Sleep(10);
+ }
+
+ static void Main()
+ {
+ runme r = new runme();
+ r.run();
+ }
+
+ void run()
+ {
+ Caller caller = new Caller();
+ caller.call_virtualMethod(new director_pass_by_value_Derived());
+ {
+ int countdown = 5;
+ while (true) {
+ WaitForGC();
+ if (--countdown == 0)
+ break;
+ };
+ }
+ // bug was the passByVal 'global' object was destroyed after the call to virtualMethod had finished.
+ int ret = runme.passByVal.getVal();
+ if (ret != 0x12345678)
+ throw new Exception("Bad return value, got " + ret.ToString("x"));
+ }
+ public static PassedByValue passByVal;
+}
+
+class director_pass_by_value_Derived : DirectorPassByValueAbstractBase {
+ public override void virtualMethod(PassedByValue pbv) {
+ runme.passByVal = pbv;
+ }
+}
diff --git a/Examples/test-suite/default_args_c.i b/Examples/test-suite/default_args_c.i
new file mode 100644
index 000000000..e0c0af056
--- /dev/null
+++ b/Examples/test-suite/default_args_c.i
@@ -0,0 +1,14 @@
+%module default_args_c
+
+/* Default arguments for C code */
+int foo1(int x = 42 || 3);
+int foo43(int x = 42 | 3);
+
+%{
+int foo1(int x) {
+ return x;
+}
+int foo43(int x) {
+ return x;
+}
+%}
diff --git a/Examples/test-suite/director_pass_by_value.i b/Examples/test-suite/director_pass_by_value.i
new file mode 100644
index 000000000..31d8ce2d2
--- /dev/null
+++ b/Examples/test-suite/director_pass_by_value.i
@@ -0,0 +1,30 @@
+%module(directors="1") director_pass_by_value
+%director DirectorPassByValueAbstractBase;
+
+%inline %{
+class PassedByValue {
+ int val;
+public:
+ PassedByValue() { val = 0x12345678; }
+ int getVal() { return val; }
+};
+
+int doSomething(int x) {
+ int yy[256];
+ yy[0] =0x9876;
+ return yy[0];
+}
+
+class DirectorPassByValueAbstractBase {
+public:
+ virtual void virtualMethod(PassedByValue pbv) = 0;
+ virtual ~DirectorPassByValueAbstractBase () {}
+};
+
+class Caller {
+public:
+ void call_virtualMethod(DirectorPassByValueAbstractBase &f) {
+ f.virtualMethod(PassedByValue());
+ }
+};
+%}
diff --git a/Examples/test-suite/enum_thorough.i b/Examples/test-suite/enum_thorough.i
index 66189fbe2..fd5978102 100644
--- a/Examples/test-suite/enum_thorough.i
+++ b/Examples/test-suite/enum_thorough.i
@@ -47,6 +47,12 @@
%inline %{
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+/* for anonymous enums */
+/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif
+
enum { AnonEnum1, AnonEnum2 = 100 };
enum { ReallyAnInteger = 200 };
//enum { AnonEnum3, AnonEnum4 } instance;
diff --git a/Examples/test-suite/enums.i b/Examples/test-suite/enums.i
index 14c6efbba..b8ffd7588 100644
--- a/Examples/test-suite/enums.i
+++ b/Examples/test-suite/enums.i
@@ -12,6 +12,12 @@
%inline %{
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+/* for anonymous enums */
+/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif
+
typedef enum {
CSP_ITERATION_FWD,
CSP_ITERATION_BWD = 11
diff --git a/Examples/test-suite/errors/c_default_error.i b/Examples/test-suite/errors/c_default_error.i
deleted file mode 100644
index f6220e11d..000000000
--- a/Examples/test-suite/errors/c_default_error.i
+++ /dev/null
@@ -1,4 +0,0 @@
-%module xxx
-
-int foo(int x = 42 || 3);
-
diff --git a/Examples/test-suite/errors/c_default_error.stderr b/Examples/test-suite/errors/c_default_error.stderr
deleted file mode 100644
index e69de29bb..000000000
diff --git a/Examples/test-suite/errors/c_varargs.i b/Examples/test-suite/errors/c_varargs.i
deleted file mode 100644
index 88f9c2e7d..000000000
--- a/Examples/test-suite/errors/c_varargs.i
+++ /dev/null
@@ -1,3 +0,0 @@
-%module xxx
-
-int foo(int x, ...);
diff --git a/Examples/test-suite/errors/c_varargs.stderr b/Examples/test-suite/errors/c_varargs.stderr
deleted file mode 100644
index e69de29bb..000000000
diff --git a/Examples/test-suite/errors/cpp_inherit_ignored.i b/Examples/test-suite/errors/cpp_inherit_ignored.i
new file mode 100644
index 000000000..fdc1c83e3
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_inherit_ignored.i
@@ -0,0 +1,19 @@
+%module xxx
+
+// Only non-ignored classes should warn about Ignored base classes
+%ignore ActualClass;
+%ignore ActualClassNoTemplates;
+
+%{
+struct BaseClassNoTemplates {};
+%}
+%inline %{
+template
+class TemplateClass {};
+
+class ActualClass : public TemplateClass {};
+class AktuelKlass : public TemplateClass {};
+
+class ActualClassNoTemplates : public BaseClassNoTemplates {};
+class AktuelKlassNoTemplates : public BaseClassNoTemplates {};
+%}
diff --git a/Examples/test-suite/errors/cpp_inherit_ignored.stderr b/Examples/test-suite/errors/cpp_inherit_ignored.stderr
new file mode 100644
index 000000000..360c1f9fc
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_inherit_ignored.stderr
@@ -0,0 +1,3 @@
+cpp_inherit_ignored.i:15: Warning 401: Nothing known about base class 'TemplateClass< int >'. Ignored.
+cpp_inherit_ignored.i:15: Warning 401: Maybe you forgot to instantiate 'TemplateClass< int >' using %template.
+cpp_inherit_ignored.i:18: Warning 401: Nothing known about base class 'BaseClassNoTemplates'. Ignored.
diff --git a/Examples/test-suite/errors/cpp_overload.i b/Examples/test-suite/errors/cpp_overload.i
deleted file mode 100644
index 34fa3cc25..000000000
--- a/Examples/test-suite/errors/cpp_overload.i
+++ /dev/null
@@ -1,15 +0,0 @@
-%module xxx
-int foo(int x);
-int foo(double x);
-
-class Foo {
-public:
- int bar(int);
- int bar(double);
-};
-
-class Spam {
-public:
- Spam();
- Spam(int);
-};
diff --git a/Examples/test-suite/errors/cpp_overload.stderr b/Examples/test-suite/errors/cpp_overload.stderr
deleted file mode 100644
index e69de29bb..000000000
diff --git a/Examples/test-suite/errors/cpp_private_defvalue.i b/Examples/test-suite/errors/cpp_private_defvalue.i
deleted file mode 100644
index 15542c7bc..000000000
--- a/Examples/test-suite/errors/cpp_private_defvalue.i
+++ /dev/null
@@ -1,7 +0,0 @@
-%module xxx
-
-class foo {
-static const int BAR = 42;
-public:
- int blah(int x = BAR);
-};
diff --git a/Examples/test-suite/errors/cpp_private_defvalue.stderr b/Examples/test-suite/errors/cpp_private_defvalue.stderr
deleted file mode 100644
index e69de29bb..000000000
diff --git a/Examples/test-suite/errors/cpp_template_argname.i b/Examples/test-suite/errors/cpp_template_argname.i
deleted file mode 100644
index b87c115c1..000000000
--- a/Examples/test-suite/errors/cpp_template_argname.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module xxx
-
-template T blah(T x);
-
-
-
-
-
diff --git a/Examples/test-suite/errors/cpp_template_argname.stderr b/Examples/test-suite/errors/cpp_template_argname.stderr
deleted file mode 100644
index e69de29bb..000000000
diff --git a/Examples/test-suite/errors/cpp_template_repeat.i b/Examples/test-suite/errors/cpp_template_repeat.i
index e63ffe8d9..f170080b7 100644
--- a/Examples/test-suite/errors/cpp_template_repeat.i
+++ b/Examples/test-suite/errors/cpp_template_repeat.i
@@ -4,4 +4,4 @@ template T blah(T x) { };
%template(iblah) blah;
%template(iiblah) blah;
-
+// The second %template instantiation above should surely be ignored with a warning, but doesn't atm
diff --git a/Examples/test-suite/errors/cpp_using_type_aliasing.stderr b/Examples/test-suite/errors/cpp_using_type_aliasing.stderr
index 3f256652f..e69de29bb 100644
--- a/Examples/test-suite/errors/cpp_using_type_aliasing.stderr
+++ b/Examples/test-suite/errors/cpp_using_type_aliasing.stderr
@@ -1,3 +0,0 @@
-cpp_using_type_aliasing.i:8: Warning 341: The 'using' keyword in type aliasing is not fully supported yet.
-cpp_using_type_aliasing.i:8: Warning 315: Nothing known about 'Okay< int >'.
-cpp_using_type_aliasing.i:8: Warning 315: Nothing known about 'Okay< int >'.
diff --git a/Examples/test-suite/errors/pp_macro_args.i b/Examples/test-suite/errors/pp_macro_args.i
deleted file mode 100644
index 8bbbfb104..000000000
--- a/Examples/test-suite/errors/pp_macro_args.i
+++ /dev/null
@@ -1,7 +0,0 @@
-%module xxx
-
-#define foo(a,x) a x
-
-#if foo
-#endif
-
diff --git a/Examples/test-suite/errors/pp_macro_args.stderr b/Examples/test-suite/errors/pp_macro_args.stderr
deleted file mode 100644
index e69de29bb..000000000
diff --git a/Examples/test-suite/exception_classname.i b/Examples/test-suite/exception_classname.i
index a5a76e24d..6900581cf 100644
--- a/Examples/test-suite/exception_classname.i
+++ b/Examples/test-suite/exception_classname.i
@@ -1,6 +1,9 @@
%module exception_classname
%warnfilter(SWIGWARN_RUBY_WRONG_NAME);
+#ifdef SWIGPHP
+%rename(ExceptionClass) Exception;
+#endif
%inline %{
class Exception {
diff --git a/Examples/test-suite/go/go_inout_runme.go b/Examples/test-suite/go/go_inout_runme.go
index 13c429b87..9aa0cd0c5 100644
--- a/Examples/test-suite/go/go_inout_runme.go
+++ b/Examples/test-suite/go/go_inout_runme.go
@@ -40,4 +40,14 @@ func main() {
fmt.Println("got", a, "want", dwant)
panic(a)
}
+
+ c2 := go_inout.NewC2()
+ pm := c2.M()
+ want = map[string]interface{}{
+ "ID": float64(1),
+ }
+ if !reflect.DeepEqual(*pm, want) {
+ fmt.Println("for c2.M got", pm, "want", want)
+ panic(pm)
+ }
}
diff --git a/Examples/test-suite/go/li_std_vector_ptr_runme.go b/Examples/test-suite/go/li_std_vector_ptr_runme.go
index cee997ad0..a9f7fe91c 100644
--- a/Examples/test-suite/go/li_std_vector_ptr_runme.go
+++ b/Examples/test-suite/go/li_std_vector_ptr_runme.go
@@ -1,12 +1,19 @@
package main
import . "./li_std_vector_ptr"
+import "fmt"
+func check(val1 int, val2 int) {
+ if val1 != val2 {
+ panic(fmt.Sprintf("Values are not the same %d %d", val1, val2))
+ }
+}
func main() {
ip1 := MakeIntPtr(11)
ip2 := MakeIntPtr(22)
vi := NewIntPtrVector()
vi.Add(ip1)
vi.Add(ip2)
- DisplayVector(vi)
+ check(GetValueFromVector(vi, 0), 11)
+ check(GetValueFromVector(vi, 1), 22)
}
diff --git a/Examples/test-suite/go_inout.i b/Examples/test-suite/go_inout.i
index 57e7bf2fb..0bcb979ef 100644
--- a/Examples/test-suite/go_inout.i
+++ b/Examples/test-suite/go_inout.i
@@ -23,7 +23,7 @@ struct RetStruct {
// Write a typemap that calls C++ by converting in and out of JSON.
-%go_import("encoding/json", "bytes", "encoding/binary")
+%go_import("encoding/json", "bytes", "encoding/binary", "reflect", "unsafe")
%insert(go_header)
%{
@@ -68,6 +68,26 @@ type In json.Marshaler
}
%}
+%typemap(gotype) RetStruct* "*map[string]interface{}"
+
+%typemap(imtype) RetStruct* "*string"
+
+%typemap(out,fragment="AllocateString") RetStruct*
+%{
+ $result = (_gostring_*)malloc(sizeof(_gostring_));
+ *$result = Swig_AllocateString($1->str.data(), $1->str.length());
+%}
+
+%typemap(goout,fragment="CopyString") RetStruct*
+%{
+ defer Swig_free(uintptr(unsafe.Pointer($1)))
+ var rm map[string]interface{}
+ if err := json.Unmarshal([]byte(swigCopyString(*$1)), &rm); err != nil {
+ panic(err)
+ }
+ $result = &rm
+%}
+
%inline
%{
@@ -87,6 +107,10 @@ struct MyArray {
std::vector strings;
};
+void* Allocate(int n) {
+ return new char[n];
+}
+
static uint64_t getuint64(const char* s) {
uint64_t ret = 0;
for (int i = 0; i < 8; i++, s++) {
@@ -121,7 +145,12 @@ static void putuint64(std::string *s, size_t off, uint64_t v) {
buf.Write(b[:])
buf.WriteString(s)
}
- str := buf.String()
+ bb := buf.Bytes()
+ p := Allocate(len(bb))
+ copy((*[1<<15]byte)(unsafe.Pointer(p))[:len(bb)], bb)
+ var str string
+ (*reflect.StringHeader)(unsafe.Pointer(&str)).Data = uintptr(unsafe.Pointer(p))
+ (*reflect.StringHeader)(unsafe.Pointer(&str)).Len = len(bb)
$result = &str
}
%}
@@ -197,3 +226,18 @@ void DoubleArray(MyArray* v) {
}
}
%}
+
+%inline
+%{
+class C1 {
+ public:
+ RetStruct* M() {
+ RetStruct* r = new RetStruct;
+ r->str = "{\"ID\":1}";
+ return r;
+ }
+};
+
+class C2 : public C1 {
+};
+%}
diff --git a/Examples/test-suite/insert_directive.i b/Examples/test-suite/insert_directive.i
index 8ad966a99..36c3af6c6 100644
--- a/Examples/test-suite/insert_directive.i
+++ b/Examples/test-suite/insert_directive.i
@@ -34,5 +34,5 @@ int inserted_wrapper(int i) { return inserted_header3(i); }
%init %{
// %inserted code %init
-int inserted_init_value = inserted_wrapper(0);
+int SWIGUNUSED inserted_init_value = inserted_wrapper(0);
%}
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in
index 64b38702c..e69964352 100644
--- a/Examples/test-suite/java/Makefile.in
+++ b/Examples/test-suite/java/Makefile.in
@@ -5,7 +5,7 @@
LANGUAGE = java
JAVA = @JAVA@
JAVAC = @JAVAC@
-JAVAFLAGS = -Xcheck:jni
+JAVAFLAGS = @JAVAFLAGS@
SCRIPTSUFFIX = _runme.java
srcdir = @srcdir@
diff --git a/Examples/test-suite/java/director_classes_runme.java b/Examples/test-suite/java/director_classes_runme.java
index 013bdc75b..5fbb9ea35 100644
--- a/Examples/test-suite/java/director_classes_runme.java
+++ b/Examples/test-suite/java/director_classes_runme.java
@@ -140,7 +140,7 @@ public class director_classes_runme {
Package packag = klass.getPackage();
String simpleName = null;
if (packag != null)
- simpleName = fullName.replaceAll(packag.getName() + ".", "");
+ simpleName = fullName.replaceAll(packag.getName() + "\\.", "");
else
simpleName = fullName;
return simpleName;
diff --git a/Examples/test-suite/java/director_pass_by_value_runme.java b/Examples/test-suite/java/director_pass_by_value_runme.java
new file mode 100644
index 000000000..24ded2ccf
--- /dev/null
+++ b/Examples/test-suite/java/director_pass_by_value_runme.java
@@ -0,0 +1,48 @@
+
+import director_pass_by_value.*;
+
+public class director_pass_by_value_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_pass_by_value");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ private static void WaitForGC() {
+ System.gc();
+ System.runFinalization();
+ try {
+ java.lang.Thread.sleep(10);
+ } catch (java.lang.InterruptedException e) {
+ }
+ }
+
+ public static void main(String argv[]) {
+ Caller caller = new Caller();
+ caller.call_virtualMethod(new director_pass_by_value_Derived());
+ {
+ int countdown = 5;
+ while (true) {
+ WaitForGC();
+ if (--countdown == 0)
+ break;
+ };
+ }
+ // bug was the passByVal 'global' object was destroyed after the call to virtualMethod had finished.
+ int ret = director_pass_by_value_runme.passByVal.getVal();
+ if (ret != 0x12345678)
+ throw new RuntimeException("Bad return value, got " + Integer.toHexString(ret));
+ }
+
+ static PassedByValue passByVal;
+}
+
+class director_pass_by_value_Derived extends DirectorPassByValueAbstractBase {
+ public void virtualMethod(PassedByValue pbv) {
+ director_pass_by_value_runme.passByVal = pbv;
+ }
+}
diff --git a/Examples/test-suite/java/smart_pointer_ignore_runme.java b/Examples/test-suite/java/smart_pointer_ignore_runme.java
new file mode 100644
index 000000000..f02bf536a
--- /dev/null
+++ b/Examples/test-suite/java/smart_pointer_ignore_runme.java
@@ -0,0 +1,19 @@
+import smart_pointer_ignore.*;
+
+public class smart_pointer_ignore_runme {
+
+ static {
+ try {
+ System.loadLibrary("smart_pointer_ignore");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ DerivedPtr d = smart_pointer_ignore.makeDerived();
+ d.base();
+ d.derived();
+ }
+}
diff --git a/Examples/test-suite/li_boost_array.i b/Examples/test-suite/li_boost_array.i
index be51d15e0..e18140a50 100644
--- a/Examples/test-suite/li_boost_array.i
+++ b/Examples/test-suite/li_boost_array.i
@@ -25,6 +25,8 @@ namespace boost {
using std::array;
}
+%ignore std::array::fill; // Some older versions of boost don't have this function
+
%include
%template(ArrayInt6) std::array;
diff --git a/Examples/test-suite/li_boost_shared_ptr_template.i b/Examples/test-suite/li_boost_shared_ptr_template.i
index e3b735c24..3965a976e 100644
--- a/Examples/test-suite/li_boost_shared_ptr_template.i
+++ b/Examples/test-suite/li_boost_shared_ptr_template.i
@@ -67,7 +67,7 @@ INTEGER bar_getter(Base& foo) {
// 2nd test - templates with default template parameters
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
-%shared_ptr(Space::BaseDefault)
+%shared_ptr(Space::BaseDefault)
%shared_ptr(Space::DerivedDefault)
%shared_ptr(Space::DerivedDefault2)
diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i
index 99fb88a52..ada146cc4 100644
--- a/Examples/test-suite/li_std_vector.i
+++ b/Examples/test-suite/li_std_vector.i
@@ -130,3 +130,13 @@ namespace aa {
std::vector< ::aa::Holder > vec1(std::vector< ::aa::Holder > x) { return x; }
%}
#endif
+
+// exercising vectors of strings
+%inline %{
+std::vector RevStringVec (const std::vector &In)
+ {
+ std::vector result(In);
+ std::reverse(result.begin(), result.end());
+ return(result);
+ }
+%}
diff --git a/Examples/test-suite/li_std_vector_ptr.i b/Examples/test-suite/li_std_vector_ptr.i
index 292c9d700..4d6794717 100644
--- a/Examples/test-suite/li_std_vector_ptr.i
+++ b/Examples/test-suite/li_std_vector_ptr.i
@@ -1,4 +1,4 @@
-// Bug 2359417
+// SF Bug 2359417
%module li_std_vector_ptr
%include "std_vector.i"
@@ -15,16 +15,76 @@ double* makeDoublePtr(double v) {
return new double(v);
}
-#if 1
+// pointer to pointer in the wrappers was preventing a vector of pointers from working
int** makeIntPtrPtr(int* v) {
return new int*(v);
}
-#endif
void displayVector(std::vector vpi) {
cout << "displayVector..." << endl;
- for (int i=0; i vpi, size_t index) {
+ return *vpi[index];
+}
+%}
+
+// A not exposed to wrappers
+%{
+struct A {
+ int val;
+ A(int val) : val(val) {}
+};
+%}
+
+%template(APtrVector) std::vector;
+
+%inline %{
+A *makeA(int val) { return new A(val); }
+int getVal(A* a) { return a->val; }
+int getVectorValueA(std::vector vpi, size_t index) {
+ return vpi[index]->val;
+}
+%}
+
+// B is fully exposed to wrappers
+%inline %{
+struct B {
+ int val;
+ B(int val = 0) : val(val) {}
+};
+%}
+
+%template(BPtrVector) std::vector;
+
+%inline %{
+B *makeB(int val) { return new B(val); }
+int getVal(B* b) { return b->val; }
+int getVectorValueB(std::vector vpi, size_t index) {
+ return vpi[index]->val;
+}
+%}
+
+// C is fully exposed to wrappers (includes code using B **)
+%inline %{
+struct C {
+ int val;
+ C(int val = 0) : val(val) {}
+};
+%}
+
+%template(CPtrVector) std::vector;
+
+%inline %{
+// pointer to pointer in the wrappers was preventing a vector of pointers from working
+C** makeCIntPtrPtr(C* v) {
+ return new C*(v);
+}
+C *makeC(int val) { return new C(val); }
+int getVal(C* b) { return b->val; }
+int getVectorValueC(std::vector vpi, size_t index) {
+ return vpi[index]->val;
+}
%}
diff --git a/Examples/test-suite/namespace_typemap.i b/Examples/test-suite/namespace_typemap.i
index 8ead78c6c..7f474bd9c 100644
--- a/Examples/test-suite/namespace_typemap.i
+++ b/Examples/test-suite/namespace_typemap.i
@@ -109,7 +109,11 @@ namespace test {
#ifdef SWIGGO
%typemap(gotype) string_class * "string"
%typemap(in) string_class * {
- $1 = new string_class($input.p);
+ char* buf = new char[$input.n + 1];
+ memcpy(buf, $input.p, $input.n);
+ buf[$input.n] = '\0';
+ $1 = new string_class(buf);
+ delete[] buf;
}
%typemap(freearg) string_class * {
delete $1;
diff --git a/Examples/test-suite/nested.i b/Examples/test-suite/nested.i
index 1d4710128..216ee4224 100644
--- a/Examples/test-suite/nested.i
+++ b/Examples/test-suite/nested.i
@@ -13,6 +13,18 @@ Also tests reported error when a #define placed in a deeply embedded struct/unio
%rename(InUnNamed) OuterStructNamed::Inner_union_named;
#endif
+#if defined(SWIG_JAVASCRIPT_V8)
+
+%inline %{
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+/* for nested C class wrappers compiled as C++ code */
+/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif
+%}
+
+#endif
+
%inline %{
struct TestStruct {
diff --git a/Examples/test-suite/nested_extend_c.i b/Examples/test-suite/nested_extend_c.i
index 8fde075a4..f1d7ff2c8 100644
--- a/Examples/test-suite/nested_extend_c.i
+++ b/Examples/test-suite/nested_extend_c.i
@@ -1,5 +1,17 @@
%module nested_extend_c
+#if defined(SWIG_JAVASCRIPT_V8)
+
+%inline %{
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+/* for nested C class wrappers compiled as C++ code */
+/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif
+%}
+
+#endif
+
#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8)
%extend hiA {
hiA() {
@@ -98,5 +110,9 @@ typedef struct {
static struct {
int i;
} THING;
+
+int useThing() {
+ return THING.i;
+}
%}
diff --git a/Examples/test-suite/nested_ignore.i b/Examples/test-suite/nested_ignore.i
new file mode 100644
index 000000000..e271eca7d
--- /dev/null
+++ b/Examples/test-suite/nested_ignore.i
@@ -0,0 +1,24 @@
+%module nested_ignore
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) B::C::D;
+
+%rename($ignore) B::C;
+
+%inline %{
+namespace B {
+ class C {
+ public:
+ struct D {
+ };
+ };
+
+ class E {
+ public:
+ typedef C::D D;
+ };
+
+ struct F
+ {
+ const E::D foo(){ return E::D(); }
+ };
+}
+%}
diff --git a/Examples/test-suite/nested_structs.i b/Examples/test-suite/nested_structs.i
index f4f7a275a..c70924958 100644
--- a/Examples/test-suite/nested_structs.i
+++ b/Examples/test-suite/nested_structs.i
@@ -1,5 +1,17 @@
%module nested_structs
+#if defined(SWIG_JAVASCRIPT_V8)
+
+%inline %{
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+/* for nested C class wrappers compiled as C++ code */
+/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif
+%}
+
+#endif
+
// bug #491476
%inline %{
struct Outer {
diff --git a/Examples/test-suite/operator_overload.i b/Examples/test-suite/operator_overload.i
index 822fc2d6f..2c906f24a 100644
--- a/Examples/test-suite/operator_overload.i
+++ b/Examples/test-suite/operator_overload.i
@@ -78,6 +78,10 @@ see bottom for a set of possible tests
%rename(OrOperator) operator ||;
#endif
+#if defined(SWIGPYTHON)
+%feature("python:slot", "tp_str", functype="reprfunc") Op::__str__;
+#endif
+
#ifdef SWIGD
// Due to the way operator overloading is implemented in D1 and D2, the prefix
// increment/decrement operators (D1) resp. the postfix ones (D2) are ignored.
@@ -94,8 +98,6 @@ see bottom for a set of possible tests
#include /* for named logical operator, eg 'operator or' */
#endif
-#include
-
class Op {
public:
int i;
@@ -114,11 +116,11 @@ public:
return *this;
}
// +=,-=... are member fns
- void operator+=(const Op& o){ i+=o.i;}
- void operator-=(const Op& o){ i-=o.i;}
- void operator*=(const Op& o){ i*=o.i;}
- void operator/=(const Op& o){ i/=o.i;}
- void operator%=(const Op& o){ i%=o.i;}
+ Op &operator+=(const Op& o){ i+=o.i; return *this; }
+ Op &operator-=(const Op& o){ i-=o.i; return *this; }
+ Op &operator*=(const Op& o){ i*=o.i; return *this; }
+ Op &operator/=(const Op& o){ i/=o.i; return *this; }
+ Op &operator%=(const Op& o){ i%=o.i; return *this; }
// the +,-,*,... are friends
// (just to make life harder)
friend Op operator+(const Op& a,const Op& b){return Op(a.i+b.i);}
@@ -250,8 +252,8 @@ public:
%{
-
-#include
+#include
+#define ASSERT(X) { if (!(X)) { throw std::runtime_error(#X); } }
void Op::sanity_check()
{
@@ -263,66 +265,66 @@ void Op::sanity_check()
Op dd=d; // assignment operator
// test equality
- assert(a!=b);
- assert(b==c);
- assert(a!=d);
- assert(d==dd);
+ ASSERT(a!=b);
+ ASSERT(b==c);
+ ASSERT(a!=d);
+ ASSERT(d==dd);
// test <
- assert(a=c);
- assert(b>d);
- assert(b>=d);
+ ASSERT(a=c);
+ ASSERT(b>d);
+ ASSERT(b>=d);
// test +=
Op e=3;
e+=d;
- assert(e==b);
+ ASSERT(e==b);
e-=c;
- assert(e==a);
+ ASSERT(e==a);
e=Op(1);
e*=b;
- assert(e==c);
+ ASSERT(e==c);
e/=d;
- assert(e==d);
+ ASSERT(e==d);
e%=c;
- assert(e==d);
+ ASSERT(e==d);
// test +
Op f(1),g(1);
- assert(f+g==Op(2));
- assert(f-g==Op(0));
- assert(f*g==Op(1));
- assert(f/g==Op(1));
- assert(f%g==Op(0));
+ ASSERT(f+g==Op(2));
+ ASSERT(f-g==Op(0));
+ ASSERT(f*g==Op(1));
+ ASSERT(f/g==Op(1));
+ ASSERT(f%g==Op(0));
// test unary operators
- assert(!a==true);
- assert(!b==false);
- assert(-a==a);
- assert(-b==Op(-5));
+ ASSERT(!a==true);
+ ASSERT(!b==false);
+ ASSERT(-a==a);
+ ASSERT(-b==Op(-5));
// test []
Op h=3;
- assert(h[0]==3);
- assert(h[1]==0);
+ ASSERT(h[0]==3);
+ ASSERT(h[1]==0);
h[0]=2; // set
- assert(h[0]==2);
+ ASSERT(h[0]==2);
h[1]=2; // ignored
- assert(h[0]==2);
- assert(h[1]==0);
+ ASSERT(h[0]==2);
+ ASSERT(h[1]==0);
// test ()
Op i=3;
- assert(i()==3);
- assert(i(1)==4);
- assert(i(1,2)==6);
+ ASSERT(i()==3);
+ ASSERT(i(1)==4);
+ ASSERT(i(1,2)==6);
// plus add some code to check the __str__ fn
- //assert(str(Op(1))=="Op(1)");
- //assert(str(Op(-3))=="Op(-3)");
+ //ASSERT(str(Op(1))=="Op(1)");
+ //ASSERT(str(Op(-3))=="Op(-3)");
// test ++ and --
Op j(100);
@@ -330,36 +332,36 @@ void Op::sanity_check()
{
Op newOp = j++;
int newInt = original++;
- assert(j.i == original);
- assert(newOp.i == newInt);
+ ASSERT(j.i == original);
+ ASSERT(newOp.i == newInt);
}
{
Op newOp = j--;
int newInt = original--;
- assert(j.i == original);
- assert(newOp.i == newInt);
+ ASSERT(j.i == original);
+ ASSERT(newOp.i == newInt);
}
{
Op newOp = ++j;
int newInt = ++original;
- assert(j.i == original);
- assert(newOp.i == newInt);
+ ASSERT(j.i == original);
+ ASSERT(newOp.i == newInt);
}
{
Op newOp = --j;
int newInt = --original;
- assert(j.i == original);
- assert(newOp.i == newInt);
+ ASSERT(j.i == original);
+ ASSERT(newOp.i == newInt);
}
// cast operators
Op k=3;
int check_k = k;
- assert (check_k == 3);
+ ASSERT (check_k == 3);
Op l=4;
double check_l = l;
- assert (check_l == 4);
+ ASSERT (check_l == 4);
}
%}
diff --git a/Examples/test-suite/php/cpp_basic_runme.php b/Examples/test-suite/php/cpp_basic_runme.php
new file mode 100644
index 000000000..6a8522e3e
--- /dev/null
+++ b/Examples/test-suite/php/cpp_basic_runme.php
@@ -0,0 +1,20 @@
+func_ptr = get_func1_ptr();
+check::equal(test_func_ptr($f, 7), 2*7*3, "get_func1_ptr() didn't work");
+$f->func_ptr = get_func2_ptr();
+check::equal(test_func_ptr($f, 7), -7*3, "get_func2_ptr() didn't work");
+
+check::done();
+?>
diff --git a/Examples/test-suite/php/director_pass_by_value_runme.php b/Examples/test-suite/php/director_pass_by_value_runme.php
new file mode 100644
index 000000000..8a8b84d67
--- /dev/null
+++ b/Examples/test-suite/php/director_pass_by_value_runme.php
@@ -0,0 +1,24 @@
+call_virtualMethod(new director_pass_by_value_Derived());
+$ret = $passByVal->getVal();
+if ($ret != 0x12345678) {
+ check::fail("Bad return value, got " . dechex($ret));
+}
+
+check::done();
+?>
diff --git a/Examples/test-suite/php/tests.php b/Examples/test-suite/php/tests.php
index 57c5c4788..d3fd66868 100644
--- a/Examples/test-suite/php/tests.php
+++ b/Examples/test-suite/php/tests.php
@@ -35,8 +35,9 @@ class check {
foreach($_original_functions[internal] as $func) unset($df[$func]);
// Now chop out any get/set accessors
foreach(array_keys($df) as $func)
- if ((GETSET && ereg('_[gs]et$',$func)) || ereg('^new_', $func)
- || ereg('_(alter|get)_newobject$', $func))
+ if ((GETSET && preg_match('/_[gs]et$/', $func)) ||
+ preg_match('/^new_/', $func) ||
+ preg_match('/_(alter|get)_newobject$/', $func))
$extrags[]=$func;
else $extra[]=$func;
// $extra=array_keys($df);
@@ -52,7 +53,8 @@ class check {
if (GETSET) {
$_extra=array();
foreach(check::get_extra_functions(false,1) as $global) {
- if (ereg('^(.*)_[sg]et$',$global,$match)) $_extra[$match[1]]=1;
+ if (preg_match('/^(.*)_[sg]et$/', $global, $match))
+ $_extra[$match[1]] = 1;
}
$extra=array_keys($_extra);
} else {
@@ -61,7 +63,8 @@ class check {
$df=array_flip(array_keys($GLOBALS));
foreach($_original_globals as $func) unset($df[$func]);
// MASK xxxx_LOADED__ variables
- foreach(array_keys($df) as $func) if (ereg('_LOADED__$',$func)) unset($df[$func]);
+ foreach(array_keys($df) as $func)
+ if (preg_match('/_LOADED__$/', $func)) unset($df[$func]);
$extra=array_keys($df);
}
}
@@ -185,7 +188,8 @@ class check {
}
function functionref($a,$type,$message) {
- if (! eregi("^_[a-f0-9]+$type$",$a)) return check::fail($message);
+ if (! preg_match("/^_[a-f0-9]+$type$/i", $a))
+ return check::fail($message);
return TRUE;
}
@@ -196,7 +200,8 @@ class check {
function resource($a,$b,$message) {
$resource=trim(check::var_dump($a));
- if (! eregi("^resource\([0-9]+\) of type \($b\)",$resource)) return check::fail($message);
+ if (! preg_match("/^resource\([0-9]+\) of type \($b\)/i", $resource))
+ return check::fail($message);
return TRUE;
}
diff --git a/Examples/test-suite/preproc_defined.i b/Examples/test-suite/preproc_defined.i
index 0a91bd98a..e1958515d 100644
--- a/Examples/test-suite/preproc_defined.i
+++ b/Examples/test-suite/preproc_defined.i
@@ -102,6 +102,7 @@ ANOTHER_MACRO(int)
void another_macro_checking(void) {
struct Defined d;
d.defined = 10;
+ (void)d;
thing(10);
stuff(10);
bumpf(10);
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index a7993b0b8..bfc5450b0 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -58,6 +58,7 @@ CPP_TEST_CASES += \
primitive_types \
python_abstractbase \
python_append \
+ python_builtin \
python_destructor_exception \
python_director \
python_docstring \
diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py
index ce0aae0eb..af04c8c0e 100644
--- a/Examples/test-suite/python/autodoc_runme.py
+++ b/Examples/test-suite/python/autodoc_runme.py
@@ -15,11 +15,19 @@ def check(got, expected, expected_builtin=None, skip=False):
def is_new_style_class(cls):
return hasattr(cls, "__class__")
+def is_fastproxy(module):
+ return "new_instancemethod" in module
+
if not is_new_style_class(A):
# Missing static methods make this hard to test... skip if -classic is
# used!
sys.exit(0)
+if is_fastproxy(dir()):
+ # Detect when -fastproxy is specified and skip test as it changes the function names making it
+ # hard to test... skip until the number of options are reduced in SWIG-3.1 and autodoc is improved
+ sys.exit(0)
+
# skip builtin check - the autodoc is missing, but it probably should not be
skip = True
diff --git a/Examples/test-suite/python/cpp11_type_aliasing_runme.py b/Examples/test-suite/python/cpp11_type_aliasing_runme.py
new file mode 100644
index 000000000..52cc81d1c
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_type_aliasing_runme.py
@@ -0,0 +1,32 @@
+from cpp11_type_aliasing import *
+
+if get_host_target().bits != 32:
+ raise RuntimeError("get_host_target().bits should return 32")
+
+if mult2(10) != 20:
+ raise RuntimeError("mult2(10) should return 20")
+
+int_ptr = allocate_int()
+inplace_mult2(int_ptr)
+if read_int(int_ptr) != 24:
+ raise RuntimeError("read_int should return 24")
+free_int(int_ptr)
+
+pair = PairSubclass(3, 4)
+if pair.first() != 3:
+ raise RuntimeError("pair.first() should return 3")
+
+if pair.second() != 4:
+ raise RuntimeError("pair.second() should return 4")
+
+if pair.a != 3:
+ raise RuntimeError("pair.a should be 3")
+
+if plus1(5) != 6:
+ raise RuntimeError("plus1(5) should return 6")
+
+if call(mult2_cb, 7) != 14:
+ raise RuntimeError("call(mult2_cb, 7) should return 14")
+
+if call(get_callback(), 7) != 14:
+ raise RuntimeError("call(get_callback(), 7) should return 14")
diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py
index b742de285..1c7705f3e 100644
--- a/Examples/test-suite/python/cpp_static_runme.py
+++ b/Examples/test-suite/python/cpp_static_runme.py
@@ -14,4 +14,5 @@ else:
StaticFunctionTest().static_func_2(1)
StaticFunctionTest().static_func_3(1, 2)
StaticMemberTest.static_int = 10
-assert StaticMemberTest.static_int == 10
+if not StaticMemberTest.static_int == 10:
+ raise RuntimeError("static_int not 10")
diff --git a/Examples/test-suite/python/default_args_c_runme.py b/Examples/test-suite/python/default_args_c_runme.py
new file mode 100644
index 000000000..5985fd75c
--- /dev/null
+++ b/Examples/test-suite/python/default_args_c_runme.py
@@ -0,0 +1,6 @@
+import default_args_c
+
+if default_args_c.foo1() != 1:
+ raise RuntimeError("failed")
+if default_args_c.foo43() != 43:
+ raise RuntimeError("failed")
diff --git a/Examples/test-suite/python/director_pass_by_value_runme.py b/Examples/test-suite/python/director_pass_by_value_runme.py
new file mode 100644
index 000000000..7744db962
--- /dev/null
+++ b/Examples/test-suite/python/director_pass_by_value_runme.py
@@ -0,0 +1,13 @@
+import director_pass_by_value
+
+passByVal = None
+class director_pass_by_value_Derived(director_pass_by_value.DirectorPassByValueAbstractBase):
+ def virtualMethod(self, b):
+ global passByVal
+ passByVal = b
+
+# bug was the passByVal global object was destroyed after the call to virtualMethod had finished.
+director_pass_by_value.Caller().call_virtualMethod(director_pass_by_value_Derived())
+ret = passByVal.getVal();
+if ret != 0x12345678:
+ raise RuntimeError("Bad return value, got " + hex(ret))
diff --git a/Examples/test-suite/python/exception_classname_runme.py b/Examples/test-suite/python/exception_classname_runme.py
index c78f4e68b..9a82c9105 100644
--- a/Examples/test-suite/python/exception_classname_runme.py
+++ b/Examples/test-suite/python/exception_classname_runme.py
@@ -1,4 +1,5 @@
import exception_classname
a = exception_classname.Exception()
-assert a.testfunc() == 42
+if a.testfunc() != 42:
+ raise RuntimeError("Not 42!")
diff --git a/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py
index 6b56ec479..eab7e282a 100644
--- a/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py
+++ b/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py
@@ -8,9 +8,8 @@ if d.bar() != 2:
raise RuntimeError
if bar_getter(b) != 1:
raise RuntimeError
-# Fix reverted in rev 12953
-# if bar_getter(d) != 2:
-# raise RuntimeError
+if bar_getter(d) != 2:
+ raise RuntimeError
b = BaseDefaultInt()
d = DerivedDefaultInt()
@@ -23,8 +22,11 @@ if d2.bar2() != 4:
raise RuntimeError
if bar2_getter(b) != 3:
raise RuntimeError
-# Fix reverted in rev 12953
-# if bar2_getter(d) != 4:
-# raise RuntimeError
-# if bar2_getter(d2) != 4:
-# raise RuntimeError
+# SWIG fix reverted in Subversion rev 12953
+# Testcase has now been modified to mask the problem by providing the default parameter 'int' in:
+# %shared_ptr(Space::BaseDefault)
+# If this is not done then d fails to convert to BaseDefault&
+if bar2_getter(d) != 4:
+ raise RuntimeError
+if bar2_getter(d2) != 4:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/li_std_vector_ptr_runme.py b/Examples/test-suite/python/li_std_vector_ptr_runme.py
index 01c654109..b49cdb4e9 100644
--- a/Examples/test-suite/python/li_std_vector_ptr_runme.py
+++ b/Examples/test-suite/python/li_std_vector_ptr_runme.py
@@ -1,7 +1,38 @@
from li_std_vector_ptr import *
+def check(val1, val2):
+ if val1 != val2:
+ raise RuntimeError("Values are not the same %s %s" % (val1, val2))
ip1 = makeIntPtr(11)
ip2 = makeIntPtr(22)
vi = IntPtrVector((ip1, ip2))
-displayVector(vi)
+check(getValueFromVector(vi, 0), 11)
+check(getValueFromVector(vi, 1), 22)
+
+vA = APtrVector([makeA(33), makeA(34)])
+check(getVectorValueA(vA, 0), 33)
+
+vB = BPtrVector([makeB(133), makeB(134)])
+check(getVectorValueB(vB, 0), 133)
+
+vC = CPtrVector([makeC(1133), makeC(1134)])
+check(getVectorValueC(vC, 0), 1133)
+
+
+vA = [makeA(233), makeA(234)]
+check(getVectorValueA(vA, 0), 233)
+
+vB = [makeB(333), makeB(334)]
+check(getVectorValueB(vB, 0), 333)
+
+vC = [makeC(3333), makeC(3334)]
+check(getVectorValueC(vC, 0), 3333)
+
+# mixed A and B should not be accepted
+vAB = [makeA(999), makeB(999)]
+try:
+ check(getVectorValueA(vAB, 0), 999)
+ raise RuntimeError("missed exception")
+except TypeError:
+ pass
diff --git a/Examples/test-suite/python/operator_overload_runme.py b/Examples/test-suite/python/operator_overload_runme.py
new file mode 100644
index 000000000..cf4277f35
--- /dev/null
+++ b/Examples/test-suite/python/operator_overload_runme.py
@@ -0,0 +1,77 @@
+from operator_overload import *
+
+# first check all the operators are implemented correctly from pure C++ code
+Op_sanity_check()
+
+pop = Op(6)/Op(3)
+
+# test routine:
+a=Op()
+b=Op(5)
+c=Op(b) # copy construct
+d=Op(2)
+dd=d # assignment operator
+
+# test equality
+if not a!=b:
+ raise RuntimeError("a!=b")
+if not b==c:
+ raise RuntimeError("b==c")
+if not a!=d:
+ raise RuntimeError("a!=d")
+if not d==dd:
+ raise RuntimeError("d==dd")
+
+# test <
+if not a=c:
+ raise RuntimeError("b>=c")
+if not b>d:
+ raise RuntimeError("b>d")
+if not b>=d:
+ raise RuntimeError("b>=d")
+
+# test +=
+e=Op(3)
+e+=d
+if not e==b:
+ raise RuntimeError("e==b (%s==%s)" % (e.i, b.i))
+e-=c
+if not e==a:
+ raise RuntimeError("e==a")
+e=Op(1)
+e*=b
+if not e==c:
+ raise RuntimeError("e==c")
+e/=d
+if not e==d:
+ raise RuntimeError("e==d")
+e%=c;
+if not e==d:
+ raise RuntimeError("e==d")
+
+# test +
+f=Op(1)
+g=Op(1)
+if not f+g==Op(2):
+ raise RuntimeError("f+g==Op(2)")
+if not f-g==Op(0):
+ raise RuntimeError("f-g==Op(0)")
+if not f*g==Op(1):
+ raise RuntimeError("f*g==Op(1)")
+if not f/g==Op(1):
+ raise RuntimeError("f/g==Op(1)")
+if not f%g==Op(0):
+ raise RuntimeError("f%g==Op(0)")
+
+# test unary operators
+if not -a==a:
+ raise RuntimeError("-a==a")
+if not -b==Op(-5):
+ raise RuntimeError("-b==Op(-5)")
+
diff --git a/Examples/test-suite/python/operbool_runme.py b/Examples/test-suite/python/operbool_runme.py
index 708dea786..cdef85abc 100644
--- a/Examples/test-suite/python/operbool_runme.py
+++ b/Examples/test-suite/python/operbool_runme.py
@@ -1,3 +1,4 @@
#!/usr/bin/env python
import operbool
-assert not operbool.Test()
+if operbool.Test():
+ raise RuntimeError("operbool failed")
diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py
index b4a20f085..4fdc79935 100644
--- a/Examples/test-suite/python/python_abstractbase_runme3.py
+++ b/Examples/test-suite/python/python_abstractbase_runme3.py
@@ -6,6 +6,10 @@ from collections import *
if is_python_builtin():
exit(0)
+# Python abc is only turned on when -py3 option is passed to SWIG
+if not is_swig_py3:
+ exit(0)
+
assert issubclass(Mapii, MutableMapping)
assert issubclass(Multimapii, MutableMapping)
assert issubclass(IntSet, MutableSet)
diff --git a/Examples/test-suite/python/python_builtin_runme.py b/Examples/test-suite/python/python_builtin_runme.py
new file mode 100644
index 000000000..70990cbfd
--- /dev/null
+++ b/Examples/test-suite/python/python_builtin_runme.py
@@ -0,0 +1,81 @@
+from python_builtin import *
+
+if is_python_builtin():
+ # Test 0 for default tp_hash
+ vs = ValueStruct(1234)
+ h = hash(vs)
+ d = dict()
+ d[h] = "hi"
+ if h not in d:
+ raise RuntimeError("h should be in d")
+ h2 = hash(ValueStruct.inout(vs))
+ if h != h2:
+ raise RuntimeError("default tp_hash not working")
+
+ # Test 1 for tp_hash
+ if hash(SimpleValue(222)) != 222:
+ raise RuntimeError("tp_hash not working")
+
+ # Test 2 for tp_hash
+ try:
+ # Was incorrectly raising: SystemError: error return without exception set
+ h = hash(BadHashFunctionReturnType())
+ raise RuntimeError("Missing TypeError")
+ except TypeError:
+ pass
+
+ # Test 3 for tp_hash
+ passed = False
+ try:
+ h = hash(ExceptionHashFunction())
+ except RuntimeError, e:
+ passed = str(e).find("oops") != -1
+ pass
+
+ if not passed:
+ raise RuntimeError("did not catch exception in hash()")
+
+ # Test 4 for tp_dealloc (which is handled differently to other slots in the SWIG source)
+ d = Dealloc1()
+ if cvar.Dealloc1CalledCount != 0:
+ raise RuntimeError("count should be 0")
+ del d
+ if cvar.Dealloc1CalledCount != 1:
+ raise RuntimeError("count should be 1")
+
+ d = Dealloc2()
+ if cvar.Dealloc2CalledCount != 0:
+ raise RuntimeError("count should be 0")
+ del d
+ if cvar.Dealloc2CalledCount != 1:
+ raise RuntimeError("count should be 1")
+
+ d = Dealloc3()
+ if cvar.Dealloc3CalledCount != 0:
+ raise RuntimeError("count should be 0")
+ del d
+ if cvar.Dealloc3CalledCount != 1:
+ raise RuntimeError("count should be 1")
+
+ # Test 5 for python:compare feature
+ m10 = MyClass(10)
+ m20 = MyClass(20)
+ m15 = MyClass(15)
+
+ if not m10 < m15:
+ raise RuntimeError("m10 < m15")
+ if not m10 < m20:
+ raise RuntimeError("m10 < m20")
+ if not m15 < m20:
+ raise RuntimeError("m15 < m20")
+
+ if m10 > m15:
+ raise RuntimeError("m10 > m15")
+ if m10 > m20:
+ raise RuntimeError("m10 > m20")
+ if m15 > m20:
+ raise RuntimeError("m15 > m20")
+
+ if MyClass.less_than_counts != 6:
+ raise RuntimeError("python:compare feature not working")
+
diff --git a/Examples/test-suite/python/python_destructor_exception_runme.py b/Examples/test-suite/python/python_destructor_exception_runme.py
index 671eff3cc..ee71ab33b 100644
--- a/Examples/test-suite/python/python_destructor_exception_runme.py
+++ b/Examples/test-suite/python/python_destructor_exception_runme.py
@@ -26,8 +26,10 @@ def test1():
sys.stderr.flush()
sys.stderr = stderr_saved
- assert attributeErrorOccurred
- assert buffer.getvalue().count("I am the ClassWithThrowingDestructor dtor doing bad things") >= 1
+ if not attributeErrorOccurred:
+ raise RuntimeError("attributeErrorOccurred failed")
+ if not buffer.getvalue().count("I am the ClassWithThrowingDestructor dtor doing bad things") >= 1:
+ raise RuntimeError("ClassWithThrowingDestructor dtor doing bad things failed")
class VectorHolder(object):
def __init__(self, v):
diff --git a/Examples/test-suite/python/template_default_arg_overloaded_extend_runme.py b/Examples/test-suite/python/template_default_arg_overloaded_extend_runme.py
new file mode 100644
index 000000000..1f71066cb
--- /dev/null
+++ b/Examples/test-suite/python/template_default_arg_overloaded_extend_runme.py
@@ -0,0 +1,20 @@
+from template_default_arg_overloaded_extend import *
+
+def check(flag):
+ if not flag:
+ raise RuntimeError("failed")
+
+rs = ResultSet()
+
+check(rs.go_get_method(0, SearchPoint()) == -1)
+check(rs.go_get_method(0, SearchPoint(), 100) == 100)
+
+check(rs.go_get_template(0, SearchPoint()) == -2)
+check(rs.go_get_template(0, SearchPoint(), 100) == 100)
+
+check(rs.over() == "over(int)")
+check(rs.over(10) == "over(int)")
+check(rs.over(SearchPoint()) == "over(giai2::SearchPoint, int)")
+check(rs.over(SearchPoint(), 10) == "over(giai2::SearchPoint, int)")
+check(rs.over(True, SearchPoint()) == "over(bool, gaia2::SearchPoint, int)")
+check(rs.over(True, SearchPoint(), 10) == "over(bool, gaia2::SearchPoint, int)")
diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py
index 3ce98bcdb..fa9c51437 100644
--- a/Examples/test-suite/python/unicode_strings_runme.py
+++ b/Examples/test-suite/python/unicode_strings_runme.py
@@ -13,11 +13,15 @@ if sys.version_info[0:2] >= (3, 1):
if unicode_strings.non_utf8_std_string() != test_string:
raise ValueError('Test comparison mismatch')
+def check(s1, s2):
+ if s1 != s2:
+ raise RuntimeError("{} != {}".format(s1, s2))
+
# Testing SWIG_PYTHON_2_UNICODE flag which allows unicode strings to be passed to C
if sys.version_info[0:2] < (3, 0):
- assert unicode_strings.charstring("hello1") == "hello1"
- assert unicode_strings.charstring(str(u"hello2")) == "hello2"
- assert unicode_strings.charstring(u"hello3") == "hello3"
- assert unicode_strings.charstring(unicode("hello4")) == "hello4"
+ check(unicode_strings.charstring("hello1"), "hello1")
+ check(unicode_strings.charstring(str(u"hello2")), "hello2")
+ check(unicode_strings.charstring(u"hello3"), "hello3")
+ check(unicode_strings.charstring(unicode("hello4")), "hello4")
unicode_strings.charstring(u"hell\xb05")
unicode_strings.charstring(u"hell\u00f66")
diff --git a/Examples/test-suite/python_abstractbase.i b/Examples/test-suite/python_abstractbase.i
index 65f3d9931..2146e758e 100644
--- a/Examples/test-suite/python_abstractbase.i
+++ b/Examples/test-suite/python_abstractbase.i
@@ -24,3 +24,9 @@ bool is_python_builtin() { return true; }
bool is_python_builtin() { return false; }
#endif
%}
+
+#ifdef SWIGPYTHON_PY3 // set when using -py3
+#define is_swig_py3 1
+#else
+#define is_swig_py3 0
+#endif
diff --git a/Examples/test-suite/python_builtin.i b/Examples/test-suite/python_builtin.i
new file mode 100644
index 000000000..e2c453d54
--- /dev/null
+++ b/Examples/test-suite/python_builtin.i
@@ -0,0 +1,138 @@
+// Test customizing slots when using the -builtin option
+
+%module python_builtin
+
+%inline %{
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+%}
+
+// Test 0 for default tp_hash
+%inline %{
+struct ValueStruct {
+ int value;
+ ValueStruct(int value) : value(value) {}
+ static ValueStruct *inout(ValueStruct *v) {
+ return v;
+ }
+};
+%}
+
+// Test 1 for tp_hash
+#if defined(SWIGPYTHON_BUILTIN)
+%feature("python:tp_hash") SimpleValue "SimpleValueHashFunction"
+#endif
+
+%inline %{
+struct SimpleValue {
+ int value;
+ SimpleValue(int value) : value(value) {}
+};
+%}
+
+%{
+#if PY_VERSION_HEX >= 0x03020000
+Py_hash_t SimpleValueHashFunction(PyObject *v)
+#else
+long SimpleValueHashFunction(PyObject *v)
+#endif
+{
+ SwigPyObject *sobj = (SwigPyObject *) v;
+ SimpleValue *p = (SimpleValue *)sobj->ptr;
+ return p->value;
+}
+hashfunc test_hashfunc_cast() {
+ return SimpleValueHashFunction;
+}
+%}
+
+// Test 2 for tp_hash
+#if defined(SWIGPYTHON_BUILTIN)
+%feature("python:slot", "tp_hash", functype="hashfunc") BadHashFunctionReturnType::bad_hash_function;
+#endif
+
+%inline %{
+struct BadHashFunctionReturnType {
+ static const char * bad_hash_function() {
+ return "bad hash function";
+ }
+};
+%}
+
+// Test 3 for tp_hash
+#if defined(SWIGPYTHON_BUILTIN)
+%feature("python:slot", "tp_hash", functype="hashfunc") ExceptionHashFunction::exception_hash_function;
+#endif
+
+%catches(const char *) exception_hash_function;
+
+%inline %{
+#if PY_VERSION_HEX < 0x03020000
+ #define Py_hash_t long
+#endif
+struct ExceptionHashFunction {
+ static Py_hash_t exception_hash_function() {
+ throw "oops";
+ }
+};
+%}
+
+// Test 4 for tp_dealloc (which is handled differently to other slots in the SWIG source)
+#if defined(SWIGPYTHON_BUILTIN)
+%feature("python:tp_dealloc") Dealloc1 "Dealloc1Destroyer"
+%feature("python:tp_dealloc") Dealloc2 "Dealloc2Destroyer"
+%feature("python:slot", "tp_dealloc", functype="destructor") Dealloc3::Destroyer;
+#endif
+
+%inline %{
+static int Dealloc1CalledCount = 0;
+static int Dealloc2CalledCount = 0;
+static int Dealloc3CalledCount = 0;
+
+struct Dealloc1 {
+};
+struct Dealloc2 {
+ ~Dealloc2() {}
+};
+struct Dealloc3 {
+ void Destroyer() {
+ Dealloc3CalledCount++;
+ delete this;
+ }
+};
+%}
+
+%{
+void Dealloc1Destroyer(PyObject *v) {
+ SwigPyObject *sobj = (SwigPyObject *) v;
+ Dealloc1 *p = (Dealloc1 *)sobj->ptr;
+ delete p;
+ Dealloc1CalledCount++;
+}
+void Dealloc2Destroyer(PyObject *v) {
+ SwigPyObject *sobj = (SwigPyObject *) v;
+ Dealloc2 *p = (Dealloc2 *)sobj->ptr;
+ delete p;
+ Dealloc2CalledCount++;
+}
+%}
+
+// Test 5 for python:compare feature
+%feature("python:compare", "Py_LT") MyClass::lessThan;
+
+%inline %{
+ class MyClass {
+ public:
+ MyClass(int val = 0) : val(val) {}
+ bool lessThan(const MyClass& other) const {
+ less_than_counts++;
+ return val < other.val;
+ }
+ int val;
+ static int less_than_counts;
+ };
+ int MyClass::less_than_counts = 0;
+%}
diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in
index 312834a51..bc12ba671 100644
--- a/Examples/test-suite/r/Makefile.in
+++ b/Examples/test-suite/r/Makefile.in
@@ -5,7 +5,8 @@
LANGUAGE = r
SCRIPTSUFFIX = _runme.R
WRAPSUFFIX = .R
-RUNR = R CMD BATCH --no-save --no-restore '--args $(SCRIPTDIR)'
+R_OPT = --quiet --no-save --no-restore
+RUNR = R CMD BATCH $(R_OPT) '--args $(SCRIPTDIR)'
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -51,18 +52,17 @@ include $(srcdir)/../common.mk
# check for syntactic correctness
run_testcase = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
- env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) || (cat $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)out ; false); \
else \
- $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$*$(WRAPSUFFIX); \
+ $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$*$(WRAPSUFFIX) || (cat ./$(SCRIPTPREFIX)$*$(WRAPSUFFIX)out ; false); \
fi
run_multitestcase = \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ]; then \
- env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \
- $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX); \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) || (cat $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX)out ; false); \
else \
- $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX); \
+ $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX) || (cat ./$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX)out ; false); \
fi; \
done
# Clean
diff --git a/Examples/test-suite/r/li_std_vector_runme.R b/Examples/test-suite/r/li_std_vector_runme.R
index e169310c2..bd02d840a 100644
--- a/Examples/test-suite/r/li_std_vector_runme.R
+++ b/Examples/test-suite/r/li_std_vector_runme.R
@@ -9,6 +9,10 @@ testvec <- c(1, 2, 3)
unittest(half(testvec), testvec/2)
unittest(average(testvec), mean(testvec))
+## string vector test
+vlen <- 13
+stringvec <- paste(letters[1:vlen], as.character(rnorm(vlen)))
+unittest(rev(stringvec), RevStringVec(stringvec))
q(save="no")
diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in
index 847c95919..d94ac7061 100644
--- a/Examples/test-suite/ruby/Makefile.in
+++ b/Examples/test-suite/ruby/Makefile.in
@@ -30,7 +30,8 @@ CPP_TEST_CASES = \
# stl_new
C_TEST_CASES += \
- li_cstring
+ li_cstring \
+ ruby_manual_proxy \
include $(srcdir)/../common.mk
diff --git a/Examples/test-suite/ruby/ruby_manual_proxy_runme.rb b/Examples/test-suite/ruby/ruby_manual_proxy_runme.rb
new file mode 100644
index 000000000..c1cee2d13
--- /dev/null
+++ b/Examples/test-suite/ruby/ruby_manual_proxy_runme.rb
@@ -0,0 +1,49 @@
+#!/usr/bin/env ruby
+#
+# The Subversion bindings use this manually written proxy class approach
+# to the Ruby bindings. Note that in C the struct svn_fs_t is an
+# opaque pointer and the Ruby FileSystem proxy class is hand written around it.
+# This testcase tests this and the C close function and subsequent error
+# handling.
+
+require 'swig_assert'
+require 'ruby_manual_proxy'
+
+module Svn
+ module Fs
+ module_function
+ def create(path)
+ f = Ruby_manual_proxy::svn_fs_create(path)
+ return f
+ end
+
+ FileSystem = SWIG::TYPE_p_svn_fs_t
+ class FileSystem
+ class << self
+ def create(*args)
+ Fs.create(*args)
+ end
+ end
+ def path
+ Ruby_manual_proxy::svn_fs_path(self)
+ end
+ end
+ end
+end
+
+f = Svn::Fs::FileSystem.create("/tmp/myfile")
+path = f.path
+f.close
+begin
+ # regression in swig-3.0.8 meant ObjectPreviouslyDeleted error was thrown instead
+ path = f.path
+ raise RuntimeError.new("IOError (1) not thrown")
+rescue IOError
+end
+
+file = nil
+begin
+ path = Ruby_manual_proxy::svn_fs_path(file)
+ raise RuntimeError.new("IOError (2) not thrown")
+rescue IOError
+end
diff --git a/Examples/test-suite/ruby_manual_proxy.i b/Examples/test-suite/ruby_manual_proxy.i
new file mode 100644
index 000000000..2cb154e6a
--- /dev/null
+++ b/Examples/test-suite/ruby_manual_proxy.i
@@ -0,0 +1,66 @@
+%module ruby_manual_proxy
+
+
+%typemap(in, numinputs=0) SWIGTYPE ** ($*1_ltype temp) "$1 = &temp;";
+
+%typemap(argout) SWIGTYPE **OUTPARAM {
+ $result = SWIG_Ruby_AppendOutput($result, SWIG_NewPointerObj(*$1, $*1_descriptor, 0));
+}
+
+%apply SWIGTYPE **OUTPARAM {
+ svn_fs_t **
+};
+
+%typemap(check) svn_fs_t * {
+ if (!$1) {
+ svn_swig_rb_raise_svn_fs_already_close();
+ }
+}
+
+%{
+typedef struct svn_fs_t {
+ char path[256];
+} svn_fs_t;
+
+void svn_fs_create(svn_fs_t **fs_p, const char *path) {
+ svn_fs_t *fs = (svn_fs_t *)malloc(sizeof(svn_fs_t));
+ strncpy(fs->path, path, 256);
+ *fs_p = fs;
+}
+const char *svn_fs_path(svn_fs_t *fs) {
+ return fs->path;
+}
+%}
+
+typedef struct svn_fs_t svn_fs_t;
+void svn_fs_create(svn_fs_t **fs_p, const char *path);
+const char *svn_fs_path(svn_fs_t *fs);
+
+%{
+static void svn_swig_rb_raise_svn_fs_already_close(void) {
+ rb_raise(rb_eIOError, "already closed");
+}
+
+static VALUE svn_fs_swig_rb_close(VALUE self) {
+ if (!DATA_PTR(self)) {
+ svn_swig_rb_raise_svn_fs_already_close();
+ }
+
+ DATA_PTR(self) = NULL;
+
+ return Qnil;
+}
+
+static VALUE svn_fs_swig_rb_closed(VALUE self) {
+ return DATA_PTR(self) ? Qfalse : Qtrue;
+}
+%}
+
+%insert("init") %{
+ {
+ VALUE cSvnfs;
+ cSvnfs = rb_const_get(_mSWIG, rb_intern("TYPE_p_svn_fs_t"));
+ rb_define_method(cSvnfs, "close",
+ VALUEFUNC(svn_fs_swig_rb_close), 0);
+ }
+%}
diff --git a/Examples/test-suite/scilab/Makefile.in b/Examples/test-suite/scilab/Makefile.in
index 9ddd8f1aa..483ed2439 100644
--- a/Examples/test-suite/scilab/Makefile.in
+++ b/Examples/test-suite/scilab/Makefile.in
@@ -13,7 +13,6 @@ top_builddir = ../@top_builddir@
C_TEST_CASES += \
scilab_consts \
- scilab_enums \
scilab_identifier_name \
CPP_TEST_CASES += \
@@ -21,6 +20,7 @@ CPP_TEST_CASES += \
primitive_types \
scilab_li_matrix \
scilab_multivalue \
+ scilab_enums \
scilab_pointer_conversion_functions \
CPP_STD_TEST_CASES += \
diff --git a/Examples/test-suite/scilab/scilab_enums_runme.sci b/Examples/test-suite/scilab/scilab_enums_runme.sci
index 3e9fb7ae0..2776bee1e 100644
--- a/Examples/test-suite/scilab/scilab_enums_runme.sci
+++ b/Examples/test-suite/scilab/scilab_enums_runme.sci
@@ -24,4 +24,13 @@ checkEnum(TYPEDEF_ENUM_1_2, 22);
checkEnum(TYPEDEF_ENUM_2_1, 31);
checkEnum(TYPEDEF_ENUM_2_2, 32);
+checkEnum(ENUM_REF_1, 1);
+checkEnum(ENUM_REF_2, 10);
+
+checkEnum(clsEnum_CLS_ENUM_1, 100);
+checkEnum(clsEnum_CLS_ENUM_2, 101);
+
+checkEnum(clsEnum_CLS_ENUM_REF_1, 101);
+checkEnum(clsEnum_CLS_ENUM_REF_2, 110);
+
exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab_enums.i b/Examples/test-suite/scilab_enums.i
index 32d5a34de..9c2e393e0 100644
--- a/Examples/test-suite/scilab_enums.i
+++ b/Examples/test-suite/scilab_enums.i
@@ -35,4 +35,21 @@ typedef enum TYPEDEF_ENUM_2 {
TYPEDEF_ENUM_2_2 = 32
} TYPEDEF_ENUM_2;
+enum ENUM_REF {
+ ENUM_REF_1 = 1,
+ ENUM_REF_2 = ENUM_REF_1 + 9
+};
+
+class clsEnum {
+public:
+ enum CLS_ENUM {
+ CLS_ENUM_1 = 100,
+ CLS_ENUM_2 = 101
+ };
+ enum CLS_ENUM_REF {
+ CLS_ENUM_REF_1 = 101,
+ CLS_ENUM_REF_2 = CLS_ENUM_REF_1 + 9
+ };
+};
+
%}
diff --git a/Examples/test-suite/smart_pointer_ignore.i b/Examples/test-suite/smart_pointer_ignore.i
new file mode 100644
index 000000000..f369de782
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_ignore.i
@@ -0,0 +1,33 @@
+%module smart_pointer_ignore
+
+
+%ignore Derived;
+
+%inline %{
+class Base {
+ public:
+ void base() {}
+};
+
+class Derived : public Base {
+ public:
+ void derived() {}
+};
+
+template
+class Ptr {
+public:
+ Ptr(T *t) : ptr(t) {}
+ T * operator->() const { return ptr; }
+private:
+ T *ptr;
+};
+%}
+
+%template(DerivedPtr) Ptr;
+
+%inline %{
+Ptr makeDerived() {
+ return Ptr(new Derived());
+}
+%}
diff --git a/Examples/test-suite/template_default_arg_overloaded_extend.i b/Examples/test-suite/template_default_arg_overloaded_extend.i
new file mode 100644
index 000000000..67d66c2fa
--- /dev/null
+++ b/Examples/test-suite/template_default_arg_overloaded_extend.i
@@ -0,0 +1,44 @@
+%module template_default_arg_overloaded_extend
+
+%inline %{
+namespace gaia2 {
+
+struct Filter {};
+struct SearchPoint {};
+struct DataSet {};
+
+template
+class BaseSearchSpace {};
+
+template
+class BaseResultSet {
+public:
+ const char *over(int i = 0) {
+ return "over(int)";
+ }
+};
+}
+%}
+
+// Specialized template extend
+%extend gaia2::BaseResultSet {
+ int go_get_method(int n, gaia2::SearchPoint, int offset = -1) {
+ return offset;
+ }
+ const char *over(gaia2::SearchPoint, int x = 0) {
+ return "over(giai2::SearchPoint, int)";
+ }
+}
+
+// Generic extend for all template instantiations
+%extend gaia2::BaseResultSet {
+ int go_get_template(int n, SearchPointType sss, int offset = -2) {
+ return offset;
+ }
+ const char *over(bool b, SearchPointType, int x = 0) {
+ return "over(bool, SearchPointType, int)";
+ }
+}
+
+%template(ResultSet) gaia2::BaseResultSet;
+
diff --git a/Examples/test-suite/traits.i b/Examples/test-suite/traits.i
deleted file mode 100644
index 0d25a60d9..000000000
--- a/Examples/test-suite/traits.i
+++ /dev/null
@@ -1,6 +0,0 @@
-%module traits
-
-%include typemaps/traits.swg
-
-
-%fragment("Traits");
diff --git a/Examples/test-suite/typedef_struct.i b/Examples/test-suite/typedef_struct.i
index 97456d9a6..185e81105 100644
--- a/Examples/test-suite/typedef_struct.i
+++ b/Examples/test-suite/typedef_struct.i
@@ -1,6 +1,13 @@
%module typedef_struct
%inline %{
+
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+/* for anonymous enums */
+/* dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] */
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif
+
typedef struct {
int numpoints;
} LineObj;
diff --git a/Examples/test-suite/typemap_manyargs.i b/Examples/test-suite/typemap_manyargs.i
index d26e97714..426fcca1b 100644
--- a/Examples/test-suite/typemap_manyargs.i
+++ b/Examples/test-suite/typemap_manyargs.i
@@ -13,6 +13,7 @@
$9 = &temp9;
$10 = &temp10; // the code generated for this was arg20 = &temp10; and arg20 does not exist.
int $10_ptr = 0; // Was arg20_ptr
+ (void)$10_ptr;
}
%inline %{
diff --git a/Examples/test-suite/typemap_subst.i b/Examples/test-suite/typemap_subst.i
index 91ac62020..946384840 100644
--- a/Examples/test-suite/typemap_subst.i
+++ b/Examples/test-suite/typemap_subst.i
@@ -27,12 +27,14 @@
(void)c;
(void)d;
(void)e;
+ (void)f;
}
{ /* Test locals */
basetemp.member = 0;
startemp = &basetemp;
temp = &startemp;
amptemp = &temp;
+ (void)amptemp;
}
{ /* Test descriptors */
void *desc = $descriptor;
diff --git a/Lib/csharp/boost_intrusive_ptr.i b/Lib/csharp/boost_intrusive_ptr.i
index 1cc5efda7..d0a048d16 100644
--- a/Lib/csharp/boost_intrusive_ptr.i
+++ b/Lib/csharp/boost_intrusive_ptr.i
@@ -1,511 +1,510 @@
-// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the
-// visibility of the constructor and getCPtr method if desired to public if using multiple modules.
-#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS
-#define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(internal, internal, CONST, TYPE)
-#endif
-#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP
-#define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(internal, internal, CONST, TYPE)
-#endif
-
-%include
-
-// Language specific macro implementing all the customisations for handling the smart pointer
-%define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
-
-// %naturalvar is as documented for member variables
-%naturalvar TYPE;
-%naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
-
-// destructor wrapper customisation
-%feature("unref") TYPE "(void)arg1; delete smartarg1;"
-
-// Typemap customisations...
-
-%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
- // plain value
- argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
- if (!argp) {
- SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
- return $null;
- }
- $1 = *argp;
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{
- //plain value(out)
- $1_ltype* resultp = new $1_ltype(($1_ltype &)$1);
- intrusive_ptr_add_ref(resultp);
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >());
-%}
-
-%typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
- // plain pointer
- smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
- $1 = (TYPE *)(smartarg ? smartarg->get() : 0);
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{
- //plain pointer(out)
- #if ($owner)
- if ($1) {
- intrusive_ptr_add_ref($1);
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
- #else
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
- #endif
-%}
-
-%typemap(in, canthrow=1) CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
- // plain reference
- $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
- if(!$1) {
- SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
- return $null;
- }
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{
- //plain reference(out)
- #if ($owner)
- if ($1) {
- intrusive_ptr_add_ref($1);
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
- #else
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
- #endif
-%}
-
-%typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
- // plain pointer by reference
- temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
- $1 = &temp;
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{
- // plain pointer by reference(out)
- #if ($owner)
- if (*$1) {
- intrusive_ptr_add_ref(*$1);
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
- #else
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0);
- #endif
-%}
-
-%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
- // intrusive_ptr by value
- smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
- if (smartarg) {
- $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
- }
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
- if ($1) {
- intrusive_ptr_add_ref($1.get());
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1.get(), SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
-%}
-
-%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
- // shared_ptr by value
- smartarg = *($&1_ltype*)&$input;
- if (smartarg) $1 = *smartarg;
-%}
-%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
- *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
-%}
-
-%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
- // intrusive_ptr by reference
- if ( $input ) {
- smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
- temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
- $1 = &temp;
- } else {
- $1 = &tempnull;
- }
-%}
-%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
- delete &($1);
- if ($self) {
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
- $1 = *temp;
- }
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
- if (*$1) {
- intrusive_ptr_add_ref($1->get());
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
-%}
-
-%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
- // intrusive_ptr by pointer
- if ( $input ) {
- smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
- temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
- $1 = &temp;
- } else {
- $1 = &tempnull;
- }
-%}
-%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
- delete $1;
- if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
- if ($1 && *$1) {
- intrusive_ptr_add_ref($1->get());
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
- if ($owner) delete $1;
-%}
-
-%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
- // intrusive_ptr by pointer reference
- smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
- if ($input) {
- temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
- }
- tempp = &temp;
- $1 = &tempp;
-%}
-%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
- if ($self) $1 = *$input;
-%}
-%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
- if (*$1 && **$1) {
- intrusive_ptr_add_ref((*$1)->get());
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >());
- } else {
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
- }
-%}
-
-// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
-%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
-#error "typemaps for $1_type not available"
-%}
-%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
-#error "typemaps for $1_type not available"
-%}
-
-
-%typemap (ctype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
- SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "void *"
-%typemap (imtype, out="global::System.IntPtr") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
- SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "global::System.Runtime.InteropServices.HandleRef"
-%typemap (cstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
- SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)"
-%typemap(csin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
- SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
- SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)"
-
-%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
- get {
- $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
- return ret;
- } %}
-%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >& %{
- get {
- $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
- return ret;
- } %}
-%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >* %{
- get {
- $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
- return ret;
- } %}
-
-
-%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
- $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
- $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
- global::System.IntPtr cPtr = $imcall;
- $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
- return ret;
- }
-
-// Base proxy classes
-%typemap(csbody) TYPE %{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- private bool swigCMemOwnBase;
-
- PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
- swigCMemOwnBase = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-%}
-
-// Derived proxy classes
-%typemap(csbody_derived) TYPE %{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- private bool swigCMemOwnDerived;
-
- PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
- swigCMemOwnDerived = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-%}
-
-%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
- lock(this) {
- if (swigCPtr.Handle != global::System.IntPtr.Zero) {
- if (swigCMemOwnBase) {
- swigCMemOwnBase = false;
- $imcall;
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- global::System.GC.SuppressFinalize(this);
- }
- }
-
-%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
- lock(this) {
- if (swigCPtr.Handle != global::System.IntPtr.Zero) {
- if (swigCMemOwnDerived) {
- swigCMemOwnDerived = false;
- $imcall;
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- global::System.GC.SuppressFinalize(this);
- base.Dispose();
- }
- }
-
-// CONST version needed ???? also for C#
-%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
-%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
-
-
-%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
-%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
-%enddef
-
-
-/////////////////////////////////////////////////////////////////////
-
-
-%include
-
-%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
-
-%naturalvar TYPE;
-%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
-
-// destructor mods
-%feature("unref") TYPE "(void)arg1; delete smartarg1;"
-
-
-// plain value
-%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{
- argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
- if (!argp) {
- SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
- return $null;
- }
- $1 = *argp; %}
-%typemap(out) CONST TYPE
-%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %}
-
-// plain pointer
-%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
- smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
- $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %}
-%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{
- *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
-%}
-
-// plain reference
-%typemap(in, canthrow=1) CONST TYPE & %{
- $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
- if (!$1) {
- SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
- return $null;
- } %}
-%typemap(out, fragment="SWIG_null_deleter") CONST TYPE &
-%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
-
-// plain pointer by reference
-%typemap(in) TYPE *CONST& ($*1_ltype temp = 0)
-%{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
- $1 = &temp; %}
-%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST&
-%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
-
-%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
- // shared_ptr by value
- smartarg = *($&1_ltype*)&$input;
- if (smartarg) $1 = *smartarg;
-%}
-%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
- *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
-%}
-
-// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
-%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
-#error "typemaps for $1_type not available"
-%}
-%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
-#error "typemaps for $1_type not available"
-%}
-
-
-%typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *"
-%typemap (imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *"
-%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE)"
-%typemap (csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE).getCPtr($csinput)"
-%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
- global::System.IntPtr cPtr = $imcall;
- return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
- }
-
-%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
- return new $typemap(cstype, TYPE)($imcall, true);
- }
-%typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
- return new $typemap(cstype, TYPE)($imcall, true);
- }
-%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
- global::System.IntPtr cPtr = $imcall;
- return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
- }
-%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
- global::System.IntPtr cPtr = $imcall;
- return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
- }
-
-// Base proxy classes
-%typemap(csbody) TYPE %{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- private bool swigCMemOwnBase;
-
- PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
- swigCMemOwnBase = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-%}
-
-// Derived proxy classes
-%typemap(csbody_derived) TYPE %{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- private bool swigCMemOwnDerived;
-
- PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
- swigCMemOwnDerived = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-%}
-
-%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
- lock(this) {
- if (swigCPtr.Handle != global::System.IntPtr.Zero) {
- if (swigCMemOwnBase) {
- swigCMemOwnBase = false;
- $imcall;
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- global::System.GC.SuppressFinalize(this);
- }
- }
-
-%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
- lock(this) {
- if (swigCPtr.Handle != global::System.IntPtr.Zero) {
- if (swigCMemOwnDerived) {
- swigCMemOwnDerived = false;
- $imcall;
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- global::System.GC.SuppressFinalize(this);
- base.Dispose();
- }
- }
-
-
-// CONST version needed ???? also for C#
-%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
-%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
-
-
-%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
-%enddef
-
+// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the
+// visibility of the constructor and getCPtr method if desired to public if using multiple modules.
+#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS
+#define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(internal, internal, CONST, TYPE)
+#endif
+#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP
+#define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(internal, internal, CONST, TYPE)
+#endif
+
+%include
+
+// Language specific macro implementing all the customisations for handling the smart pointer
+%define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
+
+// %naturalvar is as documented for member variables
+%naturalvar TYPE;
+%naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
+
+// destructor wrapper customisation
+%feature("unref") TYPE "(void)arg1; delete smartarg1;"
+
+// Typemap customisations...
+
+%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{
+ // plain value
+ argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
+ if (!argp) {
+ SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
+ return $null;
+ }
+ $1 = *argp;
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{
+ //plain value(out)
+ $1_ltype* resultp = new $1_ltype(($1_ltype &)$1);
+ intrusive_ptr_add_ref(resultp);
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >());
+%}
+
+%typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
+ // plain pointer
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
+ $1 = (TYPE *)(smartarg ? smartarg->get() : 0);
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{
+ //plain pointer(out)
+ #if ($owner)
+ if ($1) {
+ intrusive_ptr_add_ref($1);
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+ #else
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
+ #endif
+%}
+
+%typemap(in, canthrow=1) CONST TYPE & %{
+ // plain reference
+ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
+ if(!$1) {
+ SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
+ return $null;
+ }
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{
+ //plain reference(out)
+ #if ($owner)
+ if ($1) {
+ intrusive_ptr_add_ref($1);
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+ #else
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
+ #endif
+%}
+
+%typemap(in) TYPE *CONST& ($*1_ltype temp = 0) %{
+ // plain pointer by reference
+ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
+ $1 = &temp;
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{
+ // plain pointer by reference(out)
+ #if ($owner)
+ if (*$1) {
+ intrusive_ptr_add_ref(*$1);
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+ #else
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0);
+ #endif
+%}
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
+ // intrusive_ptr by value
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
+ if (smartarg) {
+ $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
+ }
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
+ if ($1) {
+ intrusive_ptr_add_ref($1.get());
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1.get(), SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+%}
+
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
+ // shared_ptr by value
+ smartarg = *($&1_ltype*)&$input;
+ if (smartarg) $1 = *smartarg;
+%}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
+ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
+%}
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
+ // intrusive_ptr by reference
+ if ( $input ) {
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
+ temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
+ $1 = &temp;
+ } else {
+ $1 = &tempnull;
+ }
+%}
+%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
+ delete &($1);
+ if ($self) {
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
+ $1 = *temp;
+ }
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
+ if (*$1) {
+ intrusive_ptr_add_ref($1->get());
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+%}
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
+ // intrusive_ptr by pointer
+ if ( $input ) {
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
+ temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
+ $1 = &temp;
+ } else {
+ $1 = &tempnull;
+ }
+%}
+%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
+ delete $1;
+ if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
+ if ($1 && *$1) {
+ intrusive_ptr_add_ref($1->get());
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+ if ($owner) delete $1;
+%}
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
+ // intrusive_ptr by pointer reference
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
+ if ($input) {
+ temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
+ }
+ tempp = &temp;
+ $1 = &tempp;
+%}
+%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
+ if ($self) $1 = *$input;
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
+ if (*$1 && **$1) {
+ intrusive_ptr_add_ref((*$1)->get());
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+%}
+
+// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
+%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+
+
+%typemap (ctype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "void *"
+%typemap (imtype, out="global::System.IntPtr") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "global::System.Runtime.InteropServices.HandleRef"
+%typemap (cstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)"
+%typemap(csin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)"
+
+%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
+ get {
+ $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
+ return ret;
+ } %}
+%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >& %{
+ get {
+ $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
+ return ret;
+ } %}
+%typemap(csvarout, excode=SWIGEXCODE2) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >* %{
+ get {
+ $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
+ return ret;
+ } %}
+
+
+%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
+ $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
+ $typemap(cstype, TYPE) ret = new $typemap(cstype, TYPE)($imcall, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
+ global::System.IntPtr cPtr = $imcall;
+ $typemap(cstype, TYPE) ret = (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);$excode
+ return ret;
+ }
+
+// Base proxy classes
+%typemap(csbody) TYPE %{
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ private bool swigCMemOwnBase;
+
+ PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
+ swigCMemOwnBase = cMemoryOwn;
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ }
+
+ CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ }
+%}
+
+// Derived proxy classes
+%typemap(csbody_derived) TYPE %{
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ private bool swigCMemOwnDerived;
+
+ PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
+ swigCMemOwnDerived = cMemoryOwn;
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ }
+
+ CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ }
+%}
+
+%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
+ lock(this) {
+ if (swigCPtr.Handle != global::System.IntPtr.Zero) {
+ if (swigCMemOwnBase) {
+ swigCMemOwnBase = false;
+ $imcall;
+ }
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ }
+ global::System.GC.SuppressFinalize(this);
+ }
+ }
+
+%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
+ lock(this) {
+ if (swigCPtr.Handle != global::System.IntPtr.Zero) {
+ if (swigCMemOwnDerived) {
+ swigCMemOwnDerived = false;
+ $imcall;
+ }
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ }
+ global::System.GC.SuppressFinalize(this);
+ base.Dispose();
+ }
+ }
+
+// CONST version needed ???? also for C#
+%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
+%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
+
+
+%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
+%enddef
+
+
+/////////////////////////////////////////////////////////////////////
+
+
+%include
+
+%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
+
+%naturalvar TYPE;
+%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+
+// destructor mods
+%feature("unref") TYPE "(void)arg1; delete smartarg1;"
+
+
+// plain value
+%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{
+ argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
+ if (!argp) {
+ SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
+ return $null;
+ }
+ $1 = *argp; %}
+%typemap(out) CONST TYPE
+%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %}
+
+// plain pointer
+%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
+ $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %}
+%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
+%}
+
+// plain reference
+%typemap(in, canthrow=1) CONST TYPE & %{
+ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
+ if (!$1) {
+ SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
+ return $null;
+ } %}
+%typemap(out, fragment="SWIG_null_deleter") CONST TYPE &
+%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
+
+// plain pointer by reference
+%typemap(in) TYPE *CONST& ($*1_ltype temp = 0)
+%{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
+ $1 = &temp; %}
+%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST&
+%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
+
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
+ // shared_ptr by value
+ smartarg = *($&1_ltype*)&$input;
+ if (smartarg) $1 = *smartarg;
+%}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
+ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
+%}
+
+// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
+%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+
+
+%typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *"
+%typemap (imtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "void *"
+%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE)"
+%typemap (csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(cstype, TYPE).getCPtr($csinput)"
+%typemap(csout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ global::System.IntPtr cPtr = $imcall;
+ return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
+ }
+
+%typemap(csout, excode=SWIGEXCODE) CONST TYPE {
+ return new $typemap(cstype, TYPE)($imcall, true);
+ }
+%typemap(csout, excode=SWIGEXCODE) CONST TYPE & {
+ return new $typemap(cstype, TYPE)($imcall, true);
+ }
+%typemap(csout, excode=SWIGEXCODE) CONST TYPE * {
+ global::System.IntPtr cPtr = $imcall;
+ return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
+ }
+%typemap(csout, excode=SWIGEXCODE) TYPE *CONST& {
+ global::System.IntPtr cPtr = $imcall;
+ return (cPtr == global::System.IntPtr.Zero) ? null : new $typemap(cstype, TYPE)(cPtr, true);
+ }
+
+// Base proxy classes
+%typemap(csbody) TYPE %{
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ private bool swigCMemOwnBase;
+
+ PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) {
+ swigCMemOwnBase = cMemoryOwn;
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ }
+
+ CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ }
+%}
+
+// Derived proxy classes
+%typemap(csbody_derived) TYPE %{
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ private bool swigCMemOwnDerived;
+
+ PTRCTOR_VISIBILITY $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGSmartPtrUpcast(cPtr), true) {
+ swigCMemOwnDerived = cMemoryOwn;
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ }
+
+ CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ }
+%}
+
+%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
+ lock(this) {
+ if (swigCPtr.Handle != global::System.IntPtr.Zero) {
+ if (swigCMemOwnBase) {
+ swigCMemOwnBase = false;
+ $imcall;
+ }
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ }
+ global::System.GC.SuppressFinalize(this);
+ }
+ }
+
+%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
+ lock(this) {
+ if (swigCPtr.Handle != global::System.IntPtr.Zero) {
+ if (swigCMemOwnDerived) {
+ swigCMemOwnDerived = false;
+ $imcall;
+ }
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ }
+ global::System.GC.SuppressFinalize(this);
+ base.Dispose();
+ }
+ }
+
+
+// CONST version needed ???? also for C#
+%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
+%typemap(imtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "global::System.Runtime.InteropServices.HandleRef"
+
+
+%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+%enddef
diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg
index f7b7927ba..d94336194 100644
--- a/Lib/csharp/csharp.swg
+++ b/Lib/csharp/csharp.swg
@@ -409,8 +409,8 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
#endif
%typemap(directorin) SWIGTYPE
-%{ $input = (void *)&$1; %}
-%typemap(csdirectorin) SWIGTYPE "new $&csclassname($iminput, false)"
+%{ $input = (void *)new $1_ltype((const $1_ltype &)$1); %}
+%typemap(csdirectorin) SWIGTYPE "new $&csclassname($iminput, true)"
%typemap(csdirectorout) SWIGTYPE "$&csclassname.getCPtr($cscall).Handle"
/* Generic pointers and references */
diff --git a/Lib/csharp/csharpkw.swg b/Lib/csharp/csharpkw.swg
index 43ca5993b..824f61874 100644
--- a/Lib/csharp/csharpkw.swg
+++ b/Lib/csharp/csharpkw.swg
@@ -2,9 +2,9 @@
#define CSHARP_CSHARPKW_SWG_
/* Warnings for C# keywords */
-#define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword, renaming to '_" `x` "'",rename="_%s") `x`
+#define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword, renaming to '" `x` "_'",rename="%s_") `x`
-#define CSHARPCLASSKW(x) %keywordwarn("'" `x` "' is a special method name used in the C# wrapper classes, class renamed to '_" `x` "'",%$isclass,rename="_%s") `x`
+#define CSHARPCLASSKW(x) %keywordwarn("'" `x` "' is a special method name used in the C# wrapper classes, class renamed to '" `x` "_'",%$isclass,rename="%s_") `x`
/*
from
diff --git a/Lib/csharp/swiginterface.i b/Lib/csharp/swiginterface.i
index 3741b87ac..e5bfd23a4 100644
--- a/Lib/csharp/swiginterface.i
+++ b/Lib/csharp/swiginterface.i
@@ -31,7 +31,7 @@
$*csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
return ($*csinterfacename)ret;
}
-%typemap(csdirectorin) CTYPE "($&csinterfacename)new $&csclassname($iminput, false)"
+%typemap(csdirectorin) CTYPE "($&csinterfacename)new $&csclassname($iminput, true)"
%typemap(csdirectorin) CTYPE & "($csinterfacename)new $csclassname($iminput, false)"
%typemap(csdirectorin) CTYPE *, CTYPE [] "($iminput == global::System.IntPtr.Zero) ? null : ($csinterfacename)new $csclassname($iminput, false)"
%typemap(csdirectorin) CTYPE *const& "($iminput == global::System.IntPtr.Zero) ? null : ($*csinterfacename)new $*csclassname($iminput, false)"
diff --git a/Lib/d/dswigtype.swg b/Lib/d/dswigtype.swg
index 41336dc91..f91d6dfe6 100644
--- a/Lib/d/dswigtype.swg
+++ b/Lib/d/dswigtype.swg
@@ -57,7 +57,7 @@
#endif
%typemap(directorin) SWIGTYPE
- "$input = (void *)&$1;"
+ "$input = (void *)new $1_ltype((const $1_ltype &)$1);"
%typemap(directorout) SWIGTYPE
%{ if (!$input) {
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type");
@@ -65,7 +65,7 @@
}
$result = *($&1_ltype)$input; %}
-%typemap(ddirectorin) SWIGTYPE "new $&dclassname($winput, false)"
+%typemap(ddirectorin) SWIGTYPE "new $&dclassname($winput, true)"
%typemap(ddirectorout) SWIGTYPE "$&dclassname.swigGetCPtr($dcall)"
%typemap(din) SWIGTYPE "$&dclassname.swigGetCPtr($dinput)"
diff --git a/Lib/go/go.swg b/Lib/go/go.swg
index 24f1b73f7..53b653f7c 100644
--- a/Lib/go/go.swg
+++ b/Lib/go/go.swg
@@ -435,10 +435,23 @@
%typemap(in)
char *, char[ANY], char[]
-%{ $1 = ($1_ltype)$input.p; %}
+%{
+ $1 = ($1_ltype)malloc($input.n + 1);
+ memcpy($1, $input.p, $input.n);
+ $1[$input.n] = '\0';
+%}
-%typemap(in) char *&
-%{ $1 = ($1_ltype)$input.p; %}
+%typemap(in) char *& (char *temp)
+%{
+ temp = (char *)malloc($input.n + 1);
+ memcpy(temp, $input.p, $input.n);
+ temp[$input.n] = '\0';
+ $1 = ($1_ltype)&temp;
+%}
+
+%typemap(freearg)
+ char *, char *&, char[ANY], char[]
+%{ free($1); %}
%typemap(out,fragment="AllocateString")
char *, char *&, char[ANY], char[]
@@ -460,7 +473,19 @@
$result = swigCopyString($input)
%}
-%typemap(directorout)
+%typemap(godirectorout)
+ char *, char *&, char[ANY], char[]
+%{
+ {
+ p := Swig_malloc(len($input) + 1)
+ s := (*[1<<30]byte)(unsafe.Pointer(p))[:len($input) + 1]
+ copy(s, $input)
+ s[len($input)] = 0
+ $result = *(*string)(unsafe.Pointer(&s))
+ }
+%}
+
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
char *, char *&, char[ANY], char[]
%{ $result = ($1_ltype)$input.p; %}
@@ -559,7 +584,7 @@
%typemap(goout) SWIGTYPE ""
%typemap(directorin) SWIGTYPE
-%{ $input = ($&1_ltype)&$1; %}
+%{ $input = new $1_ltype((const $1_ltype &)$1); %}
%typemap(godirectorin) SWIGTYPE ""
diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg
index e7a33adc4..dc6193d04 100644
--- a/Lib/go/goruntime.swg
+++ b/Lib/go/goruntime.swg
@@ -8,6 +8,10 @@
static void Swig_free(void* p) {
free(p);
}
+
+static void* Swig_malloc(int c) {
+ return malloc(c);
+}
%}
%insert(runtime) %{
diff --git a/Lib/go/std_string.i b/Lib/go/std_string.i
index 068c688cb..099ae84d4 100644
--- a/Lib/go/std_string.i
+++ b/Lib/go/std_string.i
@@ -24,8 +24,21 @@ class string;
%typemap(in) string
%{ $1.assign($input.p, $input.n); %}
+%typemap(godirectorout) string
+%{
+ {
+ p := Swig_malloc(len($input))
+ s := (*[1<<30]byte)(unsafe.Pointer(p))[:len($input)]
+ copy(s, $input)
+ $result = *(*string)(unsafe.Pointer(&s))
+ }
+%}
+
%typemap(directorout) string
-%{ $result.assign($input.p, $input.n); %}
+%{
+ $result.assign($input.p, $input.n);
+ free($input.p);
+%}
%typemap(out,fragment="AllocateString") string
%{ $result = Swig_AllocateString($1.data(), $1.length()); %}
@@ -45,10 +58,21 @@ class string;
$1 = &$1_str;
%}
+%typemap(godirectorout) const string &
+%{
+ {
+ p := Swig_malloc(len($input))
+ s := (*[1<<30]byte)(unsafe.Pointer(p))[:len($input)]
+ copy(s, $input)
+ $result = *(*string)(unsafe.Pointer(&s))
+ }
+%}
+
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
%{
static $*1_ltype $1_str;
$1_str.assign($input.p, $input.n);
+ free($input.p);
$result = &$1_str;
%}
diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i
index fefbe2e77..489acc187 100644
--- a/Lib/guile/std_map.i
+++ b/Lib/guile/std_map.i
@@ -41,7 +41,7 @@
namespace std {
template class map {
- %typemap(in) map (std::map* m) {
+ %typemap(in) map {
if (scm_is_null($input)) {
$1 = std::map< K, T >();
} else if (scm_is_pair($input)) {
@@ -72,10 +72,8 @@ namespace std {
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
- %typemap(in) const map& (std::map temp,
- std::map* m),
- const map* (std::map temp,
- std::map* m) {
+ %typemap(in) const map& (std::map temp),
+ const map* (std::map temp) {
if (scm_is_null($input)) {
temp = std::map< K, T >();
$1 = &temp;
@@ -266,7 +264,7 @@ namespace std {
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
template class map {
- %typemap(in) map (std::map* m) {
+ %typemap(in) map {
if (scm_is_null($input)) {
$1 = std::map< K, T >();
} else if (scm_is_pair($input)) {
@@ -298,10 +296,8 @@ namespace std {
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
- %typemap(in) const map& (std::map temp,
- std::map* m),
- const map* (std::map temp,
- std::map* m) {
+ %typemap(in) const map& (std::map temp),
+ const map* (std::map temp) {
if (scm_is_null($input)) {
temp = std::map< K, T >();
$1 = &temp;
@@ -480,7 +476,7 @@ namespace std {
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
template class map {
- %typemap(in) map (std::map* m) {
+ %typemap(in) map {
if (scm_is_null($input)) {
$1 = std::map< K, T >();
} else if (scm_is_pair($input)) {
@@ -511,10 +507,8 @@ namespace std {
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
- %typemap(in) const map& (std::map temp,
- std::map* m),
- const map* (std::map temp,
- std::map* m) {
+ %typemap(in) const map& (std::map temp),
+ const map* (std::map temp) {
if (scm_is_null($input)) {
temp = std::map< K, T >();
$1 = &temp;
@@ -567,7 +561,6 @@ namespace std {
K* k;
SCM head = SCM_CAR($input);
if (scm_is_pair(head)) {
- SCM key = SCM_CAR(head);
SCM val = SCM_CDR(head);
if (SWIG_ConvertPtr(val,(void **) &k,
$descriptor(K *), 0) != 0) {
@@ -609,7 +602,6 @@ namespace std {
K* k;
SCM head = SCM_CAR($input);
if (scm_is_pair(head)) {
- SCM key = SCM_CAR(head);
SCM val = SCM_CDR(head);
if (SWIG_ConvertPtr(val,(void **) &k,
$descriptor(K *), 0) != 0) {
@@ -692,7 +684,7 @@ namespace std {
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO,
T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
template<> class map {
- %typemap(in) map (std::map* m) {
+ %typemap(in) map {
if (scm_is_null($input)) {
$1 = std::map< K, T >();
} else if (scm_is_pair($input)) {
@@ -725,10 +717,8 @@ namespace std {
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
- %typemap(in) const map& (std::map temp,
- std::map* m),
- const map* (std::map temp,
- std::map* m) {
+ %typemap(in) const map& (std::map temp),
+ const map* (std::map temp) {
if (scm_is_null($input)) {
temp = std::map< K, T >();
$1 = &temp;
diff --git a/Lib/java/java.swg b/Lib/java/java.swg
index 96ca562b6..d763c5e6f 100644
--- a/Lib/java/java.swg
+++ b/Lib/java/java.swg
@@ -647,8 +647,8 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(directorin,descriptor="L$packagepath/$&javaclassname;") SWIGTYPE
%{ $input = 0;
- *(($&1_ltype*)&$input) = &$1; %}
-%typemap(javadirectorin) SWIGTYPE "new $&javaclassname($jniinput, false)"
+ *(($&1_ltype*)&$input) = new $1_ltype((const $1_ltype &)$1); %}
+%typemap(javadirectorin) SWIGTYPE "new $&javaclassname($jniinput, true)"
%typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)"
/* Generic pointers and references */
diff --git a/Lib/java/swiginterface.i b/Lib/java/swiginterface.i
index 169118278..334464157 100644
--- a/Lib/java/swiginterface.i
+++ b/Lib/java/swiginterface.i
@@ -31,7 +31,7 @@
return (cPtr == 0) ? null : ($javainterfacename)new $javaclassname(cPtr, $owner);
}
-%typemap(javadirectorin) CTYPE "($&javainterfacename)new $&javaclassname($jniinput, false)"
+%typemap(javadirectorin) CTYPE "($&javainterfacename)new $&javaclassname($jniinput, true)"
%typemap(javadirectorin) CTYPE & "($javainterfacename)new $javaclassname($jniinput, false)"
%typemap(javadirectorin) CTYPE *, CTYPE [] "($jniinput == 0) ? null : ($javainterfacename)new $javaclassname($jniinput, false)"
%typemap(javadirectorin) CTYPE *const& "($jniinput == 0) ? null : ($*javainterfacename)new $*javaclassname($jniinput, false)"
@@ -40,7 +40,7 @@
%typemap(javadirectorout) CTYPE *const& "$javacall.$*interfacename_GetInterfaceCPtr()"
%typemap(directorin,descriptor="L$packagepath/$&javainterfacename;") CTYPE
%{ $input = 0;
- *(($&1_ltype*)&$input) = &$1; %}
+ *(($&1_ltype*)&$input) = new $1_ltype((const $1_ltype &)$1); %}
%typemap(directorin,descriptor="L$packagepath/$javainterfacename;") CTYPE *, CTYPE []
%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
%typemap(directorin,descriptor="L$packagepath/$javainterfacename;") CTYPE &
diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg
index 0211b33c6..af58f3aaa 100644
--- a/Lib/octave/octcontainer.swg
+++ b/Lib/octave/octcontainer.swg
@@ -562,8 +562,8 @@ namespace swig {
static int asptr(const octave_value& obj, sequence **seq) {
if (!obj.is_defined() || Swig::swig_value_deref(obj)) {
sequence *p;
- if (SWIG_ConvertPtr(obj,(void**)&p,
- swig::type_info(),0) == SWIG_OK) {
+ swig_type_info *descriptor = swig::type_info();
+ if (descriptor && SWIG_IsOK(SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0))) {
if (seq) *seq = p;
return SWIG_OLDOBJ;
}
diff --git a/Lib/octave/octstdcommon.swg b/Lib/octave/octstdcommon.swg
index 96923f40a..799d369a7 100644
--- a/Lib/octave/octstdcommon.swg
+++ b/Lib/octave/octstdcommon.swg
@@ -42,7 +42,8 @@ namespace swig {
struct traits_asptr {
static int asptr(const octave_value& obj, Type **val) {
Type *p;
- int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0);
+ swig_type_info *descriptor = type_info();
+ int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res)) {
if (val) *val = p;
}
diff --git a/Lib/octave/std_map.i b/Lib/octave/std_map.i
index 7b85a548e..fd15661c3 100644
--- a/Lib/octave/std_map.i
+++ b/Lib/octave/std_map.i
@@ -98,7 +98,8 @@
res = traits_asptr_stdseq, std::pair >::asptr(items, val);
} else {
map_type *p;
- res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0);
+ swig_type_info *descriptor = swig::type_info();
+ res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
diff --git a/Lib/octave/std_pair.i b/Lib/octave/std_pair.i
index ab028d144..a06498bf2 100644
--- a/Lib/octave/std_pair.i
+++ b/Lib/octave/std_pair.i
@@ -47,7 +47,8 @@
return get_pair(c(0),c(1),val);
} else {
value_type *p;
- int res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0);
+ swig_type_info *descriptor = swig::type_info();
+ int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val)
*val = *p;
return res;
@@ -100,7 +101,8 @@
return get_pair(c(0),c(1),val);
} else {
value_type *p;
- int res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0);
+ swig_type_info *descriptor = swig::type_info();
+ int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val)
*val = p;
return res;
diff --git a/Lib/perl5/perlinit.swg b/Lib/perl5/perlinit.swg
index cdb73d53a..b49040d26 100644
--- a/Lib/perl5/perlinit.swg
+++ b/Lib/perl5/perlinit.swg
@@ -28,6 +28,7 @@ extern "C"
XS(SWIG_init) {
dXSARGS;
int i;
+ (void)items;
SWIG_InitializeModule(0);
diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg
index 876fae268..d1865de0a 100644
--- a/Lib/perl5/perlrun.swg
+++ b/Lib/perl5/perlrun.swg
@@ -144,9 +144,9 @@ typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *);
# ifdef PERL_OBJECT
# define SWIG_croak_null() SWIG_Perl_croak_null(pPerl)
-static void SWIG_Perl_croak_null(CPerlObj *pPerl)
+static void SWIGUNUSED SWIG_Perl_croak_null(CPerlObj *pPerl)
# else
-static void SWIG_croak_null()
+static void SWIGUNUSED SWIG_croak_null()
# endif
{
SV *err = get_sv("@", GV_ADD);
diff --git a/Lib/php/php.swg b/Lib/php/php.swg
index 05d25a1df..535c7d347 100644
--- a/Lib/php/php.swg
+++ b/Lib/php/php.swg
@@ -393,11 +393,7 @@
{
void * p = emalloc(sizeof($1));
memcpy(p, &$1, sizeof($1));
- zval * resource;
- MAKE_STD_ZVAL(resource);
- ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr);
-
- SWIG_SetPointerZval(return_value, (void *)&$1, $1_descriptor, $owner);
+ ZEND_REGISTER_RESOURCE(return_value, p, swig_member_ptr);
}
%typemap(in, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*)
@@ -429,7 +425,7 @@
%typemap(directorin) SWIGTYPE
{
- SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1), $&1_descriptor, 2);
+ SWIG_SetPointerZval($input, SWIG_as_voidptr(new $1_ltype((const $1_ltype &)$1)), $&1_descriptor, 1|2);
}
%typemap(out) void "";
diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg
index 3f0aa7ac6..0021a90e8 100644
--- a/Lib/php/phprun.swg
+++ b/Lib/php/phprun.swg
@@ -93,9 +93,6 @@ typedef struct {
int newobject;
} swig_object_wrapper;
-/* empty zend destructor for types without one */
-static ZEND_RSRC_DTOR_FUNC(SWIG_landfill) { (void)rsrc; }
-
#define SWIG_SetPointerZval(a,b,c,d) SWIG_ZTS_SetPointerZval(a,b,c,d TSRMLS_CC)
#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a))
diff --git a/Lib/php/typemaps.i b/Lib/php/typemaps.i
index 0372884a6..faae0a6ac 100644
--- a/Lib/php/typemaps.i
+++ b/Lib/php/typemaps.i
@@ -271,7 +271,7 @@ INT_TYPEMAP(unsigned long long);
%typemap(in) char INPUT[ANY] ( char temp[$1_dim0] )
%{
convert_to_string_ex($input);
- strncpy(temp,Z_LVAL_PP($input),$1_dim0);
+ strncpy(temp,Z_STRVAL_PP($input),$1_dim0);
$1 = temp;
%}
%typemap(in,numinputs=0) char OUTPUT[ANY] ( char temp[$1_dim0] )
diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg
index 5767a1422..1244dbbcc 100644
--- a/Lib/python/builtin.swg
+++ b/Lib/python/builtin.swg
@@ -187,14 +187,14 @@ wrapper##_closure(PyObject *a) { \
}
#define SWIGPY_HASHFUNC_CLOSURE(wrapper) \
-SWIGINTERN long \
+SWIGINTERN Py_hash_t \
wrapper##_closure(PyObject *a) { \
PyObject *pyresult; \
- long result; \
+ Py_hash_t result; \
pyresult = wrapper(a, NULL); \
- if (!pyresult || !PyLong_Check(pyresult)) \
- return -1; \
- result = PyLong_AsLong(pyresult); \
+ if (!pyresult) \
+ return -1; \
+ result = SWIG_PyNumber_AsPyHash(pyresult); \
Py_DECREF(pyresult); \
return result; \
}
@@ -222,14 +222,35 @@ SwigPyBuiltin_BadInit(PyObject *self, PyObject *SWIGUNUSEDPARM(args), PyObject *
}
SWIGINTERN void
-SwigPyBuiltin_BadDealloc(PyObject *pyobj) {
- SwigPyObject *sobj;
- sobj = (SwigPyObject *)pyobj;
+SwigPyBuiltin_BadDealloc(PyObject *obj) {
+ SwigPyObject *sobj = (SwigPyObject *)obj;
if (sobj->own) {
- PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", pyobj->ob_type->tp_name);
+ PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", obj->ob_type->tp_name);
}
}
+SWIGINTERN Py_hash_t
+SwigPyObject_hash(PyObject *obj) {
+ SwigPyObject *sobj = (SwigPyObject *)obj;
+ void *ptr = sobj->ptr;
+ return (Py_hash_t)ptr;
+}
+
+SWIGINTERN Py_hash_t
+SWIG_PyNumber_AsPyHash(PyObject *obj) {
+ Py_hash_t result = -1;
+#if PY_VERSION_HEX < 0x03020000
+ if (PyLong_Check(obj))
+ result = PyLong_AsLong(obj);
+#else
+ if (PyNumber_Check(obj))
+ result = PyNumber_AsSsize_t(obj, NULL);
+#endif
+ else
+ PyErr_Format(PyExc_TypeError, "Wrong type for hash function");
+ return result;
+}
+
typedef struct {
PyCFunction get;
PyCFunction set;
@@ -387,16 +408,15 @@ SwigPyStaticVar_Type(void) {
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
- /* PyObject header changed in Python 3 */
#if PY_VERSION_HEX >= 0x03000000
PyVarObject_HEAD_INIT(&PyType_Type, 0)
#else
PyObject_HEAD_INIT(&PyType_Type)
- 0,
+ 0, /* ob_size */
#endif
- "swig_static_var_getset_descriptor",
- sizeof(PyGetSetDescrObject),
- 0,
+ "swig_static_var_getset_descriptor", /* tp_name */
+ sizeof(PyGetSetDescrObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
(destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
index 46d04388b..8463e28f8 100644
--- a/Lib/python/pycontainer.swg
+++ b/Lib/python/pycontainer.swg
@@ -206,7 +206,7 @@ namespace swig {
if (step == 0) {
throw std::invalid_argument("slice step cannot be zero");
} else if (step > 0) {
- // Required range: 0 <= i < size, 0 <= j < size
+ // Required range: 0 <= i < size, 0 <= j < size, i <= j
if (i < 0) {
ii = 0;
} else if (i < (Difference)size) {
@@ -214,13 +214,15 @@ namespace swig {
} else if (insert && (i >= (Difference)size)) {
ii = (Difference)size;
}
- if ( j < 0 ) {
+ if (j < 0) {
jj = 0;
} else {
jj = (j < (Difference)size) ? j : (Difference)size;
}
+ if (jj < ii)
+ jj = ii;
} else {
- // Required range: -1 <= i < size-1, -1 <= j < size-1
+ // Required range: -1 <= i < size-1, -1 <= j < size-1, i >= j
if (i < -1) {
ii = -1;
} else if (i < (Difference) size) {
@@ -233,6 +235,8 @@ namespace swig {
} else {
jj = (j < (Difference)size ) ? j : (Difference)(size-1);
}
+ if (ii < jj)
+ ii = jj;
}
}
@@ -258,6 +262,13 @@ namespace swig {
seq->erase(position);
}
+ template
+ struct traits_reserve {
+ static void reserve(Sequence & /*seq*/, typename Sequence::size_type /*n*/) {
+ // This should be specialized for types that support reserve
+ }
+ };
+
template
inline Sequence*
getslice(const Sequence* self, Difference i, Difference j, Py_ssize_t step) {
@@ -275,6 +286,7 @@ namespace swig {
return new Sequence(sb, se);
} else {
Sequence *sequence = new Sequence();
+ swig::traits_reserve::reserve(*sequence, (jj - ii + step - 1) / step);
typename Sequence::const_iterator it = sb;
while (it!=se) {
sequence->push_back(*it);
@@ -285,17 +297,16 @@ namespace swig {
}
} else {
Sequence *sequence = new Sequence();
- if (ii > jj) {
- typename Sequence::const_reverse_iterator sb = self->rbegin();
- typename Sequence::const_reverse_iterator se = self->rbegin();
- std::advance(sb,size-ii-1);
- std::advance(se,size-jj-1);
- typename Sequence::const_reverse_iterator it = sb;
- while (it!=se) {
- sequence->push_back(*it);
- for (Py_ssize_t c=0; c<-step && it!=se; ++c)
- it++;
- }
+ swig::traits_reserve::reserve(*sequence, (ii - jj - step - 1) / -step);
+ typename Sequence::const_reverse_iterator sb = self->rbegin();
+ typename Sequence::const_reverse_iterator se = self->rbegin();
+ std::advance(sb,size-ii-1);
+ std::advance(se,size-jj-1);
+ typename Sequence::const_reverse_iterator it = sb;
+ while (it!=se) {
+ sequence->push_back(*it);
+ for (Py_ssize_t c=0; c<-step && it!=se; ++c)
+ it++;
}
return sequence;
}
@@ -309,12 +320,11 @@ namespace swig {
Difference jj = 0;
swig::slice_adjust(i, j, step, size, ii, jj, true);
if (step > 0) {
- if (jj < ii)
- jj = ii;
if (step == 1) {
size_t ssize = jj - ii;
if (ssize <= is.size()) {
// expanding/staying the same size
+ swig::traits_reserve::reserve(*self, self->size() - ssize + is.size());
typename Sequence::iterator sb = self->begin();
typename InputSeq::const_iterator isit = is.begin();
std::advance(sb,ii);
@@ -348,8 +358,6 @@ namespace swig {
}
}
} else {
- if (jj > ii)
- jj = ii;
size_t replacecount = (ii - jj - step - 1) / -step;
if (is.size() != replacecount) {
char msg[1024];
@@ -375,37 +383,33 @@ namespace swig {
Difference jj = 0;
swig::slice_adjust(i, j, step, size, ii, jj, true);
if (step > 0) {
- if (jj > ii) {
- typename Sequence::iterator sb = self->begin();
- std::advance(sb,ii);
- if (step == 1) {
- typename Sequence::iterator se = self->begin();
- std::advance(se,jj);
- self->erase(sb,se);
- } else {
- typename Sequence::iterator it = sb;
- size_t delcount = (jj - ii + step - 1) / step;
- while (delcount) {
- it = self->erase(it);
- for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
- it++;
- delcount--;
- }
- }
- }
- } else {
- if (ii > jj) {
- typename Sequence::reverse_iterator sb = self->rbegin();
- std::advance(sb,size-ii-1);
- typename Sequence::reverse_iterator it = sb;
- size_t delcount = (ii - jj - step - 1) / -step;
+ typename Sequence::iterator sb = self->begin();
+ std::advance(sb,ii);
+ if (step == 1) {
+ typename Sequence::iterator se = self->begin();
+ std::advance(se,jj);
+ self->erase(sb,se);
+ } else {
+ typename Sequence::iterator it = sb;
+ size_t delcount = (jj - ii + step - 1) / step;
while (delcount) {
- it = typename Sequence::reverse_iterator(self->erase((++it).base()));
- for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
+ it = self->erase(it);
+ for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
it++;
delcount--;
}
}
+ } else {
+ typename Sequence::reverse_iterator sb = self->rbegin();
+ std::advance(sb,size-ii-1);
+ typename Sequence::reverse_iterator it = sb;
+ size_t delcount = (ii - jj - step - 1) / -step;
+ while (delcount) {
+ it = typename Sequence::reverse_iterator(self->erase((++it).base()));
+ for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
+ it++;
+ delcount--;
+ }
}
}
}
@@ -968,8 +972,8 @@ namespace swig {
static int asptr(PyObject *obj, sequence **seq) {
if (obj == Py_None || SWIG_Python_GetSwigThis(obj)) {
sequence *p;
- if (::SWIG_ConvertPtr(obj,(void**)&p,
- swig::type_info(),0) == SWIG_OK) {
+ swig_type_info *descriptor = swig::type_info();
+ if (descriptor && SWIG_IsOK(::SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0))) {
if (seq) *seq = p;
return SWIG_OLDOBJ;
}
diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg
index 63df684b6..55eb95a6d 100644
--- a/Lib/python/pyhead.swg
+++ b/Lib/python/pyhead.swg
@@ -211,4 +211,5 @@ typedef destructor freefunc;
#if PY_VERSION_HEX < 0x03020000
#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
+#define Py_hash_t long
#endif
diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
index 2e21b8265..e671731ac 100644
--- a/Lib/python/pyinit.swg
+++ b/Lib/python/pyinit.swg
@@ -145,7 +145,6 @@ swig_varlink_type(void) {
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
- /* PyObject header changed in Python 3 */
#if PY_VERSION_HEX >= 0x03000000
PyVarObject_HEAD_INIT(NULL, 0)
#else
diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg
index 80a0d68c6..5fb22354b 100644
--- a/Lib/python/pyopers.swg
+++ b/Lib/python/pyopers.swg
@@ -18,31 +18,35 @@
where is the name of a field in a PyTypeObject, PyNumberMethods,
PyMappingMethods, PySequenceMethods, or PyBufferProcs. For example:
- %{
-
- static long myHashFunc (PyObject *pyobj) {
- MyClass *cobj;
- // Convert pyobj to cobj
- return (cobj->field1 * (cobj->field2 << 7));
- }
-
- %}
-
%feature("python:tp_hash") MyClass "myHashFunc";
+ class MyClass {
+ public:
+ ...
+ };
+
+ %{
+ // Note: Py_hash_t was introduced in Python 3.2
+ static Py_hash_t myHashFunc(PyObject *pyobj) {
+ MyClass *cobj;
+ // Convert pyobj to cobj
+ return (cobj->field1 * (cobj->field2 << 7));
+ }
+ %}
+
NOTE: It is the responsibility of the programmer (that's you) to ensure
that a statically defined slot function has the correct signature.
If, instead, you want to dispatch to an instance method, you can
use %feature("python:slot"). For example:
+ %feature("python:slot", "tp_hash", functype="hashfunc") MyClass::myHashFunc;
+
class MyClass {
public:
- long myHashFunc () const;
+ Py_hash_t myHashFunc () const;
...
};
-
- %feature("python:slot", "tp_hash", functype="hashfunc") MyClass::myHashFunc;
NOTE: Some python slots use a method signature which does not
match the signature of SWIG-wrapped methods. For those slots,
@@ -58,20 +62,21 @@
operator overloads for comparison (operator==, operator<, etc.), they
will be called from the generated rich compare function. If you
want to explicitly choose a method to handle a certain comparison
- operation, you may use %feature("python:slot") like this:
+ operation, you may use a different feature, %feature("python:compare")
+ like this:
+
+ %feature("python:compare", "Py_LT") MyClass::lessThan;
class MyClass {
public:
- bool lessThan (const MyClass& x) const;
+ bool lessThan(const MyClass& other) const;
...
};
- %feature("python:slot", "Py_LT") MyClass::lessThan;
-
... where "Py_LT" is one of the rich comparison opcodes defined in the
python header file object.h.
- If there's no method defined to handle a particular comparsion operation,
+ If there's no method defined to handle a particular comparison operation,
the default behavior is to compare pointer values of the wrapped
C++ objects.
@@ -103,7 +108,11 @@
%pybinoperator(__neg__, *::operator-(), unaryfunc, nb_negative);
%pybinoperator(__neg__, *::operator-() const, unaryfunc, nb_negative);
%pybinoperator(__mul__, *::operator*, binaryfunc, nb_multiply);
-%pybinoperator(__div__, *::operator/, binaryfunc, nb_div);
+#if defined(SWIGPYTHON_PY3)
+%pybinoperator(__truediv__, *::operator/, binaryfunc, nb_divide);
+#else
+%pybinoperator(__div__, *::operator/, binaryfunc, nb_divide);
+#endif
%pybinoperator(__mod__, *::operator%, binaryfunc, nb_remainder);
%pybinoperator(__lshift__, *::operator<<, binaryfunc, nb_lshift);
%pybinoperator(__rshift__, *::operator>>, binaryfunc, nb_rshift);
@@ -117,8 +126,6 @@
%pycompare(__eq__, *::operator==, Py_EQ);
%pycompare(__ne__, *::operator!=, Py_NE);
-%feature("python:slot", "nb_truediv", functype="binaryfunc") *::operator/;
-
/* Special cases */
%rename(__invert__) *::operator~;
%feature("python:slot", "nb_invert", functype="unaryfunc") *::operator~;
@@ -200,7 +207,11 @@ __bool__ = __nonzero__
%pyinplaceoper(__iadd__ , *::operator +=, binaryfunc, nb_inplace_add);
%pyinplaceoper(__isub__ , *::operator -=, binaryfunc, nb_inplace_subtract);
%pyinplaceoper(__imul__ , *::operator *=, binaryfunc, nb_inplace_multiply);
+#if defined(SWIGPYTHON_PY3)
+%pyinplaceoper(__itruediv__ , *::operator /=, binaryfunc, nb_inplace_divide);
+#else
%pyinplaceoper(__idiv__ , *::operator /=, binaryfunc, nb_inplace_divide);
+#endif
%pyinplaceoper(__imod__ , *::operator %=, binaryfunc, nb_inplace_remainder);
%pyinplaceoper(__iand__ , *::operator &=, binaryfunc, nb_inplace_and);
%pyinplaceoper(__ior__ , *::operator |=, binaryfunc, nb_inplace_or);
diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg
index fb5bbf6df..6a01af17c 100644
--- a/Lib/python/pyprimtypes.swg
+++ b/Lib/python/pyprimtypes.swg
@@ -223,6 +223,8 @@ SWIG_AsVal_dec(long long)(PyObject *obj, long long *val)
const double mant_min = -mant_max;
double d;
res = SWIG_AsVal(double)(obj,&d);
+ if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, mant_min, mant_max))
+ return SWIG_OverflowError;
if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, mant_min, mant_max)) {
if (val) *val = (long long)(d);
return SWIG_AddCast(res);
@@ -280,6 +282,8 @@ SWIG_AsVal_dec(unsigned long long)(PyObject *obj, unsigned long long *val)
const double mant_max = 1LL << DBL_MANT_DIG;
double d;
res = SWIG_AsVal(double)(obj,&d);
+ if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max))
+ return SWIG_OverflowError;
if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) {
if (val) *val = (unsigned long long)(d);
return SWIG_AddCast(res);
@@ -308,7 +312,7 @@ SWIG_AsVal_dec(double)(PyObject *obj, double *val)
return SWIG_OK;
%#if PY_VERSION_HEX < 0x03000000
} else if (PyInt_Check(obj)) {
- if (val) *val = PyInt_AsLong(obj);
+ if (val) *val = (double) PyInt_AsLong(obj);
return SWIG_OK;
%#endif
} else if (PyLong_Check(obj)) {
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
index 08f0848d4..ab1237f62 100644
--- a/Lib/python/pyrun.swg
+++ b/Lib/python/pyrun.swg
@@ -758,7 +758,6 @@ SwigPyObject_TypeOnce(void) {
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
- /* PyObject header changed in Python 3 */
#if PY_VERSION_HEX >= 0x03000000
PyVarObject_HEAD_INIT(NULL, 0)
#else
@@ -769,7 +768,7 @@ SwigPyObject_TypeOnce(void) {
sizeof(SwigPyObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)SwigPyObject_dealloc, /* tp_dealloc */
- 0, /* tp_print */
+ 0, /* tp_print */
#if PY_VERSION_HEX < 0x02020000
(getattrfunc)SwigPyObject_getattr, /* tp_getattr */
#else
@@ -777,7 +776,7 @@ SwigPyObject_TypeOnce(void) {
#endif
(setattrfunc)0, /* tp_setattr */
#if PY_VERSION_HEX >= 0x03000000
- 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
+ 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
#else
(cmpfunc)SwigPyObject_compare, /* tp_compare */
#endif
@@ -787,7 +786,7 @@ SwigPyObject_TypeOnce(void) {
0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
- 0, /* tp_str */
+ 0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
@@ -950,7 +949,6 @@ SwigPyPacked_TypeOnce(void) {
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp = {
- /* PyObject header changed in Python 3 */
#if PY_VERSION_HEX>=0x03000000
PyVarObject_HEAD_INIT(NULL, 0)
#else
diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg
index 2af22e2a4..8372426a0 100644
--- a/Lib/python/pystdcommon.swg
+++ b/Lib/python/pystdcommon.swg
@@ -46,7 +46,8 @@ namespace swig {
struct traits_asptr {
static int asptr(PyObject *obj, Type **val) {
Type *p;
- int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0);
+ swig_type_info *descriptor = type_info();
+ int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res)) {
if (val) *val = p;
}
diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i
index 65dd91d9c..f61f79c44 100644
--- a/Lib/python/std_map.i
+++ b/Lib/python/std_map.i
@@ -102,7 +102,8 @@
res = traits_asptr_stdseq >::asptr(items, val);
} else {
map_type *p;
- res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0);
+ swig_type_info *descriptor = swig::type_info();
+ res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = p;
}
SWIG_PYTHON_THREAD_END_BLOCK;
diff --git a/Lib/python/std_multimap.i b/Lib/python/std_multimap.i
index 2c539cf29..3209fb0f8 100644
--- a/Lib/python/std_multimap.i
+++ b/Lib/python/std_multimap.i
@@ -26,7 +26,8 @@
return traits_asptr_stdseq, std::pair >::asptr(items, val);
} else {
multimap_type *p;
- res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0);
+ swig_type_info *descriptor = swig::type_info();
+ res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
diff --git a/Lib/python/std_pair.i b/Lib/python/std_pair.i
index 5694e7e09..da31918c8 100644
--- a/Lib/python/std_pair.i
+++ b/Lib/python/std_pair.i
@@ -48,7 +48,8 @@
}
} else {
value_type *p;
- res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0);
+ swig_type_info *descriptor = swig::type_info();
+ res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = *p;
}
return res;
@@ -98,7 +99,8 @@
}
} else {
value_type *p;
- res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0);
+ swig_type_info *descriptor = swig::type_info();
+ res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i
index f956f4fb3..894840c6c 100644
--- a/Lib/python/std_unordered_map.i
+++ b/Lib/python/std_unordered_map.i
@@ -15,6 +15,13 @@
}
}
+ template
+ struct traits_reserve > {
+ static void reserve(std::unordered_map &seq, typename std::unordered_map::size_type n) {
+ seq.reserve(n);
+ }
+ };
+
template
struct traits_asptr > {
typedef std::unordered_map unordered_map_type;
@@ -29,7 +36,8 @@
res = traits_asptr_stdseq, std::pair >::asptr(items, val);
} else {
unordered_map_type *p;
- res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0);
+ swig_type_info *descriptor = swig::type_info();
+ res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
diff --git a/Lib/python/std_unordered_multimap.i b/Lib/python/std_unordered_multimap.i
index b3b723637..2410aa52b 100644
--- a/Lib/python/std_unordered_multimap.i
+++ b/Lib/python/std_unordered_multimap.i
@@ -16,6 +16,13 @@
}
}
+ template
+ struct traits_reserve > {
+ static void reserve(std::unordered_multimap &seq, typename std::unordered_multimap::size_type n) {
+ seq.reserve(n);
+ }
+ };
+
template
struct traits_asptr > {
typedef std::unordered_multimap unordered_multimap_type;
@@ -26,7 +33,8 @@
return traits_asptr_stdseq, std::pair >::asptr(items, val);
} else {
unordered_multimap_type *p;
- res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0);
+ swig_type_info *descriptor = swig::type_info();
+ res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
diff --git a/Lib/python/std_unordered_multiset.i b/Lib/python/std_unordered_multiset.i
index d5b9ff61c..0d9f3d9c6 100644
--- a/Lib/python/std_unordered_multiset.i
+++ b/Lib/python/std_unordered_multiset.i
@@ -18,6 +18,13 @@
}
}
+ template
+ struct traits_reserve > {
+ static void reserve(std::unordered_multiset &seq, typename std::unordered_multiset::size_type n) {
+ seq.reserve(n);
+ }
+ };
+
template
struct traits_asptr > {
static int asptr(PyObject *obj, std::unordered_multiset **m) {
diff --git a/Lib/python/std_unordered_set.i b/Lib/python/std_unordered_set.i
index a021cb4ed..855a28da5 100644
--- a/Lib/python/std_unordered_set.i
+++ b/Lib/python/std_unordered_set.i
@@ -16,6 +16,13 @@
}
}
+ template
+ struct traits_reserve > {
+ static void reserve(std::unordered_set &seq, typename std::unordered_set::size_type n) {
+ seq.reserve(n);
+ }
+ };
+
template
struct traits_asptr > {
static int asptr(PyObject *obj, std::unordered_set **s) {
diff --git a/Lib/python/std_vector.i b/Lib/python/std_vector.i
index 3f04a30c7..2ac41a54d 100644
--- a/Lib/python/std_vector.i
+++ b/Lib/python/std_vector.i
@@ -5,6 +5,13 @@
%fragment("StdVectorTraits","header",fragment="StdSequenceTraits")
%{
namespace swig {
+ template
+ struct traits_reserve > {
+ static void reserve(std::vector &seq, typename std::vector::size_type n) {
+ seq.reserve(n);
+ }
+ };
+
template
struct traits_asptr > {
static int asptr(PyObject *obj, std::vector **vec) {
diff --git a/Lib/r/rrun.swg b/Lib/r/rrun.swg
index 990443e23..f2c14a574 100644
--- a/Lib/r/rrun.swg
+++ b/Lib/r/rrun.swg
@@ -1,15 +1,4 @@
-#ifdef __cplusplus
-#include
-extern "C" {
-#endif
-
-/* for raw pointer */
-#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_R_ConvertPtr(obj, pptr, type, flags)
-#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_R_ConvertPtr(obj, pptr, type, flags)
-#define SWIG_NewPointerObj(ptr, type, flags) SWIG_R_NewPointerObj(ptr, type, flags)
-
-
/* Remove global namespace pollution */
#if !defined(SWIG_NO_R_NO_REMAP)
# define R_NO_REMAP
@@ -20,6 +9,17 @@ extern "C" {
#include
#include
+
+#ifdef __cplusplus
+#include
+extern "C" {
+#endif
+
+/* for raw pointer */
+#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_R_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_R_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_NewPointerObj(ptr, type, flags) SWIG_R_NewPointerObj(ptr, type, flags)
+
#include
#include
@@ -218,10 +218,6 @@ SWIGRUNTIME SEXP
SWIG_MakePtr(void *ptr, const char *typeName, R_SWIG_Owner owner)
{
SEXP external, r_obj;
- const char *p = typeName;
-
- if(typeName[0] == '_')
- p = typeName + 1;
Rf_protect(external = R_MakeExternalPtr(ptr, Rf_install(typeName), R_NilValue));
Rf_protect(r_obj = NEW_OBJECT(MAKE_CLASS((char *) typeName)));
diff --git a/Lib/r/rstdcommon.swg b/Lib/r/rstdcommon.swg
index b11cf677b..e6c873a07 100644
--- a/Lib/r/rstdcommon.swg
+++ b/Lib/r/rstdcommon.swg
@@ -40,7 +40,8 @@ namespace swig {
struct traits_asptr {
static int asptr(SWIG_Object obj, Type **val) {
Type *p;
- int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0);
+ swig_type_info *descriptor = type_info();
+ int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res)) {
if (val) *val = p;
}
diff --git a/Lib/r/std_vector.i b/Lib/r/std_vector.i
index d10097c1e..4ec51dc91 100644
--- a/Lib/r/std_vector.i
+++ b/Lib/r/std_vector.i
@@ -192,7 +192,6 @@
}
UNPROTECT(1);
return(result);
- //return SWIG_R_NewPointerObj(val, type_info< std::vector >(), owner);
}
};
@@ -208,7 +207,6 @@
}
UNPROTECT(1);
return(result);
- //return SWIG_R_NewPointerObj(val, type_info< std::vector >(), owner);
}
};
@@ -516,13 +514,37 @@
}
};
+ template <>
+ struct traits_asptr < std::vector > > {
+ static int asptr(SEXP obj, std::vector > **val) {
+ std::vector > *p;
+ // R character vectors are STRSXP containing CHARSXP
+ // access a CHARSXP using STRING_ELT
+ int sexpsz = Rf_length(obj);
+ p = new std::vector >(sexpsz);
+ SEXP coerced;
+ PROTECT(coerced = Rf_coerceVector(obj, STRSXP));
+ //SEXP *S = CHARACTER_POINTER(coerced);
+ for (unsigned pos = 0; pos < p->size(); pos++)
+ {
+ const char * thecstring = CHAR(STRING_ELT(coerced, pos));
+ (*p)[pos] = std::basic_string(thecstring);
+ }
+ int res = SWIG_OK;
+ if (SWIG_IsOK(res)) {
+ if (val) *val = p;
+ }
+ UNPROTECT(1);
+ return res;
+ }
+ };
+
// catchall for R to vector conversion
template
struct traits_asptr < std::vector > {
static int asptr(SEXP obj, std::vector **val) {
std::vector *p;
- Rprintf("my asptr\n");
- int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector >(), 0);
+ int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector >(), 0);
if (SWIG_IsOK(res)) {
if (val) *val = p;
}
@@ -816,35 +838,56 @@
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector)
%traits_type_name(std::vector)
-%typemap("rtypecheck") std::vector, std::vector const, std::vector const&
+%typemap("rtypecheck") std::vector, std::vector *, std::vector &
%{ is.numeric($arg) %}
%typemap("rtype") std::vector "numeric"
-%typemap("scoercein") std::vector, std::vector const, std::vector const& "";
+%typemap("scoercein") std::vector, std::vector *, std::vector & "$input = as.numeric($input);";
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector)
%traits_type_name(std::vector)
// reuse these for float
-%typemap("rtype") std::vector = std::vector;
-%typemap("rtypecheck") std::vector = std::vector;
-%typemap("scoercein") std::vector = std::vector;
+%typemap("rtype") std::vector, std::vector *, std::vector & = std::vector;
+%typemap("rtypecheck") std::vector, std::vector *, std::vector & = std::vector;
+%typemap("scoercein") std::vector, std::vector *, std::vector & = std::vector;
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector);
%traits_type_name(std::vector);
-%typemap("rtypecheck") std::vector