Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-05-09 11:23:55


"Arora, Vivek" <varora_at_[hidden]> writes:

> In addition to exposing C++ classes to Python is Boost a good option
> for use as a reflection library? i.e. is it possible to enumerate and
> invoke methods and access fields reflected by the Boost Macros(or Pyste)
> directly within C++. Offcourse one obvious way is to invoke methods
> indirectly via the Python interpreter but this will be quite inefficient.

I don't think Boost.Python is a particularly good tool for that unless
you need Python bindings anyway... and even then, some information
about argument lists, overloads, etc., would be lost. I *have* been
thinking for some time that a Pyste-like system could be used to
generate MPL-compatible class descriptions that could be explored at
compile-time or at runtime.

For example, given:

    class X
    {
       int f(double);
       char* x;
       static int y;
    };

You might generate, as a starting point:

    template <class T, T v, char const*> struct member {};
    template <class T> struct members;

    template <>
    struct members<X>
      : mpl::vector<
            member<int(X::*)(double), &X::f, "f">
          , member<char*(X::*), &X::x, "x">
          , member<int&, X::y, "y">
>
    {
    };

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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