|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-03-01 18:18:11
I suggest exposing an appropriate getter function as "__getattr__a__" as
described at:
http://www.boost.org/libs/python/doc/special.html#getter_setter
----- Original Message -----
From: "ab_goldin" <agoldin_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, March 01, 2002 5:52 PM
Subject: [boost] boost::python and static members
> In a library I am trying to wrap exists a class the whole purpose of
> which is to enclose some global variables. Its fields are declared as
> static. I have no idea how to wrap them in boost::python. An obvious
> way fails:
>
>
> file://------------ test.cpp -----------------
>
>
>
>
> class test {
> public:
> static int a;
> int b;
> };
>
>
>
> #include <boost/python/class_builder.hpp>
>
>
> namespace python = boost::python;
>
>
>
>
> namespace {
> BOOST_PYTHON_MODULE_INIT(tst)
> {
> // create an object representing this extension module
> python::module_builder module("tst");
> python::class_builder<test> test_class(module, "test");
> test_class.def_readonly(&test::a, "a");
> test_class.def_readonly(&test::b, "b");
> }
> }
> file://--------------------
>
> Compilation:
>
> cd /home/goldin/camwa/supermix-python/
> make -k test
> g++ -I/home/goldin/python/src/boost_1_27_0 -I/usr/include/python2.1
> -Wall -I/home/goldin/python/src/boost_1_27_0 -c test.cpp
> test.cpp: In function `void {anonymous}::init_module_tst()':
> test.cpp:28: no matching function for call to
>
`boost::python::class_builder<test,boost::python::detail::held_instance<test
>
> >::def_readonly (int *, const char[2])'
>
> Compiler does not complain about non-static field.
>
>
> I am not using C++ that much, so I could miss something obvious. Could
> some kind soul please give me a hint what to do?
>
>
> I am running Debian testing (woody), i386
>
> gcc:
>
> gcc -v
> Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
> gcc version 2.95.4 (Debian prerelease)
>
> boost 1.27 freshly from boost website (not one packaged with debian).
>
>
> Info: http://www.boost.org Send unsubscribe requests 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