<!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&nbsp;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>&nbsp;&nbsp;&nbsp; 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&lt;A&gt;<BR>{<BR>&nbsp;&nbsp;&nbsp; 
void handleMessage(void *message)<BR>&nbsp;&nbsp;&nbsp; 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
this-&gt;get_override("handleMessage")(message);<BR>&nbsp;&nbsp;&nbsp; 
}<BR>};<BR><BR>class_&lt;AWrapper, 
boost::noncopyable&gt;("A")<BR>&nbsp;&nbsp;&nbsp; .def("handleMessage", 
pure_virtual(&amp;A::handleMessage))<BR>;<BR><BR><BR>My python test code looks 
like this:<BR><BR>import APackage<BR><BR>class aclass(APackage.A):<BR>&nbsp;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.&nbsp; Is there some way around <BR>this?&nbsp; 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>&nbsp;&nbsp;&nbsp; void handleMessage(void 
*message)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
int size = 
getMessageSize(message);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
PyObject *obj = PyBuffer_FromReadWriteMemory(message, 
size);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
this-&gt;get_override("handleMessage")(obj);<BR>&nbsp;&nbsp;&nbsp; }<BR><BR>Has 
anyone done this type of thing?&nbsp; 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>