Gr_shared_ptr.i vs boost_shared_ptr.i

Hi all,

I’ve been trying every now again to create classes in gnuradio that
are not signal processing blocks but are wrapped up in the same way
used boost::shared_ptr and SWIG. I haven’t been able to replicate how
it’s done for the signal processing blocks.

I have been able to get the same thing working outside of gnuradio
using the boost_shared_ptr.i SWIG library. Unfortunately I can’t use
that within gnuradio because the namespace clashes with
gr_shared_ptr.i. My guess is that things are done the way they are in
gnuradio because when they were written the boost_shared_ptr.i library
wasn’t available. Does anyone know of any reasons not to use
boost_shared_ptr.i instead of gr_shared_ptr.i within gnuradio? I
think it should make things simpler.

Cheers,
Ben

The features I’d like to use from the library are the macros
SWIG_SHARED_PTR and SWIG_SHARED_PTR_DERIVED.

I’m using swig-1.3.40 (standard for ubuntu 10.04). The macros were
added in swig-1.3.34 (Feb 2008). In the current version (swig-2.02)
they still work but are deprecated and replaced by %shared_ptr.

On Mon, Mar 21, 2011 at 4:23 PM, Ben R. [email protected] wrote:

The features I’d like to use from the library are the macros
SWIG_SHARED_PTR and SWIG_SHARED_PTR_DERIVED.

I’m using swig-1.3.40 (standard for ubuntu 10.04). The macros were
added in swig-1.3.34 (Feb 2008). In the current version (swig-2.02)
they still work but are deprecated and replaced by %shared_ptr.

If they are available in SWIG 1.3.34, then we should be fine supporting
it.
I still have to make sure there isn’t something else in the way Eric
implemented it. I’m guessing you are right, though, and that when Eric
started using SWIG this way, they did not natively support shared
pointers.
Hopefully, we can just move over to using the SWIG version without a
problem
and then you can have access to what you need.

Don’t worry about the deprecation in version 2 of SWIG; I doubt we’ll be
moving there any time soon for compatibility reasons.

Tom

I’ve decided using boost_shared_ptr.i with gnuradio is too hard. It
would require way too many changes and is not worth it.

On a related note, I’ve finally worked out how the implicit type
conversion that’s going on with the SWIGed gr_basic_block hierarchy is
happening. It isn’t happening, rather it is being done explicitly at
the python level (i.e. in hier_block2.py).

Ben