[Kde-bindings] unsigned char* marshalling patch

Bartosz Wadolowski bartosz.wadolowski at gmail.com
Thu Dec 4 03:14:20 UTC 2008


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

PS: it just me or qtruby and smoke needs a lot of comments and
probably some refactoring?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: u_char_ptr.diff
Type: text/x-patch
Size: 1877 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20081203/f7db7888/attachment.diff>


More information about the Kde-bindings mailing list