Merge branch 'tamuratak-fix_ruby_null_shared_ptr'

* tamuratak-fix_ruby_null_shared_ptr:
  [ruby] add a test.
  [ruby] use std::vector::back() method.
  [ruby] enable a test for null shared_ptr in containers.
  [ruby] add a test for null shared_ptr in containers.
  [ruby] treat null shared_ptr in std containers properly.

Conflicts:
	Examples/test-suite/ruby/Makefile.in
This commit is contained in:
William S Fulton 2017-04-24 19:50:59 +01:00
commit ee44f9ba67
5 changed files with 81 additions and 2 deletions

View file

@ -5,7 +5,8 @@ namespace swig {
template <class Type> struct traits_asval;
struct pointer_category;
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> swig_type_info* type_info();
template <class Type> const char* type_name();

View file

@ -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.
Remove const likewise here, otherwise SWIG_TypeQuery("std::shared_ptr<const Type>") will return NULL.