summaryrefslogtreecommitdiff
path: root/Lib/python/pycontainer.swg
diff options
context:
space:
mode:
authorMarcelo Matus <mmatus@acms.arizona.edu>2006-01-08 07:08:21 +0000
committerMarcelo Matus <mmatus@acms.arizona.edu>2006-01-08 07:08:21 +0000
commit972974c0e3939a959c31926908264301845835db (patch)
treee9519cf2f6266e718a959b2869b5dbb884ebef07 /Lib/python/pycontainer.swg
parente8d67c80f3d8dd276a3e8953715f40d79efacc4b (diff)
downloadswig-972974c0e3939a959c31926908264301845835db.tar.gz
fix to avoid copies when the wrapper class exists
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8293 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Lib/python/pycontainer.swg')
-rw-r--r--Lib/python/pycontainer.swg32
1 files changed, 16 insertions, 16 deletions
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
index 3695998f6..06b76435c 100644
--- a/Lib/python/pycontainer.swg
+++ b/Lib/python/pycontainer.swg
@@ -717,10 +717,6 @@ namespace swig {
return SWIG_OLDOBJ;
}
}
- if (seq) {
- PyErr_Format(PyExc_TypeError, "a %s is expected",
- swig::type_name<sequence>());
- }
return SWIG_ERROR;
}
};
@@ -733,19 +729,23 @@ namespace swig {
typedef typename sequence::const_iterator const_iterator;
static PyObject *from(const sequence& seq) {
- size_type size = seq.size();
- if (size <= (size_type)INT_MAX) {
- PyObject *obj = PyTuple_New((int)size);
- int i = 0;
- for (const_iterator it = seq.begin();
- it != seq.end(); ++it, ++i) {
- PyTuple_SetItem(obj,i,swig::from<value_type>(*it));
- }
- return obj;
+ swig_type_info *desc = swig::type_info<sequence>();
+ if (desc && desc->clientdata) {
+ return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN);
} else {
- PyErr_SetString(PyExc_OverflowError,
- "sequence size not valid in python");
- return NULL;
+ size_type size = seq.size();
+ if (size <= (size_type)INT_MAX) {
+ PyObject *obj = PyTuple_New((int)size);
+ int i = 0;
+ for (const_iterator it = seq.begin();
+ it != seq.end(); ++it, ++i) {
+ PyTuple_SetItem(obj,i,swig::from<value_type>(*it));
+ }
+ return obj;
+ } else {
+ PyErr_SetString(PyExc_OverflowError,"sequence size not valid in python");
+ return NULL;
+ }
}
}
};