Remove conversion from one STL container to another
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10214 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c7ec8c691d
commit
cb9d191276
4 changed files with 42 additions and 8 deletions
|
|
@ -1,6 +1,16 @@
|
||||||
Version 1.3.34 (in progress)
|
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<int> to std::vector<double>
|
||||||
|
or std::list<int> to std::vector<int> or even std::vector<Foo> to
|
||||||
|
std::vector<Bar> 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
|
01/18/2008: wsfulton
|
||||||
Add 'directorinattributes' and 'directoroutattributes' typemap attributes
|
Add 'directorinattributes' and 'directoroutattributes' typemap attributes
|
||||||
for the imtype typemap. These should contain C# attributes which will
|
for the imtype typemap. These should contain C# attributes which will
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
%module li_std_vector
|
%module li_std_vector
|
||||||
|
|
||||||
|
%warnfilter(509) overloaded1;
|
||||||
|
%warnfilter(509) overloaded2;
|
||||||
|
|
||||||
%include "std_string.i"
|
%include "std_string.i"
|
||||||
%include "std_vector.i"
|
%include "std_vector.i"
|
||||||
%include "cpointer.i"
|
%include "cpointer.i"
|
||||||
|
|
@ -126,3 +129,11 @@ std::vector<std::string> vecStr(std::vector<std::string> v) {
|
||||||
namespace std {
|
namespace std {
|
||||||
%template(ConstIntVector) vector<const int *>;
|
%template(ConstIntVector) vector<const int *>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
std::string overloaded1(std::vector<double> vi) { return "vector<double>"; }
|
||||||
|
std::string overloaded1(std::vector<int> vi) { return "vector<int>"; }
|
||||||
|
std::string overloaded2(std::vector<int> vi) { return "vector<int>"; }
|
||||||
|
std::string overloaded2(std::vector<double> vi) { return "vector<double>"; }
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,3 +111,16 @@ iv[1:3] = []
|
||||||
if iv[1] != 3:
|
if iv[1] != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
# Overloading checks
|
||||||
|
if overloaded1(iv) != "vector<int>":
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if overloaded1(dv) != "vector<double>":
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if overloaded2(iv) != "vector<int>":
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if overloaded2(dv) != "vector<double>":
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -702,7 +702,14 @@ namespace swig {
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
|
|
||||||
static int asptr(PyObject *obj, sequence **seq) {
|
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<sequence>(),0) == SWIG_OK) {
|
||||||
|
if (seq) *seq = p;
|
||||||
|
return SWIG_OLDOBJ;
|
||||||
|
}
|
||||||
|
} else if (PySequence_Check(obj)) {
|
||||||
try {
|
try {
|
||||||
PySequence_Cont<value_type> pyseq(obj);
|
PySequence_Cont<value_type> pyseq(obj);
|
||||||
if (seq) {
|
if (seq) {
|
||||||
|
|
@ -721,13 +728,6 @@ namespace swig {
|
||||||
}
|
}
|
||||||
return SWIG_ERROR;
|
return SWIG_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
sequence *p;
|
|
||||||
if (SWIG_ConvertPtr(obj,(void**)&p,
|
|
||||||
swig::type_info<sequence>(),0) == SWIG_OK) {
|
|
||||||
if (seq) *seq = p;
|
|
||||||
return SWIG_OLDOBJ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return SWIG_ERROR;
|
return SWIG_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue