From: "Gonzalo Garramuño" Date: 2007-12-27T17:14:12+09:00 Subject: Re: C++ Functors and Ruby extensions Gonzalo Garramu�o wrote: > Jason Roelofs wrote: >> >> >> SWIG does not handle nested classes, a *serious* defect to what I'm >> trying to do. > > Which is partially not true. SWIG supports nested classes just fine but > you need to provide more glue code to expose the class as the swig > *parser* will not automatically parse them for you. The amount of code > you need to write is probably less than the equivalent of boost python. > > Here's a simple dummy example. Actually, just looking at the swig internals, the typedef is unneeded and the code can be simplified to just: %module nested // this is what's in your .h file %inline { class A { public: A() {} ~A() {} class B { public: B() {} ~B() {} }; }; } // We rename the nested class to something valid %rename("A__B") A::B; // the glue code--- we copy the B definition here and call it A::B class A::B { public: B() {} ~B() {} }; %init { // we define a constant inside A so we can invoke A::B.new() rb_define_const(cA.klass, "B", cA__B.klass ); } -- Gonzalo Garramu�o ggarra@advancedsl.com.ar AMD4400 - ASUS48N-E GeForce7300GT Xubuntu Gutsy