[ruby] treat null shared_ptr in std containers properly.
This commit is contained in:
parent
79620b10a9
commit
661c3fc554
2 changed files with 13 additions and 1 deletions
|
|
@ -5,7 +5,8 @@ namespace swig {
|
||||||
template <class Type> struct traits_asval;
|
template <class Type> struct traits_asval;
|
||||||
struct pointer_category;
|
struct pointer_category;
|
||||||
template <class Type, class Category> struct traits_as;
|
template <class Type, class Category> struct traits_as;
|
||||||
template<class Type> struct traits_from;
|
template <class Type> struct traits_from;
|
||||||
|
template <class Type> struct traits_from_ptr;
|
||||||
template <class Type> struct noconst_traits;
|
template <class Type> struct noconst_traits;
|
||||||
template <class Type> swig_type_info* type_info();
|
template <class Type> swig_type_info* type_info();
|
||||||
template <class Type> const char* type_name();
|
template <class Type> const char* type_name();
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,17 @@ namespace swig {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class Type>
|
||||||
|
struct traits_from_ptr<std::shared_ptr<Type> > {
|
||||||
|
static VALUE from(std::shared_ptr<Type> *val, int owner = 0) {
|
||||||
|
if (val && *val) {
|
||||||
|
return SWIG_NewPointerObj(val, type_info<std::shared_ptr<Type> >(), owner);
|
||||||
|
} else {
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The descriptors in the shared_ptr typemaps remove the const qualifier for the SWIG type system.
|
The descriptors in the shared_ptr typemaps remove the const qualifier for the SWIG type system.
|
||||||
Remove const likewise here, otherwise SWIG_TypeQuery("std::shared_ptr<const Type>") will return NULL.
|
Remove const likewise here, otherwise SWIG_TypeQuery("std::shared_ptr<const Type>") will return NULL.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue