[Kde-bindings] KDE/kdebindings/ruby/qtruby

Richard Dale Richard_Dale at tipitina.demon.co.uk
Mon Jun 23 09:33:54 UTC 2008


SVN commit 823405 by rdale:

* Change prepareQtReturnType from a standalone function to a method
  in the SigSlotBase class. It should work with int types, and fix
  the bug reported by Stefano Crocco.

CCMAIL: kde-bindings at kde.org



 M  +6 -0      ChangeLog  
 M  +4 -6      src/Qt.cpp  
 M  +26 -29    src/marshall_types.cpp  
 M  +2 -1      src/marshall_types.h  


--- trunk/KDE/kdebindings/ruby/qtruby/ChangeLog #823404:823405
@@ -1,3 +1,9 @@
+2008-06-23  Richard Dale  <richard.j.dale at gmail.com>
+
+	* Change prepareQtReturnType from a standalone function to a method
+	  in the SigSlotBase class. It should work with int types, and fix
+	  the bug reported by Stefano Crocco.
+
 2008-06-22  Richard Dale  <richard.j.dale at gmail.com>
 
 	* Fix bug in resolve_classname_qt() caused by missing break statments
--- trunk/KDE/kdebindings/ruby/qtruby/src/Qt.cpp #823404:823405
@@ -362,9 +362,8 @@
 	void ** o = new void*[_items];
 	smokeStackToQtStack(_stack, o + 1, 1, _items, _args);
 	void * ptr;
-	prepareQtReturnValue(*_args[0], _stack, o);
-	if (o[0] == 0 && _args[0]->argType != xmoc_void)
-		o[0] = &ptr;
+	o[0] = &ptr;
+	prepareReturnValue(o);
 
 	_obj->metaObject()->activate(_obj, _id, o);
 
@@ -419,9 +418,8 @@
 	void ** o = new void*[_items];
 	smokeStackToQtStack(_stack, o + 1, 1, _items, _args);
 	void * ptr;
-	prepareQtReturnValue(*_args[0], _stack, o);
-	if (o[0] == 0 && _args[0]->argType != xmoc_void)
-		o[0] = &ptr;
+	o[0] = &ptr;
+	prepareReturnValue(o);
 
 	_obj->qt_metacall(QMetaObject::InvokeMetaMethod, _id, o);
 	
--- trunk/KDE/kdebindings/ruby/qtruby/src/marshall_types.cpp #823404:823405
@@ -312,35 +312,6 @@
 	}
 }
 
-void prepareQtReturnValue(const MocArgument& arg, Smoke::Stack stack, void** o)
-{
-	o[0] = 0;
-	
-	if (arg.argType == xmoc_ptr) {
-		QString type(arg.st.name());
-		type = type.trimmed();
-		if (!type.endsWith('*')) {  // a real pointer type, so a simple void* will do
-			type.remove('&');
-			const char* className = (const char*) type.toLatin1();
-			Smoke::ModuleIndex ci = qt_Smoke->findClass(className);
-			if (ci.index) {
-				Smoke::ModuleIndex mi = ci.smoke->findMethod(className, className);
-				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;
-				}
-			}
-		}
-	} else if (arg.argType == xmoc_QString) {
-		o[0] = new QString;
-	} else if (arg.argType != xmoc_void) {
-		o[0] = &stack[0];
-	}
-}
-
 MethodReturnValueBase::MethodReturnValueBase(Smoke *smoke, Smoke::Index meth, Smoke::Stack stack) :
 	_smoke(smoke), _method(meth), _stack(stack) 
 { 
@@ -671,6 +642,32 @@
 	_cur = oldcur;
 }
 
+void 
+SigSlotBase::prepareReturnValue(void** o)
+{
+	if (_args[0]->argType == xmoc_ptr) {
+		QByteArray type(_args[0]->st.name());
+		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;
+				}
+			}
+		}
+	} else if (_args[0]->argType == xmoc_QString) {
+		o[0] = new QString;
+	}
+}
+
 /*
 	Converts a ruby value returned by a slot invocation to a Qt slot 
 	reply type
--- trunk/KDE/kdebindings/ruby/qtruby/src/marshall_types.h #823404:823405
@@ -30,7 +30,6 @@
 #include "smokeruby.h"
 
 Marshall::HandlerFn getMarshallFn(const SmokeType &type);
-void prepareQtReturnValue(const MocArgument& arg, Smoke::Stack stack, void** o);
 
 extern void smokeStackToQtStack(Smoke::Stack stack, void ** o, int start, int end, QList<MocArgument*> args);
 extern void smokeStackFromQtStack(Smoke::Stack stack, void ** _o, int start, int end, QList<MocArgument*> args);
@@ -177,6 +176,7 @@
 	virtual void mainfunction() = 0;
 	void unsupported();
 	void next(); 
+	void prepareReturnValue(void** o);
 
 protected:
 	QList<MocArgument*> _args;
@@ -200,6 +200,7 @@
 	void emitSignal();
 	void mainfunction();
 	bool cleanup();
+
 };
 
 class Q_DECL_EXPORT InvokeNativeSlot : public SigSlotBase {



More information about the Kde-bindings mailing list