[Kde-bindings] KDE/kdebindings/ruby/qtruby
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Fri Oct 19 10:26:36 UTC 2007
SVN commit 726967 by rdale:
* Ruby signal declared in superclasses were not being inherited by
subclasses correctly. Fixed bug reported by cheiron on the #qtruby
irc channel - thanks for the report and test program.
CCMAIL: kde-bindings at kde.org
M +6 -0 ChangeLog
M +41 -34 src/Qt.cpp
M +0 -9 src/lib/Qt/qtruby4.rb
--- trunk/KDE/kdebindings/ruby/qtruby/ChangeLog #726966:726967
@@ -1,3 +1,9 @@
+2007-10-19 Richard Dale <rdale at foton.es>
+
+ * Ruby signal declared in superclasses were not being inherited by
+ subclasses correctly. Fixed bug reported by cheiron on the #qtruby
+ irc channel - thanks for the report and test program.
+
2007-10-14 Richard Dale <rdale at foton.es>
* The QScintilla class names now all start with Qsci instead of Qext,
--- trunk/KDE/kdebindings/ruby/qtruby/src/Qt.cpp #726966:726967
@@ -434,7 +434,7 @@
void ** o = new void*[_items];
smokeStackToQtStack(_stack, o + 1, _items - 1, _args + 1);
_obj->metaObject()->activate(_obj, _id, o);
-
+
if (_args[0].argType != xmoc_void) {
SignalReturnValue r(o, _result, _args);
}
@@ -2105,49 +2105,56 @@
//----------------- Sig/Slot ------------------
-VALUE
-getmetainfo(VALUE self, int &offset, int &index)
+static VALUE
+qt_signal(int argc, VALUE * argv, VALUE self)
{
- char * signalname = rb_id2name(rb_frame_last_func());
- VALUE metaObject_value = rb_funcall(qt_internal_module, rb_intern("getMetaObject"), 2, Qnil, self);
+ smokeruby_object *o = value_obj_info(self);
+ QObject *qobj = (QObject*)o->smoke->cast(o->ptr, o->classId, o->smoke->idClass("QObject"));
+ if (qobj->signalsBlocked()) {
+ return Qfalse;
+ }
- smokeruby_object *ometa = value_obj_info(metaObject_value);
- if(!ometa) return 0;
- QMetaObject *metaobject = (QMetaObject*)ometa->ptr;
+ QLatin1String signalname(rb_id2name(rb_frame_last_func()));
+ VALUE metaObject_value = rb_funcall(qt_internal_module, rb_intern("getMetaObject"), 2, Qnil, self);
- offset = metaobject->methodOffset();
+ smokeruby_object *ometa = value_obj_info(metaObject_value);
+ if (ometa == 0) {
+ return Qnil;
+ }
- VALUE signalInfo = rb_funcall(qt_internal_module, rb_intern("signalInfo"), 2, self, rb_str_new2(signalname));
- VALUE reply_type = rb_ary_entry(signalInfo, 0);
- VALUE member = rb_ary_entry(signalInfo, 1);
- index = NUM2INT(rb_ary_entry(signalInfo, 2));
- return rb_funcall(qt_internal_module, rb_intern("getMocArguments"), 2, reply_type, member);
-}
+ int i = -1;
+ const QMetaObject * m = (QMetaObject*) ometa->ptr;
+ for (i = m->methodCount() - 1; i > -1; i--) {
+ if (m->method(i).methodType() == QMetaMethod::Signal) {
+ QString name(m->method(i).signature());
+static QRegExp * rx = 0;
+ if (rx == 0) {
+ rx = new QRegExp("\\(.*");
+ }
+ name.replace(*rx, "");
-static VALUE
-qt_signal(int argc, VALUE * argv, VALUE self)
-{
- smokeruby_object *o = value_obj_info(self);
- QObject *qobj = (QObject*)o->smoke->cast(
- o->ptr,
- o->classId,
- o->smoke->idClass("QObject")
- );
- if(qobj->signalsBlocked()) return Qfalse;
+ if (name == signalname) {
+ break;
+ }
+ }
+ }
- int offset;
- int index;
+ if (i == -1) {
+ return Qnil;
+ }
- VALUE args = getmetainfo(self, offset, index);
+ VALUE args = rb_funcall( qt_internal_module,
+ rb_intern("getMocArguments"),
+ 2,
+ rb_str_new2(m->method(i).typeName()),
+ rb_str_new2(m->method(i).signature()) );
- if(args == Qnil) return Qfalse;
-
VALUE result = Qnil;
- // Okay, we have the signal info. *whew*
- EmitSignal signal(qobj, offset + index, argc, args, argv, &result);
- signal.next();
+ // Okay, we have the signal info. *whew*
+ EmitSignal signal(qobj, i, argc, args, argv, &result);
+ signal.next();
- return result;
+ return result;
}
static VALUE
--- trunk/KDE/kdebindings/ruby/qtruby/src/lib/Qt/qtruby4.rb #726966:726967
@@ -2377,15 +2377,6 @@
end
end
- def Internal.signalInfo(qobject, signal_name)
- signals = Meta[qobject.class.name].get_signals
- signals.each_with_index do |signal, i|
- if signal.name == signal_name
- return [signal.reply_type, signal.full_name, i]
- end
- end
- end
-
def Internal.getMocArguments(reply_type, member)
argStr = member.sub(/.*\(/, '').sub(/\)$/, '')
args = argStr.scan(/([^,]*<[^>]+>)|([^,]+)/)
More information about the Kde-bindings
mailing list