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

Arno Rehn kde at arnorehn.de
Fri May 18 12:23:59 UTC 2007


SVN commit 665951 by arnorehn:

* Made 'ref' arguments work.

CCMAIL: kde-bindings at kde.org



 M  +4 -0      ChangeLog  
 M  +5 -5      src/SmokeInvocation.cs  
 M  +53 -4     src/qyoto.cpp  
 M  +1 -1      src/qyoto.h  


--- trunk/KDE/kdebindings/csharp/qyoto/ChangeLog #665950:665951
@@ -1,3 +1,7 @@
+2007-05-18  Arno Rehn  <arno at arnorehn.de>
+
+	* Made 'ref' arguments work.
+
 2007-05-15  Richard Dale  <rdale at foton.es>
 
 	* Regenerated the Qyoto sources from the current qt-copy snapshot as 
--- trunk/KDE/kdebindings/csharp/qyoto/src/SmokeInvocation.cs #665950:665951
@@ -53,7 +53,7 @@
 		static extern int FindMethodId(string className, string mungedName, string signature);
 		
 		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
-		static extern void CallSmokeMethod(int methodId, IntPtr target, IntPtr sp, int items);
+		static extern void CallSmokeMethod(int methodId, IntPtr target, IntPtr sp, int items, bool refArgs);
 
 		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
 		static extern int QyotoHash(IntPtr obj);
@@ -420,14 +420,14 @@
 			unsafe {
 				fixed(StackItem * stackPtr = stack) {
 					if (instance == null) {
-						CallSmokeMethod((int) methodId, (IntPtr) 0, (IntPtr) stackPtr, stack.Length);
+						CallSmokeMethod((int) methodId, (IntPtr) 0, (IntPtr) stackPtr, stack.Length, true);
 					} else {
 #if DEBUG
 						GCHandle instanceHandle = DebugGCHandle.Alloc(instance);
 #else
 						GCHandle instanceHandle = GCHandle.Alloc(instance);
 #endif
-						CallSmokeMethod(methodId, (IntPtr) instanceHandle, (IntPtr) stackPtr, stack.Length);
+						CallSmokeMethod(methodId, (IntPtr) instanceHandle, (IntPtr) stackPtr, stack.Length, true);
 #if DEBUG
 						DebugGCHandle.Free(instanceHandle);
 #else
@@ -508,14 +508,14 @@
 			unsafe {
 				fixed(StackItem * stackPtr = stack) {
 					if (instance == null) {
-						CallSmokeMethod((int) methodId, (IntPtr) 0, (IntPtr) stackPtr, args.Length / 2);
+						CallSmokeMethod((int) methodId, (IntPtr) 0, (IntPtr) stackPtr, args.Length / 2, false);
 					} else {
 #if DEBUG
 						GCHandle instanceHandle = DebugGCHandle.Alloc(instance);
 #else
 						GCHandle instanceHandle = GCHandle.Alloc(instance);
 #endif
-						CallSmokeMethod(methodId, (IntPtr) instanceHandle, (IntPtr) stackPtr, args.Length / 2);
+						CallSmokeMethod(methodId, (IntPtr) instanceHandle, (IntPtr) stackPtr, args.Length / 2, false);
 #if DEBUG
 						DebugGCHandle.Free(instanceHandle);
 #else
--- trunk/KDE/kdebindings/csharp/qyoto/src/qyoto.cpp #665950:665951
@@ -491,6 +491,48 @@
     bool cleanup() { return false; }
 };
 
+class RefArguments : public Marshall {
+    Smoke *_smoke;
+    Smoke::Index _method;
+    Smoke::StackItem * _retval;
+    Smoke::Stack _stack;
+    Smoke::Stack _sp;
+    Smoke::Index* _args;
+    int _items;
+    int _cur;
+public:
+	RefArguments(Smoke *smoke, Smoke::Index method, Smoke::Stack stack, Smoke::Stack sp, Smoke::Index* args, int items) :
+		_cur(0), _smoke(smoke), _method(method),  _stack(stack), _sp(sp), _args(args), _items(items)  {
+    }
+
+    const Smoke::Method &method() { return _smoke->methods[_method]; }
+    SmokeType type() { return SmokeType(_smoke, _args[_cur]); }
+    Marshall::Action action() { return Marshall::ToObject; }
+    Smoke::StackItem &item() { return _stack[_cur]; }
+    Smoke::StackItem &var() {
+    	return _sp[_cur];
+    }
+
+	void unsupported() {
+		qFatal(	"Cannot handle '%s' as return-type of %s::%s",
+				type().name(),
+				strcmp(_smoke->className(method().classId), "QGlobalSpace") == 0 ? "" : _smoke->className(method().classId),
+				_smoke->methodNames[method().name] );
+	}
+	Smoke *smoke() { return _smoke; }
+	void next() {
+		int oldcur = _cur;
+		_cur++;
+		while(_cur < _items) {
+			Marshall::HandlerFn fn = getMarshallFn(type());
+			(*fn)(this);
+			_cur++;
+		}
+		_cur = oldcur;
+	}
+	bool cleanup() { return false; }
+};
+
 class MethodCall : public Marshall {
     int _cur;
     Smoke *_smoke;
@@ -501,11 +543,13 @@
 	smokeqyoto_object * _o;
     Smoke::Stack _sp;
     int _items;
+    int numItems;
     Smoke::StackItem * _retval;
     bool _called;
+    bool _refArgs;
 public:
-    MethodCall(Smoke *smoke, Smoke::Index method, void * target, Smoke::Stack sp, int items) :
-	_cur(-1), _smoke(smoke), _method(method), _target(target), _o(0), _sp(sp), _items(items), _called(false)
+    MethodCall(Smoke *smoke, Smoke::Index method, void * target, Smoke::Stack sp, int items, bool refArgs) :
+	_cur(-1), _smoke(smoke), _method(method), _target(target), _o(0), _sp(sp), _items(items), _refArgs(refArgs), _called(false)
 	{
 		if (!isConstructor() && !isStatic()) {
 			_o = (smokeqyoto_object*) (*GetSmokeObject)(_target);
@@ -524,6 +568,7 @@
 	
 		_args = _smoke->argumentList + _smoke->methods[_method].args;
 		_items = _smoke->methods[_method].numArgs;
+		numItems = items;
 		_stack = new Smoke::StackItem[items + 1];
 		_retval = _sp;
     }
@@ -593,6 +638,10 @@
 			(*SetSmokeObject)(_target, 0);
 			free_smokeqyoto_object(_o);
 		} else {
+			if (_refArgs) {
+				RefArguments ref(_smoke, _method, _stack, _sp, _args, numItems);
+				ref.next();
+			}
 			MethodReturnValue r(_smoke, _method, _stack, _retval);
 		}
 
@@ -1659,7 +1708,7 @@
 }
 
 void
-CallSmokeMethod(int methodId, void * obj, Smoke::StackItem * sp, int items)
+CallSmokeMethod(int methodId, void * obj, Smoke::StackItem * sp, int items, bool refArgs)
 {
 #ifdef DEBUG
 	printf("ENTER CallSmokeMethod(methodId: %d target: 0x%8.8x items: %d)\n", methodId, obj, items);
@@ -1681,7 +1730,7 @@
 		items = 1;
 	}
 
-	MethodCall c(qt_Smoke, methodId, obj, sp, items);
+	MethodCall c(qt_Smoke, methodId, obj, sp, items, refArgs);
 	c.next();
 
 #ifdef DEBUG
--- trunk/KDE/kdebindings/csharp/qyoto/src/qyoto.h #665950:665951
@@ -133,7 +133,7 @@
 
 extern Q_DECL_EXPORT void SetApplicationTerminated();
 extern Q_DECL_EXPORT int QyotoHash(void * obj);
-extern Q_DECL_EXPORT void CallSmokeMethod(int methodId, void * obj, Smoke::StackItem * sp, int items);
+extern Q_DECL_EXPORT void CallSmokeMethod(int methodId, void * obj, Smoke::StackItem * sp, int items, bool refArgs);
 extern Q_DECL_EXPORT bool SignalEmit(char * signature, char * type, void * obj, Smoke::StackItem * sp, int items);
 extern Q_DECL_EXPORT void * make_metaObject(	void * obj, void * parentMeta, 
 						const char* stringdata, int stringdata_count, 



More information about the Kde-bindings mailing list