[Kde-bindings] unsigned char* marshalling patch

Richard Dale rdale at foton.es
Thu Dec 4 19:47:53 UTC 2008


On Thursday 04 December 2008 03:14:20 Bartosz Wadolowski wrote:
> unsigned char* marshalling in qtruby didn't work. patch fixing it is
> attached to this mail.
> It works as char* case does - I simply copied code and added one casting.
> It also fixes method matching with string argument in qtruby4.rb. In
> cases when method could take constant or regular (unsigned)char
> pointer Qt::Internal.checkarg was returning the same value. Now in
> case of constant arguments it returns lower value. I also made this
> part of code a little bit more readable.
> Those changes made possible to use those QImage constructors and
> probably some other methods:
> QImage ( uchar * data, int width, int height, Format format )
> QImage ( const uchar * data, int width, int height, Format format )
> QImage ( uchar * data, int width, int height, int bytesPerLine, Format
> format ) QImage ( const uchar * data, int width, int height, int
> bytesPerLine, Format format )
>
> IMPORTANT NOTE:
> Some Qt/KDE objects use Ruby String*, passed as (unsigned )char*
> method argument, as  internal buffer/array(call it as you like). In
> those cases programmer need to make sure that Ruby String object is
> not being garbage collected or changed(in most cases) for the time its
> being used by Qt/KDE object. It is also quite possible that Qt/KDE
> object will change Ruby String.
> *Or rather its internal C char array
We may have to review the parts for the Qt/KDE apis that use 'char *'/'uchar 
*'s and work out if this will cause problems.

I've commited the patch thanks! I removed the references to QCStrings as they 
were left over from Qt3 and aren't needed anymore.

> PS: it just me or qtruby and smoke needs a lot of comments and
> probably some refactoring?
I think Smoke needs some documentation, not necessarily comments in the code. 
We've started to do something on the KDE Tech Base wiki.

I think the main problem with the QtRuby code is the inconsistent 
layout/indentation and maybe I would like to remove  all tabs sometime. 

Another problem is that we split up the code into two libs (a private one and 
a shared one) some months ago and there are too many public items in the 
shared lib, and some of them need to move to the private library as they are 
only needed by QtRuby itself, and not by extensions based on QtRuby. But I 
would say that it is basically sound.

-- Richard



More information about the Kde-bindings mailing list