[Kde-bindings] KDE/kdebindings/csharp/qyoto

Arno Rehn kde at arnorehn.de
Sat Jul 12 16:50:52 UTC 2008


SVN commit 831417 by arnorehn:

* Special case QDBusVariant in SlotReturnValue.
* Make QDBusVariant work with CreateInstance()
* Make QDBusReply similar to C++'s QDBusReply.

CCMAIL: kde-bindings at kde.org



 M  +6 -0      ChangeLog  
 M  +6 -4      examples/qdbus/complexpingpong/complexping.cs  
 M  +1 -1      qdbus/QDBusReply.cs  
 M  +1 -1      qdbus/QDBusVariant.cs  
 M  +1 -1      src/handlers.cpp  
 M  +6 -0      src/qyoto.cpp  
 M  +18 -9     src/slotreturnvalue.cpp  


--- trunk/KDE/kdebindings/csharp/qyoto/ChangeLog #831416:831417
@@ -1,3 +1,9 @@
+2008-07-12  Arno Rehn  <arno at arnorehn.de>
+
+    * Special case QDBusVariant in SlotReturnValue.
+    * Make QDBusVariant work with CreateInstance()
+    * Make QDBusReply similar to C++'s QDBusReply.
+
 2008-07-12  Richard Dale  <richard.j.dale at gmail.com>
 
 	* Change the slot/signal argument parsing code to work the same way as in
--- trunk/KDE/kdebindings/csharp/qyoto/examples/qdbus/complexpingpong/complexping.cs #831416:831417
@@ -60,9 +60,9 @@
             } else if (line.StartsWith("value=")) {
                 iface.SetProperty("value", new QVariant(line.Substring(6)));            
             } else {
-               QDBusReply<QVariant> reply = new QDBusReply<QVariant>(iface.Call("query", new QVariant(line)));
+               QDBusReply<string> reply = new QDBusReply<string>(iface.Call("query", new QVariant(line)));
                 if (reply.IsValid())
-                    Console.WriteLine("Reply was: {0}", reply.Value().ToString());
+                    Console.WriteLine("Reply was: {0}", reply.Value());
             }
 
             if (iface.LastError().IsValid())
@@ -85,8 +85,10 @@
                      SIGNAL("serviceOwnerChanged(QString,QString,QString)"),
                      SLOT("Start(QString,QString,QString)"));
 
-        QProcess pong = new QProcess();
-        pong.Start("mono ./complexpong.exe");
+        // start the process manually - doesn't work this way..
+        // QProcess pong = new QProcess(qApp);
+        // pong.Start("mono ./complexpong.exe");
+        // pong.WaitForStarted();
 
         return QCoreApplication.Exec();
     }
--- trunk/KDE/kdebindings/csharp/qyoto/qdbus/QDBusReply.cs #831416:831417
@@ -11,7 +11,7 @@
 			}
 
 			if (reply.Arguments().Count >= 1) {
-				m_data = (reply.Arguments()[0]).Value<T>();
+				m_data = (reply.Arguments()[0]).Value<QDBusVariant>().Value<T>();
 				return;
 			}
 
--- trunk/KDE/kdebindings/csharp/qyoto/qdbus/QDBusVariant.cs #831416:831417
@@ -3,7 +3,7 @@
 	using System;
 
 	public class QDBusVariant : QVariant {
-
+		protected QDBusVariant(Type dummy) : base((Type) null) {}
 		public QDBusVariant() : base() { }
 		public QDBusVariant(QVariant variant) : base(variant) { }
 
--- trunk/KDE/kdebindings/csharp/qyoto/src/handlers.cpp #831416:831417
@@ -1303,7 +1303,7 @@
 		}
 
 		if (m->type().isStack()) {
-// 		    o->allocated = true;
+		    o->allocated = true;
 			// Keep a mapping of the pointer so that it is only wrapped once
 		    mapPointer(obj, o, o->classId, 0);
 		}
--- trunk/KDE/kdebindings/csharp/qyoto/src/qyoto.cpp #831416:831417
@@ -300,6 +300,12 @@
 	smokeqyoto_object *o = (smokeqyoto_object*) (*GetSmokeObject)(variant);
 	void * value = QMetaType::construct(	QMetaType::type(typeName), 
 											(void *) ((QVariant *)o->ptr)->constData() );
+	if (qstrcmp(typeName, "QDBusVariant") == 0) {
+		Smoke::ModuleIndex id = o->smoke->findClass("QVariant");
+		smokeqyoto_object  * vo = alloc_smokeqyoto_object(true, id.smoke, id.index, (void *) value);
+		(*FreeGCHandle)(variant);
+		return (*CreateInstance)("Qyoto.QDBusVariant", vo);
+	}
 	Smoke::ModuleIndex id = o->smoke->findClass(typeName);
 	smokeqyoto_object  * vo = alloc_smokeqyoto_object(true, id.smoke, id.index, (void *) value);
 	(*FreeGCHandle)(variant);
--- trunk/KDE/kdebindings/csharp/qyoto/src/slotreturnvalue.cpp #831416:831417
@@ -13,6 +13,8 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <QtDBus>
+
 #include "slotreturnvalue.h"
 #include "qyoto.h"
 
@@ -23,15 +25,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 arrary 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