20 Aug 04:40
Boost-users] [python]How to pass C++ object reference to python code?
From: Neil Fang <neilfang2009 <at> gmail.com>
Subject: Boost-users] [python]How to pass C++ object reference to python code?
Newsgroups: gmane.comp.lib.boost.user
Date: 2008-08-20 02:43:41 GMT
Subject: Boost-users] [python]How to pass C++ object reference to python code?
Newsgroups: gmane.comp.lib.boost.user
Date: 2008-08-20 02:43:41 GMT
I'm trying embedding python using boost::python. Just as the same way
as the boost::python quick start "embedding.cpp".
I have a C++ base class, with a virtual function do something on
another C++ object:
struct MyClass
{
void printThis()
{
std::cout << "0x" << this << std::endl;
}
};
// An abstract base class
class Base : public boost::noncopyable
{
public:
virtual ~Base() {};
virtual void printMyClass(MyClass& myObj) = 0;
};
Than, I want to write some Python derived class code:
"from embedded_hello import * \n"
"class PythonDerived(Base): \n"
" def printMyClass(self, myObj): \n"
" myObj.printThis() \n"
But I found that the "myObj" passed to python code is another obj, not
the object created in C++ code. How can use the object created in C++
object rather than a copyed object? Thanks!
(Continue reading)
RSS Feed