dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #01431
Re: [FFC-dev] Solution for nested classes for SWIG
Great. I shouldn't be a problem to generate the nested classes outside
of the top level class definition.
I'll put it on the TODO list for FFC.
/Anders
On Wed, Nov 02, 2005 at 11:34:48AM +0100, Johan Jansson wrote:
> Hi!
>
> I think I've found a solution for helping SWIG parse nested
> classes. The only thing that's necessary seems to be to move the class
> definition out to the top level:
>
> class MyClass
> {
> public:
> MyClass(double d);
>
> double foo();
> double d;
>
> class Internal;
> };
>
> class MyClass::Internal
> {
> public:
> Internal(double e);
>
> double bar();
> double e;
> };
>
> Now the SWIG parser doesn't seem to have any problems parsing the
> nested class. Then the naming issues can be taken care of by the
> rename directive:
>
> %rename(MyClassInternal) MyClass::Internal;
>
> Here's a thread discussing it:
>
> http://mailman.cs.uchicago.edu/pipermail/swig/2004-April/009591.html
>
> This is a bit worrying though:
>
> "it should be possible simply to hoist the nested class out of the
> containing class and pretend as if they were defined consecutively.
> This was dismissed as a hack (although I don't understand why) and
> that a better scheme was in the works."
>
> But just like the poster, I can't see why that would be a hack.
>
> I'll do some more testing and see what I can find out.
>
> Johan
>
> _______________________________________________
> FFC-dev mailing list
> FFC-dev@xxxxxxxxxx
> http://www.fenics.org/cgi-bin/mailman/listinfo/ffc-dev
>
--
Anders Logg
Research Assistant Professor
Toyota Technological Institute at Chicago
http://www.tti-c.org/logg/
References