[Kde-bindings] KDE/kdebindings/ruby/qtruby
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Thu Dec 11 16:31:21 UTC 2008
SVN commit 895746 by rdale:
* Make some changes from the patch at
http://napalm.sf.cz/qt4-qtruby-ruby1.9.patch to make it easier to
port qtruby to Ruby 1.9. Thanks to Davor Ocelic and Mr Napalm.
CCMAIL: kde-bindings at kde.org
M +5 -0 ChangeLog
M +2 -1 src/Qt.cpp
M +4 -4 src/handlers.cpp
M +18 -18 src/qtruby.cpp
M +1 -1 src/qtruby.h
--- trunk/KDE/kdebindings/ruby/qtruby/ChangeLog #895745:895746
@@ -1,3 +1,8 @@
+2008-12-11 Richard Dale <richard.j.dale at gmail.com>
+ * Make some changes from the patch at
+ http://napalm.sf.cz/qt4-qtruby-ruby1.9.patch to make it easier to port
+ qtruby to Ruby 1.9. Thanks to Davor Ocelic and Mr Napalm.
+
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
--- trunk/KDE/kdebindings/ruby/qtruby/src/Qt.cpp #895745:895746
@@ -443,7 +443,7 @@
}
-void rb_str_catf(VALUE self, const char *format, ...)
+VALUE rb_str_catf(VALUE self, const char *format, ...)
{
#define CAT_BUFFER_SIZE 2048
static char p[CAT_BUFFER_SIZE];
@@ -453,6 +453,7 @@
p[CAT_BUFFER_SIZE - 1] = '\0';
rb_str_cat2(self, p);
va_end(ap);
+ return self;
}
const char *
--- trunk/KDE/kdebindings/ruby/qtruby/src/handlers.cpp #895745:895746
@@ -896,7 +896,7 @@
}
if (qstrcmp(KCODE, "UTF8") == 0)
- return new QString(QString::fromUtf8(StringValuePtr(rstring), RSTRING(rstring)->len));
+ return new QString(QString::fromUtf8(StringValuePtr(rstring), RSTRING_LEN(rstring)));
else if (qstrcmp(KCODE, "EUC") == 0)
return new QString(codec->toUnicode(StringValuePtr(rstring)));
else if (qstrcmp(KCODE, "SJIS") == 0)
@@ -904,12 +904,12 @@
else if(qstrcmp(KCODE, "NONE") == 0)
return new QString(QString::fromLatin1(StringValuePtr(rstring)));
- return new QString(QString::fromLocal8Bit(StringValuePtr(rstring), RSTRING(rstring)->len));
+ return new QString(QString::fromLocal8Bit(StringValuePtr(rstring), RSTRING_LEN(rstring)));
}
QByteArray*
qbytearrayFromRString(VALUE rstring) {
- return new QByteArray(StringValuePtr(rstring), RSTRING(rstring)->len);
+ return new QByteArray(StringValuePtr(rstring), RSTRING_LEN(rstring));
}
VALUE
@@ -1234,7 +1234,7 @@
stringlist->append(QByteArray());
continue;
}
- stringlist->append(QByteArray(StringValuePtr(item), RSTRING(item)->len));
+ stringlist->append(QByteArray(StringValuePtr(item), RSTRING_LEN(item)));
}
m->item().s_voidp = stringlist;
--- trunk/KDE/kdebindings/ruby/qtruby/src/qtruby.cpp #895745:895746
@@ -253,7 +253,7 @@
// Start with #<Qt::HBoxLayout:0x30139030> from the original inspect() call
// Drop the closing '>'
VALUE inspect_str = rb_call_super(0, 0);
- rb_str_resize(inspect_str, RSTRING(inspect_str)->len - 1);
+ rb_str_resize(inspect_str, RSTRING_LEN(inspect_str) - 1);
smokeruby_object * o = 0;
Data_Get_Struct(self, smokeruby_object, o);
@@ -296,7 +296,7 @@
// Start with #<Qt::HBoxLayout:0x30139030>
// Drop the closing '>'
VALUE inspect_str = rb_funcall(self, rb_intern("to_s"), 0, 0);
- rb_str_resize(inspect_str, RSTRING(inspect_str)->len - 1);
+ rb_str_resize(inspect_str, RSTRING_LEN(inspect_str) - 1);
rb_funcall(pp, rb_intern("text"), 1, inspect_str);
rb_funcall(pp, rb_intern("breakable"), 0);
@@ -311,7 +311,7 @@
VALUE obj = getPointerObject(qobject->parent());
if (obj != Qnil) {
VALUE parent_inspect_str = rb_funcall(obj, rb_intern("to_s"), 0, 0);
- rb_str_resize(parent_inspect_str, RSTRING(parent_inspect_str)->len - 1);
+ rb_str_resize(parent_inspect_str, RSTRING_LEN(parent_inspect_str) - 1);
parentInspectString = StringValuePtr(parent_inspect_str);
} else {
parentInspectString.sprintf("#<%s:0x0", qobject->parent()->metaObject()->className());
@@ -374,14 +374,14 @@
static VALUE
q_register_resource_data(VALUE /*self*/, VALUE version, VALUE tree_value, VALUE name_value, VALUE data_value)
{
- const unsigned char * tree = (const unsigned char *) malloc(RSTRING(tree_value)->len);
- memcpy((void *) tree, (const void *) RSTRING(tree_value)->ptr, RSTRING(tree_value)->len);
+ const unsigned char * tree = (const unsigned char *) malloc(RSTRING_LEN(tree_value));
+ memcpy((void *) tree, (const void *) RSTRING(tree_value)->ptr, RSTRING_LEN(tree_value));
- const unsigned char * name = (const unsigned char *) malloc(RSTRING(name_value)->len);
- memcpy((void *) name, (const void *) RSTRING(name_value)->ptr, RSTRING(name_value)->len);
+ const unsigned char * name = (const unsigned char *) malloc(RSTRING_LEN(name_value));
+ memcpy((void *) name, (const void *) RSTRING(name_value)->ptr, RSTRING_LEN(name_value));
- const unsigned char * data = (const unsigned char *) malloc(RSTRING(data_value)->len);
- memcpy((void *) data, (const void *) RSTRING(data_value)->ptr, RSTRING(data_value)->len);
+ const unsigned char * data = (const unsigned char *) malloc(RSTRING_LEN(data_value));
+ memcpy((void *) data, (const void *) RSTRING(data_value)->ptr, RSTRING_LEN(data_value));
return qRegisterResourceData(NUM2INT(version), tree, name, data) ? Qtrue : Qfalse;
}
@@ -389,14 +389,14 @@
static VALUE
q_unregister_resource_data(VALUE /*self*/, VALUE version, VALUE tree_value, VALUE name_value, VALUE data_value)
{
- const unsigned char * tree = (const unsigned char *) malloc(RSTRING(tree_value)->len);
- memcpy((void *) tree, (const void *) RSTRING(tree_value)->ptr, RSTRING(tree_value)->len);
+ const unsigned char * tree = (const unsigned char *) malloc(RSTRING_LEN(tree_value));
+ memcpy((void *) tree, (const void *) RSTRING(tree_value)->ptr, RSTRING_LEN(tree_value));
- const unsigned char * name = (const unsigned char *) malloc(RSTRING(name_value)->len);
- memcpy((void *) name, (const void *) RSTRING(name_value)->ptr, RSTRING(name_value)->len);
+ const unsigned char * name = (const unsigned char *) malloc(RSTRING_LEN(name_value));
+ memcpy((void *) name, (const void *) RSTRING(name_value)->ptr, RSTRING_LEN(name_value));
- const unsigned char * data = (const unsigned char *) malloc(RSTRING(data_value)->len);
- memcpy((void *) data, (const void *) RSTRING(data_value)->ptr, RSTRING(data_value)->len);
+ const unsigned char * data = (const unsigned char *) malloc(RSTRING_LEN(data_value));
+ memcpy((void *) data, (const void *) RSTRING(data_value)->ptr, RSTRING_LEN(data_value));
return qUnregisterResourceData(NUM2INT(version), tree, name, data) ? Qtrue : Qfalse;
}
@@ -1813,12 +1813,12 @@
superdata = (QMetaObject *) p->ptr;
}
- char *stringdata = new char[RSTRING(stringdata_value)->len];
+ char *stringdata = new char[RSTRING_LEN(stringdata_value)];
int count = RARRAY(data_value)->len;
uint * data = new uint[count];
- memcpy( (void *) stringdata, RSTRING(stringdata_value)->ptr, RSTRING(stringdata_value)->len );
+ memcpy( (void *) stringdata, RSTRING(stringdata_value)->ptr, RSTRING_LEN(stringdata_value) );
for (long i = 0; i < count; i++) {
VALUE rv = rb_ary_entry(data_value, i);
@@ -1890,7 +1890,7 @@
printf("\nqt_meta_stringdata:\n \"");
int strlength = 0;
- for (int j = 0; j < RSTRING(stringdata_value)->len; j++) {
+ for (int j = 0; j < RSTRING_LEN(stringdata_value); j++) {
strlength++;
if (meta->d.stringdata[j] == 0) {
printf("\\0");
--- trunk/KDE/kdebindings/ruby/qtruby/src/qtruby.h #895745:895746
@@ -135,7 +135,7 @@
extern Q_DECL_EXPORT void unmapPointer(smokeruby_object *, Smoke::Index, void*);
extern Q_DECL_EXPORT const char * resolve_classname(smokeruby_object * o);
-extern Q_DECL_EXPORT void rb_str_catf(VALUE self, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
+extern Q_DECL_EXPORT VALUE rb_str_catf(VALUE self, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
extern Q_DECL_EXPORT VALUE findMethod(VALUE self, VALUE c_value, VALUE name_value);
extern Q_DECL_EXPORT VALUE findAllMethods(int argc, VALUE * argv, VALUE self);
More information about the Kde-bindings
mailing list