UTL STL container descriptor checks
The vector of pointers (just fixed) were not working correctly because the
descriptors returned from swig::type_info() were sometimes returning
zero. Zero should only be used for void * as the subsequent call to
SWIG_ConvertPtr will blindly cast the pointer without checking
descriptor.
std::vector<void *> does not work and will require further changes:
specializing traits_info<void *> to return 0 and traits_asptr<void *>.
I tried this and traits_asptr<void> also needs to be added in which
seems odd and requires further investigation...
Lib/python/pystdcommon.swg:
template <> struct traits_info<void *> {
static swig_type_info *type_info() {
static swig_type_info *info = 0;
}
};
Lib/std/std_common.i:
template <>
struct traits_asptr<void *> {
static int asptr(PyObject *obj, void ***val) {
void **p;
swig_type_info *descriptor = 0;
int res = SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0);
if (SWIG_IsOK(res)) {
if (val) *val = p;
}
return res;
}
};
// this is needed, but am not sure this is expected
template <>
struct traits_asptr<void> {
static int asptr(PyObject *obj, void **val) {
void **p;
swig_type_info *descriptor = 0;
int res = SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0);
if (SWIG_IsOK(res)) {
if (val) *val = p;
}
return res;
}
};
This commit is contained in:
parent
6e9184b6f8
commit
91aba9f719
18 changed files with 53 additions and 41 deletions
|
|
@ -562,8 +562,8 @@ namespace swig {
|
|||
static int asptr(const octave_value& obj, sequence **seq) {
|
||||
if (!obj.is_defined() || Swig::swig_value_deref(obj)) {
|
||||
sequence *p;
|
||||
if (SWIG_ConvertPtr(obj,(void**)&p,
|
||||
swig::type_info<sequence>(),0) == SWIG_OK) {
|
||||
swig_type_info *descriptor = swig::type_info<sequence>();
|
||||
if (descriptor && SWIG_IsOK(SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0))) {
|
||||
if (seq) *seq = p;
|
||||
return SWIG_OLDOBJ;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ namespace swig {
|
|||
struct traits_asptr {
|
||||
static int asptr(const octave_value& obj, Type **val) {
|
||||
Type *p;
|
||||
int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
|
||||
swig_type_info *descriptor = type_info<Type>();
|
||||
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,8 @@
|
|||
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
|
||||
} else {
|
||||
map_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
|
||||
swig_type_info *descriptor = swig::type_info<map_type>();
|
||||
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res) && val) *val = p;
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@
|
|||
return get_pair(c(0),c(1),val);
|
||||
} else {
|
||||
value_type *p;
|
||||
int res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0);
|
||||
swig_type_info *descriptor = swig::type_info<value_type>();
|
||||
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res) && val)
|
||||
*val = *p;
|
||||
return res;
|
||||
|
|
@ -100,7 +101,8 @@
|
|||
return get_pair(c(0),c(1),val);
|
||||
} else {
|
||||
value_type *p;
|
||||
int res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0);
|
||||
swig_type_info *descriptor = swig::type_info<value_type>();
|
||||
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res) && val)
|
||||
*val = p;
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -968,8 +968,8 @@ namespace swig {
|
|||
static int asptr(PyObject *obj, sequence **seq) {
|
||||
if (obj == Py_None || SWIG_Python_GetSwigThis(obj)) {
|
||||
sequence *p;
|
||||
if (::SWIG_ConvertPtr(obj,(void**)&p,
|
||||
swig::type_info<sequence>(),0) == SWIG_OK) {
|
||||
swig_type_info *descriptor = swig::type_info<sequence>();
|
||||
if (descriptor && SWIG_IsOK(::SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0))) {
|
||||
if (seq) *seq = p;
|
||||
return SWIG_OLDOBJ;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ namespace swig {
|
|||
struct traits_asptr {
|
||||
static int asptr(PyObject *obj, Type **val) {
|
||||
Type *p;
|
||||
int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
|
||||
swig_type_info *descriptor = type_info<Type>();
|
||||
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,8 @@
|
|||
res = traits_asptr_stdseq<map_type, std::pair<K, T> >::asptr(items, val);
|
||||
} else {
|
||||
map_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
|
||||
swig_type_info *descriptor = swig::type_info<map_type>();
|
||||
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res) && val) *val = p;
|
||||
}
|
||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@
|
|||
return traits_asptr_stdseq<std::multimap<K,T>, std::pair<K, T> >::asptr(items, val);
|
||||
} else {
|
||||
multimap_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<multimap_type>(),0);
|
||||
swig_type_info *descriptor = swig::type_info<multimap_type>();
|
||||
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res) && val) *val = p;
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@
|
|||
}
|
||||
} else {
|
||||
value_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0);
|
||||
swig_type_info *descriptor = swig::type_info<value_type>();
|
||||
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res) && val) *val = *p;
|
||||
}
|
||||
return res;
|
||||
|
|
@ -98,7 +99,8 @@
|
|||
}
|
||||
} else {
|
||||
value_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0);
|
||||
swig_type_info *descriptor = swig::type_info<value_type>();
|
||||
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res) && val) *val = p;
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@
|
|||
res = traits_asptr_stdseq<std::unordered_map<K,T>, std::pair<K, T> >::asptr(items, val);
|
||||
} else {
|
||||
unordered_map_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<unordered_map_type>(),0);
|
||||
swig_type_info *descriptor = swig::type_info<unordered_map_type>();
|
||||
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res) && val) *val = p;
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@
|
|||
return traits_asptr_stdseq<std::unordered_multimap<K,T>, std::pair<K, T> >::asptr(items, val);
|
||||
} else {
|
||||
unordered_multimap_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<unordered_multimap_type>(),0);
|
||||
swig_type_info *descriptor = swig::type_info<unordered_multimap_type>();
|
||||
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res) && val) *val = p;
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ namespace swig {
|
|||
struct traits_asptr {
|
||||
static int asptr(SWIG_Object obj, Type **val) {
|
||||
Type *p;
|
||||
int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
|
||||
swig_type_info *descriptor = type_info<Type>();
|
||||
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -464,8 +464,7 @@ namespace swig
|
|||
%typemap(in,noblock=1,fragment="RubySequence_Cont")
|
||||
const_iterator(swig::ConstIterator *iter = 0, int res),
|
||||
const_reverse_iterator(swig::ConstIterator *iter = 0, int res) {
|
||||
res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter),
|
||||
swig::ConstIterator::descriptor(), 0);
|
||||
res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::ConstIterator::descriptor(), 0);
|
||||
if (!SWIG_IsOK(res) || !iter) {
|
||||
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
|
||||
} else {
|
||||
|
|
@ -497,16 +496,14 @@ namespace swig
|
|||
%typecheck(%checkcode(ITERATOR),noblock=1,fragment="RubySequence_Cont")
|
||||
const_iterator, const_reverse_iterator {
|
||||
swig::ConstIterator *iter = 0;
|
||||
int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter),
|
||||
swig::ConstIterator::descriptor(), 0);
|
||||
int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::ConstIterator::descriptor(), 0);
|
||||
$1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::ConstIterator_T<$type > *>(iter) != 0));
|
||||
}
|
||||
|
||||
%typecheck(%checkcode(ITERATOR),noblock=1,fragment="RubySequence_Cont")
|
||||
iterator, reverse_iterator {
|
||||
swig::ConstIterator *iter = 0;
|
||||
int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter),
|
||||
swig::Iterator::descriptor(), 0);
|
||||
int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::Iterator::descriptor(), 0);
|
||||
$1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::Iterator_T<$type > *>(iter) != 0));
|
||||
}
|
||||
|
||||
|
|
@ -1037,8 +1034,8 @@ namespace swig {
|
|||
}
|
||||
} else {
|
||||
sequence *p;
|
||||
if (SWIG_ConvertPtr(obj,(void**)&p,
|
||||
swig::type_info<sequence>(),0) == SWIG_OK) {
|
||||
swig_type_info *descriptor = swig::type_info<sequence>();
|
||||
if (descriptor && SWIG_IsOK(SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0))) {
|
||||
if (seq) *seq = p;
|
||||
return SWIG_OLDOBJ;
|
||||
}
|
||||
|
|
@ -1077,8 +1074,8 @@ namespace swig {
|
|||
}
|
||||
} else {
|
||||
sequence *p;
|
||||
if (SWIG_ConvertPtr(obj,(void**)&p,
|
||||
swig::type_info<sequence>(),0) == SWIG_OK) {
|
||||
swig_type_info *descriptor = swig::type_info<sequence>();
|
||||
if (descriptor && SWIG_IsOK(SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0))) {
|
||||
if (seq) *seq = p;
|
||||
return SWIG_OLDOBJ;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ namespace swig {
|
|||
struct traits_asptr {
|
||||
static int asptr(VALUE obj, Type **val) {
|
||||
Type *p;
|
||||
int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
|
||||
swig_type_info *descriptor = type_info<Type>();
|
||||
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,8 @@
|
|||
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
|
||||
} else {
|
||||
map_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
|
||||
swig_type_info *descriptor = swig::type_info<map_type>();
|
||||
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res) && val) *val = p;
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@
|
|||
}
|
||||
} else {
|
||||
value_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,
|
||||
swig::type_info<value_type>(),0);
|
||||
swig_type_info *descriptor = swig::type_info<value_type>();
|
||||
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res) && val) *val = *p;
|
||||
}
|
||||
return res;
|
||||
|
|
@ -90,8 +90,8 @@
|
|||
}
|
||||
} else {
|
||||
value_type *p;
|
||||
res = SWIG_ConvertPtr(obj,(void**)&p,
|
||||
swig::type_info<value_type>(),0);
|
||||
swig_type_info *descriptor = swig::type_info<value_type>();
|
||||
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res) && val) *val = p;
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ namespace swig {
|
|||
struct traits_asptr {
|
||||
static int asptr(const SwigSciObject& obj, Type **val) {
|
||||
Type *p;
|
||||
int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
|
||||
swig_type_info *descriptor = type_info<Type>();
|
||||
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ namespace swig {
|
|||
typedef Type value_type;
|
||||
static int asptr(SWIG_Object obj, value_type **val) {
|
||||
Type *vptr;
|
||||
static swig_type_info* desc = SWIG_TypeQuery("Type *");
|
||||
int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0);
|
||||
static swig_type_info* descriptor = SWIG_TypeQuery("Type *");
|
||||
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&vptr, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = vptr;
|
||||
return res;
|
||||
|
|
@ -109,8 +109,8 @@ namespace swig {
|
|||
typedef Type value_type;
|
||||
static int asptr(SWIG_Object obj, value_type **val) {
|
||||
Type *vptr;
|
||||
static swig_type_info* desc = SWIG_TypeQuery("Type *");
|
||||
int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0);
|
||||
static swig_type_info* descriptor = SWIG_TypeQuery("Type *");
|
||||
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&vptr, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = vptr;
|
||||
return res;
|
||||
|
|
@ -147,8 +147,8 @@ namespace swig {
|
|||
typedef Type value_type;
|
||||
static int asptr(SWIG_Object obj, value_type **val) {
|
||||
Type *vptr;
|
||||
static swig_type_info* desc = SWIG_TypeQuery("Type *");
|
||||
int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0);
|
||||
static swig_type_info* descriptor = SWIG_TypeQuery("Type *");
|
||||
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&vptr, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = vptr;
|
||||
return SWIG_OLDOBJ;
|
||||
|
|
@ -188,8 +188,8 @@ namespace swig {
|
|||
typedef Type value_type;
|
||||
static int asptr(SWIG_Object obj, value_type **val) {
|
||||
Type *vptr;
|
||||
static swig_type_info* desc = SWIG_TypeQuery("Type *");
|
||||
int res = SWIG_ConvertPtr(obj, (void **)&vptr, desc, 0);
|
||||
static swig_type_info* descriptor = SWIG_TypeQuery("Type *");
|
||||
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&vptr, descriptor, 0) : SWIG_ERROR;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = vptr;
|
||||
return res;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue