[Kde-bindings] KDE/kdebindings/ruby/qtruby
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Wed Dec 10 12:46:23 UTC 2008
SVN commit 895236 by rdale:
* Special case the Qt::Image.bits() method. Use the const variant so that
Qt doesn't make a deep copy. Is that what Davor Ocelic and David Palacio
would like it to do?
* For other uses of 'uchar *' return types add a marshaller, hoping that
will be null terminated.
CCMAIL: kde-bindings at kde.org
M +7 -0 ChangeLog
M +11 -1 src/marshall_basetypes.h
M +12 -1 src/qtruby.cpp
--- trunk/KDE/kdebindings/ruby/qtruby/ChangeLog #895235:895236
@@ -1,3 +1,10 @@
+2008-12-10 Richard Dale <richard.j.dale at gmail.com>
+ * Special case the Qt::Image.bits() method. Use the const variant so that
+ Qt doesn't make a deep copy. Is that what Davor Ocelic and David Palacio
+ would like it to do?
+ * For other uses of 'uchar *' return types add a marshaller, hoping that
+ will be null terminated.
+
2008-12-09 Richard Dale <richard.j.dale at gmail.com>
* Added an ancestors() method to Qt::Base that returns an Array of the
super classes of a class in the Smoke library. For instance:
--- trunk/KDE/kdebindings/ruby/qtruby/src/marshall_basetypes.h #895235:895236
@@ -200,7 +200,17 @@
template <>
void marshall_to_ruby<unsigned char *>(Marshall *m)
{
- m->unsupported();
+ char * sv = (char *)m->item().s_voidp;
+ VALUE obj;
+ if (sv != 0)
+ obj = rb_str_new2(sv);
+ else
+ obj = Qnil;
+
+ if (m->cleanup())
+ delete[] sv;
+
+ *(m->var()) = obj;
}
#endif
--- trunk/KDE/kdebindings/ruby/qtruby/src/qtruby.cpp #895235:895236
@@ -590,6 +590,15 @@
return rb_str_new(bytes->data(), bytes->size());
}
+static VALUE
+qimage_bits(VALUE self)
+{
+ smokeruby_object *o = value_obj_info(self);
+ QImage * image = (QImage *) o->ptr;
+ const uchar * bytes = image->bits();
+ return rb_str_new((const char *) bytes, image->numBytes());
+}
+
#ifdef QT_QTDBUS
static VALUE
qdbusargument_endarraywrite(VALUE self)
@@ -2053,7 +2062,7 @@
{
VALUE class_list = rb_ary_new();
- for(int i = 1; i <= qt_Smoke->numClasses; i++) {
+ for (int i = 1; i <= qt_Smoke->numClasses; i++) {
if (qt_Smoke->classes[i].className)
rb_ary_push(class_list, rb_str_new2(qt_Smoke->classes[i].className));
}
@@ -2180,6 +2189,8 @@
rb_define_method(klass, "const_data", (VALUE (*) (...)) qbytearray_data, 0);
} else if (packageName == "Qt::Char") {
rb_define_method(klass, "to_s", (VALUE (*) (...)) qchar_to_s, 0);
+ } else if (packageName == "Qt::Image") {
+ rb_define_method(klass, "bits", (VALUE (*) (...)) qimage_bits, 0);
} else if (packageName == "Qt::ItemSelection") {
rb_define_method(klass, "[]", (VALUE (*) (...)) qitemselection_at, 1);
rb_define_method(klass, "at", (VALUE (*) (...)) qitemselection_at, 1);
More information about the Kde-bindings
mailing list