[ruby] For swig::from, use template specialization to convert shared_ptr<const T> to shared_ptr<T>.

This commit is contained in:
Takashi Tamura 2017-03-03 12:50:23 +09:00
commit f96c2ad73d
5 changed files with 72 additions and 0 deletions

View file

@ -7,6 +7,8 @@
%fragment("StdTraits","header",fragment="StdTraitsCommon")
{
%#define SWIG_RUBYSTDCOMMON
namespace swig {
/*
Traits that provides the from method

View file

@ -1,2 +1,17 @@
#define SWIG_SHARED_PTR_NAMESPACE std
%include <boost_shared_ptr.i>
%wrapper %{
#ifdef SWIG_RUBYSTDCOMMON
namespace swig {
template<class Type>
struct traits_from<std::shared_ptr<const Type> > {
static VALUE from(const std::shared_ptr<const Type>& val) {
std::shared_ptr<Type> p = std::const_pointer_cast<Type>(val);
return swig::from(p);
}
};
};
#endif
%}