Minor code refactor in Python traits_asptr::asptr

This commit is contained in:
William S Fulton 2020-02-13 19:28:03 +00:00
commit 67a38589a8

View file

@ -45,23 +45,22 @@ namespace swig {
template <class Type> template <class Type>
struct traits_asptr { struct traits_asptr {
static int asptr(PyObject *obj, Type **val) { static int asptr(PyObject *obj, Type **val) {
int res = SWIG_ERROR;
swig_type_info *descriptor = type_info<Type>();
if (val) { if (val) {
Type *p = 0; Type *p = 0;
swig_type_info *descriptor = type_info<Type>();
int newmem = 0; int newmem = 0;
int res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR; res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR;
if (SWIG_IsOK(res)) { if (SWIG_IsOK(res)) {
if (newmem & SWIG_CAST_NEW_MEMORY) { if (newmem & SWIG_CAST_NEW_MEMORY) {
res |= SWIG_NEWOBJMASK; res |= SWIG_NEWOBJMASK;
} }
*val = p; *val = p;
} }
return res;
} else { } else {
swig_type_info *descriptor = type_info<Type>(); res = descriptor ? SWIG_ConvertPtr(obj, 0, descriptor, 0) : SWIG_ERROR;
int res = descriptor ? SWIG_ConvertPtr(obj, 0, descriptor, 0) : SWIG_ERROR;
return res;
} }
return res;
} }
}; };