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
|
|
@ -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