On Thu, Feb 10, 2011 at 08:48:55AM +0000, Garth N. Wells wrote: > > > On 10/02/11 07:38, Johan Hake wrote: > > On Wednesday February 9 2011 23:32:55 Anders Logg wrote: > >> On Wed, Feb 09, 2011 at 04:40:19PM -0800, Johan Hake wrote: > >>> Nice fix! > >>> > >>> I thought we needed to introduce shared_ptr versions of refinements call. > >>> But I realise this fix only work for SWIG 2.0. As all shared_ptr_foo are > >>> renamed to foo. > >>> > >>> We need to add an extra layer of %rename/%ignore for the SWIG 2.0 case. > >>> > >>> I can do this. But again it introduces another layer of complexity you > >>> mention in your other post. > >> > >> That didn't seem to work. The buildbot now says: > >> > >> File > >> "/home/fenicsslave/jhbuildbot/fenics/lib/python2.6/site-packages/dolfin/mes > >> h/refine.py", line 30, in refine > >> return mesh.child_shared_ptr() > >> TypeError: in method 'HierarchicalMesh_child_shared_ptr', argument 1 > >> of type 'dolfin::Hierarchical< dolfin::Mesh > *' > >> > >> What does that mean? mesh.child_shared_ptr() should return a > >> shared_ptr to an object of class T (in this case Mesh), which it does > >> in the C++ interface. It should not return a pointer to an object of > >> class Hierarchical<T>. > > > > It is related to the "fix" Garth introduced. He used foo_shared_ptr, but > > that > > one does not work for SWIG < 2.0. These methods are now ignored or renamed > > for > > all SWIG versions, and everything should be well and fine for both versions > > of > > SWIG. > > > > I don't think that this is really a fix. The Python refine should return > a shared_ptr, otherwise we can have problems with things going out of > scope. The underlying problem is SWIG not wrapping the Mesh shared_ptrs > properly.
But isn't that exactly what's happening now? The C++ shared_ptr_foo() functions are renamed to foo() so when you call foo() in Python you get the shared_ptr. I think we should do this everywhere: 1. foo returns reference foo_shared_ptr returns shared_ptr in C++ 2. foo ignored in Python 3. foo_shared_ptr renamed to foo in Python -- Anders > Gar > > > Good night! > > > > Johan > > > > _______________________________________________ > > Mailing list: https://launchpad.net/~dolfin > > Post to : [email protected] > > Unsubscribe : https://launchpad.net/~dolfin > > More help : https://help.launchpad.net/ListHelp > > _______________________________________________ > Mailing list: https://launchpad.net/~dolfin > Post to : [email protected] > Unsubscribe : https://launchpad.net/~dolfin > More help : https://help.launchpad.net/ListHelp _______________________________________________ Mailing list: https://launchpad.net/~dolfin Post to : [email protected] Unsubscribe : https://launchpad.net/~dolfin More help : https://help.launchpad.net/ListHelp

