accept None in std::vector<A*>
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5841 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
427c969c60
commit
7ac0a7f883
2 changed files with 4 additions and 4 deletions
|
|
@ -26,7 +26,7 @@ if bv[0] != bv[2]:
|
||||||
raise RuntimeError,"bad std::vector<bool> mapping"
|
raise RuntimeError,"bad std::vector<bool> mapping"
|
||||||
|
|
||||||
b = B(5)
|
b = B(5)
|
||||||
va = VecA([b,b,b,b])
|
va = VecA([b,None,b,b])
|
||||||
if va[0].f(1) != 6:
|
if va[0].f(1) != 6:
|
||||||
raise RuntimeError,"bad std::vector<A*> mapping"
|
raise RuntimeError,"bad std::vector<A*> mapping"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,7 @@ namespace swigpy {
|
||||||
PyErr_SetString(PyExc_TypeError, msg.c_str());
|
PyErr_SetString(PyExc_TypeError, msg.c_str());
|
||||||
}
|
}
|
||||||
if (throw_error) throw std::invalid_argument(msg);
|
if (throw_error) throw std::invalid_argument(msg);
|
||||||
|
memset(v_def,0,sizeof(Type));
|
||||||
return *v_def;
|
return *v_def;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -277,14 +278,13 @@ namespace swigpy {
|
||||||
struct traits_as<Type*, pointer_category> {
|
struct traits_as<Type*, pointer_category> {
|
||||||
static Type* as(PyObject *obj, bool throw_error) {
|
static Type* as(PyObject *obj, bool throw_error) {
|
||||||
Type *v = 0;
|
Type *v = 0;
|
||||||
int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : 0) && v;
|
int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : 0);
|
||||||
if (res) {
|
if (res) {
|
||||||
return v;
|
return v;
|
||||||
} else {
|
} else {
|
||||||
// Uninitialized return value, no Type() constructor required.
|
|
||||||
std::string msg = "a value of type '";
|
std::string msg = "a value of type '";
|
||||||
msg += swigpy::type_name<Type>();
|
msg += swigpy::type_name<Type>();
|
||||||
msg += "' is expected";
|
msg += "*' is expected";
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
PyErr_SetString(PyExc_TypeError, msg.c_str());
|
PyErr_SetString(PyExc_TypeError, msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue