Boost logo

Boost :

Subject: Re: [boost] Reflection?
From: Jeremy Pack (rostovpack_at_[hidden])
Date: 2008-11-03 18:54:54


Jean-Louis,

What you want to do would require storing a great deal of extra information,
in addition to that stored by Boost.Reflection. Since one of my primary
emphases is performance, I doubt that my library is an ideal framework upon
which to build what you propose. I would imagine though that much of the
code could be very useful to you.

Have you looked at GCCXML? It could very well give you much of the
functionality that you desire (class names, function names and signatures,
types with data etc.)
I'm not sure if the version of Boost.Reflection in the Sandbox contains the
inheritance code. If not, I'll just need to make sure I have unit tests
together for it and then I'll submit it.

Given the normal speed of C++ evolution, I expect to wait quite a while
before being able to write multi-methods.

Jeremy

On Mon, Nov 3, 2008 at 3:17 PM, Jean-Louis Leroy <jl_at_[hidden]> wrote:

> Jeremy Pack wrote:
>
>> Jean-Louis,
>> Boost.Reflection handles multiple and virtual inheritance fine.
>>
>
> Does the version from
> http://boost-extension.blogspot.com/2008/07/latest-release-downloadable.htmlcontain support for inheritance already?
>
> My primary interest is not in reflection per se, for me it's just a tool
> upon which one can build generic object-processing tools like dumping
> objects to text descriptions or XML or implementing object-relational
> mapping.
>
> Once we have reflection, we need a way to deal with fields in a generic
> manner, whatever their type: int, vector<int>, vector< vector<int> > etc.
> One solution is to reflect the structure of the field's type as well: make
> the field class contain a pointer to a polymorphic type object, from which
> one derives int_type, a vector_type - which contains in turn a pointer to
> the element's type - etc. Pattern freaks will call it a composite ;-)
>
> The next step is multimethods. Once we have them we can write code like
> this:
>
> // using BS's proposed syntax in D&E
> void process_type(virtual type&, virtual processor&, void*);
>
> void process(instance i, processor& p)
> for each field (i)
> process_type(*field->type, p, field->address(i))
>
> class text_dumper : public processor { ... };
>
> void process_type(virtual int_type& t,
> virtual text_processor& p, char* pv) {
> p << *reinterpret_cast<int*>(pv);
> }
>
> void process_type(virtual vector_type& t,
> virtual text_processor& p, char* pv) {
> p.indent();
> char *iter = t.begin(pv), last = t.end(pv);
> while (iter != last) {
> process_type(t.element_type, p, iter);
> t.forward(iter);
> }
> p.outdent();
> }
>
> What do you think of the idea?
>
>
> Jean-Louis
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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