[pygccxml-development] Exposing boost::python::list
Brought to you by:
mbaas,
roman_yakovenko
|
From: Scott S. <sc...@bi...> - 2011-08-01 20:15:15
|
Hi,
I'd like to have a class which as a boost::python::list as a public
attribute. I know that gccxml cannot parse boost/python.hpp, so given a
suggestion on the mailing list archives, I have done the following:
#pragma once
#ifndef __GCCXML__
#include <boost/python.hpp>
typedef boost::python::list list;
#else
class list;
#endif
class MyClass {
public:
list * mylist;
};
MyClass::MyClass()
{
mylist = new boost::python::list();
mylist.append(1);
}
MyClass::~MyClass()
{
delete mylist;
}
Py++ is able to create the bindings and it compiles fine. However, when
accessing the 'mylist' attribute in python, I'm seeing the following
behavior:
>>> print type(myclass.mylist)
>>> print type(myclass.mylist)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot create weak reference to 'list' object
>>> print type(myclass.mylist)
Fatal Python error: GC object already tracked
Aborted
I think I'm going about this the wrong way, but am unsure of the proper
way. Would this be a use case for the 'inserting_code' functionality of
py++?
Thank you!
Scott
|