On Nov 20, 2007 4:41 PM, William S Fulton <wsf@fultondesigns.co.uk> wrote:
Jason Roelofs wrote:
> Hey all
>
> I've been putting together a wrapper around Ogre 3d (www.ogre3d.org
> < http://www.ogre3d.org>) for Ruby using SWIG
> (http://ogrerb.rubyforge.org <http://ogrerb.rubyforge.org >) and have run
> into a brick wall. Ogre makes heavy use of nested classes and to
> continue effectively and efficiently I need something that properly
> reads and wraps these classes without hundreds of lines of manual
> wrapper code. So I've got a few options:
>
> 1. Build my own wrapper system, much like Boost::Python and Luabind and
> abandon SWIG entirely
> 2. Take on the task of adding this much-needed functionality to SWIG.
>
> Option 1 will take a very long time, will be a ton of work and a lot of
> reinventing the wheel.
>
> I've given a lot of thought to Option 2, and some research into what
> it's going to take to "complete" SWIG, as I see it. For one, I can start
> with the hack-patch that's been submitted and look into making it proper
> and production quality, or for two I can build another back-end parser
> using gcc-xml ( http://www.gccxml.org).
>
> Side note: I've recently found out about CABLE and CABLESwig
> (http://public.kitware.com/Cable/HTML/Index.html
> <http://public.kitware.com/Cable/HTML/Index.html>) and while I will give
> these a look to see if they'll help my situation, SWIG still itself
> needs this functionality.
>
> I know I'm not the first one, but the discussion has been sporadic
> enough that it's hard to know what people have suggested or if there's
> any work that's been done with this. So I guess before I really start on
> this, I'd like to hear what others have done, what you guys think of the
> best way of implementing this, etc.
>

Hi Jason

It certainly will "complete" the missing functionality in SWIG and there
are a number of users who are missing this feature quite badly.

I think adding nested classes to the parser is going to be one big job
in itself and using the cable gcc-xml parser might make this easier, but
then this isn't really SWIG and is not an actively maintained project as
far as I'm aware. The main obstacle for SWiG is fixing the parser. Once
you've got over the parsing issues, then the first step would probably
be to wrap all the nested classes as if they were global classes, in
much the same way that classes within different namespaces are wrapped
as if they are in one global namespace. That way all the language
modules will then be able to support nested classes. Users might have to
put in the odd %rename to avoid name clashes, but that isn't a big deal.
Otherwise you could mangle the names the way the C nested structs are
wrapped.

Once you've achieved that, then we can all help out more and the
different language maintainers can improve the nested class support by
mapping to something analogous in the target language.

There hasn't been any work on this other than that patch in SF. It is a
big project to take on and we wish you lots of luck. We'll try and help
as much as we can on this list. However, most of the parser expertise
lies with Dave Beazley and requires a good grasp of lex/yacc. Please
keep us up to date on progress (even if you decide not to add this support).

William

For the record, GCC-XML is in active development (see: http://www.gccxml.org/Bug/my_view_page.php ), they just haven't gotten around to make an official release in some time.

I'll definitely keep you guys up to date with what I do with my project. Thanks for the support.

Jason