← Back to team overview

ffc team mailing list archive

Re: shared_ptr code

 

On Monday 24 November 2008 14:09:06 Anders Logg wrote:
> On Sun, Nov 23, 2008 at 06:36:46PM +0100, Johan Hake wrote:
> > Hello!
> >
> > When I tried the shared_ptr stuff in pydolfin i included some change for
> > the jit genereated swig modules in ffc.
> >
> > I think we landed on not including the shared_ptr stuff yet in pydolfin,
> > but I would like to "save" the code for any potential use when we some
> > time in the future want to include it.
> >
> > Is it ok to add the generation of shared_ptr code, only visible in the
> > swig interface file, to FFC and then add an option, option["shared_ptr"],
> > which will default to False?
> >
> > Johan
>
> Yes, why not. As long as it does not make the code generation code
> overly complex.

Ok, then I hand a boundle with this change. It consists of two commits. One 
makeing the base class Element inherit from object inste, i.e., letting it be 
a new style class. This is needed to overload the __new__ function, which is 
handy in PyDOLFIN. 

The second commit, includes the shared_ptr code generation. It is small and 
will only effect the swig interface code.

It will only work for swig version 1.3.34 or higher, and then only for 
boost::shared_ptr. In the svn version of swig and in the comming 1.3.37 will 
also std::tr1::shared_ptr be supported.

The key point is to %include boost_shared_ptr.i and define which classes shall 
be enabled. This has to be done both for base and derived classes.

Johan


References