Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-04-02 09:54:07


Please read the section of the boost::python documentation on enums at
http://www.boost.org/libs/python/doc/enums.html
If you still have problems, post again.

Regards,
Dave
----- Original Message -----
From: "Enrico Sirola" <enrico.sirola_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, April 02, 2001 9:20 AM
Subject: [boost] boost-python, help needed

> 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
>
>
> To unsubscribe, send email to: <mailto:boost-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


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