| Store | Cart

[C++-sig] Embedding Python - creating Python objects from C++

From: Sohail Somani <soh...@taggedtype.net>
Mon, 30 Nov 2009 14:09:48 -0500
On 29/11/09 7:50 PM, Sohail Somani wrote:
> // constructs a new instance of UserClass in Python using magic> // but uses shared_ptr to keep alive> shared_ptr<Base> base(/* magic here */);

This seemed to work:

// Boost Python/C++
class_<Base,shared_ptr<Base> >("Base")
  .def(...)
;

# Python
class UserClass(Base):
   ...

// Back in C++
object = module["UserClass"]
shared_ptr<Base> ptr = extract<shared_ptr<Base> >(object());

I'll find out soon enough if it works like I'm expecting ;-)

-- 
Sohail Somani
http://uint32t.blogspot.com

Recent Messages in this Thread
Sohail Somani Nov 30, 2009 12:50 am
Sohail Somani Nov 30, 2009 07:09 pm
Messages in this thread