From: William S F. <ws...@fu...> - 2009-03-30 17:33:17
|
Macumber, Daniel wrote: > Hello, I have been wrestling with SWIG trying to find the best way to wrap code that uses both Foo as well as boost::shared_ptr<Foo>. I have been able to kludge together a solution that "works" using the std.i support in SWIG and various snippets of shared_ptr examples I have found on the web. However the Ruby code ends up looking almost exactly like C++, which is not very attractive to me. I also assume there are some "best practices" to follow when wrapping shared_ptr, but I have not been able to figure these out. Secondly, I am confused about the built in support for wrapping shared_ptr. It appears that there is advanced support for shared_ptr in Python but not in Ruby. Is this true and if so what level of effort is required to add the same support to Ruby? I have posted some psuedo code below showing the type of C++ code I am trying to wrap and my (initial) thoughts on how I would want to use it in Ruby. Can anyone point me to any help on this? > Daniel, the default smart pointer handling in SWIG is a bit klunky and I improved it for shared_ptr with the more advanced support for Java, C# and Python a while back. In theory it can also support Ruby with some modifications in the runtime type system, but have not looked at what is required in detail. If this was ported for Ruby your use cases would work as intended and there would be no memory management issues. There is a bit of information in the CHANGES file about this more advanced shared_ptr support. William |