From 63cdb9b4d08bb1c26abfd6d93c5f4601f1b1c04d Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Tue, 20 Jan 2004 20:51:46 +0000 Subject: [PATCH] small error fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5649 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/std_complex.i | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/python/std_complex.i b/Lib/python/std_complex.i index 8d46d9458..3c0122bdc 100644 --- a/Lib/python/std_complex.i +++ b/Lib/python/std_complex.i @@ -9,7 +9,7 @@ static inline int SwigComplex_Check(PyObject *o) { - return (PyComplex_Check(o) || PyFloat_Check(o) || PyInt_Check(o)) ? 1 : 0; + return PyComplex_Check(o) || PyFloat_Check(o) || PyInt_Check(o) || PyLong_Check(o); } template @@ -22,6 +22,8 @@ SwigComplex_As(PyObject *o) return __Complex(PyFloat_AsDouble(o), 0); } else if (PyInt_Check(o)) { return __Complex(PyInt_AsLong(o), 0); + } else if (PyLong_Check(o)) { + return __Complex(PyLong_AsLongLong(o), 0); } else { PyErr_SetString(PyExc_TypeError, "Expecting a complex or compatible type"); return __Complex(0,0); @@ -68,11 +70,11 @@ SwigComplex_AsComplexDouble(PyObject *o) // C++ proxy class typemaps %typemap(directorin) Complex { - $input = PyComplex_FromDoubles($1_name.real(), $1_name.imag()); + $input = PyComplex_FromDoubles($1_name.real(), $1_name.imag()); } %typemap(directorin) const Complex & { - $input = PyComplex_FromDoubles($1_name.real(), $1_name.imag()); + $input = PyComplex_FromDoubles($1_name.real(), $1_name.imag()); } %typemap(directorout) Complex { @@ -82,7 +84,7 @@ SwigComplex_AsComplexDouble(PyObject *o) } } - %typemap(directorout) const complex& (Complex temp) { + %typemap(directorout) const Complex & (Complex temp) { temp = SwigComplex_As< Complex >($input); if (PyErr_Occurred()) { throw Swig::DirectorTypeMismatchException("Expecting a complex or compatible type");