[C++-sig] wrapping global variables

David Abrahams dave at boost-consulting.com
Mon Oct 21 01:01:28 CEST 2002


Dominique Devriese <dominique.devriese at student.kuleuven.ac.be> writes:

> Thanks !
> Actually, what i needed wasn't exactly that, but well, this:
> 
> "
> static Buffer curbuf;
> 
> BOOST_PYTHON_MODULE_INIT(ee)
> {
>   python::class_<Buffer>( "Buffer" )
>     .def( "length", &Buffer::length )
>     ;
>   python::scope().attr( "curbuf" ) = curbuf;
> }
> "
> 
> But it works great, sorry i didn't think of that myself...
> cheers

for this case you might want:

  scope().attr( "curbuf" ) = boost::ref(curbuf);

-Dave
-- 
                    David Abrahams
dave at boost-consulting.com * http://www.boost-consulting.com

Building C/C++ Extensions for Python: Dec 9-11, Austin, TX
http://www.enthought.com/training/building_extensions.html





More information about the Cplusplus-sig mailing list