diff --git a/Lib/ruby/rubystdcommon_forward.swg b/Lib/ruby/rubystdcommon_forward.swg index 27bcb9960..4120b38e4 100644 --- a/Lib/ruby/rubystdcommon_forward.swg +++ b/Lib/ruby/rubystdcommon_forward.swg @@ -5,7 +5,8 @@ namespace swig { template struct traits_asval; struct pointer_category; template struct traits_as; - template struct traits_from; + template struct traits_from; + template struct traits_from_ptr; template struct noconst_traits; template swig_type_info* type_info(); template const char* type_name(); diff --git a/Lib/ruby/std_shared_ptr.i b/Lib/ruby/std_shared_ptr.i index f6c0a15ac..f2b05ef36 100644 --- a/Lib/ruby/std_shared_ptr.i +++ b/Lib/ruby/std_shared_ptr.i @@ -113,6 +113,17 @@ namespace swig { } }; + template + struct traits_from_ptr > { + static VALUE from(std::shared_ptr *val, int owner = 0) { + if (val && *val) { + return SWIG_NewPointerObj(val, type_info >(), 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") will return NULL.