aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcelo Matus <mmatus@acms.arizona.edu>2005-10-20 09:47:56 +0000
committerMarcelo Matus <mmatus@acms.arizona.edu>2005-10-20 09:47:56 +0000
commitba3efb09176587cdff2db4b06821a2bbae65d423 (patch)
tree3bd4867dca5c55664ec52cd23caf2209a898d410
parent733322c5391af70e6c7bbfd4160b3ed26e539088 (diff)
downloadswig-ba3efb09176587cdff2db4b06821a2bbae65d423.tar.gz
finishing the first stage of the typemap unification scheme, fixing issues with gcc and valgrind
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7692 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--CHANGES.current20
-rw-r--r--Examples/test-suite/python/li_carrays_runme.py9
-rw-r--r--Examples/test-suite/python/voidtest_runme.py6
-rw-r--r--Examples/test-suite/voidtest.i2
-rw-r--r--Lib/allkw.swg2
-rw-r--r--Lib/exception.i2
-rw-r--r--Lib/python/carrays.i7
-rw-r--r--Lib/python/director_h.swg2
-rw-r--r--Lib/python/exception.i1
-rw-r--r--Lib/python/pycontainer.swg4
-rw-r--r--Lib/python/pyerrors.swg53
-rw-r--r--Lib/python/pyinit.swg36
-rw-r--r--Lib/python/pyrun.swg170
-rw-r--r--Lib/python/pyruntime.swg1
-rw-r--r--Lib/python/pystdcommon.swg6
-rw-r--r--Lib/python/python.swg1
-rw-r--r--Lib/python/pytypemaps.swg26
-rw-r--r--Lib/ruby/carrays.i4
-rw-r--r--Lib/ruby/exception.i1
-rw-r--r--Lib/ruby/ruby.swg17
-rw-r--r--Lib/ruby/rubyerrors.swg47
-rw-r--r--Lib/ruby/rubyrun.swg44
-rw-r--r--Lib/ruby/rubytypemaps.swg19
-rw-r--r--Lib/swigerrors.swg17
-rw-r--r--Lib/swiglabels.swg16
-rw-r--r--Lib/tcl/carrays.i2
-rw-r--r--Lib/tcl/exception.i1
-rw-r--r--Lib/tcl/tcl8.swg17
-rw-r--r--Lib/tcl/tclerrors.swg39
-rw-r--r--Lib/tcl/tclrun.swg195
-rw-r--r--Lib/tcl/tcltypemaps.swg13
-rw-r--r--Lib/typemaps/carrays.swg23
-rw-r--r--Lib/typemaps/enumint.swg2
-rw-r--r--Lib/typemaps/exception.swg9
-rw-r--r--Lib/typemaps/strings.swg12
-rw-r--r--Lib/typemaps/swigmacros.swg51
-rw-r--r--Lib/typemaps/swigobject.swg2
-rw-r--r--Lib/typemaps/swigtype.swg8
-rw-r--r--Lib/typemaps/valtypes.swg2
-rw-r--r--Lib/typemaps/void.swg4
-rw-r--r--Source/Modules/main.cxx9
-rw-r--r--Source/Modules/python.cxx24
-rw-r--r--Source/Modules/ruby.cxx34
-rw-r--r--Source/Modules/tcl8.cxx11
44 files changed, 555 insertions, 416 deletions
diff --git a/CHANGES.current b/CHANGES.current
index 83c77431b..9322083b6 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -1,6 +1,26 @@
Version 1.3.27 (October 15, 2005)
=================================
+10/20/2005: mmatus
+ Ruby, Tcl, Python:
+
+ - Uniform way to fail (label fail:), now finally
+ SWIG_exception works across the three languages and all
+ the typemaps.
+
+ - Add proper cleanup code to ruby
+
+ - More valgrind fixes
+
+ - Simplify the inline use, it seems a small interface of
+ 20,000 lines (plus many many templates0 can break
+ gcc -O3 easily.
+
+ - Finalize the typemaps library. All the old *.i files
+ (carray.i, cpointer.i, exception.i) had been implemented
+ in the new typemaps library.
+
+
10/19/2005: wuzzeb
Update the Runtime Typemap documentation in Typemaps.html
diff --git a/Examples/test-suite/python/li_carrays_runme.py b/Examples/test-suite/python/li_carrays_runme.py
new file mode 100644
index 000000000..ad48eab61
--- /dev/null
+++ b/Examples/test-suite/python/li_carrays_runme.py
@@ -0,0 +1,9 @@
+from li_carrays import *
+
+d = doubleArray(10)
+
+d[0] = 7
+d[5] = d[0] + 3
+
+if d[5] + d[0] != 17:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/voidtest_runme.py b/Examples/test-suite/python/voidtest_runme.py
index e1f46b176..067b10740 100644
--- a/Examples/test-suite/python/voidtest_runme.py
+++ b/Examples/test-suite/python/voidtest_runme.py
@@ -5,3 +5,9 @@ f = voidtest.Foo()
f.memberfunc()
voidtest.Foo_staticmemberfunc()
+
+def fvoid():
+ pass
+
+if f.memberfunc() != fvoid():
+ raise RuntimeError
diff --git a/Examples/test-suite/voidtest.i b/Examples/test-suite/voidtest.i
index 01e7e8485..01b8dc882 100644
--- a/Examples/test-suite/voidtest.i
+++ b/Examples/test-suite/voidtest.i
@@ -7,7 +7,7 @@ void globalfunc(void) {
class Foo {
public:
- Foo() { }
+ Foo(void) { }
void memberfunc(void) { }
static void staticmemberfunc(void) { }
};
diff --git a/Lib/allkw.swg b/Lib/allkw.swg
index f711a0a16..caa7fd137 100644
--- a/Lib/allkw.swg
+++ b/Lib/allkw.swg
@@ -24,7 +24,7 @@
%include "python/pythonkw.swg"
%include "ocaml/ocamlkw.swg"
%include "ruby/rubykw.swg"
-%include "tcl/tcl8kw.swg"
+%include "tcl/tclkw.swg"
#endif //__Lib_allkw_swg__
diff --git a/Lib/exception.i b/Lib/exception.i
index 877d6d28e..531b1a584 100644
--- a/Lib/exception.i
+++ b/Lib/exception.i
@@ -6,6 +6,8 @@
// This SWIG library file provides language independent exception handling
+%insert("runtime") "swigerrors.swg"
+
#ifdef SWIGPERL5
%{
#define SWIG_exception(a,b) SWIG_croak(b)
diff --git a/Lib/python/carrays.i b/Lib/python/carrays.i
index 8be67abce..8d6d44082 100644
--- a/Lib/python/carrays.i
+++ b/Lib/python/carrays.i
@@ -1,2 +1,9 @@
+%define %array_class(TYPE,NAME)
+ %array_class_wrap(TYPE,NAME,__getitem__,__setitem__)
+%enddef
+
%include <typemaps/carrays.swg>
+
+
+
diff --git a/Lib/python/director_h.swg b/Lib/python/director_h.swg
index 19b83c10b..a34cfd02a 100644
--- a/Lib/python/director_h.swg
+++ b/Lib/python/director_h.swg
@@ -98,7 +98,7 @@ namespace Swig {
swig_msg += msg;
}
if (!PyErr_Occurred()) {
- SWIG_Python_SetErrorMsg(error, getMessage());
+ PyErr_SetString(error, getMessage());
} else {
SWIG_Python_AddErrorMsg(getMessage());
}
diff --git a/Lib/python/exception.i b/Lib/python/exception.i
new file mode 100644
index 000000000..0246cfde8
--- /dev/null
+++ b/Lib/python/exception.i
@@ -0,0 +1 @@
+%include <typemaps/exception.swg>
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
index fd735eadf..780cf4f78 100644
--- a/Lib/python/pycontainer.swg
+++ b/Lib/python/pycontainer.swg
@@ -142,7 +142,7 @@ namespace swig
char msg[1024];
snprintf(msg, sizeof(msg), "in sequence element %d ", _index);
if (!PyErr_Occurred()) {
- SWIG_set_errmsg(SWIG_TypeError,swig::type_name<T>());
+ SWIG_type_error(swig::type_name<T>());
}
SWIG_Python_AddErrorMsg(msg);
SWIG_Python_AddErrorMsg(e.what());
@@ -336,7 +336,7 @@ namespace swig
if (set_err) {
char msg[1024];
snprintf(msg, sizeof(msg), "in sequence element %d of type %s", i, swig::type_name<value_type>());
- SWIG_set_errmsg(SWIG_TypeError, msg);
+ SWIG_Error(SWIG_RuntimeError, msg);
}
return false;
}
diff --git a/Lib/python/pyerrors.swg b/Lib/python/pyerrors.swg
index 0437c9319..13bdefc54 100644
--- a/Lib/python/pyerrors.swg
+++ b/Lib/python/pyerrors.swg
@@ -2,49 +2,55 @@
* error manipulation
* ----------------------------------------------------------------------------- */
-
%insert("header") %{
SWIGINTERN PyObject*
SWIG_Python_ErrorType(int code) {
+ PyObject* type = 0;
switch(code) {
case SWIG_MemoryError:
- return PyExc_MemoryError;
+ type = PyExc_MemoryError;
+ break;
case SWIG_IOError:
- return PyExc_IOError;
+ type = PyExc_IOError;
+ break;
case SWIG_RuntimeError:
- return PyExc_RuntimeError;
+ type = PyExc_RuntimeError;
+ break;
case SWIG_IndexError:
- return PyExc_IndexError;
+ type = PyExc_IndexError;
+ break;
case SWIG_TypeError:
- return PyExc_TypeError;
+ type = PyExc_TypeError;
+ break;
case SWIG_DivisionByZero:
- return PyExc_ZeroDivisionError;
+ type = PyExc_ZeroDivisionError;
+ break;
case SWIG_OverflowError:
- return PyExc_OverflowError;
+ type = PyExc_OverflowError;
+ break;
case SWIG_SyntaxError:
- return PyExc_SyntaxError;
+ type = PyExc_SyntaxError;
+ break;
case SWIG_ValueError:
- return PyExc_ValueError;
+ type = PyExc_ValueError;
+ break;
case SWIG_SystemError:
- return PyExc_SystemError;
+ type = PyExc_SystemError;
+ break;
case SWIG_AttributeError:
- return PyExc_AttributeError;
+ type = PyExc_AttributeError;
+ break;
default:
- return PyExc_RuntimeError;
+ type = PyExc_RuntimeError;
}
+ return type;
}
-SWIGINTERN void
-SWIG_Python_SetErrorMsg(PyObject *type, const char *mesg) {
- PyErr_SetString(type, mesg);
-}
-
-SWIGINTERNINLINE void
-SWIG_Python_SetExceptionObj(swig_type_info *desc, PyObject *obj) {
- PyErr_SetObject((desc && desc->clientdata ? (PyObject *)(desc->clientdata) : PyExc_RuntimeError), obj);
+SWIGINTERNINLINE PyObject *
+SWIG_Python_ExceptionType(swig_type_info *desc) {
+ return (desc && desc->clientdata ? (PyObject *)(desc->clientdata) : PyExc_RuntimeError);
}
-
SWIGINTERN void
SWIG_Python_AddErrorMsg(const char* mesg)
@@ -56,10 +62,11 @@ SWIG_Python_AddErrorMsg(const char* mesg)
if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
if (value) {
PyObject *old_str = PyObject_Str(value);
- Py_XINCREF(type);
PyErr_Clear();
+ Py_XINCREF(type);
PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
Py_DECREF(old_str);
+ Py_DECREF(value);
} else {
PyErr_Format(PyExc_RuntimeError, mesg);
}
diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
index 3541cbafc..212fe1ec8 100644
--- a/Lib/python/pyinit.swg
+++ b/Lib/python/pyinit.swg
@@ -7,18 +7,18 @@
%init %{
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
/* Python-specific SWIG API */
#define SWIG_newvarlink() SWIG_Python_newvarlink()
#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
-
+
/* -----------------------------------------------------------------------------
* global variable support code.
* ----------------------------------------------------------------------------- */
-
+
typedef struct swig_globalvar {
char *name; /* Name of global variable */
PyObject *(*get_attr)(void); /* Return the current value */
@@ -50,6 +50,17 @@ swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) {
return 0;
}
+SWIGINTERN void
+swig_varlink_delete(swig_varlinkobject *v) {
+ swig_globalvar *var = v->vars;
+ while (var) {
+ swig_globalvar *n = var->next;
+ free(var->name);
+ free(var);
+ var = n;
+ }
+}
+
SWIGINTERN PyObject *
swig_varlink_getattr(swig_varlinkobject *v, char *n) {
swig_globalvar *var = v->vars;
@@ -92,7 +103,7 @@ swig_varlink_type(void) {
(char *)"swigvarlink", /* Type name (tp_name) */
sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
0, /* Itemsize (tp_itemsize) */
- 0, /* Deallocator (tp_dealloc) */
+ (destructor) swig_varlink_delete, /* Deallocator (tp_dealloc) */
(printfunc) swig_varlink_print, /* Print (tp_print) */
(getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
(setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
@@ -162,6 +173,13 @@ SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int
v->vars = gv;
}
+SWIGINTERN PyObject *
+SWIG_globals() {
+ static PyObject *_SWIG_globals = 0;
+ if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();
+ return _SWIG_globals;
+}
+
/* -----------------------------------------------------------------------------
* constants/methods manipulation
* ----------------------------------------------------------------------------- */
@@ -185,6 +203,7 @@ SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
}
if (obj) {
PyDict_SetItemString(d, constants[i].name, obj);
+ Py_DECREF(obj);
}
}
}
@@ -233,7 +252,7 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
}
}
}
-}
+}
#ifdef __cplusplus
}
@@ -247,17 +266,16 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
extern "C"
#endif
SWIGEXPORT void SWIG_init(void) {
- static PyObject *SWIG_globals = 0;
PyObject *m, *d;
- if (!SWIG_globals) SWIG_globals = SWIG_newvarlink();
-
+
/* Fix SwigMethods to carry the callback ptrs when needed */
SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
m = Py_InitModule((char *) SWIG_name, SwigMethods);
d = PyModule_GetDict(m);
-
+
SWIG_InitializeModule(0);
SWIG_InstallConstants(d,swig_const_table);
+
%}
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
index b87e39255..3a6a82605 100644
--- a/Lib/python/pyrun.swg
+++ b/Lib/python/pyrun.swg
@@ -32,35 +32,27 @@
/* Runtime API */
-#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
-#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
+
+#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
+#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
/* Error manipulation */
-#define SWIG_ERROR -1
-#define SWIG_fail goto fail
-#define SWIG_var_fail return 1
-#define SWIG_error(code, msg) SWIG_Python_SetErrorMsg(SWIG_Python_ErrorType(code), msg)
-#define SWIG_exception(code, msg) do { SWIG_error(code, msg); SWIG_fail; } while (0)
-#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_error(SWIG_RuntimeError, msg); SWIG_fail; } else
+#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
+#define SWIG_Error(code, msg) PyErr_SetString(SWIG_Python_ErrorType(code), msg)
+#define SWIG_fail goto fail
/* -----------------------------------------------------------------------------
* Pointer declarations
* ----------------------------------------------------------------------------- */
-SWIGRUNTIMEINLINE PyObject *
-SWIG_Python_NoneObject() {
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/* -----------------------------------------------------------------------------
- * Create a new pointer object
- * ----------------------------------------------------------------------------- */
-
#ifdef __cplusplus
extern "C" {
+#if 0
+} /* cc-mode */
#endif
+#endif
+
/* PySwigObject */
@@ -191,51 +183,51 @@ PySwigObject_type(void) {
static PyTypeObject pyswigobject_type
#if !defined(__cplusplus)
- ;
+ ;
static int type_init = 0;
if (!type_init) {
PyTypeObject tmp
#endif
- = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /*ob_size*/
- (char *)"PySwigObject", /*tp_name*/
- sizeof(PySwigObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)PySwigObject_dealloc, /*tp_dealloc*/
- (printfunc)PySwigObject_print, /*tp_print*/
- (getattrfunc)0, /*tp_getattr*/
- (setattrfunc)0, /*tp_setattr*/
- (cmpfunc)PySwigObject_compare, /*tp_compare*/
- (reprfunc)PySwigObject_repr, /*tp_repr*/
- &PySwigObject_as_number, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- (hashfunc)0, /*tp_hash*/
- (ternaryfunc)0, /*tp_call*/
- (reprfunc)PySwigObject_str, /*tp_str*/
- /* Space for future expansion */
- 0,0,0,0,
- pyswigobject_type__doc__, /* Documentation string */
+ = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0, /*ob_size*/
+ (char *)"PySwigObject", /*tp_name*/
+ sizeof(PySwigObject), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor)PySwigObject_dealloc, /*tp_dealloc*/
+ (printfunc)PySwigObject_print, /*tp_print*/
+ (getattrfunc)0, /*tp_getattr*/
+ (setattrfunc)0, /*tp_setattr*/
+ (cmpfunc)PySwigObject_compare, /*tp_compare*/
+ (reprfunc)PySwigObject_repr, /*tp_repr*/
+ &PySwigObject_as_number, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ (hashfunc)0, /*tp_hash*/
+ (ternaryfunc)0, /*tp_call*/
+ (reprfunc)PySwigObject_str, /*tp_str*/
+ /* Space for future expansion */
+ 0,0,0,0,
+ pyswigobject_type__doc__, /* Documentation string */
#if PY_VERSION_HEX >= 0x02000000
- 0, /* tp_traverse */
- 0, /* tp_clear */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
#endif
#if PY_VERSION_HEX >= 0x02010000
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
#endif
#if PY_VERSION_HEX >= 0x02020000
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
#endif
#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
+ 0, /* tp_del */
#endif
#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
+ 0,0,0,0 /* tp_alloc -> tp_next */
#endif
- };
+ };
#if !defined(__cplusplus)
pyswigobject_type = tmp;
type_init = 1;
@@ -348,51 +340,51 @@ PySwigPacked_type(void) {
"Swig object carries a C/C++ instance pointer";
static PyTypeObject pyswigpacked_type
#if !defined(__cplusplus)
- ;
+ ;
static int type_init = 0;
if (!type_init) {
PyTypeObject tmp
#endif
- = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /*ob_size*/
- (char *)"PySwigPacked", /*tp_name*/
- sizeof(PySwigPacked), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)PySwigPacked_dealloc, /*tp_dealloc*/
- (printfunc)PySwigPacked_print, /*tp_print*/
- (getattrfunc)0, /*tp_getattr*/
- (setattrfunc)0, /*tp_setattr*/
- (cmpfunc)PySwigPacked_compare, /*tp_compare*/
- (reprfunc)PySwigPacked_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- (hashfunc)0, /*tp_hash*/
- (ternaryfunc)0, /*tp_call*/
- (reprfunc)PySwigPacked_str, /*tp_str*/
- /* Space for future expansion */
- 0,0,0,0,
- pyswigpacked_type__doc__, /* Documentation string */
+ = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0, /*ob_size*/
+ (char *)"PySwigPacked", /*tp_name*/
+ sizeof(PySwigPacked), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor)PySwigPacked_dealloc, /*tp_dealloc*/
+ (printfunc)PySwigPacked_print, /*tp_print*/
+ (getattrfunc)0, /*tp_getattr*/
+ (setattrfunc)0, /*tp_setattr*/
+ (cmpfunc)PySwigPacked_compare, /*tp_compare*/
+ (reprfunc)PySwigPacked_repr, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ (hashfunc)0, /*tp_hash*/
+ (ternaryfunc)0, /*tp_call*/
+ (reprfunc)PySwigPacked_str, /*tp_str*/
+ /* Space for future expansion */
+ 0,0,0,0,
+ pyswigpacked_type__doc__, /* Documentation string */
#if PY_VERSION_HEX >= 0x02000000
- 0, /* tp_traverse */
- 0, /* tp_clear */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
#endif
#if PY_VERSION_HEX >= 0x02010000
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
#endif
#if PY_VERSION_HEX >= 0x02020000
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
#endif
#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
+ 0, /* tp_del */
#endif
#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
+ 0,0,0,0 /* tp_alloc -> tp_next */
#endif
- };
+ };
#if !defined(__cplusplus)
pyswigpacked_type = tmp;
type_init = 1;
@@ -479,7 +471,7 @@ SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags)
if (newref) { Py_DECREF(obj); }
goto type_check;
-type_check:
+ type_check:
if (ty) {
tc = SWIG_TypeCheck(c,ty);
if (!tc) goto type_error;
@@ -492,7 +484,7 @@ type_check:
}
return SWIG_OK;
-type_error:
+ type_error:
PyErr_Clear();
if (pyobj && !obj) {
obj = pyobj;
@@ -524,12 +516,15 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t
}
return SWIG_OK;
-type_error:
+ type_error:
PyErr_Clear();
return SWIG_ERROR;
}
-/* Create a new array object */
+/* -----------------------------------------------------------------------------
+ * Create a new pointer object
+ * ----------------------------------------------------------------------------- */
+
SWIGRUNTIME PyObject *
SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
PyObject *robj = 0;
@@ -562,6 +557,8 @@ SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
return robj;
}
+/* Create a new array object */
+
SWIGRUNTIME PyObject *
SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
PyObject *robj = 0;
@@ -603,7 +600,7 @@ SWIG_Python_GetModule(void) {
#if PY_MAJOR_VERSION < 2
/* PyModule_AddObject function was introduced in Python 2.0. The following function
-is copied out of Python/modsupport.c in python version 2.3.4 */
+ is copied out of Python/modsupport.c in python version 2.3.4 */
SWIGINTERN int
PyModule_AddObject(PyObject *m, char *name, PyObject *o)
{
@@ -646,5 +643,8 @@ SWIG_Python_SetModule(swig_module_info *swig_module) {
}
#ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
}
#endif
diff --git a/Lib/python/pyruntime.swg b/Lib/python/pyruntime.swg
index 1f16cb630..021579eb5 100644
--- a/Lib/python/pyruntime.swg
+++ b/Lib/python/pyruntime.swg
@@ -33,6 +33,7 @@ PyString_FromFormat(const char *fmt, ...) {
%}
%insert(runtime) "swigrun.swg"; /* SWIG API */
+%insert(runtime) "swigerrors.swg" /* SWIG errors */
%insert(runtime) "pyapi.swg"; /* Pyton API */
%insert(runtime) "pyrun.swg"; /* Python run-time code */
diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg
index a266906cb..373d6f313 100644
--- a/Lib/python/pystdcommon.swg
+++ b/Lib/python/pystdcommon.swg
@@ -114,7 +114,7 @@ namespace swig {
Type v;
if (!obj || (asval(obj, &v) != SWIG_OK)) {
if (!PyErr_Occurred()) {
- SWIG_Python_SetErrorMsg(SWIG_Python_ErrorType(SWIG_TypeError), swig::type_name<Type>());
+ SWIG_type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
}
@@ -139,7 +139,7 @@ namespace swig {
// Uninitialized return value, no Type() constructor required.
static Type *v_def = (Type*) malloc(sizeof(Type));
if (!PyErr_Occurred()) {
- SWIG_Python_SetErrorMsg(SWIG_Python_ErrorType(SWIG_TypeError), swig::type_name<Type>());
+ SWIG_type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
memset(v_def,0,sizeof(Type));
@@ -157,7 +157,7 @@ namespace swig {
return v;
} else {
if (!PyErr_Occurred()) {
- SWIG_Python_SetErrorMsg(SWIG_Python_ErrorType(SWIG_TypeError),swig::type_name<Type>());
+ SWIG_type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
return 0;
diff --git a/Lib/python/python.swg b/Lib/python/python.swg
index 7c10c4802..36fb72071 100644
--- a/Lib/python/python.swg
+++ b/Lib/python/python.swg
@@ -17,7 +17,6 @@
/* -----------------------------------------------------------------------------
* Error manipulation
* ----------------------------------------------------------------------------- */
-
%include <pyerrors.swg>
/* -----------------------------------------------------------------------------
diff --git a/Lib/python/pytypemaps.swg b/Lib/python/pytypemaps.swg
index 324e33801..ee35cadce 100644
--- a/Lib/python/pytypemaps.swg
+++ b/Lib/python/pytypemaps.swg
@@ -18,16 +18,11 @@
%define_swig_object(PyObject *)
+#define SWIG_VoidObject() (Py_INCREF(Py_None) ? Py_None : 0)
#define SWIG_SetResultObj(obj) $result = obj
#define SWIG_AppendResultObj(obj) $result = SWIG_Python_AppendResult($result, obj)
-#define SWIG_SetConstantObj(name, obj) PyDict_SetItemString(d, name, obj);
-#define SWIG_NoneObject() SWIG_Python_NoneObject()
-
-/* error manipulation */
-#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
-#define SWIG_SetErrorObj(code, obj) PyErr_SetObject(SWIG_ErrorType(code), obj)
-#define SWIG_SetErrorMsg(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code),msg)
-#define SWIG_ExceptionObj(desc, type, obj) SWIG_Python_SetExceptionObj(desc, obj)
+#define SWIG_SetConstantObj(name, obj) SWIG_block(PyObject *_obj = obj; PyDict_SetItemString(d, name, _obj); Py_DECREF(_obj))
+#define SWIG_Raise(obj, type, desc) PyObject *_obj = obj; PyErr_SetObject(SWIG_Python_ExceptionType(desc), _obj); Py_DECREF(_obj)
#define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
@@ -35,14 +30,9 @@
* All the typemaps
* ----------------------------------------------------------------------------- */
-
-%fragment("t_output_helper","header") %{
-#define t_output_helper SWIG_Python_AppendResult
-%}
-
-
%include "pyfragments.swg"
+%include <typemaps/exception.swg>
%include <pyswigtype.swg>
%include <typemaps/void.swg>
%include <typemaps/valtypes.swg>
@@ -54,3 +44,11 @@
%include <typemaps/misctypes.swg>
%include <typemaps/enumint.swg>
+
+/* -----------------------------------------------------------------------------
+ * Backward compatibility output helper
+ * ----------------------------------------------------------------------------- */
+%fragment("t_output_helper","header") %{
+#define t_output_helper SWIG_Python_AppendResult
+%}
+
diff --git a/Lib/ruby/carrays.i b/Lib/ruby/carrays.i
index 8be67abce..8f74cd9ba 100644
--- a/Lib/ruby/carrays.i
+++ b/Lib/ruby/carrays.i
@@ -1,2 +1,6 @@
+%define %array_class(TYPE,NAME)
+ %array_class_wrap(TYPE,NAME,__getitem__,__setitem__)
+%enddef
+
%include <typemaps/carrays.swg>
diff --git a/Lib/ruby/exception.i b/Lib/ruby/exception.i
new file mode 100644
index 000000000..0246cfde8
--- /dev/null
+++ b/Lib/ruby/exception.i
@@ -0,0 +1 @@
+%include <typemaps/exception.swg>
diff --git a/Lib/ruby/ruby.swg b/Lib/ruby/ruby.swg
index 911962a24..581c1d01d 100644
--- a/Lib/ruby/ruby.swg
+++ b/Lib/ruby/ruby.swg
@@ -5,25 +5,24 @@
* ----------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
- * The runtime part
+ * Inner macros
* ----------------------------------------------------------------------------- */
-%include <rubyruntime.swg>
+%include <rubymacros.swg>
/* -----------------------------------------------------------------------------
- * Special user directives
+ * Error manipulation
* ----------------------------------------------------------------------------- */
-%include <rubyuserdir.swg>
+%include <rubyerrors.swg>
/* -----------------------------------------------------------------------------
- * Inner macros
+ * The runtime part
* ----------------------------------------------------------------------------- */
-%include <rubymacros.swg>
+%include <rubyruntime.swg>
/* -----------------------------------------------------------------------------
- * Error manipulation
+ * Special user directives
* ----------------------------------------------------------------------------- */
-
-%include <rubyerrors.swg>
+%include <rubyuserdir.swg>
/* -----------------------------------------------------------------------------
* Look for user fragments file. If not found, include empty system one.
diff --git a/Lib/ruby/rubyerrors.swg b/Lib/ruby/rubyerrors.swg
index 40af35de9..fe5ce8bd0 100644
--- a/Lib/ruby/rubyerrors.swg
+++ b/Lib/ruby/rubyerrors.swg
@@ -2,45 +2,54 @@
* error manipulation
* ----------------------------------------------------------------------------- */
+%insert("runtime") "swigerrors.swg"
%insert("header") %{
SWIGINTERN VALUE
SWIG_Ruby_ErrorType(int SWIG_code) {
+ VALUE type;
switch (SWIG_code) {
case SWIG_MemoryError:
- return rb_eNoMemError;
+ type = rb_eNoMemError;
+ break;
case SWIG_IOError:
- return rb_eIOError;
+ type = rb_eIOError;
+ break;
case SWIG_RuntimeError:
- return rb_eRuntimeError;
+ type = rb_eRuntimeError;
+ break;
case SWIG_IndexError:
- return rb_eIndexError;
+ type = rb_eIndexError;
+ break;
case SWIG_TypeError:
- return rb_eTypeError;
+ type = rb_eTypeError;
+ break;
case SWIG_DivisionByZero:
- return rb_eZeroDivError;
+ type = rb_eZeroDivError;
+ break;
case SWIG_OverflowError:
- return rb_eRangeError;
+ type = rb_eRangeError;
+ break;
case SWIG_SyntaxError:
- return rb_eSyntaxError;
+ type = rb_eSyntaxError;
+ break;
case SWIG_ValueError:
- return rb_eArgError;
+ type = rb_eArgError;
+ break;
case SWIG_SystemError:
- return rb_eFatal;
+ type = rb_eFatal;
+ break;
case SWIG_AttributeError:
- return rb_eRuntimeError;
+ type = rb_eRuntimeError;
+ break;
case SWIG_UnknownError:
- return rb_eRuntimeError;
+ type = rb_eRuntimeError;
+ break;
default:
- return rb_eRuntimeError;
+ type = rb_eRuntimeError;
}
-}
-
-
-SWIGINTERN void
-SWIG_Ruby_SetErrorMsg(VALUE type, const char *msg) {
- rb_raise(type, msg);
+ return type;
}
%}
diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg
index db6d05776..cb894f909 100644
--- a/Lib/ruby/rubyrun.swg
+++ b/Lib/ruby/rubyrun.swg
@@ -29,38 +29,41 @@
/* Runtime API */
-#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule()
-#define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer)
-/* Ruby-specific SWIG API */
+#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule()
+#define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer)
-#define SWIG_InitRuntime() SWIG_Ruby_InitRuntime()
-#define SWIG_define_class(ty) SWIG_Ruby_define_class(ty)
-#define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty)
-#define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value)
-#define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty)
/* Error manipulation */
-#define SWIG_ERROR -1
-#define SWIG_fail goto fail
-#define SWIG_var_fail return Qnil
-#define SWIG_error(code, msg) SWIG_Ruby_SetErrorMsg(SWIG_Ruby_ErrorType(code), msg)
-#define SWIG_exception(code, msg) do { SWIG_error(code, msg); SWIG_fail; } while (0)
-#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_error(SWIG_RuntimeError, msg); SWIG_fail; } else
+#define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code)
+#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg)
+#define SWIG_fail goto fail
+
+
+/* Ruby-specific SWIG API */
+
+#define SWIG_InitRuntime() SWIG_Ruby_InitRuntime()
+#define SWIG_define_class(ty) SWIG_Ruby_define_class(ty)
+#define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty)
+#define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value)
+#define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty)
+/* -----------------------------------------------------------------------------
+ * pointers/data manipulation
+ * ----------------------------------------------------------------------------- */
+
#ifdef __cplusplus
extern "C" {
+#if 0
+} /* cc-mode */
+#endif
#endif
/* Flags for new pointer objects */
#define SWIG_TRACK_OBJECTS 0x4
-/* -----------------------------------------------------------------------------
- * pointers/data manipulation
- * ----------------------------------------------------------------------------- */
-
typedef struct {
VALUE klass;
VALUE mImpl;
@@ -256,7 +259,7 @@ SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty, int fl
}
return SWIG_OK;
-type_error:
+ type_error:
return SWIG_ERROR;
}
@@ -285,5 +288,8 @@ SWIG_Ruby_SetModule(swig_module_info *pointer)
}
#ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
}
#endif
diff --git a/Lib/ruby/rubytypemaps.swg b/Lib/ruby/rubytypemaps.swg
index 9734c1281..bb5ae0a8d 100644
--- a/Lib/ruby/rubytypemaps.swg
+++ b/Lib/ruby/rubytypemaps.swg
@@ -13,16 +13,11 @@
%define_swig_object(VALUE)
+#define SWIG_VoidObject() Qnil
#define SWIG_SetResultObj(obj) $result = obj
#define SWIG_AppendResultObj(obj) $result = SWIG_Ruby_AppendResult($result, obj)
-#define SWIG_SetConstantObj(name, obj) rb_define_const($module, name, obj);
-#define SWIG_NoneObject() Qnil
-
-/* error manipulation */
-#define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code)
-#define SWIG_SetErrorObj(code, obj) SWIG_Ruby_SetErrorMsg(SWIG_ErrorType(code),obj)
-#define SWIG_SetErrorMsg(code, msg) SWIG_Ruby_SetErrorMsg(SWIG_ErrorType(code),msg)
-#define SWIG_ExceptionObj(d, type, obj) rb_exc_raise(rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)))
+#define SWIG_SetConstantObj(name, obj) rb_define_const($module, name, obj)
+#define SWIG_Raise(obj, type, desc) rb_exc_raise(rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)))
#define SWIG_DirOutFail(code, msg) Swig::DirectorTypeMismatchException::raise(SWIG_ErrorType(code), msg)
@@ -32,6 +27,7 @@
%include "rubyfragments.swg"
+%include <typemaps/exception.swg>
%include <typemaps/swigtype.swg>
%include <typemaps/void.swg>
%include <typemaps/valtypes.swg>
@@ -43,3 +39,10 @@
%include <typemaps/misctypes.swg>
%include <typemaps/enumint.swg>
+
+/* -----------------------------------------------------------------------------
+ * Backward compatibility output helper
+ * ----------------------------------------------------------------------------- */
+%fragment("output_helper","header") %{
+#define output_helper SWIG_Ruby_AppendResult
+%}
diff --git a/Lib/swigerrors.swg b/Lib/swigerrors.swg
new file mode 100644
index 000000000..b3871873a
--- /dev/null
+++ b/Lib/swigerrors.swg
@@ -0,0 +1,17 @@
+/* Errors in SWIG */
+
+#define SWIG_OK 0
+#define SWIG_ERROR -1
+
+#define SWIG_MemoryError 1
+#define SWIG_IOError 2
+#define SWIG_RuntimeError 3
+#define SWIG_IndexError 4
+#define SWIG_TypeError 5
+#define SWIG_DivisionByZero 6
+#define SWIG_OverflowError 7
+#define SWIG_SyntaxError 8
+#define SWIG_ValueError 9
+#define SWIG_SystemError 10
+#define SWIG_AttributeError 11
+#define SWIG_UnknownError 99
diff --git a/Lib/swiglabels.swg b/Lib/swiglabels.swg
index 7af5ed637..aaeac5d5f 100644
--- a/Lib/swiglabels.swg
+++ b/Lib/swiglabels.swg
@@ -69,19 +69,3 @@
#endif
-/* Error labels */
-#define SWIG_OK 0
-#define SWIG_ERROR -1
-
-#define SWIG_MemoryError 1
-#define SWIG_IOError 2
-#define SWIG_RuntimeError 3
-#define SWIG_IndexError 4
-#define SWIG_TypeError 5
-#define SWIG_DivisionByZero 6
-#define SWIG_OverflowError 7
-#define SWIG_SyntaxError 8
-#define SWIG_ValueError 9
-#define SWIG_SystemError 10
-#define SWIG_AttributeError 11
-#define SWIG_UnknownError 99
diff --git a/Lib/tcl/carrays.i b/Lib/tcl/carrays.i
index 8be67abce..0236672d3 100644
--- a/Lib/tcl/carrays.i
+++ b/Lib/tcl/carrays.i
@@ -1,2 +1,4 @@
%include <typemaps/carrays.swg>
+
+
diff --git a/Lib/tcl/exception.i b/Lib/tcl/exception.i
new file mode 100644
index 000000000..0246cfde8
--- /dev/null
+++ b/Lib/tcl/exception.i
@@ -0,0 +1 @@
+%include <typemaps/exception.swg>
diff --git a/Lib/tcl/tcl8.swg b/Lib/tcl/tcl8.swg
index 4b076f210..6bdc674ca 100644
--- a/Lib/tcl/tcl8.swg
+++ b/Lib/tcl/tcl8.swg
@@ -5,25 +5,24 @@
* ----------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
- * The runtime part
+ * Inner macros
* ----------------------------------------------------------------------------- */
-%include <tclruntime.swg>
+%include <tclmacros.swg>
/* -----------------------------------------------------------------------------
- * Special user directives
+ * Error manipulation
* ----------------------------------------------------------------------------- */
-%include <tcluserdir.swg>
+%include <tclerrors.swg>
/* -----------------------------------------------------------------------------
- * Inner macros
+ * The runtime part
* ----------------------------------------------------------------------------- */
-%include <tclmacros.swg>
+%include <tclruntime.swg>
/* -----------------------------------------------------------------------------
- * Error manipulation
+ * Special user directives
* ----------------------------------------------------------------------------- */
-
-%include <tclerrors.swg>
+%include <tcluserdir.swg>
/* -----------------------------------------------------------------------------
* Look for user fragments file. If not found, include empty system one.
diff --git a/Lib/tcl/tclerrors.swg b/Lib/tcl/tclerrors.swg
index 6dbc4ab99..68281cd5c 100644
--- a/Lib/tcl/tclerrors.swg
+++ b/Lib/tcl/tclerrors.swg
@@ -2,37 +2,52 @@
* error manipulation
* ----------------------------------------------------------------------------- */
+%insert("runtime") "swigerrors.swg"
+
%insert("header") %{
SWIGINTERN const char*
SWIG_Tcl_ErrorType(int code) {
+ const char* type = 0;
switch(code) {
case SWIG_MemoryError:
- return "MemoryError";
+ type = "MemoryError";
+ break;
case SWIG_IOError:
- return "IOError";
+ type = "IOError";
+ break;
case SWIG_RuntimeError:
- return "RuntimeError";
+ type = "RuntimeError";
+ break;
case SWIG_IndexError:
- return "IndexError";
+ type = "IndexError";
+ break;
case SWIG_TypeError:
- return "TypeError";
+ type = "TypeError";
+ break;
case SWIG_DivisionByZero:
- return "ZeroDivisionError";
+ type = "ZeroDivisionError";
+ break;
case SWIG_OverflowError:
- return "OverflowError";
+ type = "OverflowError";
+ break;
case SWIG_SyntaxError:
- return "SyntaxError";
+ type = "SyntaxError";
+ break;
case SWIG_ValueError:
- return "ValueError";
+ type = "ValueError";
+ break;
case SWIG_SystemError:
- return "SystemError";
+ type = "SystemError";
+ break;
case SWIG_AttributeError:
- return "AttributeError";
+ type = "AttributeError";
+ break;
default:
- return "RuntimeError";
+ type = "RuntimeError";
}
+ return type;
}
diff --git a/Lib/tcl/tclrun.swg b/Lib/tcl/tclrun.swg
index 282f0be00..83ae8c7b8 100644
--- a/Lib/tcl/tclrun.swg
+++ b/Lib/tcl/tclrun.swg
@@ -29,36 +29,46 @@
#define SWIG_ConvertMember(obj, ptr, sz, ty, flags) SWIG_Tcl_ConvertPacked(interp,obj, ptr, sz, ty, flags)
#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Tcl_NewPackedObj(ptr, sz, type, 0)
+
/* Runtime API */
-#define SWIG_GetModule(clientdata) SWIG_Tcl_GetModule((Tcl_Interp *) (clientdata))
-#define SWIG_SetModule(clientdata, pointer) SWIG_Tcl_SetModule((Tcl_Interp *) (clientdata), pointer)
-/* Tcl-specific SWIG API */
-#define SWIG_Acquire(ptr) SWIG_Tcl_Acquire(ptr)
-#define SWIG_MethodCommand SWIG_Tcl_MethodCommand
-#define SWIG_Disown(ptr) SWIG_Tcl_Disown(ptr)
-#define SWIG_ConvertPtrFromString(c, ptr, ty, flags) SWIG_Tcl_ConvertPtrFromString(interp, c, ptr, ty, flags)
-#define SWIG_MakePtr(c, ptr, ty, flags) SWIG_Tcl_MakePtr(c, ptr, ty, flags)
-#define SWIG_PointerTypeFromString(c) SWIG_Tcl_PointerTypeFromString(c)
-#define SWIG_GetArgs SWIG_Tcl_GetArgs
-#define SWIG_GetConstantObj(key) SWIG_Tcl_GetConstantObj(key)
-#define SWIG_ObjectConstructor SWIG_Tcl_ObjectConstructor
-#define SWIG_Thisown(ptr) SWIG_Tcl_Thisown(ptr)
-#define SWIG_ObjectDelete SWIG_Tcl_ObjectDelete
+#define SWIG_GetModule(clientdata) SWIG_Tcl_GetModule((Tcl_Interp *) (clientdata))
+#define SWIG_SetModule(clientdata, pointer) SWIG_Tcl_SetModule((Tcl_Interp *) (clientdata), pointer)
+
/* Error manipulation */
-#define SWIG_fail goto fail
-#define SWIG_var_fail return "$name"
-#define SWIG_exception(code, msg) do { SWIG_Tcl_SetErrorMsg(interp, SWIG_Tcl_ErrorType(code), msg); SWIG_fail; } while (0)
-#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Tcl_SetErrorMsg(interp, 0, msg); SWIG_fail; } else
-#ifdef __cplusplus
-extern "C" {
-#endif
+#define SWIG_ErrorType(code) SWIG_Tcl_ErrorType(code)
+#define SWIG_Error(code, msg) SWIG_Tcl_SetErrorMsg(interp, SWIG_Tcl_ErrorType(code), msg)
+#define SWIG_fail goto fail
+
+
+/* Tcl-specific SWIG API */
+
+#define SWIG_Acquire(ptr) SWIG_Tcl_Acquire(ptr)
+#define SWIG_MethodCommand SWIG_Tcl_MethodCommand
+#define SWIG_Disown(ptr) SWIG_Tcl_Disown(ptr)
+#define SWIG_ConvertPtrFromString(c, ptr, ty, flags) SWIG_Tcl_ConvertPtrFromString(interp, c, ptr, ty, flags)
+#define SWIG_MakePtr(c, ptr, ty, flags) SWIG_Tcl_MakePtr(c, ptr, ty, flags)
+#define SWIG_PointerTypeFromString(c) SWIG_Tcl_PointerTypeFromString(c)
+#define SWIG_GetArgs SWIG_Tcl_GetArgs
+#define SWIG_GetConstantObj(key) SWIG_Tcl_GetConstantObj(key)
+#define SWIG_ObjectConstructor SWIG_Tcl_ObjectConstructor
+#define SWIG_Thisown(ptr) SWIG_Tcl_Thisown(ptr)
+#define SWIG_ObjectDelete SWIG_Tcl_ObjectDelete
+
/* -----------------------------------------------------------------------------
* pointers/data manipulation
* ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* cc-mode */
+#endif
+#endif
+
/* Object support */
SWIGRUNTIME Tcl_HashTable*
@@ -172,7 +182,7 @@ SWIG_Tcl_ConvertPacked(Tcl_Interp *interp, Tcl_Obj *obj, void *ptr, int sz, swig
}
return SWIG_OK;
-type_error:
+ type_error:
if (flags) {
if (ty) {
@@ -419,8 +429,8 @@ SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_
}
}
if (strcmp(method,"cget") == 0) {
- Tcl_SetResult(interp,(char *) "Invalid attribute name.", TCL_STATIC);
- return TCL_ERROR;
+ Tcl_SetResult(interp,(char *) "Invalid attribute name.", TCL_STATIC);
+ return TCL_ERROR;
}
Tcl_SetResult(interp, (char *) "Invalid method. Must be one of: configure cget -acquire -disown -delete", TCL_STATIC);
cls = inst->classptr;
@@ -479,79 +489,79 @@ SWIG_Tcl_NewInstanceObj(Tcl_Interp *interp, void *thisvalue, swig_type_info *typ
/* Function to create objects */
SWIGRUNTIME int
SWIG_Tcl_ObjectConstructor(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
- Tcl_Obj *newObj = 0;
- void *thisvalue = 0;
- swig_instance *newinst = 0;
- swig_class *classptr = (swig_class *) clientData;
- swig_wrapper cons = 0;
- char *name = 0;
- int firstarg = 0;
- int thisarg = 0;
- int destroy = 1;
-
- if (!classptr) {
- Tcl_SetResult(interp, (char *) "swig: internal runtime error. No class object defined.", TCL_STATIC);
- return TCL_ERROR;
- }
- cons = classptr->constructor;
- if (objc > 1) {
- char *s = Tcl_GetStringFromObj(objv[1],NULL);
- if (strcmp(s,"-this") == 0) {
- thisarg = 2;
- cons = 0;
- } else if (strcmp(s,"-args") == 0) {
- firstarg = 1;
- } else if (objc == 2) {
- firstarg = 1;
- name = s;
- } else if (objc >= 3) {
- char *s1;
- name = s;
- s1 = Tcl_GetStringFromObj(objv[2],NULL);
- if (strcmp(s1,"-this") == 0) {
- thisarg = 3;
- cons = 0;
- } else {
- firstarg = 1;
- }
+ Tcl_Obj *newObj = 0;
+ void *thisvalue = 0;
+ swig_instance *newinst = 0;
+ swig_class *classptr = (swig_class *) clientData;
+ swig_wrapper cons = 0;
+ char *name = 0;
+ int firstarg = 0;
+ int thisarg = 0;
+ int destroy = 1;
+
+ if (!classptr) {
+ Tcl_SetResult(interp, (char *) "swig: internal runtime error. No class object defined.", TCL_STATIC);
+ return TCL_ERROR;
+ }
+ cons = classptr->constructor;
+ if (objc > 1) {
+ char *s = Tcl_GetStringFromObj(objv[1],NULL);
+ if (strcmp(s,"-this") == 0) {
+ thisarg = 2;
+ cons = 0;
+ } else if (strcmp(s,"-args") == 0) {
+ firstarg = 1;
+ } else if (objc == 2) {
+ firstarg = 1;
+ name = s;
+ } else if (objc >= 3) {
+ char *s1;
+ name = s;
+ s1 = Tcl_GetStringFromObj(objv[2],NULL);
+ if (strcmp(s1,"-this") == 0) {
+ thisarg = 3;
+ cons = 0;
+ } else {
+ firstarg = 1;
}
}
- if (cons) {
- int result;
- result = (*cons)(0, interp, objc-firstarg, &objv[firstarg]);
- if (result != TCL_OK) {
- return result;
- }
- newObj = Tcl_DuplicateObj(Tcl_GetObjResult(interp));
+ }
+ if (cons) {
+ int result;
+ result = (*cons)(0, interp, objc-firstarg, &objv[firstarg]);
+ if (result != TCL_OK) {
+ return result;
+ }
+ newObj = Tcl_DuplicateObj(Tcl_GetObjResult(interp));
+ if (!name) name = Tcl_GetStringFromObj(newObj,NULL);
+ } else if (thisarg > 0) {
+ if (thisarg < objc) {
+ destroy = 0;
+ newObj = Tcl_DuplicateObj(objv[thisarg]);
if (!name) name = Tcl_GetStringFromObj(newObj,NULL);
- } else if (thisarg > 0) {
- if (thisarg < objc) {
- destroy = 0;
- newObj = Tcl_DuplicateObj(objv[thisarg]);
- if (!name) name = Tcl_GetStringFromObj(newObj,NULL);
- } else {
- Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC);
- return TCL_ERROR;
- }
} else {
- Tcl_SetResult(interp, (char *) "No constructor available.", TCL_STATIC);
+ Tcl_SetResult(interp, (char *) "wrong # args.", TCL_STATIC);
return TCL_ERROR;
}
- if (SWIG_Tcl_ConvertPtr(interp,newObj, (void **) &thisvalue, *(classptr->type), 0) != SWIG_OK) {
- Tcl_DecrRefCount(newObj);
- return TCL_ERROR;
- }
- newinst = (swig_instance *) malloc(sizeof(swig_instance));
- newinst->thisptr = newObj;
- Tcl_IncrRefCount(newObj);
- newinst->thisvalue = thisvalue;
- newinst->classptr = classptr;
- newinst->destroy = destroy;
- if (destroy) {
- SWIG_Acquire(thisvalue);
- }
- newinst->cmdtok = Tcl_CreateObjCommand(interp,name, (swig_wrapper) SWIG_MethodCommand, (ClientData) newinst, (swig_delete_func) SWIG_ObjectDelete);
- return TCL_OK;
+ } else {
+ Tcl_SetResult(interp, (char *) "No constructor available.", TCL_STATIC);
+ return TCL_ERROR;
+ }
+ if (SWIG_Tcl_ConvertPtr(interp,newObj, (void **) &thisvalue, *(classptr->type), 0) != SWIG_OK) {
+ Tcl_DecrRefCount(newObj);
+ return TCL_ERROR;
+ }
+ newinst = (swig_instance *) malloc(sizeof(swig_instance));
+ newinst->thisptr = newObj;
+ Tcl_IncrRefCount(newObj);
+ newinst->thisvalue = thisvalue;
+ newinst->classptr = classptr;
+ newinst->destroy = destroy;
+ if (destroy) {
+ SWIG_Acquire(thisvalue);
+ }
+ newinst->cmdtok = Tcl_CreateObjCommand(interp,name, (swig_wrapper) SWIG_MethodCommand, (ClientData) newinst, (swig_delete_func) SWIG_ObjectDelete);
+ return TCL_OK;
}
/* -----------------------------------------------------------------------------*
@@ -655,5 +665,8 @@ SWIG_Tcl_GetArgs(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], const char
}
#ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
}
#endif
diff --git a/Lib/tcl/tcltypemaps.swg b/Lib/tcl/tcltypemaps.swg
index 953076863..d4f52d3ba 100644
--- a/Lib/tcl/tcltypemaps.swg
+++ b/Lib/tcl/tcltypemaps.swg
@@ -13,16 +13,12 @@
%define_swig_object(Tcl_Obj *)
+#define SWIG_VoidObject() NULL
#define SWIG_SetResultObj(obj) $result = obj
-#define SWIG_AppendResultObj(obj) $result = (Tcl_ListObjAppendElement(NULL,$result,obj) == TCL_OK) ? $result : NULL;
+#define SWIG_AppendResultObj(obj) $result = (Tcl_ListObjAppendElement(NULL,$result,obj) == TCL_OK) ? $result : NULL
#define SWIG_SetConstantObj(name, obj) SWIG_Tcl_SetConstantObj(interp, name, obj)
-#define SWIG_NoneObject() NULL
-
-/* error manipulation */
-#define SWIG_ErrorType(code) SWIG_Tcl_ErrorType(code)
-#define SWIG_SetErrorObj(code,obj) SWIG_Tcl_SetErrorObj(interp,SWIG_ErrorType(code),obj)
-#define SWIG_SetErrorMsg(code,msg) SWIG_Tcl_SetErrorMsg(interp,SWIG_ErrorType(code),msg)
-#define SWIG_ExceptionObj(d,type,obj) SWIG_Tcl_SetErrorObj(interp,type,obj)
+#define SWIG_Raise(obj,type,desc) SWIG_Tcl_SetErrorObj(interp,type,obj)
+#define SWIG_DirOutFail(code, msg) /* no directors supported */
/* -----------------------------------------------------------------------------
* All the typemaps
@@ -30,6 +26,7 @@
%include "tclfragments.swg"
+%include <typemaps/exception.swg>
%include <tclswigtype.swg>
%include <typemaps/void.swg>
%include <typemaps/valtypes.swg>
diff --git a/Lib/typemaps/carrays.swg b/Lib/typemaps/carrays.swg
index b52f01ae7..ad116f50a 100644
--- a/Lib/typemaps/carrays.swg
+++ b/Lib/typemaps/carrays.swg
@@ -61,21 +61,22 @@ void NAME##_setitem(TYPE *ary, size_t index, TYPE value);
* void setitem(int index, TYPE value);
* TYPE * cast();
* static NAME *frompointer(TYPE *t);
- * }
+ * }
*
+ * Use
+ *
+ * %array_class_wrap(TYPE,NAME,GET,SET)
+ *
+ * if you want different names for the get/set methods.
* ----------------------------------------------------------------------------- */
-%define %array_class(TYPE,NAME)
+%define %array_class_wrap(TYPE,NAME,getitem,setitem)
%{
typedef TYPE NAME;
%}
-typedef struct NAME {
- /* Put language specific enhancements here */
-#if defined(SWIGPYTHON) || defined(SWIGRUBY)
- %rename(__getitem__) getitem;
- %rename(__setitem__) setitem;
-#endif
+
+typedef struct NAME {
} NAME;
%extend NAME {
@@ -109,3 +110,9 @@ typedef struct NAME {
%enddef
+
+#ifndef %array_class
+%define %array_class(TYPE,NAME)
+ %array_class_wrap(TYPE,NAME,getitem,setitem)
+%enddef
+#endif
diff --git a/Lib/typemaps/enumint.swg b/Lib/typemaps/enumint.swg
index a9128d5cc..f18d196ca 100644
--- a/Lib/typemaps/enumint.swg
+++ b/Lib/typemaps/enumint.swg
@@ -49,7 +49,7 @@
$input = from_meth($1_name);
}
%typemap(throws,noblock=1,fragment=frag) enum SWIGTYPE {
- SWIG_exception_obj(0,"$type", from_meth($1));
+ SWIG_raise(from_meth($1),"$type",0);
}
%enddef
diff --git a/Lib/typemaps/exception.swg b/Lib/typemaps/exception.swg
new file mode 100644
index 000000000..0225bdf04
--- /dev/null
+++ b/Lib/typemaps/exception.swg
@@ -0,0 +1,9 @@
+// This SWIG library file provides language independent exception handling
+%include <typemaps/swigmacros.swg>
+
+%insert("runtime") {
+
+ SWIG_define(SWIG_exception(code, msg), SWIG_block(SWIG_error(code, msg); SWIG_fail))
+ SWIG_define(SWIG_contract_assert(expr, msg), if (!(expr)) { SWIG_error(SWIG_RuntimeError, msg); SWIG_fail; } else)
+
+}
diff --git a/Lib/typemaps/strings.swg b/Lib/typemaps/strings.swg
index a34a170ed..b5fe5a229 100644
--- a/Lib/typemaps/strings.swg
+++ b/Lib/typemaps/strings.swg
@@ -184,7 +184,7 @@
/* throws */
%typemap(throws,noblock=1,fragment=#SWIG_FromCharPtr) Char * {
- SWIG_exception_obj(0, "$type", SWIG_FromCharPtr($1));
+ SWIG_raise(SWIG_FromCharPtr($1), "$type", 0);
}
@@ -327,7 +327,7 @@
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
while (size && ($1[size - 1] == '\0')) --size;
%#endif
- SWIG_exception_obj(0, "$type", SWIG_FromCharPtrAndSize($1, size));
+ SWIG_raise(SWIG_FromCharPtrAndSize($1, size), "$type", 0);
}
/* -------------------------------------------------------------------
@@ -357,9 +357,8 @@
#endif /* SWIG_DIRECTOR_TYPEMAPS */
%typemap(throws,noblock=1,fragment=#SWIG_FromCharPtrAndSize)
- Char FIXSIZE[ANY], const Char FIXSIZE[ANY]
-{
- SWIG_exception_obj(0, "$type", SWIG_FromCharPtrAndSize($1, $1_dim0));
+ Char FIXSIZE[ANY], const Char FIXSIZE[ANY] {
+ SWIG_raise(SWIG_FromCharPtrAndSize($1, $1_dim0), "$type", 0);
}
/* ------------------------------------------------------------
@@ -484,10 +483,11 @@ SWIG_As##CharName##Array(SWIG_Object obj, Char *val, size_t size)
if (val) {
if (csize) memcpy(val, cptr, csize*sizeof(Char));
if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(Char));
- if (alloc == SWIG_NEWOBJ) SWIG_delete_array(cptr);
}
+ if (alloc == SWIG_NEWOBJ) SWIG_delete_array(cptr);
return SWIG_OK;
}
+ if (alloc == SWIG_NEWOBJ) SWIG_delete_array(cptr);
}
return SWIG_TypeError;
}
diff --git a/Lib/typemaps/swigmacros.swg b/Lib/typemaps/swigmacros.swg
index c5bcf0ff7..9cfca8670 100644
--- a/Lib/typemaps/swigmacros.swg
+++ b/Lib/typemaps/swigmacros.swg
@@ -85,29 +85,33 @@
/* macros for result manipulation */
-#define SWIG_set_result(obj) SWIG_SetResultObj(obj)
-#define SWIG_append_result(obj) SWIG_AppendResultObj(obj)
-#define SWIG_set_constant(n, v) SWIG_SetConstantObj(n,v)
+#define SWIG_set_result(obj) SWIG_SetResultObj(obj)
+#define SWIG_append_result(obj) SWIG_AppendResultObj(obj)
+#define SWIG_set_constant(name,value) SWIG_SetConstantObj(name,value)
/* macros for error manipulation */
-#define SWIG_TypeErrorFmt(_type,_name) "expected '"_type"'"
-#define SWIG_VarFailFmt(_type,_name) "in variable '"_name"' of type '"_type"'"
-#define SWIG_ArgFailFmt(_type,_argn) "in argument " #_argn" of type '" _type"'"
-#define SWIG_OutFailFmt(_type) "in output of type '"_type"'"
-#define SWIG_ArgNullRefFmt(_type, _argn) "null reference " SWIG_ArgFailFmt(_type, _argn)
-#define SWIG_VarNullRefFmt(_type, _name) "null reference " SWIG_VarFailFmt(_type, _name)
-#define SWIG_OutNullRefFmt(_type) "null reference " SWIG_OutFailFmt(_type)
+#define SWIG_NullRefFmt() "invalid null reference "
+#define SWIG_VarFailFmt(_type,_name) "in variable '"_name"' of type '"_type"'"
+#define SWIG_ArgFailFmt(_type,_argn) "in argument " #_argn" of type '" _type"'"
+#define SWIG_OutFailFmt(_type) "in output value of type '"_type"'"
+#define SWIG_ArgNullRefFmt(_type, _argn) SWIG_NullRefFmt() SWIG_ArgFailFmt(_type, _argn)
+#define SWIG_VarNullRefFmt(_type, _name) SWIG_NullRefFmt() SWIG_VarFailFmt(_type, _name)
+#define SWIG_OutNullRefFmt(_type) SWIG_NullRefFmt() SWIG_OutFailFmt(_type)
-#define SWIG_ArgFail(code,type,argn) SWIG_SetErrorMsg(code,SWIG_ArgFailFmt(type, argn))
-#define SWIG_VarFail(code,type,name) SWIG_SetErrorMsg(code,SWIG_VarFailFmt(type, name))
-#define SWIG_ArgNullRef(type,argn) SWIG_SetErrorMsg(SWIG_ValueError, SWIG_ArgNullRefFmt(type, argn))
-#define SWIG_VarNullRef(type,name) SWIG_SetErrorMsg(SWIG_ValueError, SWIG_VarNullRefFmt(type, name))
-#define SWIG_OutNullRef(type) SWIG_SetErrorMsg(SWIG_ValueError, SWIG_OutNullRefFmt(type))
+#define SWIG_ArgFail(code,type,argn) SWIG_Error(code, SWIG_ArgFailFmt(type, argn))
+#define SWIG_VarFail(code,type,name) SWIG_Error(code, SWIG_VarFailFmt(type, name))
+#define SWIG_ArgNullRef(type,argn) SWIG_Error(SWIG_ValueError, SWIG_ArgNullRefFmt(type, argn))
+#define SWIG_VarNullRef(type,name) SWIG_Error(SWIG_ValueError, SWIG_VarNullRefFmt(type, name))
+#define SWIG_OutNullRef(type) SWIG_Error(SWIG_ValueError, SWIG_OutNullRefFmt(type))
-#define SWIG_set_errmsg(code,msg...) SWIG_SetErrorMsg(code,msg)
-#define SWIG_set_errobj(code,obj) SWIG_SetErrorObj(code,obj)
-#define SWIG_error_block(Block...) SWIG_block(Block)
+/* setting an error */
+#define SWIG_error(code,msg...) SWIG_Error(code, msg)
+#define SWIG_type_error(msg...) SWIG_Error(SWIG_TypeError, msg)
+
+
+/* setting an error and exit */
+#define SWIG_error_block(Block...) SWIG_block(Block)
#define SWIG_arg_fail(code, type, arg) SWIG_error_block(SWIG_ArgFail(code, type, arg); SWIG_fail)
#define SWIG_arg_nullref(type, arg) SWIG_error_block(SWIG_ArgNullRef(type, arg); SWIG_fail)
@@ -118,14 +122,13 @@
#define SWIG_global_fail(code, type, name) SWIG_error_block(SWIG_VarFail(code, type, name); SWIG_fail)
#define SWIG_global_nullref(type, name) SWIG_error_block(SWIG_VarNullRef(type, name); SWIG_fail)
-#define SWIG_var_fail(code, type, name) SWIG_error_block(SWIG_VarFail(code, type, name); SWIG_var_fail)
-#define SWIG_var_nullref(type, name) SWIG_error_block(SWIG_VarNullRef(type, name); SWIG_var_fail)
+#define SWIG_var_fail(code, type, name) SWIG_error_block(SWIG_VarFail(code, type, name); SWIG_fail)
+#define SWIG_var_nullref(type, name) SWIG_error_block(SWIG_VarNullRef(type, name); SWIG_fail)
#define SWIG_dout_fail(code, type) SWIG_DirOutFail(code, SWIG_OutFailFmt(type))
#define SWIG_dout_nullref(type) SWIG_DirOutFail(SWIG_ValueError, SWIG_OutNullRefFmt(type))
-
-#define SWIG_exception_obj(desc, type, obj) SWIG_error_block(SWIG_ExceptionObj(desc, type, obj); SWIG_fail)
+#define SWIG_raise(obj, type, desc) SWIG_error_block(SWIG_Raise(obj, type, desc); SWIG_fail)
/*
@@ -133,7 +136,7 @@
Use it, for example in Tcl, as
- %define_swig_object(Tcl_Obj)
+ %define_swig_object(Tcl_Obj *)
*/
#define SWIG_Object __NULL__
@@ -153,7 +156,7 @@
* ----------------------------------------------------------------------------- */
/* define a new macro */
-%define SWIG_define(Def, Val)
+%define SWIG_define(Def, Val...)
%#define Def Val
%enddef
diff --git a/Lib/typemaps/swigobject.swg b/Lib/typemaps/swigobject.swg
index e2d0a21a0..049e56ef0 100644
--- a/Lib/typemaps/swigobject.swg
+++ b/Lib/typemaps/swigobject.swg
@@ -13,7 +13,7 @@
%typecheck(SWIG_TYPECHECK_POINTER) SWIG_Object "$1 = ($input != 0);";
%typemap(throws,noblock=1) SWIG_Object {
- SWIG_exception_obj(0, "$type", $1);
+ SWIG_raise($1, "$type", 0);
}
%typemap(constcode,noblock=1) SWIG_Object {
diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg
index b8fb71a8b..3556a9053 100644
--- a/Lib/typemaps/swigtype.swg
+++ b/Lib/typemaps/swigtype.swg
@@ -357,19 +357,19 @@
* ------------------------------------------------------------ */
%typemap(throws,noblock=1) SWIGTYPE {
- SWIG_exception_obj($&descriptor, "$type", SWIG_NewPointerObj(SWIG_new_copy($1, $ltype),$&descriptor,SWIG_POINTER_OWN));
+ SWIG_raise(SWIG_NewPointerObj(SWIG_new_copy($1, $ltype),$&descriptor,SWIG_POINTER_OWN), "$type", $&descriptor);
}
%typemap(throws,noblock=1) SWIGTYPE * {
- SWIG_exception_obj($descriptor, "$type", SWIG_NewPointerObj(SWIG_as_voidptr($1),$descriptor,0));
+ SWIG_raise(SWIG_NewPointerObj(SWIG_as_voidptr($1),$descriptor,0), "$type", $descriptor);
}
%typemap(throws,noblock=1) SWIGTYPE [ANY] {
- SWIG_exception_obj($descriptor, "$type", SWIG_NewPointerObj(SWIG_as_voidptr($1),$descriptor,0));
+ SWIG_raise(SWIG_NewPointerObj(SWIG_as_voidptr($1),$descriptor,0), "$type", $descriptor);
}
%typemap(throws,noblock=1) SWIGTYPE & {
- SWIG_exception_obj($descriptor, "$type", SWIG_NewPointerObj(SWIG_as_voidptr(&$1),$descriptor,0));
+ SWIG_raise(SWIG_NewPointerObj(SWIG_as_voidptr(&$1),$descriptor,0), "$type", $descriptor);
}
/* ------------------------------------------------------------
diff --git a/Lib/typemaps/valtypes.swg b/Lib/typemaps/valtypes.swg
index abe8914b7..290370f88 100644
--- a/Lib/typemaps/valtypes.swg
+++ b/Lib/typemaps/valtypes.swg
@@ -124,7 +124,7 @@
%define SWIG_VALUE_THROWS_TYPEMAP(from_meth,frag,Type...)
%typemap(throws,noblock=1,fragment=frag) Type {
- SWIG_exception_obj(0, "Type", from_meth(SWIG_static_cast($1,$basetype)));
+ SWIG_raise(from_meth(SWIG_static_cast($1,Type)), "$type", 0);
}
%enddef
diff --git a/Lib/typemaps/void.swg b/Lib/typemaps/void.swg
index b541a86ed..a702d232b 100644
--- a/Lib/typemaps/void.swg
+++ b/Lib/typemaps/void.swg
@@ -10,7 +10,7 @@
}
}
-%typemap(freearg,noblock=1) void * "";
+%typemap(freearg) void * "";
%typemap(in,noblock=1) void * const& ($*ltype temp) {
if (SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&temp), 0, $disown) != SWIG_OK) {
@@ -23,7 +23,7 @@
/* out */
%typemap(out,noblock=1) void {
- SWIG_set_result(SWIG_NoneObject());
+ SWIG_set_result(SWIG_VoidObject());
}
/* varin */
diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
index 65c6949e8..dbc4e505c 100644
--- a/Source/Modules/main.cxx
+++ b/Source/Modules/main.cxx
@@ -305,6 +305,15 @@ static void SWIG_dump_runtime() {
Printf(runtime, "%s", s);
Delete(s);
+ s = Swig_include_sys("swigerrors.swg");
+ if (!s) {
+ Printf(stderr, "*** Unable to open 'swigerrors.swg'\n");
+ Close(runtime);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ Printf(runtime, "%s", s);
+ Delete(s);
+
s = Swig_include_sys("swigrun.swg");
if (!s) {
Printf(stderr, "*** Unable to open 'swigrun.swg'\n");
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index 51f6f9af0..ebe49f2a2 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -1177,7 +1177,7 @@ public:
outarg = NewString("");
kwargs = NewString("");
- Wrapper_add_local(f,"resultobj", "PyObject *resultobj = NULL");
+ Wrapper_add_local(f,"resultobj", "PyObject *resultobj = 0");
/* Write code to extract function parameters. */
emit_args(d, l, f);
@@ -1491,7 +1491,6 @@ public:
/* Output cleanup code */
int need_cleanup = Len(cleanup) != 0;
if (need_cleanup) {
- Printf(f->code,"cleanup:\n");
Printv(f->code,cleanup,NIL);
}
@@ -1515,12 +1514,10 @@ public:
Printf(f->code,"fail:\n");
if (need_cleanup) {
- Printf(f->code,"if (resultobj) Py_DECREF(resultobj);\n");
- Printf(f->code,"resultobj = NULL;\n");
- Printf(f->code,"goto cleanup;\n");
- } else {
- Printf(f->code,"return NULL;\n");
+ Printv(f->code,cleanup,NIL);
}
+ Printv(f->code,tab4,"return NULL;\n",NIL);
+
Printf(f->code,"}\n");
@@ -1606,7 +1603,7 @@ public:
Python dictionary. */
if (!have_globals) {
- Printf(f_init,"\t PyDict_SetItemString(d,(char*)\"%s\", SWIG_globals);\n",global_name);
+ Printf(f_init,"\t PyDict_SetItemString(d,(char*)\"%s\", SWIG_globals());\n",global_name);
have_globals=1;
if ((shadow) && (!(shadow & PYSHADOW_MEMBER))) {
Printf(f_shadow_stubs,"%s = %s.%s\n", global_name, module, global_name);
@@ -1636,7 +1633,9 @@ public:
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number,
"Unable to set variable of type %s.\n", SwigType_str(t,0));
}
- Printf(setf->code," return 0;\n");
+ Printv(setf->code,tab4,"return 0;\n",NULL);
+ Printf(setf->code,"fail:\n");
+ Printv(setf->code,tab4,"return 1;\n",NULL);
} else {
/* Is a readonly variable. Issue an error */
if (CPlusPlus) {
@@ -1645,8 +1644,7 @@ public:
Printf(setf->def,"static int %s_set(PyObject *_val) {", wname);
}
Printv(setf->code,
- tab4, "PyErr_SetString(PyExc_TypeError,\"Variable ", iname,
- " is read-only.\");\n",
+ tab4, "SWIG_Error(SWIG_AttributeError,\"Variable ", iname," is read-only.\");\n",
tab4, "return 1;\n",
NIL);
}
@@ -1656,7 +1654,7 @@ public:
/* Create a function for getting the value of a variable */
Printf(getf->def,"static PyObject *%s_get(void) {", wname);
- Wrapper_add_local(getf,"pyobj", "PyObject *pyobj = NULL");
+ Wrapper_add_local(getf,"pyobj", "PyObject *pyobj = 0");
if ((tm = Swig_typemap_lookup_new("varout",n,name,0))) {
Replaceall(tm,"$source",name);
Replaceall(tm,"$target","pyobj");
@@ -1671,7 +1669,7 @@ public:
Wrapper_print(getf,f_wrappers);
/* Now add this to the variable linking mechanism */
- Printf(f_init,"\t SWIG_addvarlink(SWIG_globals,(char*)\"%s\",%s_get, %s_set);\n", iname, wname, wname);
+ Printf(f_init,"\t SWIG_addvarlink(SWIG_globals(),(char*)\"%s\",%s_get, %s_set);\n", iname, wname, wname);
DelWrapper(setf);
DelWrapper(getf);
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index 6c424d6e1..d3ca16ef6 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -1314,7 +1314,6 @@ public:
/* Dump the argument cleanup code */
int need_cleanup = (current != CONSTRUCTOR_ALLOCATE) && (Len(cleanup) != 0);
if (need_cleanup) {
- Printv(f->code,"cleanup:\n",NIL);
Printv(f->code,cleanup,NIL);
}
@@ -1343,38 +1342,27 @@ public:
Printv(f->code, tab4, "return self;\n", NIL);
Printv(f->code,"fail:\n",NIL);
if (need_cleanup) {
- Printv(f->code, tab4, "self = Qnil;\n", NIL);
- Printv(f->code, tab4, "goto cleanup;\n", NIL);
- } else {
- Printv(f->code, tab4, "return Qnil;\n", NIL);
- }
+ Printv(f->code,cleanup,NIL);
+ }
+ Printv(f->code, tab4, "return Qnil;\n", NIL);
} else {
Wrapper_add_local(f,"vresult","VALUE vresult = Qnil");
Printv(f->code, tab4, "return vresult;\n", NIL);
Printv(f->code,"fail:\n",NIL);
if (need_cleanup) {
- Printv(f->code, tab4, "vresult = Qnil;\n", NIL);
- Printv(f->code, tab4, "goto cleanup;\n", NIL);
- } else {
- Printv(f->code, tab4, "return Qnil;\n", NIL);
- }
+ Printv(f->code,cleanup,NIL);
+ }
+ Printv(f->code, tab4, "return Qnil;\n", NIL);
}
} else {
Printv(f->code, tab4, "return Qnil;\n", NIL);
Printv(f->code,"fail:\n",NIL);
if (need_cleanup) {
- Printv(f->code, tab4, "goto cleanup;\n", NIL);
- } else {
- Printv(f->code, tab4, "return Qnil;\n", NIL);
+ Printv(f->code,cleanup,NIL);
}
+ Printv(f->code, tab4, "return Qnil;\n", NIL);
}
- /* Error handling code */
- /*
- Printf(f->code,"fail:\n");
- Printv(f->code,cleanup,NIL);
- Printv(f->code,"return Qnil;\n",NIL);
- */
Printf(f->code,"}\n");
/* Substitute the cleanup code */
@@ -1500,7 +1488,7 @@ public:
Printv(getf->code, tab4, "return _val;\n}\n", NIL);
Wrapper_print(getf,f_wrappers);
- if (GetFlag(n,"feature:immutable")) {
+ if (!is_assignable(n)) {
setfname = NewString("NULL");
} else {
/* create setter */
@@ -1518,7 +1506,9 @@ public:
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number,
"Unable to set variable of type %s\n", SwigType_str(t,0));
}
- Printv(setf->code, tab4, "return _val;\n",NIL);
+ Printv(setf->code, tab4, "return _val;\n", NIL);
+ Printf(setf->code, "fail:\n");
+ Printv(setf->code, tab4, "return Qnil;\n", NIL);
Printf(setf->code,"}\n");
Wrapper_print(setf,f_wrappers);
}
diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx
index 47e0c8d6a..06ea65eed 100644
--- a/Source/Modules/tcl8.cxx
+++ b/Source/Modules/tcl8.cxx
@@ -583,7 +583,7 @@ public:
DelWrapper(getf);
/* Try to create a function setting a variable */
- if (!GetFlag(n,"feature:immutable")) {
+ if (is_assignable(n)) {
setf = NewWrapper();
setname = Swig_name_wrapper(Swig_name_set(iname));
Printv(setf->def,"SWIGINTERN char *",setname, "(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",NIL);
@@ -600,6 +600,8 @@ public:
Printf(setf->code,"if (!value) return NULL;\n");
Printf(setf->code,"%s\n", tm);
Printf(setf->code,"return NULL;\n");
+ Printf(setf->code,"fail:\n");
+ Printf(setf->code,"return \"%s\";\n", iname);
Printf(setf->code,"}\n");
if (setf) Wrapper_print(setf,f_wrappers);
} else {
@@ -608,10 +610,13 @@ public:
readonly = 1;
}
DelWrapper(setf);
- }
+ } else {
+ readonly = 1;
+ }
+
Printv(var_tab, tab4,"{ SWIG_prefix \"", iname, "\", 0, (swig_variable_func) ", getname, ",", NIL);
- if (readonly || GetFlag(n,"feature:immutable")) {
+ if (readonly) {
static int readonlywrap = 0;
if (!readonlywrap) {
Wrapper *ro = NewWrapper();