[ruby] For swig::from, use template specialization to convert shared_ptr<const T> to shared_ptr<T>.
This commit is contained in:
parent
b8d383cb4a
commit
f96c2ad73d
5 changed files with 72 additions and 0 deletions
|
|
@ -7,6 +7,8 @@
|
|||
%fragment("StdTraits","header",fragment="StdTraitsCommon")
|
||||
{
|
||||
|
||||
%#define SWIG_RUBYSTDCOMMON
|
||||
|
||||
namespace swig {
|
||||
/*
|
||||
Traits that provides the from method
|
||||
|
|
|
|||
|
|
@ -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
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue