Tom
23-08-2009 10:23:28
Hey, I was getting any responses on the mailing list, so I thought I'd try here 
I'm currently working on getting awesomium ported to python. I've
hit a barrier unfortunately. I'm not too experienced in wrapped C++
libraries to python, so bare with me. I'm using py++ and Boost.python.
I haven't really done much script wise with py++, as using the GUI
seems to be suffient enough.
Now on to my problem. Awesomium's webview render method takes in
an unsigned char* as such:
and here is how it is used in it's C++ demo:
here is my python code:
and this is the error I'm getting:
Now I realize I'll probably have to do something in boost.python to
have the types match up, but I'm not sure what to do. I've messed
around a bit with to_python_converter, but haven't had much luck
unfortunately. Here is the boost.python code:
Hopefully it's something fairly simple to solve. Like I mentioned I
don't have too much experience with using boost.python or py++, so
forgive me if it's something fairly obvious. We'll probably be
releasing the port once we have everything working, there are a few
other things I still have to sort out with the bindings, but it's
almost done.

I'm currently working on getting awesomium ported to python. I've
hit a barrier unfortunately. I'm not too experienced in wrapped C++
libraries to python, so bare with me. I'm using py++ and Boost.python.
I haven't really done much script wise with py++, as using the GUI
seems to be suffient enough.
Now on to my problem. Awesomium's webview render method takes in
an unsigned char* as such:
void Awesomium::WebView::render(unsigned char* destination, int
destRowSpan, int destDepth, Awesomium::Rect* renderedRect)
and here is how it is used in it's C++ demo:
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = webTexture->getBuffer
();
pixelBuffer->lock(0,width*height,Ogre::HardwareBuffer::HBL_DISCARD);
const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
size_t dstBpp = Ogre::PixelUtil::getNumElemBytes(pixelBox.format);
size_t dstPitch = pixelBox.rowPitch * dstBpp;
Ogre::uint8* dstData = static_cast<Ogre::uint8*>(pixelBox.data);
std::cout << dstData << std::endl;
view->render(dstData, (int)dstPitch, (int)dstBpp, 0);
pixelBuffer->unlock();
here is my python code:
pixelBuffer = self.webTexture.getBuffer()
pixellBuffer.lock(0,self.webTexture.getWidth()
*self.webTexture.getHeight(),ogre.HardwareBuffer.HBL_DISCARD)
pixelBox = pixelBuffer.getCurrentLock()
dstBpp = ogre.PixelUtil.getNumElemBytes(pixelBox.format)
dstPitch = pixelBox.rowPitch * dstBpp
dataType = ctypes.POINTER(ctypes.c_uint8)
data = dataType.from_address(pixelBox.data)
print data,type(data)
self.view.render(data,dstPitch,dstBpp)
pixelBuffer.unlock()
and this is the error I'm getting:
ArgumentError: Python argument types in
WebView.render(WebView, LP_c_ubyte, int, int)
did not match C++ signature:
render(class Awesomium::WebView {lvalue}, unsigned char *, int,
int)
Now I realize I'll probably have to do something in boost.python to
have the types match up, but I'm not sure what to do. I've messed
around a bit with to_python_converter, but haven't had much luck
unfortunately. Here is the boost.python code:
.def( "render"
,bp::make_function( (void (*)( ::Awesomium::WebView &,unsigned
char*,int,int ))(&WebView_wrapper::render),
bp::with_custodian_and_ward_postcall< 1, 2 >() ))
static void render( ::Awesomium::WebView& instance, unsigned char*
destination, int destRowSpan, int destDepth ){
instance.render( destination, destRowSpan, destDepth, 0 );
}
Hopefully it's something fairly simple to solve. Like I mentioned I
don't have too much experience with using boost.python or py++, so
forgive me if it's something fairly obvious. We'll probably be
releasing the port once we have everything working, there are a few
other things I still have to sort out with the bindings, but it's
almost done.