diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2016-07-28 08:31:03 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2016-07-28 22:51:29 +0100 |
commit | 91aba9f719273778fe0196f9bc8659131c9e2cf8 (patch) | |
tree | 9fc17a09e8fc28aacb1cad45035fe0aad1508dc1 /Lib/scilab | |
parent | 6e9184b6f82e99a5095b5812a4b6b7040f87d17d (diff) | |
download | swig-91aba9f719273778fe0196f9bc8659131c9e2cf8.tar.gz |
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;
}
};
Diffstat (limited to 'Lib/scilab')
-rw-r--r-- | Lib/scilab/scistdcommon.swg | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/scilab/scistdcommon.swg b/Lib/scilab/scistdcommon.swg index 7fdc72212..63f3ca164 100644 --- a/Lib/scilab/scistdcommon.swg +++ b/Lib/scilab/scistdcommon.swg @@ -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; } |