[Kde-bindings] KDE/kdebindings/ruby/qtruby
Arno Rehn
kde at arnorehn.de
Sat Jun 28 19:09:59 UTC 2008
SVN commit 825598 by arnorehn:
* Special case QDBusVariants in SlotReturnValue and make it behave
like the moc. This makes the complexpingpong example work.
Maybe more things need to be special cased, like in
SigSlotBase::prepareReturnValue().
* Add special cases for lists and maps to
SigSlotBase::prepareReturnValue().
* Add 'QList<QObject*>' to the handlers array.
* Small fixes to complexping.rb.
CCMAIL: kde-bindings at kde.org
M +11 -0 ChangeLog
M +2 -2 examples/qdbus/complexpingpong/complexping.rb
M +3 -0 src/handlers.cpp
M +39 -17 src/marshall_types.cpp
--- trunk/KDE/kdebindings/ruby/qtruby/ChangeLog #825597:825598
@@ -1,3 +1,14 @@
+2008-06-28 Arno Rehn <arno at arnorehn.de>
+
+ * Special case QDBusVariants in SlotReturnValue and make it behave
+ like the moc. This makes the complexpingpong example work.
+ Maybe more things need to be special cased, like in
+ SigSlotBase::prepareReturnValue().
+ * Add special cases for lists and maps to
+ SigSlotBase::prepareReturnValue().
+ * Add 'QList<QObject*>' to the handlers array.
+ * Small fixes to complexping.rb.
+
2008-06-23 Richard Dale <richard.j.dale at gmail.com>
* Change prepareQtReturnType from a standalone function to a method
--- trunk/KDE/kdebindings/ruby/qtruby/examples/qdbus/complexpingpong/complexping.rb #825597:825598
@@ -57,7 +57,7 @@
puts("value = %s" % reply)
end
elsif line =~ /^value=/
- iface.value = line[6, line.length]
+ iface.setValue Qt::Variant.new(line[6, line.length])
else
reply = Qt::DBusReply.new(iface.call("query", Qt::Variant.new(line)))
if reply.valid?
@@ -87,6 +87,6 @@
SLOT('start(QString,QString,QString)'))
pong = Qt::Process.new
-pong.start("./complexpong.rb")
+pong.start("ruby ./complexpong.rb")
app.exec
--- trunk/KDE/kdebindings/ruby/qtruby/src/handlers.cpp #825597:825598
@@ -1001,6 +1001,7 @@
}
*(m->var()) = obj;
+ break;
}
default:
@@ -2251,6 +2252,8 @@
{ "QwtValueList", marshall_QListqreal },
{ "QwtValueList&", marshall_QListqreal },
{ "QList<double>&", marshall_QListqreal },
+ { "QList<QObject*>", marshall_QObjectList },
+ { "QList<QObject*>&", marshall_QObjectList },
{ "QList<QTableWidgetItem*>", marshall_QTableWidgetItemList },
{ "QList<QTableWidgetItem*>&", marshall_QTableWidgetItemList },
{ "QList<QTableWidgetSelectionRange>", marshall_QTableWidgetSelectionRangeList },
--- trunk/KDE/kdebindings/ruby/qtruby/src/marshall_types.cpp #825597:825598
@@ -19,6 +19,7 @@
#include "marshall_types.h"
#include <rubysig.h>
#include <smoke/qt_smoke.h>
+#include <QtDBus>
static bool qtruby_embedded = false;
@@ -647,19 +648,32 @@
{
if (_args[0]->argType == xmoc_ptr) {
QByteArray type(_args[0]->st.name());
+ type.replace("const ", "");
if (!type.endsWith('*')) { // a real pointer type, so a simple void* will do
if (type.endsWith('&')) {
type.resize(type.size() - 1);
}
- Smoke::ModuleIndex ci = qt_Smoke->findClass(type);
- if (ci.index != 0) {
- Smoke::ModuleIndex mi = ci.smoke->findMethod(type, type);
- if (mi.index) {
- Smoke::Class& c = ci.smoke->classes[ci.index];
- Smoke::Method& meth = mi.smoke->methods[mi.smoke->methodMaps[mi.index].method];
- Smoke::StackItem _stack[1];
- c.classFn(meth.method, 0, _stack);
- o[0] = _stack[0].s_voidp;
+ if (type.startsWith("QList")) {
+ o[0] = new QList<void*>;
+ } else if (type.startsWith("QVector")) {
+ o[0] = new QVector<void*>;
+ } else if (type.startsWith("QHash")) {
+ o[0] = new QHash<void*, void*>;
+ } else if (type.startsWith("QMap")) {
+ o[0] = new QMap<void*, void*>;
+ } else if (type == "QDBusVariant") {
+ o[0] = new QDBusVariant;
+ } else {
+ Smoke::ModuleIndex ci = qt_Smoke->findClass(type);
+ if (ci.index != 0) {
+ Smoke::ModuleIndex mi = ci.smoke->findMethod(type, type);
+ if (mi.index) {
+ Smoke::Class& c = ci.smoke->classes[ci.index];
+ Smoke::Method& meth = mi.smoke->methods[mi.smoke->methodMaps[mi.index].method];
+ Smoke::StackItem _stack[1];
+ c.classFn(meth.method, 0, _stack);
+ o[0] = _stack[0].s_voidp;
+ }
}
}
}
@@ -684,14 +698,22 @@
_stack = new Smoke::StackItem[1];
Marshall::HandlerFn fn = getMarshallFn(type());
(*fn)(this);
- // Save any address in zeroth element of the arrary of 'void*'s passed to
- // qt_metacall()
- void * ptr = o[0];
- smokeStackToQtStack(_stack, o, 0, 1, _replyType);
- // Only if the zeroth element of the array of 'void*'s passed to qt_metacall()
- // contains an address, is the return value of the slot needed.
- if (ptr != 0) {
- *(void**)ptr = *(void**)(o[0]);
+
+ QByteArray t(type().name());
+ t.replace("const ", "");
+ t.replace("&", "");
+ if (t == "QDBusVariant") {
+ *reinterpret_cast<QDBusVariant*>(o[0]) = *(QDBusVariant*) _stack[0].s_class;
+ } else {
+ // Save any address in zeroth element of the arrary of 'void*'s passed to
+ // qt_metacall()
+ void * ptr = o[0];
+ smokeStackToQtStack(_stack, o, 0, 1, _replyType);
+ // Only if the zeroth element of the array of 'void*'s passed to qt_metacall()
+ // contains an address, is the return value of the slot needed.
+ if (ptr != 0) {
+ *(void**)ptr = *(void**)(o[0]);
+ }
}
}
More information about the Kde-bindings
mailing list