Boost logo

Boost :

From: Enrico Sirola (enrico.sirola_at_[hidden])
Date: 2001-04-02 08:20:23


hi,
i'm trying to experiment a bit with boost::python library. I took a
look at the examples and now I'm starting to write some python
extensions for python using boost. My problem is as follows

I have the following piece of code i would like to export to python:

namespace A {
    enum B {B1, B2, B3};
    class C {
        public:
            C(int);
            int Cintmethod() const;
            B Cmethod() const;
    }
}

then i try to export it as follows:

namespace python = boost::python;

BOOST_PYTHON_MODULE(mymodule)
{
    try
    {
        using namespace A;
        python::module_builder this_module("mymodule");
        python::class_builder<C> expC_class(this_module, "expC");
        expC_class.def(python::constructor<int>());
        expC_class.def(&C::Cintmethod, "Cintmethod");
        expC_class.def(&C::Cmethod, "Cmethod");
    }
    catch (...)
    {
        python::handle_exception();
    }
}

I have problems while exporting the Cmethod function. The compiler
generates tons of errors (template programming... uhm...), but since i
succeed in exporting the Cintmethod function, it seems the problems
are related to the "B" enum. Does any1 know how to solve this?
I'm sorry for the very basic question, but this is my first experience
with python extension modules.
thanks in advance for your help,
bye for now,
enrico

-- 
Enrico Sirola <enri_at_[hidden]>
gpg public key available from wwwkeys.pgp.net
Key fingerprint = B446 7332 ED55 BC68 5FE8  DE0F 98DF EC86 377F E07F

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