[Kde-bindings] KDE/kdebindings/ruby/korundum
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Mon Aug 11 10:41:58 UTC 2008
SVN commit 845248 by rdale:
* The KDE::ActionCollection#addAction method wasn't working with the two
argument form where the second arg was either a KDE::Action or a
Qt::Action as the normal overloaded method resolution code can't
distinguish between the two. So special case it for now. Fixes problem
reported by Stafono Crocco. For example, the following code now works
correctly:
a1 = KDE::RecentFilesAction.new "Recent", action_collection
action_collection.addAction "recent", a1
a2 = Qt::Action.new(self)
action_collection.addAction "foobar", a2
CCMAIL: kde-bindings at kde.org
M +15 -0 ChangeLog
M +41 -1 src/Korundum.cpp
--- trunk/KDE/kdebindings/ruby/korundum/ChangeLog #845247:845248
@@ -1,3 +1,18 @@
+2008-08-11 Richard Dale <richard.j.dale at gmail.com>
+
+ * The KDE::ActionCollection#addAction method wasn't working with the two
+ argument form where the second arg was either a KDE::Action or a
+ Qt::Action as the normal overloaded method resolution code can't
+ distinguish between the two. So special case it for now. Fixes problem
+ reported by Stafono Crocco. For example, the following code now works
+ correctly:
+
+ a1 = KDE::RecentFilesAction.new "Recent", action_collection
+ action_collection.addAction "recent", a1
+ a2 = Qt::Action.new(self)
+ action_collection.addAction "foobar", a2
+
+
2008-08-07 Richard Dale <richard.j.dale at gmail.com>
* The special cased KDE::ConfigSkeleton.new(nil) constructor wasn't
--- trunk/KDE/kdebindings/ruby/korundum/src/Korundum.cpp #845247:845248
@@ -43,7 +43,7 @@
#include <qtruby.h>
#include <smokeruby.h>
-// #include <marshall_basetypes.h>
+#include <marshall_types.h>
#include <iostream>
@@ -127,13 +127,53 @@
return self;
}
+static VALUE
+kactioncollection_add_action(int argc, VALUE * argv, VALUE self)
+{
+ if (argc == 2 && TYPE(argv[0]) == T_STRING && TYPE(argv[1]) == T_DATA) {
+ smokeruby_object *o = value_obj_info(self);
+ smokeruby_object *a = value_obj_info(argv[1]);
+
+ Smoke::ModuleIndex nameId = qt_Smoke->NullModuleIndex;
+ nameId = o->smoke->idMethodName("addAction$#");
+ Smoke::ModuleIndex ci = { o->smoke, o->classId };
+ Smoke::ModuleIndex meth = o->smoke->findMethod(ci, nameId);
+ Smoke::Index i = meth.smoke->methodMaps[meth.index].method;
+ i = -i; // turn into ambiguousMethodList index
+ while (meth.smoke->ambiguousMethodList[i] != 0) {
+ if ( ( qstrcmp( meth.smoke->types[meth.smoke->argumentList[meth.smoke->methods[meth.smoke->ambiguousMethodList[i]].args + 1]].name,
+ "QAction*" ) == 0
+ && a->smoke->isDerivedFromByName(a->smoke->classes[a->classId].className, "QAction")
+ && !a->smoke->isDerivedFromByName(a->smoke->classes[a->classId].className, "KAction") )
+ || ( qstrcmp( meth.smoke->types[meth.smoke->argumentList[meth.smoke->methods[meth.smoke->ambiguousMethodList[i]].args + 1]].name,
+ "KAction*" ) == 0
+ && a->smoke->isDerivedFromByName(a->smoke->classes[a->classId].className, "KAction") ) )
+ {
+ _current_method.smoke = meth.smoke;
+ _current_method.index = meth.smoke->ambiguousMethodList[i];
+ QtRuby::MethodCall c(meth.smoke, _current_method.index, self, argv, 2);
+ c.next();
+ return *(c.var());
+ }
+
+ i++;
+ }
+ }
+
+ return rb_call_super(argc, argv);
+}
+
static void classCreated(const char* package, VALUE /*module*/, VALUE klass)
{
QString packageName(package);
if (packageName == "KDE::ConfigSkeleton") {
kconfigskeleton_class = klass;
rb_define_method(klass, "addItem", (VALUE (*) (...)) config_additem, -1);
+ rb_define_method(klass, "add_item", (VALUE (*) (...)) config_additem, -1);
rb_define_method(klass, "initialize", (VALUE (*) (...)) config_initialize, -1);
+ } else if (packageName == "KDE::ActionCollection") {
+ rb_define_method(klass, "addAction", (VALUE (*) (...)) kactioncollection_add_action, -1);
+ rb_define_method(klass, "add_action", (VALUE (*) (...)) kactioncollection_add_action, -1);
}
}
More information about the Kde-bindings
mailing list