From 769b26d5754e64ddc37be1e546e1951c94e082d9 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 6 May 2011 20:56:42 +0000
Subject: [PATCH 01/59] Fix %varargs when used with a numerical argument, which
was emitting one more optional argument than documented
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12657 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 5 +++++
Examples/test-suite/python/varargs_runme.py | 16 ++++++++++++++++
Examples/test-suite/varargs.i | 5 +++++
Source/CParse/parser.y | 3 +--
4 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index f928203d8..bc347308e 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -4,6 +4,11 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.4 (in progress)
===========================
+2011-05-05: wsfulton
+ Fix %varargs when used with a numerical argument, eg %varargs(3, char *arg = NULL).
+ It was possible to use one extra optional argument than document. Now the above only
+ generates 3 optional char * arguments. Reported by Karl Wette.
+
2011-05-05: wsfulton
[Lua, Python, Tcl] C/C++ prototypes shown in error message when calling an overloaded
method with incorrect arguments improved to show always show fully qualified name
diff --git a/Examples/test-suite/python/varargs_runme.py b/Examples/test-suite/python/varargs_runme.py
index 301de78a7..a55f0630e 100644
--- a/Examples/test-suite/python/varargs_runme.py
+++ b/Examples/test-suite/python/varargs_runme.py
@@ -16,3 +16,19 @@ if varargs.test_def("Hello",1) != "Hello":
if varargs.test_def("Hello") != "Hello":
raise RuntimeError, "Failed"
+
+###
+if varargs.test_plenty("Hello") != "Hello":
+ raise RuntimeError, "Failed"
+
+if varargs.test_plenty("Hello", 1) != "Hello":
+ raise RuntimeError, "Failed"
+
+if varargs.test_plenty("Hello", 1, 2) != "Hello":
+ raise RuntimeError, "Failed"
+
+try:
+ varargs.test_plenty("Hello", 1, 2, 3)
+ raise RuntimeError
+except NotImplementedError:
+ pass
diff --git a/Examples/test-suite/varargs.i b/Examples/test-suite/varargs.i
index c7931fed2..dd56cb073 100644
--- a/Examples/test-suite/varargs.i
+++ b/Examples/test-suite/varargs.i
@@ -5,6 +5,7 @@
%varargs(int mode = 0) test_def;
%varargs(int mode = 0) Foo::Foo;
%varargs(int mode = 0) Foo::statictest(const char*fmt, ...);
+%varargs(2, int mode = 0) test_plenty(const char*fmt, ...);
%inline %{
char *test(const char *fmt, ...) {
@@ -36,4 +37,8 @@ public:
}
};
+const char *test_plenty(const char *fmt, ...) {
+ return fmt;
+}
+
%}
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index d95390892..2ee117506 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -2628,8 +2628,7 @@ varargs_parms : parms { $$ = $1; }
$$ = 0;
} else {
$$ = Copy($3);
- Setattr($$,"name","VARARGS_SENTINEL");
- for (i = 0; i < n; i++) {
+ for (i = 0; i < n-1; i++) {
p = Copy($3);
set_nextSibling(p,$$);
Delete($$);
From cba65bd5248076c67d63d5b773b1b22c410b4592 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 6 May 2011 21:10:01 +0000
Subject: [PATCH 02/59] revert 12657 - incorrect changes made
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12658 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 5 -----
Examples/test-suite/python/varargs_runme.py | 5 ++++-
Source/CParse/parser.y | 3 ++-
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index bc347308e..f928203d8 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -4,11 +4,6 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.4 (in progress)
===========================
-2011-05-05: wsfulton
- Fix %varargs when used with a numerical argument, eg %varargs(3, char *arg = NULL).
- It was possible to use one extra optional argument than document. Now the above only
- generates 3 optional char * arguments. Reported by Karl Wette.
-
2011-05-05: wsfulton
[Lua, Python, Tcl] C/C++ prototypes shown in error message when calling an overloaded
method with incorrect arguments improved to show always show fully qualified name
diff --git a/Examples/test-suite/python/varargs_runme.py b/Examples/test-suite/python/varargs_runme.py
index a55f0630e..f96a43d85 100644
--- a/Examples/test-suite/python/varargs_runme.py
+++ b/Examples/test-suite/python/varargs_runme.py
@@ -27,8 +27,11 @@ if varargs.test_plenty("Hello", 1) != "Hello":
if varargs.test_plenty("Hello", 1, 2) != "Hello":
raise RuntimeError, "Failed"
+if varargs.test_plenty("Hello", 1, 2, 3) != "Hello":
+ raise RuntimeError, "Failed"
+
try:
- varargs.test_plenty("Hello", 1, 2, 3)
+ varargs.test_plenty("Hello", 1, 2, 3, 4)
raise RuntimeError
except NotImplementedError:
pass
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 2ee117506..d95390892 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -2628,7 +2628,8 @@ varargs_parms : parms { $$ = $1; }
$$ = 0;
} else {
$$ = Copy($3);
- for (i = 0; i < n-1; i++) {
+ Setattr($$,"name","VARARGS_SENTINEL");
+ for (i = 0; i < n; i++) {
p = Copy($3);
set_nextSibling(p,$$);
Delete($$);
From a52612f84563cb623e720b176a7e80a6ef70cf79 Mon Sep 17 00:00:00 2001
From: Stefan Zager
Date: Sun, 8 May 2011 06:54:21 +0000
Subject: [PATCH 03/59] Fixed PyGetSetDescr for python3.2.
Fixed memory management in special_variable_macros test.
Don't define asdict() for multimap.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12659 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 3 +++
Examples/test-suite/python/Makefile.in | 3 ++-
Examples/test-suite/special_variable_macros.i | 16 ++++++++++--
Lib/python/builtin.swg | 25 +++++++++++--------
Lib/python/pyhead.swg | 5 ++++
Lib/python/pyinit.swg | 9 +++++++
Lib/python/std_map.i | 11 ++++----
7 files changed, 53 insertions(+), 19 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index f928203d8..dca3acdd6 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -4,6 +4,9 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.4 (in progress)
===========================
+2011-05-07: szager
+ [python] Fixed PyGetSetDescr for python3.2.
+
2011-05-05: wsfulton
[Lua, Python, Tcl] C/C++ prototypes shown in error message when calling an overloaded
method with incorrect arguments improved to show always show fully qualified name
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index 06ae7ef24..108cb60eb 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -93,7 +93,8 @@ BUILTIN_BROKEN = \
default_constructor.cpptest \
director_exception.cpptest \
exception_order.cpptest \
- threads_exception.cpptest
+ threads_exception.cpptest \
+ python_abstractbase.cpptest
BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES))
diff --git a/Examples/test-suite/special_variable_macros.i b/Examples/test-suite/special_variable_macros.i
index 1ad673b41..ba9889d7a 100644
--- a/Examples/test-suite/special_variable_macros.i
+++ b/Examples/test-suite/special_variable_macros.i
@@ -5,13 +5,25 @@
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'NewName' due to Go name ('NewName') conflict with 'Name' */
+%ignore Name::operator=;
+
%inline %{
struct Name {
- Name(const char *n="none") : name(n) {}
+ Name(const char *n="none") : name(strdup(n ? n : "")) {}
+ Name(const Name& x) : name(strdup(x.name)) {}
+ Name& operator= (const Name& x)
+ {
+ if (this != &x) {
+ free(this->name);
+ this->name = strdup(x.name);
+ }
+ return *this;
+ }
+ ~Name () { free(this->name); }
const char *getName() const { return name; };
Name *getNamePtr() { return this; };
private:
- const char *name;
+ char *name;
};
struct NameWrap {
NameWrap(const char *n="casternone") : name(n) {}
diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg
index 8852832d1..de1457c41 100644
--- a/Lib/python/builtin.swg
+++ b/Lib/python/builtin.swg
@@ -285,17 +285,22 @@ SwigPyBuiltin_FunpackSetterClosure (PyObject *obj, PyObject *val, void *closure)
SWIGINTERN void
SwigPyStaticVar_dealloc(PyDescrObject *descr) {
_PyObject_GC_UNTRACK(descr);
+ /*
Py_XDECREF(descr->d_type);
Py_XDECREF(descr->d_name);
+ */
+ Py_XDECREF(PyDescr_TYPE(descr));
+ Py_XDECREF(PyDescr_NAME(descr));
PyObject_GC_Del(descr);
}
SWIGINTERN PyObject *
SwigPyStaticVar_repr(PyGetSetDescrObject *descr) {
#if PY_VERSION_HEX >= 0x03000000
- return PyUnicode_FromFormat("", descr->d_name, descr->d_type->tp_name);
+
+ return PyUnicode_FromFormat("", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name);
#else
- return PyString_FromFormat("", PyString_AsString(descr->d_name), descr->d_type->tp_name);
+ return PyString_FromFormat("", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name);
#endif
}
@@ -303,7 +308,7 @@ SWIGINTERN int
SwigPyStaticVar_traverse(PyObject *self, visitproc visit, void *arg) {
PyDescrObject *descr;
descr = (PyDescrObject *)self;
- Py_VISIT((PyObject*) descr->d_type);
+ Py_VISIT((PyObject*) PyDescr_TYPE(descr));
return 0;
}
@@ -312,9 +317,9 @@ SwigPyStaticVar_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *SWIGUNU
if (descr->d_getset->get != NULL)
return descr->d_getset->get(obj, descr->d_getset->closure);
#if PY_VERSION_HEX >= 0x03000000
- PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not readable", descr->d_name, descr->d_type->tp_name);
+ PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not readable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name);
#else
- PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(descr->d_name), descr->d_type->tp_name);
+ PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name);
#endif
return NULL;
}
@@ -324,9 +329,9 @@ SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value)
if (descr->d_getset->set != NULL)
return descr->d_getset->set(obj, value, descr->d_getset->closure);
#if PY_VERSION_HEX >= 0x03000000
- PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not writable", descr->d_name, descr->d_type->tp_name);
+ PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not writable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name);
#else
- PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(descr->d_name), descr->d_type->tp_name);
+ PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name);
#endif
return -1;
}
@@ -425,10 +430,10 @@ SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) {
descr = (PyGetSetDescrObject *)PyType_GenericAlloc(&SwigPyStaticVar_Type, 0);
assert(descr);
Py_XINCREF(type);
- descr->d_type = type;
- descr->d_name = PyString_InternFromString(getset->name);
+ PyDescr_TYPE(descr) = type;
+ PyDescr_NAME(descr) = PyString_InternFromString(getset->name);
descr->d_getset = getset;
- if (descr->d_name == NULL) {
+ if (PyDescr_NAME(descr) == NULL) {
Py_DECREF(descr);
descr = NULL;
}
diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg
index dacf2d713..803cd0745 100644
--- a/Lib/python/pyhead.swg
+++ b/Lib/python/pyhead.swg
@@ -206,3 +206,8 @@ typedef destructor freefunc;
# define SWIGPY_USE_CAPSULE
# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
#endif
+
+#if PY_VERSION_HEX < 0x03020000
+#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
+#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
+#endif
diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
index 4682912c8..d5de1f8a6 100644
--- a/Lib/python/pyinit.swg
+++ b/Lib/python/pyinit.swg
@@ -325,7 +325,16 @@ SWIG_init(void) {
PyObject *m, *d, *md;
#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef SWIG_module = {
+# if PY_VERSION_HEX >= 0x03020000
PyModuleDef_HEAD_INIT,
+# else
+ {
+ PyObject_HEAD_INIT(NULL)
+ NULL, /* m_init */
+ 0, /* m_index */
+ NULL, /* m_copy */
+ },
+# endif
(char *) SWIG_name,
NULL,
-1,
diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i
index 42f565908..fec816222 100644
--- a/Lib/python/std_map.i
+++ b/Lib/python/std_map.i
@@ -168,10 +168,6 @@
swig::SwigPyIterator* iteritems(PyObject **PYTHON_SELF) {
return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}
-
- PyObject* asdict() {
- return swig::traits_from< Map >::asdict(*self);
- }
}
#else
@@ -292,14 +288,17 @@
void __setitem__(const key_type& key) {
self->erase(key);
}
- }
- %extend {
void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
(*self)[key] = x;
}
+
+ PyObject* asdict() {
+ return swig::traits_from< Map >::asdict(*self);
+ }
}
+
%enddef
From 63f21af8d01a38cbefcaae87fe8746ba744eb80d Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Thu, 12 May 2011 20:20:36 +0000
Subject: [PATCH 04/59] PyVarObject_HEAD_INIT to conform to C standard -
pointers cannot be used in static initializers
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12660 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/python/pyinit.swg | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
index d5de1f8a6..7a32a5046 100644
--- a/Lib/python/pyinit.swg
+++ b/Lib/python/pyinit.swg
@@ -143,7 +143,7 @@ swig_varlink_type(void) {
const PyTypeObject tmp = {
/* PyObject header changed in Python 3 */
#if PY_VERSION_HEX >= 0x03000000
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
+ PyVarObject_HEAD_INIT(NULL, 0)
#else
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
@@ -186,11 +186,13 @@ swig_varlink_type(void) {
#endif
};
varlink_type = tmp;
- /* for Python 3 we already assigned ob_type in PyVarObject_HEAD_INIT() */
-#if PY_VERSION_HEX < 0x03000000
- varlink_type.ob_type = &PyType_Type;
-#endif
type_init = 1;
+#if PY_VERSION_HEX < 0x02020000
+ varlink_type.ob_type = &PyType_Type;
+#else
+ if (PyType_Ready(&varlink_type) < 0)
+ return NULL;
+#endif
}
return &varlink_type;
}
From 1aa65e2220b99e204c5f4e83f7f7b56904849815 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Thu, 12 May 2011 21:07:57 +0000
Subject: [PATCH 05/59] PyVarObject_HEAD_INIT to conform to C standard -
pointers cannot be used in static initializers
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12661 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/python/builtin.swg | 144 +++++++++++++++++++++++------------------
1 file changed, 81 insertions(+), 63 deletions(-)
diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg
index de1457c41..b6f0c4ce0 100644
--- a/Lib/python/builtin.swg
+++ b/Lib/python/builtin.swg
@@ -336,68 +336,6 @@ SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value)
return -1;
}
-SWIGINTERN PyTypeObject SwigPyStaticVar_Type = {
-#if PY_VERSION_HEX >= 0x03000000
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
-#else
- PyObject_HEAD_INIT(&PyType_Type)
- 0,
-#endif
- "swig_static_var_getset_descriptor",
- sizeof(PyGetSetDescrObject),
- 0,
- (destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_compare */
- (reprfunc)SwigPyStaticVar_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- PyObject_GenericGetAttr, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */
- 0, /* tp_doc */
- SwigPyStaticVar_traverse, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- (descrgetfunc)SwigPyStaticVar_get, /* tp_descr_get */
- (descrsetfunc)SwigPyStaticVar_set, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
-#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
-#endif
-#if PY_VERSION_HEX >= 0x02060000
- 0, /* tp_version */
-#endif
-#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
-#endif
-};
-
SWIGINTERN int
SwigPyObjectType_setattro(PyTypeObject *type, PyObject *name, PyObject *value) {
PyObject *attribute;
@@ -424,10 +362,90 @@ SwigPyObjectType_setattro(PyTypeObject *type, PyObject *name, PyObject *value) {
return -1;
}
+SWIGINTERN PyTypeObject*
+SwigPyStaticVar_Type(void) {
+ static PyTypeObject staticvar_type;
+ 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,
+#endif
+ "swig_static_var_getset_descriptor",
+ sizeof(PyGetSetDescrObject),
+ 0,
+ (destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ (reprfunc)SwigPyStaticVar_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */
+ 0, /* tp_doc */
+ SwigPyStaticVar_traverse, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ (descrgetfunc)SwigPyStaticVar_get, /* tp_descr_get */
+ (descrsetfunc)SwigPyStaticVar_set, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
+#endif
+#if PY_VERSION_HEX >= 0x02060000
+ 0, /* tp_version */
+#endif
+#ifdef COUNT_ALLOCS
+ 0,0,0,0 /* tp_alloc -> tp_next */
+#endif
+ };
+ staticvar_type = tmp;
+ type_init = 1;
+#if PY_VERSION_HEX < 0x02020000
+ staticvar_type.ob_type = &PyType_Type;
+#else
+ if (PyType_Ready(&staticvar_type) < 0)
+ return NULL;
+#endif
+ }
+ return &staticvar_type;
+}
+
SWIGINTERN PyGetSetDescrObject *
SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) {
+
PyGetSetDescrObject *descr;
- descr = (PyGetSetDescrObject *)PyType_GenericAlloc(&SwigPyStaticVar_Type, 0);
+ descr = (PyGetSetDescrObject *)PyType_GenericAlloc(SwigPyStaticVar_Type(), 0);
assert(descr);
Py_XINCREF(type);
PyDescr_TYPE(descr) = type;
From 34e7c826317db2a38e8a6e9a2ab3c4b860078723 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 13 May 2011 05:58:58 +0000
Subject: [PATCH 06/59] Remove a compiler warning for builtin
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12662 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/python/pyrun.swg | 1 +
1 file changed, 1 insertion(+)
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
index c9b772e4b..d730a2dbe 100644
--- a/Lib/python/pyrun.swg
+++ b/Lib/python/pyrun.swg
@@ -1070,6 +1070,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
return (SwigPyObject *) pyobj;
#ifdef SWIGPYTHON_BUILTIN
+ (void)obj;
# ifdef PyWeakref_CheckProxy
if (PyWeakref_CheckProxy(pyobj)) {
pyobj = PyWeakref_GET_OBJECT(pyobj);
From d2dd14e6280083392c6a47b5ac65ffeb5a42dc9b Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 13 May 2011 06:01:07 +0000
Subject: [PATCH 07/59] Python 3.2 portability fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12663 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Varargs.html | 41 ++++++++----
Examples/test-suite/python_varargs_typemap.i | 67 +++++++++++++-------
2 files changed, 71 insertions(+), 37 deletions(-)
diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html
index fb34a3ad9..eb14363af 100644
--- a/Doc/Manual/Varargs.html
+++ b/Doc/Manual/Varargs.html
@@ -461,23 +461,36 @@ like this:
%typemap(in) (...)(char *args[10]) {
- int i;
- int argc;
- for (i = 0; i < 10; i++) args[i] = 0;
- argc = PyTuple_Size(varargs);
- if (argc > 10) {
- PyErr_SetString(PyExc_ValueError,"Too many arguments");
+ int i;
+ int argc;
+ for (i = 0; i < 10; i++) args[i] = 0;
+ argc = PyTuple_Size(varargs);
+ if (argc > 10) {
+ PyErr_SetString(PyExc_ValueError, "Too many arguments");
+ return NULL;
+ }
+ for (i = 0; i < argc; i++) {
+ PyObject *pyobj = PyTuple_GetItem(varargs, i);
+ char *str = 0;
+%#if PY_VERSION_HEX>=0x03000000
+ PyObject *pystr;
+ if (!PyUnicode_Check(pyobj)) {
+ PyErr_SetString(PyExc_ValueError, "Expected a string");
return NULL;
}
- for (i = 0; i < argc; i++) {
- PyObject *o = PyTuple_GetItem(varargs,i);
- if (!PyString_Check(o)) {
- PyErr_SetString(PyExc_ValueError,"Expected a string");
- return NULL;
- }
- args[i] = PyString_AsString(o);
+ pystr = PyUnicode_AsUTF8String(pyobj);
+ str = PyBytes_AsString(pystr);
+ Py_XDECREF(pystr);
+%#else
+ if (!PyString_Check(pyobj)) {
+ PyErr_SetString(PyExc_ValueError, "Expected a string");
+ return NULL;
}
- $1 = (void *) args;
+ str = PyString_AsString(pyobj);
+%#endif
+ args[i] = str;
+ }
+ $1 = (void *) args;
}
diff --git a/Examples/test-suite/python_varargs_typemap.i b/Examples/test-suite/python_varargs_typemap.i
index 3fdf8d4d5..4bc6f3fbd 100644
--- a/Examples/test-suite/python_varargs_typemap.i
+++ b/Examples/test-suite/python_varargs_typemap.i
@@ -4,40 +4,61 @@
* chapter of the SWIG manual.
*/
+%{
+%}
+
%typemap(in) (...)(char *args[10]) {
- int i;
- int argc;
- for (i = 0; i < 10; i++) args[i] = 0;
- argc = PyTuple_Size(varargs);
- if (argc > 10) {
- PyErr_SetString(PyExc_ValueError,"Too many arguments");
+ int i;
+ int argc;
+ for (i = 0; i < 10; i++) args[i] = 0;
+ argc = PyTuple_Size(varargs);
+ if (argc > 10) {
+ PyErr_SetString(PyExc_ValueError, "Too many arguments");
+ return NULL;
+ }
+ for (i = 0; i < argc; i++) {
+ PyObject *pyobj = PyTuple_GetItem(varargs, i);
+ char *str = 0;
+%#if PY_VERSION_HEX>=0x03000000
+ PyObject *pystr;
+ if (!PyUnicode_Check(pyobj)) {
+ PyErr_SetString(PyExc_ValueError, "Expected a string");
return NULL;
}
- for (i = 0; i < argc; i++) {
- PyObject *o = PyTuple_GetItem(varargs,i);
- if (!PyString_Check(o)) {
- PyErr_SetString(PyExc_ValueError,"Expected a string");
- return NULL;
- }
- args[i] = PyString_AsString(o);
+ pystr = PyUnicode_AsUTF8String(pyobj);
+ str = PyBytes_AsString(pystr);
+ Py_XDECREF(pystr);
+%#else
+ if (!PyString_Check(pyobj)) {
+ PyErr_SetString(PyExc_ValueError, "Expected a string");
+ return NULL;
}
- $1 = (void *) args;
+ str = PyString_AsString(pyobj);
+%#endif
+ args[i] = str;
+ }
+ $1 = (void *) args;
}
%feature("action") testfunc {
- char **args = (char **) arg3;
- result = testfunc(arg1, arg2, args[0], args[1], args[2], args[3], args[4],
- args[5],args[6],args[7],args[8],args[9], NULL);
+ char **args = (char **) arg3;
+ result = testfunc(arg1, arg2, args[0], args[1], args[2], args[3], args[4],
+ args[5],args[6],args[7],args[8],args[9], NULL);
}
%inline {
char* testfunc (int arg1, double arg2, ...)
{
- va_list ap;
- char *c;
- va_start(ap, arg2);
- c = va_arg(ap, char*);
- va_end(ap);
- return c;
+ va_list ap;
+ char *c;
+ va_start(ap, arg2);
+ c = va_arg(ap, char*);
+ va_end(ap);
+ return c;
}
}
+
+%inline %{
+char *doublecheck(char *inputval) { return inputval; }
+%}
+
From ef1546a287851ddea8eeb515bc925b557ebf8063 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 14 May 2011 00:10:10 +0000
Subject: [PATCH 08/59] cosmetic - cleanup
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12664 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/python/builtin.swg | 4 ----
1 file changed, 4 deletions(-)
diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg
index b6f0c4ce0..97150dc5c 100644
--- a/Lib/python/builtin.swg
+++ b/Lib/python/builtin.swg
@@ -285,10 +285,6 @@ SwigPyBuiltin_FunpackSetterClosure (PyObject *obj, PyObject *val, void *closure)
SWIGINTERN void
SwigPyStaticVar_dealloc(PyDescrObject *descr) {
_PyObject_GC_UNTRACK(descr);
- /*
- Py_XDECREF(descr->d_type);
- Py_XDECREF(descr->d_name);
- */
Py_XDECREF(PyDescr_TYPE(descr));
Py_XDECREF(PyDescr_NAME(descr));
PyObject_GC_Del(descr);
From 6e87b73c40b427dc7591a197cb5b615cf5423f54 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 14 May 2011 00:11:40 +0000
Subject: [PATCH 09/59] reorder tests alphabetically
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12665 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/python/Makefile.in | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index 108cb60eb..0e600b16f 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -31,42 +31,42 @@ PY2TO3 = 2to3 -x import
CPP_TEST_CASES += \
argcargvtest \
- python_autodoc \
- python_append \
callback \
complextest \
director_stl \
director_wstring \
file_test \
iadd \
- inout \
- input \
- inplaceadd \
implicittest \
+ inout \
+ inplaceadd \
+ input \
li_cstring \
li_cwstring \
li_factory \
li_implicit \
- li_std_vectora \
- li_std_vector_extra \
li_std_map_member \
li_std_multimap \
li_std_pair_extra \
li_std_set \
li_std_stream \
li_std_string_extra \
+ li_std_vectora \
+ li_std_vector_extra \
li_std_wstream \
li_std_wstring \
primitive_types \
python_abstractbase \
+ python_append \
+ python_autodoc \
python_kwargs \
python_nondynamic \
python_overload_simple_cast \
python_richcompare \
+ simutry \
std_containers \
swigobject \
- template_matrix \
- simutry
+ template_matrix
# li_std_carray
# director_profile
@@ -88,13 +88,13 @@ C_TEST_CASES += \
include $(srcdir)/../common.mk
BUILTIN_BROKEN = \
- li_std_string_extra.cpptest \
- li_std_wstring.cpptest \
default_constructor.cpptest \
director_exception.cpptest \
exception_order.cpptest \
- threads_exception.cpptest \
- python_abstractbase.cpptest
+ li_std_string_extra.cpptest \
+ li_std_wstring.cpptest \
+ python_abstractbase.cpptest \
+ threads_exception.cpptest
BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES))
From 74aa3f218f47ae49faf58a2073f5425e7aa61033 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 14 May 2011 00:13:43 +0000
Subject: [PATCH 10/59] %varargs - better documentation and remove additional
argument generation which didn't work properly as a sentinel
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12666 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 8 ++++
Doc/Manual/Varargs.html | 49 ++++++++++++++++-----
Examples/test-suite/python/varargs_runme.py | 7 ++-
Source/CParse/parser.y | 9 +++-
4 files changed, 57 insertions(+), 16 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index dca3acdd6..464a9579a 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -4,6 +4,14 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.4 (in progress)
===========================
+2011-05-14: wsfulton
+ %varargs when used with a numeric argument used to create an additional argument
+ which was intended to provide a guaranteed sentinel value. This never worked and now
+ the additional argument is not generated.
+
+2011-05-13: wsfulton
+ [python] Additional fixes for python3.2 support.
+
2011-05-07: szager
[python] Fixed PyGetSetDescr for python3.2.
diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html
index eb14363af..ed52001e8 100644
--- a/Doc/Manual/Varargs.html
+++ b/Doc/Manual/Varargs.html
@@ -331,33 +331,62 @@ int open(const char *path, int oflags, int mode = 0);
In this case, %varargs is simply providing more specific information about the
extra arguments that might be passed to a function.
-If the parameters to a varargs function are of uniform type, %varargs can also
+If the arguments to a varargs function are of uniform type, %varargs can also
accept a numerical argument count as follows:
-%varargs(10,char *arg = NULL) execlp;
+%varargs(3, char *str = NULL) execlp;
...
-int execlp(const char *path, const char *arg1, ...);
+int execlp(const char *path, const char *arg, ...);
-This would wrap execlp() as a function that accepted up to 10 optional arguments.
+and is effectively seen as:
+
+
+
+
+int execlp(const char *path, const char *arg,
+ char *str1 = NULL,
+ char *str2 = NULL,
+ char *str3 = NULL);
+
+
+
+
+This would wrap execlp() as a function that accepted up to 3 optional arguments.
Depending on the application, this may be more than enough for practical purposes.
-Argument replacement is most appropriate in cases where the types of
-the extra arguments is uniform and the maximum number of arguments is
-known. When replicated argument replacement is used, at least one extra
-argument is added to the end of the arguments when making the function call.
-This argument serves as a sentinel to make sure the list is properly terminated.
-It has the same value as that supplied to the %varargs directive.
+The handling of default arguments can be changed via the
+compactdefaultargs feature. If this feature is used, for example
+
+
+
+
+%feature("compactdefaultargs") execlp;
+%varargs(3, char *str = NULL) execlp;
+...
+int execlp(const char *path, const char *arg, ...);
+
+
+
+
+a call from the target language which does not provide the maximum number of arguments, such as,
+execlp("a", "b", "c")
+will generate C code which includes the missing default values, that is, execlp("a", "b", "c", NULL, NULL).
+If compactdefaultargs is not used, then the generated code will be
+execlp("a", "b", "c"). The former is useful for helping providing a sentinel to terminate the argument list.
+Argument replacement is most appropriate in cases where the types of
+the extra arguments are uniform and the maximum number of arguments are
+known.
Argument replacement is not as useful when working with functions that accept
mixed argument types such as printf(). Providing general purpose
wrappers to such functions presents special problems (covered shortly).
diff --git a/Examples/test-suite/python/varargs_runme.py b/Examples/test-suite/python/varargs_runme.py
index f96a43d85..2c68f4e06 100644
--- a/Examples/test-suite/python/varargs_runme.py
+++ b/Examples/test-suite/python/varargs_runme.py
@@ -27,11 +27,10 @@ if varargs.test_plenty("Hello", 1) != "Hello":
if varargs.test_plenty("Hello", 1, 2) != "Hello":
raise RuntimeError, "Failed"
-if varargs.test_plenty("Hello", 1, 2, 3) != "Hello":
- raise RuntimeError, "Failed"
-
try:
- varargs.test_plenty("Hello", 1, 2, 3, 4)
+ varargs.test_plenty("Hello", 1, 2, 3)
raise RuntimeError
except NotImplementedError:
pass
+except TypeError:
+ pass
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index d95390892..2ac0c1916 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -2627,10 +2627,15 @@ varargs_parms : parms { $$ = $1; }
Swig_error(cparse_file, cparse_line,"Argument count in %%varargs must be positive.\n");
$$ = 0;
} else {
+ String *name = Getattr($3, "name");
$$ = Copy($3);
- Setattr($$,"name","VARARGS_SENTINEL");
- for (i = 0; i < n; i++) {
+ if (name)
+ Setattr($$, "name", NewStringf("%s%d", name, n));
+ for (i = 1; i < n; i++) {
p = Copy($3);
+ name = Getattr(p, "name");
+ if (name)
+ Setattr(p, "name", NewStringf("%s%d", name, n-i));
set_nextSibling(p,$$);
Delete($$);
$$ = p;
From 830e019a09673cce6b80948c4a7b8fd3beca7a22 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 14 May 2011 01:09:36 +0000
Subject: [PATCH 11/59] HTML fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12667 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Contents.html | 5 ++++
Doc/Manual/Python.html | 50 +++++++++++++++++++++++-----------------
2 files changed, 34 insertions(+), 21 deletions(-)
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 74a201bc6..736bd08a8 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -1332,6 +1332,11 @@
Further details on the Python class interface
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index fac680825..c7a083701 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -43,7 +43,11 @@
Further details on the Python class interface
@@ -2210,7 +2214,7 @@ unacceptable for a high-performance library. The new -builtin
option instructs SWIG to forego the use of proxy classes, and instead
create wrapped types as new built-in Python types. When this option is used,
the following section ("Proxy classes") does not apply. Details on the use of
-the -builtin option are in the Built-in Classes
+the -builtin option are in the Built-in Classes
section.
@@ -2303,7 +2307,8 @@ you can attach new Python methods to the class and you can even inherit from it
by Python built-in types until Python 2.2).
-33.4.2 Built-in Classes
+33.4.2 Built-in Classes
+
The -builtin option provides a significant performance improvement
@@ -2346,23 +2351,25 @@ please refer to the python documentation:
http://docs.python.org/extending/newtypes.html
-33.4.2.1 Limitations
+33.4.2.1 Limitations
+
Use of the -builtin option implies a couple of limitations:
-python version support:
-
-- Versions 2.5 and up are fully supported
-- Versions 2.3 and 2.4 are mostly supported; there are problems with director classes and/or sub-classing a wrapped type in python.
-- Versions older than 2.3 are not supported.
-
-Some legacy syntax is no longer supported; in particular:
-
-- The functional interface is no longer exposed. For example, you may no longer call Whizzo.new_CrunchyFrog(). Instead, you must use Whizzo.CrunchyFrog().
-- Static member variables are no longer accessed through the 'cvar' field (e.g., Dances.cvar.FishSlap).
-They are instead accessed in the idiomatic way (Dances.FishSlap).
-
-Wrapped types may not be raised as python exceptions. Here's why: the python internals expect that all sub-classes of Exception will have this struct layout:
+ python version support:
+
+ - Versions 2.5 and up are fully supported
+ - Versions 2.3 and 2.4 are mostly supported; there are problems with director classes and/or sub-classing a wrapped type in python.
+ - Versions older than 2.3 are not supported.
+
+
+ Some legacy syntax is no longer supported; in particular:
+
+ - The functional interface is no longer exposed. For example, you may no longer call Whizzo.new_CrunchyFrog(). Instead, you must use Whizzo.CrunchyFrog().
+ - Static member variables are no longer accessed through the 'cvar' field (e.g., Dances.cvar.FishSlap).
+ They are instead accessed in the idiomatic way (Dances.FishSlap).
+
+Wrapped types may not be raised as python exceptions. Here's why: the python internals expect that all sub-classes of Exception will have this struct layout:
@@ -2422,7 +2429,6 @@ class MyPyException (Exception) :
Reverse binary operators (e.g., __radd__) are not supported.
-
To illustrate the last point, if you have a wrapped class called MyString,
@@ -2473,7 +2479,8 @@ The above code fails, because the first operand -- a native python string --
doesn't know how to add an instance of MyString to itself.
-
33.4.2.2 Operator overloads -- use them!
+
33.4.2.2 Operator overloads -- use them!
+
The entire justification for the -builtin option is improved
performance. To that end, the best way to squeeze maximum performance out
@@ -2491,10 +2498,10 @@ slot entries. For example, suppose you have this class:
class Twit {
public:
- Twit operator+ (const Twit& twit) const;
+ Twit operator+ (const Twit& twit) const;
// Forward to operator+
- Twit add (const Twit& twit) const
+ Twit add (const Twit& twit) const
{ return *this + twit; }
};
@@ -2575,6 +2582,7 @@ structs.
33.4.3 Memory management
+
NOTE: Although this section refers to proxy objects, everything here also applies
when the -builtin option is used.
From aac2b5d2e16bba3866b6643473f68a7a82d91594 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 14 May 2011 23:54:09 +0000
Subject: [PATCH 12/59] Remove VARARGS_SENTINEL typemaps further to revision
12666. Note that the idea of having a named typemap for sentinels is flawed
unless the named typemap is provided for every single type in the typemap
library.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12668 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Varargs.html | 20 ++++++++++++++++++++
Lib/swig.swg | 6 ------
Lib/typemaps/swigtype.swg | 5 -----
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html
index ed52001e8..c27db603d 100644
--- a/Doc/Manual/Varargs.html
+++ b/Doc/Manual/Varargs.html
@@ -381,6 +381,26 @@ a call from the target language which does not provide the maximum number of arg
will generate C code which includes the missing default values, that is, execlp("a", "b", "c", NULL, NULL).
If compactdefaultargs is not used, then the generated code will be
execlp("a", "b", "c"). The former is useful for helping providing a sentinel to terminate the argument list.
+However, this is not guaranteed, for example when a user passes a non-NULL value for all the parameters.
+When using compactdefaultargs it is possible to guarantee the NULL sentinel is passed through the,
+numinputs=0 'in' typemap attribute, naming the last parameter.
+For example,
+
+
+
+
+%feature("compactdefaultargs") execlp;
+%varargs(3, char *str = NULL) execlp;
+%typemap(in, numinputs=0) char *str3 ""
+...
+int execlp(const char *path, const char *arg, ...);
+
+
+
+
+Note that str3 is the name of the last argument, as we have used %vargars with 3.
+Now execlp("a", "b", "c", "d", "e") will result in an error as one too many arguments has been passed,
+as now only 2 additional 'str' arguments can be passed with the 3rd one always using the specified default NULL.
diff --git a/Lib/swig.swg b/Lib/swig.swg
index e7c01823e..a6fef0257 100644
--- a/Lib/swig.swg
+++ b/Lib/swig.swg
@@ -500,12 +500,6 @@ namespace std {
}
}
-/* Typemap for variable length arguments sentinel value. Used
- by the %varargs directive. */
-
-%typemap(in,numinputs=0) SWIGTYPE *VARARGS_SENTINEL, SWIGTYPE VARARGS_SENTINEL "";
-
-
/* -----------------------------------------------------------------------------
* Overloading support
* ----------------------------------------------------------------------------- */
diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg
index bd113e278..47baabf52 100644
--- a/Lib/typemaps/swigtype.swg
+++ b/Lib/typemaps/swigtype.swg
@@ -559,11 +559,6 @@
* --- Special typemaps ---
* ------------------------------------------------------------ */
-/* VARARGS_SENTINEL typemap. Used by the %varargs directive. */
-
-%typemap(in,numinputs=0) SWIGTYPE *VARARGS_SENTINEL, SWIGTYPE VARARGS_SENTINEL "";
-
-
/* DISOWN typemap */
%typemap(in, noblock=1) SWIGTYPE *DISOWN (int res = 0) {
From cb0a9752064e0cd64ed82656f02daacbbeec5fc0 Mon Sep 17 00:00:00 2001
From: Stefan Zager
Date: Mon, 16 May 2011 06:12:15 +0000
Subject: [PATCH 13/59] Documented non-looping dependency graph requirement for
-builtin.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12669 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Python.html | 90 ++++++++++++++++++++++++++++++++++++++----
1 file changed, 82 insertions(+), 8 deletions(-)
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index c7a083701..0ca6796af 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -2369,7 +2369,8 @@ please refer to the python documentation:
- Static member variables are no longer accessed through the 'cvar' field (e.g., Dances.cvar.FishSlap).
They are instead accessed in the idiomatic way (Dances.FishSlap).
-Wrapped types may not be raised as python exceptions. Here's why: the python internals expect that all sub-classes of Exception will have this struct layout:
+
+ Wrapped types may not be raised as python exceptions. Here's why: the python internals expect that all sub-classes of Exception will have this struct layout:
@@ -2427,14 +2428,10 @@ class MyPyException (Exception) :
-Reverse binary operators (e.g., __radd__) are not supported.
-
-
-
-To illustrate the last point, if you have a wrapped class called MyString,
+
Reverse binary operators (e.g., __radd__) are not supported.
+To illustrate this point, if you have a wrapped class called MyString,
and you want to use instances of MyString interchangeably with native python
-strings, you can define an 'operator+ (const char*)' method :
-
+strings, you can define an 'operator+ (const char*)' method :
@@ -2478,6 +2475,83 @@ episode = "Dead " + mystr
The above code fails, because the first operand -- a native python string --
doesn't know how to add an instance of MyString to itself.
+
+
+
If you have multiple SWIG modules that share type information (more info),
+the -builtin option requiress a bit of extra discipline to ensure that base classes are initialized before derived classes. Specifically:
+
+- There must be an unambiguous non-looping dependency graph for the modules.
+- Module dependencies must be explicitly stated with %import statements in the SWIG interface file.
+
+
+
+
As an example, suppose module A has this interface in A.i :
+
+
+%module "A";
+
+class Base {
+...
+};
+
+
+
If you want to wrap another module containing a class that inherits from A, this is how it would look :
+
+
+%module "B";
+
+%import "A.i"
+
+class Derived : public Base {
+...
+};
+
+
+
The import "A.i" statement is required, because module B depends on module A.
+
+
As long as you obey these requirements, your python code may import the modules in any order :
+
+
+import B
+import A
+
+d = B.Derived()
+
+
+
Here's an example of two interface files that have a dependency loop:
+
+
A.i:
+
+
+%module "A";
+
+class BaseA {
+...
+};
+
+class DerivedA : public BaseB {
+...
+};
+
+
+
B.i:
+
+
+%module "B";
+
+class BaseB {
+...
+};
+
+class DerivedB : public BaseA {
+...
+};
+
+
+
These modules are incompatible with the -builtin option.
+
+
+
33.4.2.2 Operator overloads -- use them!
From 8848b16e01af1b90c01d1c9e3fc6d92259df4d61 Mon Sep 17 00:00:00 2001
From: Xavier Delacour
Date: Tue, 17 May 2011 01:56:43 +0000
Subject: [PATCH 14/59] Octave changes by Karl Wette:
It's currently not possible to tell SWIG whether or not symbols should be
loaded into the global namespace by default. In fact, it's not even possible
to make the generated .oct module *not* load all symbols globally, due to a
bug in Lib/octave/octruntime.swg (line 37: "noglobal" should be "global").
It's also not possible to change the name of the symbol used to access
global variables/constants from the default "cvar".
This patch adds 3 Octave-specific command-line options:
* -global/-noglobal tell SWIG whether the generated .oct module should load
symbols into the global namespace by default. The default option is -global
to preserve existing behaviour.
* -globals sets the name of the symbol used to access global
variables/constants. It is set to "cvar" by default.
These options are parsed in Source/Modules/octave.cxx, and written to the
wrapping code as the macros SWIG_global_load and SWIG_global_name.
In Lib/octave/octruntime.swg, the Octave entry point DEFUN_DLD function now
contains a expanded input argument parser, which uses the same command-line
arguments (-global/-noglobal, -globals) as can be passed to SWIG itself;
this allows the module user to change the default loading behaviour of the
module user at load time. The parser checks for non-string and unrecognised
arguments, and also checks that the argument to -globals is a valid Octave
identifier. A -help option prints a short usage message.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12670 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/octave/octruntime.swg | 51 ++++++++++++++++++++++++++++++++-------
Source/Modules/octave.cxx | 33 ++++++++++++++++++++++---
2 files changed, 72 insertions(+), 12 deletions(-)
diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg
index e19b781c2..48da0cf48 100644
--- a/Lib/octave/octruntime.swg
+++ b/Lib/octave/octruntime.swg
@@ -1,4 +1,5 @@
%insert(runtime) %{
+#include
#include
#include
#include
@@ -20,6 +21,45 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
static bool already_init=false;
if (already_init)
return octave_value_list();
+
+ // parse command line
+ const char* usage="usage: " SWIG_name_d " [-global|-noglobal] [-globals ]";
+ bool global_load=SWIG_global_load;
+ std::string global_name=SWIG_global_name;
+ for (int j=0;jassign(swig_globals[j].name,&swig_globals[j]);
octave_swig_type* module_ns=new octave_swig_type(0, 0, 0, true);
- module_ns->assign("cvar",Swig::swig_value_ref(cvar_ns));
+ module_ns->assign(global_name,Swig::swig_value_ref(cvar_ns));
for (int j=0;swig_globals[j].name;++j)
if (swig_globals[j].method)
module_ns->assign(swig_globals[j].name,&swig_globals[j]);
@@ -68,7 +101,7 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
// the incref is necessary so install_global doesn't destroy module_ns,
// as it would if it installed something with the same name as the module.
module_ns->incref();
- if (global_option)
+ if (global_load)
module_ns->install_global();
module_ns->decref();
diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx
index ab53340fe..dcd690844 100644
--- a/Source/Modules/octave.cxx
+++ b/Source/Modules/octave.cxx
@@ -15,9 +15,14 @@ char cvsroot_octave_cxx[] = "$Id$";
#include "swigmod.h"
+static bool global_load = true;
+static String *global_name = 0;
+
static const char *usage = (char *) "\
Octave Options (available with -octave)\n\
- [no additional options]\n\
+ -global - Load all symbols into the global namespace [default]\n\
+ -globals - Set used to access C global variables [default: 'cvar']\n\
+ -noglobal - Do not load all symbols into the global namespace\n\
\n";
@@ -64,11 +69,29 @@ public:
for (int i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) {
- fputs(usage, stdout);
- }
+ fputs(usage, stderr);
+ } else if (strcmp(argv[i], "-global") == 0) {
+ global_load = true;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i], "-noglobal") == 0) {
+ global_load = false;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i], "-globals") == 0) {
+ if (argv[i + 1]) {
+ global_name = NewString(argv[i + 1]);
+ Swig_mark_arg(i);
+ Swig_mark_arg(i + 1);
+ i++;
+ } else {
+ Swig_arg_error();
+ }
+ }
}
}
+ if (!global_name)
+ global_name = NewString("cvar");
+
SWIG_library_directory("octave");
Preprocessor_define("SWIGOCTAVE 1", 0);
SWIG_config_file("octave.swg");
@@ -131,6 +154,10 @@ public:
Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module);
Printf(f_runtime, "#define SWIG_name %s\n", module);
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIG_global_load %s\n", global_load ? "true" : "false");
+ Printf(f_runtime, "#define SWIG_global_name \"%s\"\n", global_name);
+
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
Swig_banner(f_directors_h);
From a3689a02fc646162259465fb102061fb9499f398 Mon Sep 17 00:00:00 2001
From: Xavier Delacour
Date: Tue, 17 May 2011 01:57:46 +0000
Subject: [PATCH 15/59] Fixes to two bugs in Lib/octave/octcomplex.swg (by Karl
Wette)
* replace PyObject with octave_value in the SWIG_AsVal(float) fragment
* modify %swig_fromcplx_conv to use the correct Octave constructor for
double (Complex) and float (FloatComplex)
Also remove an unneeded %ifcplusplus (Octave wrapping code is always in C++).
Checked that %swig_cplxflt_convn now compiles correctly for single-precision
complex values, and that make check-octave-examples passes.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12671 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/octave/octcomplex.swg | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/Lib/octave/octcomplex.swg b/Lib/octave/octcomplex.swg
index 7eb373ae4..a3e9ebf77 100644
--- a/Lib/octave/octcomplex.swg
+++ b/Lib/octave/octcomplex.swg
@@ -4,17 +4,17 @@
the complex Constructor method, and the Real and Imag complex
accesor methods.
- See the std_complex.i and ccomplex.i for concret examples.
+ See the std_complex.i and ccomplex.i for concrete examples.
*/
/* the common from conversor */
-%define %swig_fromcplx_conv(Type, Real, Imag)
+%define %swig_fromcplx_conv(Type, OctConstructor, Real, Imag)
%fragment(SWIG_From_frag(Type),"header")
{
SWIGINTERNINLINE octave_value
- SWIG_From(Type)(%ifcplusplus(const Type&, Type) c)
+ SWIG_From(Type)(const Type& c)
{
- return octave_value(Complex(Real(c), Imag(c)));
+ return octave_value(OctConstructor(Real(c), Imag(c)));
}
}
%enddef
@@ -45,7 +45,7 @@
return SWIG_TypeError;
}
}
-%swig_fromcplx_conv(Type, Real, Imag);
+%swig_fromcplx_conv(Type, Complex, Real, Imag);
%enddef
// the float case
@@ -53,7 +53,7 @@
%fragment(SWIG_AsVal_frag(Type),"header",
fragment=SWIG_AsVal_frag(float)) {
SWIGINTERN int
- SWIG_AsVal(Type)(PyObject *o, Type *val)
+ SWIG_AsVal(Type) (const octave_value& ov, Type* val)
{
if (ov.is_complex_scalar()) {
if (val) {
@@ -81,7 +81,7 @@
}
}
-%swig_fromcplx_conv(Type, Real, Imag);
+%swig_fromcplx_conv(Type, FloatComplex, Real, Imag);
%enddef
#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \
@@ -90,6 +90,3 @@
#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \
%swig_cplxdbl_conv(Type, Constructor, Real, Imag)
-
-
-
From e22eb835742606b3911956a344a66f3780dd0338 Mon Sep 17 00:00:00 2001
From: Xavier Delacour
Date: Tue, 17 May 2011 01:59:19 +0000
Subject: [PATCH 16/59] Minor improvement to the printing of Octave SWIG
classes (by Karl Wette)
Uses Octave's indentation functions to make sure the classes are
printed at the correct indentation level, e.g. for a cell array
containing SWIG-wrapped classes.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12672 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/octave/octrun.swg | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg
index 5b90d91b3..657223f7a 100644
--- a/Lib/octave/octrun.swg
+++ b/Lib/octave/octrun.swg
@@ -849,26 +849,32 @@ namespace Swig {
member_map tmp;
load_members(tmp);
- os << "{" << std::endl;
+ indent(os);
+ os << "{"; newline(os);
+ increment_indent_level();
for (unsigned int j = 0; j < types.size(); ++j) {
+ indent(os);
if (types[j].first->clientdata) {
const swig_octave_class *c = (const swig_octave_class *) types[j].first->clientdata;
- os << " " << c->name << ", ptr = " << types[j].second.ptr << std::endl;
+ os << c->name << ", ptr = " << types[j].second.ptr; newline(os);
} else {
- os << " " << types[j].first->name << ", ptr = " << types[j].second.ptr << std::endl;
+ os << types[j].first->name << ", ptr = " << types[j].second.ptr; newline(os);
}
}
for (member_map::const_iterator it = tmp.begin(); it != tmp.end(); ++it) {
+ indent(os);
if (it->second.first) {
const char *objtype = it->second.first->method ? "method" : "variable";
const char *modifier = (it->second.first->flags &1) ? "static " : (it->second.first->flags &2) ? "global " : "";
- os << " " << it->second.first->name << " (" << modifier << objtype << ")" << std::endl;
+ os << it->second.first->name << " (" << modifier << objtype << ")"; newline(os);
assert(it->second.first->name == it->first);
} else {
- os << " " << it->first << std::endl;
+ os << it->first; newline(os);
}
}
- os << "}" << std::endl;
+ decrement_indent_level();
+ indent(os);
+ os << "}"; newline(os);
}
};
@@ -998,7 +1004,8 @@ namespace Swig {
}
void print(std::ostream &os, bool pr_as_read_syntax = false) const {
- os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size() << std::endl;
+ indent(os);
+ os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size(); newline(os);
}
From 360c1aaa1b82aa49a4270fccf29f6ed2d6e2cd83 Mon Sep 17 00:00:00 2001
From: Xavier Delacour
Date: Tue, 17 May 2011 01:59:53 +0000
Subject: [PATCH 17/59] Fix an incompatibility with never versions of Octave
(by Karl Wette)
According to the Octave changelog (ChangeLog and src/ChangeLog
in the Octave 3.4.0 source), octave_base_value::map_value() now
returns an octave_map instead of an Octave_map; this change dates
from Octave API version 40 onward. This patch makes the necessary
changes to the SWIG runtime while remaining backward-compatible.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12673 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/octave/octrun.swg | 11 +++++++++++
Lib/octave/octtypemaps.swg | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg
index 657223f7a..81c10d528 100644
--- a/Lib/octave/octrun.swg
+++ b/Lib/octave/octrun.swg
@@ -715,9 +715,15 @@ namespace Swig {
return outarg(0).string_value();
}
+#if OCTAVE_API_VERSION_NUMBER >= 40
+ virtual octave_map map_value() const {
+ return octave_map();
+ }
+#else
virtual Octave_map map_value() const {
return Octave_map();
}
+#endif
virtual string_vector map_keys() const {
member_map tmp;
@@ -929,8 +935,13 @@ namespace Swig {
virtual std::string string_value(bool force = false) const
{ return ptr->string_value(force); }
+#if OCTAVE_API_VERSION_NUMBER >= 40
+ virtual octave_map map_value() const
+ { return ptr->map_value(); }
+#else
virtual Octave_map map_value() const
{ return ptr->map_value(); }
+#endif
virtual string_vector map_keys() const
{ return ptr->map_keys(); }
diff --git a/Lib/octave/octtypemaps.swg b/Lib/octave/octtypemaps.swg
index cc5fce346..e331cf4b3 100644
--- a/Lib/octave/octtypemaps.swg
+++ b/Lib/octave/octtypemaps.swg
@@ -61,7 +61,7 @@
%typemap(out) octave_value_list {
_outp->append($1);
}
-%typemap(out,noblock=1) Octave_map {
+%typemap(out,noblock=1) octave_map, Octave_map {
$result=$1;
}
%typemap(out,noblock=1) NDArray {
From 2d5c4302b0f27e7e23145b2eaa937cd0c2b73845 Mon Sep 17 00:00:00 2001
From: Xavier Delacour
Date: Tue, 17 May 2011 02:00:25 +0000
Subject: [PATCH 18/59] Adds support for Python __r*__ operators (by Karl
Wette)
The Python operator model, when evaluating e.g. x + y, is to call
x.__add__(y), then y.__radd__(x) if the former does not exist, etc.
This patch adds similar functionality to the SWIG runtime code.
For the special case of the comparison operators __l*__ and __g*__,
the reverse operators are __g*__ and __l*__ respectively.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12674 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/octave/octrun.swg | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg
index 81c10d528..c4c01ed82 100644
--- a/Lib/octave/octrun.swg
+++ b/Lib/octave/octrun.swg
@@ -809,6 +809,16 @@ namespace Swig {
octave_value ret;
if (lhs_ost && lhs_ost->dispatch_binary_op(std::string("__") + op_name + std::string("__"), rhs, ret))
return ret;
+ if (rhs_ost) {
+ if (strlen(op_name) == 2 && (op_name[1] == 't' || op_name[1] == 'e')) {
+ if (op_name[0] == 'l' && rhs_ost->dispatch_binary_op(std::string("__g") + op_name[1] + std::string("__"), lhs, ret))
+ return ret;
+ if (op_name[0] == 'g' && rhs_ost->dispatch_binary_op(std::string("__l") + op_name[1] + std::string("__"), lhs, ret))
+ return ret;
+ }
+ if (rhs_ost->dispatch_binary_op(std::string("__r") + op_name + std::string("__"), lhs, ret))
+ return ret;
+ }
std::string symbol;
octave_value_list args;
From 06221dacaef9d5708532ed7cca0077cba4efc77d Mon Sep 17 00:00:00 2001
From: Xavier Delacour
Date: Tue, 17 May 2011 02:02:15 +0000
Subject: [PATCH 19/59] Allow global operators to be SWIG-wrapped functions (by
Karl Wette)
The Octave run-time allows global operators to be implemented,
e.g. op_scalar_add_X for adding a scalar and a wrapped struct X.
However it doesn't currently seem possible for these operators to
map to SWIG-wrapped functions. This is because dispatch_global_op()
looks for the operators to be installed as global variables, whereas
install_global() installs SWIG-wrapped functions as builtin functions;
the two appear to be separate symbol tables in Octave.
This patch modifies install_global() to install global operator functions
as both builtin functions and as global variables, where the value of the
global variable is a function handle to the operator function. It decides
if a function is a global operator if it begins with the prefix "op_"; this
prefix can be modified through a new command-line variable. It also always
installs the operators globally, regardless of whether the rest of the module
is being loaded globally. To accomplish this, install_global() is now always
called, but takes a bool argument specifying whether it should load symbols
globally. If a function is not a global operator, install_global() should
behave as before.
Tested that this compiles and works on Octave 3.2.4 and 3.4.0.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12675 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/octave/octrun.swg | 26 +++++++++++++++-----------
Lib/octave/octruntime.swg | 3 +--
Source/Modules/octave.cxx | 14 ++++++++++++++
3 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg
index c4c01ed82..49b032fc9 100644
--- a/Lib/octave/octrun.swg
+++ b/Lib/octave/octrun.swg
@@ -457,22 +457,26 @@ namespace Swig {
rhs.members.clear();
}
- void install_global() {
+ void install_global(bool global_load) {
for (member_map::const_iterator it = members.begin(); it != members.end(); ++it) {
- if (it->second.first && it->second.first->method)
+ bool is_global_op = (it->first.substr(0, strlen(SWIG_op_prefix)) == SWIG_op_prefix);
+ bool is_func_defined = (it->second.first && it->second.first->method);
+ if (is_func_defined && (is_global_op || global_load)) {
install_builtin_function(it->second.first->method, it->first,
- it->second.first->doc?it->second.first->doc:std::string());
- else if (it->second.second.is_defined()) {
+ it->second.first->doc ? it->second.first->doc : std::string());
+ }
+ octave_value global_val = is_global_op ? make_fcn_handle(it->first) : it->second.second;
+ if (global_val.is_defined() && (is_global_op || global_load)) {
#if OCTAVE_API_VERSION_NUMBER<37
link_to_global_variable(curr_sym_tab->lookup(it->first, true));
#else
symbol_table::varref(it->first);
symbol_table::mark_global(it->first);
#endif
- set_global_value(it->first, it->second.second);
+ set_global_value(it->first, global_val);
#if OCTAVE_API_VERSION_NUMBER<37
- octave_swig_type *ost = Swig::swig_value_deref(it->second.second);
+ octave_swig_type *ost = Swig::swig_value_deref(global_val);
if (ost) {
const char* h = ost->help_text();
if (h) {
@@ -775,7 +779,7 @@ namespace Swig {
}
static bool dispatch_global_op(const std::string &symbol, const octave_value_list &args, octave_value &ret) {
- // we assume that "op_"-prefixed functions are installed in global namespace
+ // we assume that SWIG_op_prefix-prefixed functions are installed in global namespace
// (rather than any module namespace).
octave_value fcn = get_global_value(symbol, true);
@@ -792,7 +796,7 @@ namespace Swig {
octave_value ret;
if (ost->dispatch_unary_op(std::string("__") + op_name + std::string("__"), ret))
return ret;
- std::string symbol = "op_" + ost->swig_type_name() + "_" + op_name;
+ std::string symbol = SWIG_op_prefix + ost->swig_type_name() + "_" + op_name;
octave_value_list args;
args.append(make_value_hack(x));
if (dispatch_global_op(symbol, args, ret))
@@ -825,7 +829,7 @@ namespace Swig {
args.append(make_value_hack(lhs));
args.append(make_value_hack(rhs));
- symbol = "op_";
+ symbol = SWIG_op_prefix;
symbol += lhs_ost ? lhs_ost->swig_type_name() : lhs.type_name();
symbol += "_";
symbol += op_name;
@@ -834,7 +838,7 @@ namespace Swig {
if (dispatch_global_op(symbol, args, ret))
return ret;
- symbol = "op_";
+ symbol = SWIG_op_prefix;
symbol += lhs_ost ? lhs_ost->swig_type_name() : lhs.type_name();
symbol += "_";
symbol += op_name;
@@ -843,7 +847,7 @@ namespace Swig {
if (dispatch_global_op(symbol, args, ret))
return ret;
- symbol = "op_";
+ symbol = SWIG_op_prefix;
symbol += "any";
symbol += "_";
symbol += op_name;
diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg
index 48da0cf48..da5b9c512 100644
--- a/Lib/octave/octruntime.swg
+++ b/Lib/octave/octruntime.swg
@@ -101,8 +101,7 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
// the incref is necessary so install_global doesn't destroy module_ns,
// as it would if it installed something with the same name as the module.
module_ns->incref();
- if (global_load)
- module_ns->install_global();
+ module_ns->install_global(global_load);
module_ns->decref();
#if OCTAVE_API_VERSION_NUMBER<37
diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx
index dcd690844..b46214463 100644
--- a/Source/Modules/octave.cxx
+++ b/Source/Modules/octave.cxx
@@ -17,12 +17,14 @@ char cvsroot_octave_cxx[] = "$Id$";
static bool global_load = true;
static String *global_name = 0;
+static String *op_prefix = 0;
static const char *usage = (char *) "\
Octave Options (available with -octave)\n\
-global - Load all symbols into the global namespace [default]\n\
-globals - Set used to access C global variables [default: 'cvar']\n\
-noglobal - Do not load all symbols into the global namespace\n\
+ -opprefix - Prefix for global operator functions [default: 'op_']\n\
\n";
@@ -85,12 +87,23 @@ public:
} else {
Swig_arg_error();
}
+ } else if (strcmp(argv[i], "-opprefix") == 0) {
+ if (argv[i + 1]) {
+ op_prefix = NewString(argv[i + 1]);
+ Swig_mark_arg(i);
+ Swig_mark_arg(i + 1);
+ i++;
+ } else {
+ Swig_arg_error();
+ }
}
}
}
if (!global_name)
global_name = NewString("cvar");
+ if (!op_prefix)
+ op_prefix = NewString("op_");
SWIG_library_directory("octave");
Preprocessor_define("SWIGOCTAVE 1", 0);
@@ -157,6 +170,7 @@ public:
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIG_global_load %s\n", global_load ? "true" : "false");
Printf(f_runtime, "#define SWIG_global_name \"%s\"\n", global_name);
+ Printf(f_runtime, "#define SWIG_op_prefix \"%s\"\n", op_prefix);
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
From 1756036825b7994917132b96de81912974fdc02f Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 17 May 2011 05:47:23 +0000
Subject: [PATCH 20/59] Help goes to stdout not stderr
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12676 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Source/Modules/octave.cxx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx
index b46214463..11fbc46fd 100644
--- a/Source/Modules/octave.cxx
+++ b/Source/Modules/octave.cxx
@@ -15,7 +15,7 @@ char cvsroot_octave_cxx[] = "$Id$";
#include "swigmod.h"
-static bool global_load = true;
+static bool global_load = true;
static String *global_name = 0;
static String *op_prefix = 0;
@@ -71,7 +71,7 @@ public:
for (int i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) {
- fputs(usage, stderr);
+ fputs(usage, stdout);
} else if (strcmp(argv[i], "-global") == 0) {
global_load = true;
Swig_mark_arg(i);
From df75ceb87018d0d05b7cd1290be057eddfeb8b88 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 17 May 2011 06:38:53 +0000
Subject: [PATCH 21/59] begin section was missing in some of the docs
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12677 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Extending.html | 11 ++++++-----
Doc/Manual/SWIG.html | 5 +++--
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html
index c6e006033..ff666791c 100644
--- a/Doc/Manual/Extending.html
+++ b/Doc/Manual/Extending.html
@@ -2754,15 +2754,16 @@ int Python::top(Node *n) {
-Within SWIG wrappers, there are four main sections. These are (in order)
+Within SWIG wrappers, there are five main sections. These are (in order)
-- runtime: This section has most of the common SWIG runtime code
-
- header: This section holds declarations and inclusions from the .i file
-
- wrapper: This section holds all the wrappering code
+
- begin: This section is a placeholder for users to put code at the beginning of the C/C++ wrapper file.
+
- runtime: This section has most of the common SWIG runtime code.
+
- header: This section holds declarations and inclusions from the .i file.
+
- wrapper: This section holds all the wrappering code.
- init: This section holds the module initalisation function
-(the entry point for the interpreter)
+(the entry point for the interpreter).
Different parts of the SWIG code will fill different sections,
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index fd510f2a4..bcfcc60f5 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -3034,14 +3034,15 @@ output of SWIG is structured first.
-When SWIG creates its output file, it is broken up into four sections
+When SWIG creates its output file, it is broken up into five sections
corresponding to runtime code, headers, wrapper functions, and module
initialization code (in that order).
- Begin section.
-A placeholder to put code at the beginning of the C/C++ wrapper file.
+A placeholder for users to put code at the beginning of the C/C++ wrapper file.
+This is most often used to define preprocessor macros that are used in later sections.
- Runtime code.
From e45ba03570ba91fe22bd48fb2e56e1ed5416a155 Mon Sep 17 00:00:00 2001
From: Xavier Delacour
Date: Tue, 17 May 2011 16:06:42 +0000
Subject: [PATCH 22/59] Add CHANGES.current note about octave API>=40
compatability change
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12678 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGES.current b/CHANGES.current
index 464a9579a..581b1f7b0 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -4,6 +4,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.4 (in progress)
===========================
+2011-05-16: xavier98
+ [octave] Fix an incompatibility with never versions of Octave. Case on Octave
+ API >= 40 to handle rename of Octave_map to octave_map.
+
2011-05-14: wsfulton
%varargs when used with a numeric argument used to create an additional argument
which was intended to provide a guaranteed sentinel value. This never worked and now
From 7e5fa23c5f6641c6051cb3f14640398d52b26748 Mon Sep 17 00:00:00 2001
From: Xavier Delacour
Date: Tue, 17 May 2011 16:11:26 +0000
Subject: [PATCH 23/59] more CHANGES.current edits
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12679 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGES.current b/CHANGES.current
index 581b1f7b0..762cb17bf 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -7,6 +7,10 @@ Version 2.0.4 (in progress)
2011-05-16: xavier98
[octave] Fix an incompatibility with never versions of Octave. Case on Octave
API >= 40 to handle rename of Octave_map to octave_map.
+ [octave] Add support for y.__rop__(x) operators when x.__op__(y) doesn't exist.
+ [octave] Allow global operators to be defined by SWIG-wrapped functions.
+ [octave] Fix several bugs around module namespaces; add -global, -noglobal,
+ -globals command line options to the module.
2011-05-14: wsfulton
%varargs when used with a numeric argument used to create an additional argument
From f35dd29dffac35899aa7e4d473a48ac39d126650 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 17 May 2011 18:12:53 +0000
Subject: [PATCH 24/59] Apply #3300072 from Christian Delbaere to fix multiple
module loading not always sharing variables across modules.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12680 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
Examples/test-suite/tcl/imports_runme.tcl | 19 +++++++++++--------
Lib/tcl/tclrun.swg | 2 +-
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index 762cb17bf..76f9ad671 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -4,6 +4,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.4 (in progress)
===========================
+2011-05-17: wsfulton
+ [Tcl] Apply #3300072 from Christian Delbaere to fix multiple module loading not
+ always sharing variables across modules.
+
2011-05-16: xavier98
[octave] Fix an incompatibility with never versions of Octave. Case on Octave
API >= 40 to handle rename of Octave_map to octave_map.
diff --git a/Examples/test-suite/tcl/imports_runme.tcl b/Examples/test-suite/tcl/imports_runme.tcl
index 85abe49ed..6b2e77bde 100644
--- a/Examples/test-suite/tcl/imports_runme.tcl
+++ b/Examples/test-suite/tcl/imports_runme.tcl
@@ -1,14 +1,17 @@
# This is the imports runtime testcase.
+proc import {} {
+ if [ catch { load ./imports_b[info sharedlibextension] imports_b} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+ exit 1
+ }
+ if [ catch { load ./imports_a[info sharedlibextension] imports_a} err_msg ] {
+ puts stderr "Could not load shared object:\n$err_msg"
+ exit 1
+ }
+}
-if [ catch { load ./imports_b[info sharedlibextension] imports_b} err_msg ] {
- puts stderr "Could not load shared object:\n$err_msg"
- exit 1
-}
-if [ catch { load ./imports_a[info sharedlibextension] imports_a} err_msg ] {
- puts stderr "Could not load shared object:\n$err_msg"
-exit 1
-}
+import
set x [new_B]
A_hello $x
diff --git a/Lib/tcl/tclrun.swg b/Lib/tcl/tclrun.swg
index 240560b80..66bb4d201 100644
--- a/Lib/tcl/tclrun.swg
+++ b/Lib/tcl/tclrun.swg
@@ -277,7 +277,7 @@ SWIG_Tcl_SetModule(Tcl_Interp *interp, swig_module_info *module) {
/* create a new pointer */
data = SWIG_PackData(buf, &module, sizeof(swig_type_info **));
*data = 0;
- Tcl_SetVar(interp, (char *)"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, buf, 0);
+ Tcl_SetVar(interp, (char *)"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, buf, TCL_GLOBAL_ONLY);
}
/* -----------------------------------------------------------------------------*
From e71624749a8464c2ad1769b991601ff69d8e8b0c Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 17 May 2011 19:15:50 +0000
Subject: [PATCH 25/59] Apply #3289851 to fix memory leak in directors when
checking for pending exceptions.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12681 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
Source/Modules/java.cxx | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/CHANGES.current b/CHANGES.current
index 76f9ad671..2ca012599 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -4,6 +4,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.4 (in progress)
===========================
+2011-05-17: wsfulton
+ [Java] Apply #3289851 from Alan Harder to fix memory leak in directors when checking
+ for pending exceptions.
+
2011-05-17: wsfulton
[Tcl] Apply #3300072 from Christian Delbaere to fix multiple module loading not
always sharing variables across modules.
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index 6cdf26fe3..bf7098b7a 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -3990,7 +3990,7 @@ public:
Printf(w->code, "jenv->%s(Swig::jclass_%s, Swig::director_methids[%s], %s);\n", methop, imclass_name, methid, jupcall_args);
- Printf(w->code, "if (jenv->ExceptionOccurred()) return $null;\n");
+ Printf(w->code, "if (jenv->ExceptionCheck() == JNI_TRUE) return $null;\n");
if (!is_void) {
String *jresult_str = NewString("jresult");
From d4ac9ba49d5d650322734b5665ac4732ea3bd27f Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 17 May 2011 19:47:47 +0000
Subject: [PATCH 26/59] Add release summary
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12682 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
RELEASENOTES | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/RELEASENOTES b/RELEASENOTES
index ea2f0c5b6..a9ee792b8 100644
--- a/RELEASENOTES
+++ b/RELEASENOTES
@@ -4,6 +4,14 @@ and CHANGES files.
Release Notes
=============
+SWIG-2.0.4 summary:
+This is mainly a Python oriented release including support for Python
+built-in types for superior performance with the new -builtin option.
+Python 3.2 support has also been added and various Python bugs have
+been fixed. There are also the usual minor generic improvements, as
+well as bug fixes and enhancements for D, Lua, Octave, and Tcl.
+Octave 3.4 support has also been added.
+
SWIG-2.0.3 summary:
- A bug fix release including a couple of fixes for regressions in the
2.0 series.
From 90d20c7fe8c3b7467f4ad2330442e61908ca95b6 Mon Sep 17 00:00:00 2001
From: Stefan Zager
Date: Tue, 17 May 2011 21:53:39 +0000
Subject: [PATCH 27/59] Cleaned up section about dependency requirements for
-builtin.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12683 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Python.html | 37 ++-----------------------------------
1 file changed, 2 insertions(+), 35 deletions(-)
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index 0ca6796af..863c088d5 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -2480,7 +2480,7 @@ doesn't know how to add an instance of MyString to itself.
If you have multiple SWIG modules that share type information (more info),
the -builtin option requiress a bit of extra discipline to ensure that base classes are initialized before derived classes. Specifically:
-- There must be an unambiguous non-looping dependency graph for the modules.
+- There must be an unambiguous dependency graph for the modules.
- Module dependencies must be explicitly stated with %import statements in the SWIG interface file.
@@ -2515,41 +2515,8 @@ class Derived : public Base {
import B
import A
-d = B.Derived()
+assert(issubclass(B.Derived, A.Base))
-
-Here's an example of two interface files that have a dependency loop:
-
-A.i:
-
-
-%module "A";
-
-class BaseA {
-...
-};
-
-class DerivedA : public BaseB {
-...
-};
-
-
-B.i:
-
-
-%module "B";
-
-class BaseB {
-...
-};
-
-class DerivedB : public BaseA {
-...
-};
-
-
-These modules are incompatible with the -builtin option.
-
From 2946576efb1bb076d7567f4cd0e0453ac06ab624 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Wed, 18 May 2011 00:29:36 +0000
Subject: [PATCH 28/59] Workaround for Octave crashing at extit in the mods
and multi_import testcases
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12684 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/octave/Makefile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in
index 0dbb6a1e5..f12047e74 100644
--- a/Examples/test-suite/octave/Makefile.in
+++ b/Examples/test-suite/octave/Makefile.in
@@ -3,7 +3,7 @@
#######################################################################
LANGUAGE = octave
-OCTAVE = @OCTAVE@ -q
+OCTAVE = @OCTAVE@ -qf
SCRIPTSUFFIX = _runme.m
srcdir = @srcdir@
top_srcdir = @top_srcdir@
From af858d846ecadb7e5c79b6e0898df4691d981b08 Mon Sep 17 00:00:00 2001
From: Stefan Zager
Date: Wed, 18 May 2011 03:25:35 +0000
Subject: [PATCH 29/59] Fixes for -builtin docs.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12685 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Python.html | 6 +++---
RELEASENOTES | 16 ++++++++++------
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index 863c088d5..d179d3beb 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -43,7 +43,7 @@
- Further details on the Python class interface
- Proxy classes
-
- Built-in Classes
+
- Built-in Types
- Limitations
- Operator overloads -- use them!
@@ -2214,7 +2214,7 @@ unacceptable for a high-performance library. The new -builtin
option instructs SWIG to forego the use of proxy classes, and instead
create wrapped types as new built-in Python types. When this option is used,
the following section ("Proxy classes") does not apply. Details on the use of
-the -builtin option are in the Built-in Classes
+the -builtin option are in the Built-in Types
section.
@@ -2307,7 +2307,7 @@ you can attach new Python methods to the class and you can even inherit from it
by Python built-in types until Python 2.2).
-
33.4.2 Built-in Classes
+33.4.2 Built-in Types
diff --git a/RELEASENOTES b/RELEASENOTES
index a9ee792b8..36feb6ddf 100644
--- a/RELEASENOTES
+++ b/RELEASENOTES
@@ -5,12 +5,16 @@ and CHANGES files.
Release Notes
=============
SWIG-2.0.4 summary:
-This is mainly a Python oriented release including support for Python
-built-in types for superior performance with the new -builtin option.
-Python 3.2 support has also been added and various Python bugs have
-been fixed. There are also the usual minor generic improvements, as
-well as bug fixes and enhancements for D, Lua, Octave, and Tcl.
-Octave 3.4 support has also been added.
+- This is mainly a Python oriented release including support for Python
+ built-in types for superior performance with the new -builtin option.
+ The -builtin option is especially suitable for performance-critical
+ libraries and applications that call wrapped methods repeatedly.
+ See the python-specific chapter of the SWIG manual for more info.
+
+- Python 3.2 support has also been added and various Python bugs have
+ been fixed. There are also the usual minor generic improvements, as
+ well as bug fixes and enhancements for D, Lua, Octave, and Tcl.
+ Octave 3.4 support has also been added.
SWIG-2.0.3 summary:
- A bug fix release including a couple of fixes for regressions in the
From fe7a09c04afb977cf92bae8d2abb3eaa386ca8fc Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Thu, 19 May 2011 06:37:41 +0000
Subject: [PATCH 30/59] html fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12686 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Contents.html | 2 +-
Doc/Manual/Python.html | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 736bd08a8..04cbbcf2a 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -1332,7 +1332,7 @@
- Further details on the Python class interface
-For details of abstract base class, please see PEP 3119.
+For details of abstract base class, please see
+PEP 3119.
From c44249f32cdc10cd13bc4de59f2a5b79aa22f69c Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Tue, 24 May 2011 23:55:35 +0000
Subject: [PATCH 46/59] Add link to PEP 3107.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12714 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Python.html | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index 13b20d953..07f9e87d7 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -5305,7 +5305,8 @@ all overloaded functions share the same function in SWIG generated proxy class.
-For detailed usage of function annotation, see PEP 3107.
+For detailed usage of function annotation, see
+PEP 3107.
33.12.2 Buffer interface
From 748e951e7e1b159c83ac93f4332e08ce608aaaa4 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Wed, 25 May 2011 05:19:48 +0000
Subject: [PATCH 47/59] Add testcase virtual_vs_nonvirtual_base as a regression
test for SF#3124665.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12715 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/common.mk | 1 +
.../php/virtual_vs_nonvirtual_base_runme.php | 11 +++++
.../test-suite/virtual_vs_nonvirtual_base.i | 48 +++++++++++++++++++
3 files changed, 60 insertions(+)
create mode 100644 Examples/test-suite/php/virtual_vs_nonvirtual_base_runme.php
create mode 100644 Examples/test-suite/virtual_vs_nonvirtual_base.i
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 3b0efd1eb..52a551a56 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -437,6 +437,7 @@ CPP_TEST_CASES += \
varargs_overload \
virtual_destructor \
virtual_poly \
+ virtual_vs_nonvirtual_base \
voidtest \
wallkw \
wrapmacro
diff --git a/Examples/test-suite/php/virtual_vs_nonvirtual_base_runme.php b/Examples/test-suite/php/virtual_vs_nonvirtual_base_runme.php
new file mode 100644
index 000000000..0d4aa3d5f
--- /dev/null
+++ b/Examples/test-suite/php/virtual_vs_nonvirtual_base_runme.php
@@ -0,0 +1,11 @@
+
+
+require "tests.php";
+require "virtual_vs_nonvirtual_base.php";
+
+$fail = new SimpleClassFail();
+$work = new SimpleClassWork();
+
+check::equal($work->getInner()->get(), $fail->getInner()->get(), "should both be 10");
+
+?>
diff --git a/Examples/test-suite/virtual_vs_nonvirtual_base.i b/Examples/test-suite/virtual_vs_nonvirtual_base.i
new file mode 100644
index 000000000..9e8bc5eab
--- /dev/null
+++ b/Examples/test-suite/virtual_vs_nonvirtual_base.i
@@ -0,0 +1,48 @@
+%module virtual_vs_nonvirtual_base;
+// Regression test for SF#3124665.
+%inline {
+
+class SimpleVirtual
+{
+ public:
+ virtual int implementMe() = 0;
+};
+
+class SimpleNonVirtual
+{
+ public:
+ int dummy() { return 0; }
+};
+
+class SimpleReturnClass
+{
+ public:
+ SimpleReturnClass(int i) : value(i) {};
+ int get() const { return value; }
+ private:
+ int value;
+};
+
+class SimpleClassFail : public SimpleVirtual
+{
+ public:
+ SimpleClassFail() : inner(10) {}
+ SimpleReturnClass getInner() { return inner; }
+
+ virtual int implementMe() { return 0; }
+ private:
+ SimpleReturnClass inner;
+};
+
+class SimpleClassWork : public SimpleNonVirtual
+{
+ public:
+ SimpleClassWork() : inner(10) {}
+ SimpleReturnClass getInner() { return inner; }
+
+ virtual int implementMe() { return 0; }
+ private:
+ SimpleReturnClass inner;
+};
+
+}
From 924be5044d2ec82ffa4d05ce5d8418aea378f1ff Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Wed, 25 May 2011 17:13:45 +0000
Subject: [PATCH 48/59] cosmetic style fix on pointer declarations
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12716 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/guile/typemaps.i | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i
index 4eda6eeeb..edf227d46 100644
--- a/Lib/guile/typemaps.i
+++ b/Lib/guile/typemaps.i
@@ -292,18 +292,18 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer);
%typemap (varin, doc="NEW-VALUE is a string") char * {$1 = ($1_ltype)SWIG_scm2str($input);}
%typemap (out, doc="") char * {$result = gh_str02scm((const char *)$1);}
%typemap (varout, doc="") char * {$result = gh_str02scm($1);}
- %typemap (in, doc="$NAME is a string") char * *INPUT(char * temp, int must_free = 0) {
+ %typemap (in, doc="$NAME is a string") char **INPUT(char * temp, int must_free = 0) {
temp = (char *) SWIG_scm2str($input); $1 = &temp;
must_free = 1;
}
- %typemap (in,numinputs=0) char * *OUTPUT (char * temp)
+ %typemap (in,numinputs=0) char **OUTPUT (char * temp)
{$1 = &temp;}
- %typemap (argout,doc="$NAME (a string)") char * *OUTPUT
+ %typemap (argout,doc="$NAME (a string)") char **OUTPUT
{SWIG_APPEND_VALUE(gh_str02scm(*$1));}
- %typemap (in) char * *BOTH = char * *INPUT;
- %typemap (argout) char * *BOTH = char * *OUTPUT;
- %typemap (in) char * *INOUT = char * *INPUT;
- %typemap (argout) char * *INOUT = char * *OUTPUT;
+ %typemap (in) char **BOTH = char **INPUT;
+ %typemap (argout) char **BOTH = char **OUTPUT;
+ %typemap (in) char **INOUT = char **INPUT;
+ %typemap (argout) char **INOUT = char **OUTPUT;
/* SWIG_scm2str makes a malloc'ed copy of the string, so get rid of it after
the function call. */
From 49532b718138f7b0188f0e7499010c72a3a89735 Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor
Date: Fri, 27 May 2011 00:04:32 +0000
Subject: [PATCH 49/59] Some improvements to the Go documentation. From Gary
Holt .
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12719 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Contents.html | 3 +-
Doc/Manual/Go.html | 160 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 161 insertions(+), 2 deletions(-)
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 04cbbcf2a..b53923c17 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -764,6 +764,8 @@
- Go Templates
- Go Director Classes
- Default Go primitive type mappings
+
- Output arguments
+
- Adding additional go code
@@ -1689,4 +1691,3 @@