<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16608" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I'm new to Python and Boost.python
and as</FONT><FONT face=Arial size=2><FONT face="Times New Roman" size=3>
the subject implies, I'm having trouble wrapping a C++ class that looks <BR>like
this:<BR><BR>struct A<BR>{<BR> virtual void handleMessage(void
*message)=0;<BR>};<BR><BR><BR>To wrap this class, I've written the following
code:<BR><BR>struct AWrapper : A, wrapper<A><BR>{<BR>
void handleMessage(void *message)<BR>
{<BR>
this->get_override("handleMessage")(message);<BR>
}<BR>};<BR><BR>class_<AWrapper,
boost::noncopyable>("A")<BR> .def("handleMessage",
pure_virtual(&A::handleMessage))<BR>;<BR><BR><BR>My python test code looks
like this:<BR><BR>import APackage<BR><BR>class aclass(APackage.A):<BR> def
handleMessage(msg) : print msg<BR><BR><BR>But this code crashes when the
handleMessage function is called in python (I <BR>think) because 'void *' cannot
be marshalled. Is there some way around <BR>this? Also, since the
void* object is intended to be "zero copy", I should <BR>probably convert the
void * to a PyObject first and re-write my <BR>handleMessage to look like
this:<BR><BR> void handleMessage(void
*message)<BR> {<BR>
int size =
getMessageSize(message);<BR><BR>
PyObject *obj = PyBuffer_FromReadWriteMemory(message,
size);<BR><BR>
this->get_override("handleMessage")(obj);<BR> }<BR><BR>Has
anyone done this type of thing? I'm writing this code using MS Visual
<BR>Studio 8 and if anyone can help, it would *very*
appreciated.<BR><BR>Thanks!<BR>James</FONT><BR><BR><BR><BR></DIV></FONT></BODY></HTML>