[Kde-bindings] branches/KDE/3.5/kdebindings/qtruby

Richard Dale Richard_Dale at tipitina.demon.co.uk
Fri Dec 16 13:55:40 UTC 2005


SVN commit 488928 by rdale:

2005-12-16  Richard Dale  <Richard_Dale at tipitina.demon.co.uk>

	* Improved the code to call a C++ slot via qt_invoke() when a ruby slot hasn't 
	  been defined. It now invokes the method in the Smoke lib directly, rather
	  than going via method_missing().

CCMAIL: kde-bindings at kde.org



 M  +6 -0      ChangeLog  
 M  +17 -3     rubylib/qtruby/Qt.cpp  


--- branches/KDE/3.5/kdebindings/qtruby/ChangeLog #488927:488928
@@ -1,3 +1,9 @@
+2005-12-16  Richard Dale  <Richard_Dale at tipitina.demon.co.uk>
+
+	* Improved the code to call a C++ slot via qt_invoke() when a ruby slot hasn't 
+	  been defined. It now invokes the method in the Smoke lib directly, rather
+	  than going via method_missing().
+
 2005-12-08  Richard Dale  <Richard_Dale at tipitina.demon.co.uk>
 
 	* The ruby display() method was clashing with a display() method in some
--- branches/KDE/3.5/kdebindings/qtruby/rubylib/qtruby/Qt.cpp #488927:488928
@@ -1698,7 +1698,7 @@
 }
 
 static VALUE
-qt_invoke(int argc, VALUE * argv, VALUE self)
+qt_invoke(int /*argc*/, VALUE * argv, VALUE self)
 {
     // Arguments: int id, QUObject *o
     int id = NUM2INT(argv[0]);
@@ -1722,8 +1722,22 @@
     bool isSignal = strcmp(rb_id2name(rb_frame_last_func()), "qt_emit") == 0;
     VALUE mocArgs = getslotinfo(self, id, slotname, index, isSignal);
     if(mocArgs == Qnil) {
-		// No ruby slot or signal found, assume the target is a C++ one
-		return rb_call_super(argc, argv);
+		// No ruby slot found, assume the target is a C++ one
+		Smoke::Index nameId = o->smoke->idMethodName("qt_invoke$?");
+		Smoke::Index meth = o->smoke->findMethod(o->classId, nameId);
+		if(meth > 0) {
+			Smoke::Method &m = o->smoke->methods[o->smoke->methodMaps[meth].method];
+			Smoke::ClassFn fn = o->smoke->classes[m.classId].classFn;
+			Smoke::StackItem i[3];
+			i[1].s_int = id;
+			i[2].s_class = _o;
+			(*fn)(m.method, o->ptr, i);
+			return i[0].s_bool == 1 ? Qtrue : Qfalse;
+		}
+
+		// Should never happen..
+		rb_raise(rb_eRuntimeError, "Cannot find %s::qt_invoke() method\n", 
+			o->smoke->classes[o->classId].className );
     }
 
     QString name(slotname);



More information about the Kde-bindings mailing list