diff --git a/CHANGES.current b/CHANGES.current index 8f8030ea7..b297994a5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,16 @@ Version 1.3.34 (in progress) ============================ +01/21/2008: wsfulton + [Python] For STL containers, SWIG no longer attempts to convert from one + STL container to another, eg from std::vector to std::vector + or std::list to std::vector or even std::vector to + std::vector as it previously did. In fact SWIG no longer attempts to + convert any SWIG wrapped C++ proxy class that is also a Python sequence, + whereas previously it would. Any non-SWIG Python sequence will still be + accepted wherever an STL container is accepted. Overloaded methods using + containers should be faster. + 01/18/2008: wsfulton Add 'directorinattributes' and 'directoroutattributes' typemap attributes for the imtype typemap. These should contain C# attributes which will diff --git a/Examples/test-suite/python/li_std_vector.i b/Examples/test-suite/python/li_std_vector.i index 278c37623..d1af1a70a 100644 --- a/Examples/test-suite/python/li_std_vector.i +++ b/Examples/test-suite/python/li_std_vector.i @@ -1,5 +1,8 @@ %module li_std_vector +%warnfilter(509) overloaded1; +%warnfilter(509) overloaded2; + %include "std_string.i" %include "std_vector.i" %include "cpointer.i" @@ -126,3 +129,11 @@ std::vector vecStr(std::vector v) { namespace std { %template(ConstIntVector) vector; } + +%inline %{ +std::string overloaded1(std::vector vi) { return "vector"; } +std::string overloaded1(std::vector vi) { return "vector"; } +std::string overloaded2(std::vector vi) { return "vector"; } +std::string overloaded2(std::vector vi) { return "vector"; } +%} + diff --git a/Examples/test-suite/python/li_std_vector_runme.py b/Examples/test-suite/python/li_std_vector_runme.py index ed2943b67..a811fc49b 100644 --- a/Examples/test-suite/python/li_std_vector_runme.py +++ b/Examples/test-suite/python/li_std_vector_runme.py @@ -111,3 +111,16 @@ iv[1:3] = [] if iv[1] != 3: raise RuntimeError +# Overloading checks +if overloaded1(iv) != "vector": + raise RuntimeError + +if overloaded1(dv) != "vector": + raise RuntimeError + +if overloaded2(iv) != "vector": + raise RuntimeError + +if overloaded2(dv) != "vector": + raise RuntimeError + diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index b2908e003..7b8e56e6d 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -702,7 +702,14 @@ namespace swig { typedef T value_type; static int asptr(PyObject *obj, sequence **seq) { - if (PySequence_Check(obj)) { + if (SWIG_Python_GetSwigThis(obj)) { + sequence *p; + if (SWIG_ConvertPtr(obj,(void**)&p, + swig::type_info(),0) == SWIG_OK) { + if (seq) *seq = p; + return SWIG_OLDOBJ; + } + } else if (PySequence_Check(obj)) { try { PySequence_Cont pyseq(obj); if (seq) { @@ -721,13 +728,6 @@ namespace swig { } return SWIG_ERROR; } - } else { - sequence *p; - if (SWIG_ConvertPtr(obj,(void**)&p, - swig::type_info(),0) == SWIG_OK) { - if (seq) *seq = p; - return SWIG_OLDOBJ; - } } return SWIG_ERROR; }