Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-11-22 11:10:19


Remy Blank <remy.blank_REMOVE_THIS_at_[hidden]> writes:

>> > But there has to be a better way, hasn't it?
>>
>> Yes**. The mechanism in Boost.Python allows you to register just the
>> relationships between adjacent base and derived classes, and it fills
>> in the rest of the graph. Maybe it's time to refactor this code for
>> general use in Boost...
>
> This sounds good. I'm trying to develop an introspection framework for
> C++ classes (and later dynamically created classes), so I will already
> have the inheritance information. I expect your implementation makes
> heavy use of typeid() and dynamic_cast<>?

Yes.

> Other conversions would have to be registered explicitly (char -> int,
> char const* -> std::string, ...), possibly half-automated by using
> typelists and mpl algorithms.

That's a whole different beast, since it involves creating a new
object.

> It's too bad that we have to replicate at runtime what the compiler
> already knows how to do at compile time (namely navigating inheritance
> hierarchies)...
>
> I have looked at Boost.Python, and it is very similar to what I had in
> mind. Would it be possible to make Boost.Python more general to describe
> C++ class information for runtime use, and have Boost.Python be a
> subset?

?? There's no way that Boost.Python could be a subset of the facility
we're talking about. It does way, way more than casting around an
inheritance hierarchy. IOW, it's already way more general.

> I don't have a lot of time on my hands, but if you think this would
> be a good idea, I would love to give it a try (except that I'm a
> little scared by Boost.Python's complexity, and I don't know Python
> (yet)).

I don't understand. The stuff in inheritance.cpp doesn't touch Python
at all. It's pure C++.

> BTW, how does Boost.Python compare to SWIG (http://www.swig.org/) ?
> It seems to supports Python, amongst others.

There's an outdated comparisons page at
http://www.boost.org/libs/python/doc/comparisons.html. SWIG and
Boost.Python are both much better now than when that was written.

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk