[Kde-bindings] KDE/kdebindings/qtruby
Caleb Tennis
caleb at gentoo.org
Thu Aug 25 16:04:28 UTC 2005
SVN commit 453241 by ctennis:
Change the metaObject creation to not use the d pointer directly in the code but
instead to create an struct on the stack, then copy it to the heap object (which
is fast since it's just four pointers).
CCMAIL: kde-bindings at kde.org
M +4 -0 ChangeLog
M +13 -28 rubylib/qtruby/Qt.cpp
--- trunk/KDE/kdebindings/qtruby/ChangeLog #453240:453241
@@ -1,3 +1,7 @@
+2005-08-25 Caleb Tennsi <caleb at aei-tech.com>
+ * Changed metaobject creation to not use d pointers per the comment in the
+ code.
+
2005-08-24 Richard Dale <Richard_Dale at tipitina.demon.co.uk>
* Added windowflags example
--- trunk/KDE/kdebindings/qtruby/rubylib/qtruby/Qt.cpp #453240:453241
@@ -1173,9 +1173,8 @@
}
// Should never happen..
- rb_raise( rb_eRuntimeError,
- "Cannot find %s::qt_metacall() method\n",
- o->smoke->classes[o->classId].className );
+ rb_raise(rb_eRuntimeError, "Cannot find %s::qt_metacall() method\n",
+ o->smoke->classes[o->classId].className );
}
if (_c != QMetaObject::InvokeMetaMethod) {
@@ -1500,37 +1499,26 @@
Smoke::StackItem i[1];
(*fn)(methodId.method, o->ptr, i);
- // C++ expert needed. Is it possible to allocate a QMetaObject
- // via 'new', without explicitely setting the d pointer? For
- // example, in moc generated code a QMetaObject is allocated
- // statically like this:
- //
- // const QMetaObject LCDRange::staticMetaObject = {
- // { &QWidget::staticMetaObject, qt_meta_stringdata_LCDRange,
- // qt_meta_data_LCDRange, 0 }
- // };
- //
- // Is there a C++ syntax for combining curly brackets with new
- // to create a new instance in a similar manner to the above,
- // without needing to refer to the d pointer to set the fields?
- //
- // But for now set the d pointer instead..
- QMetaObject * meta = new QMetaObject;
- meta->d.superdata = (QMetaObject *) i[0].s_voidp;
+ QMetaObject *superdata = (QMetaObject *) i[0].s_voidp;
+ char *stringdata = new char[RSTRING(stringdata_value)->len];
- meta->d.stringdata = new char[RSTRING(stringdata_value)->len];
- memcpy( (void *) meta->d.stringdata,
- RSTRING(stringdata_value)->ptr,
- RSTRING(stringdata_value)->len );
-
int count = RARRAY(data_value)->len;
uint * data = new uint[count];
+ memcpy( (void *) stringdata, RSTRING(stringdata_value)->ptr, RSTRING(stringdata_value)->len );
+
for (long i = 0; i < count; i++) {
VALUE rv = rb_ary_entry(data_value, i);
data[i] = NUM2UINT(rv);
}
+
+ QMetaObject ob = {
+ { superdata, stringdata, data, 0 }
+ } ;
+ QMetaObject * meta = new QMetaObject;
+ *meta = ob;
+
#ifdef DEBUG
printf("make_metaObject() superdata: %p\n", meta->d.superdata);
printf("stringdata: ");
@@ -1550,9 +1538,6 @@
printf("\n");
#endif
- meta->d.data = (const uint *) data;
- meta->d.extradata = 0;
-
smokeruby_object * m = (smokeruby_object *) malloc(sizeof(smokeruby_object));
m->smoke = qt_Smoke;
m->classId = qt_Smoke->idClass("QMetaObject");
More information about the Kde-bindings
mailing list