[Kde-bindings] playground/bindings/kimono

Richard Dale Richard_Dale at tipitina.demon.co.uk
Mon Nov 28 09:17:30 UTC 2005


SVN commit 483798 by rdale:

* Added a marshaller for converting string[] type to a char**
* Added hello world example from Arno Rehn
* Changed the QApplication initializer to take just an argv string[],
  with no argc int

CCMAIL: kde-bindings at kde.org


 A             Hello.cs  
 M  +9 -0      SmokeInvocation.cs  
 M  +11 -8     makefile  
 M  +10 -0     qt3handlers.cpp  
 M  +3 -3      qt3qyoto.cpp  
 M  +4 -1      qt3qyoto/QApplication.cs  


--- trunk/playground/bindings/kimono/SmokeInvocation.cs #483797:483798
@@ -65,6 +65,9 @@
 		delegate void RemoveIntPtr(IntPtr ptr);
 		
 		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		static extern IntPtr StringArrayToCharStarStar(string[] strArray);
+
+		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
 		static extern void AddGetSmokeObject(GetIntPtr callback);
 		
 		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
@@ -155,6 +158,7 @@
 		public ArrayList FindMethod(string name) {
 			ArrayList result = new ArrayList();
 			
+			Console.WriteLine("FindMethod() className: {0} MethodName: {1}", _className, name);
 			int meth = FindMethodId(_className, name);
 			if (meth == 0) {
 				meth = FindMethodId("QGlobalSpace", name);
@@ -164,6 +168,7 @@
 				return result;
 			} else if (meth > 0) {
 				int i = MethodFromMap(meth);
+				Console.WriteLine("FindMethod() MethodName: {0} result: {1}", name, i);
 				if (i == 0) {		// shouldn't happen
 					;
 				} else if (i > 0) {	// single match
@@ -239,6 +244,10 @@
 						stack[i+1].s_float = (float) callMessage.Args[i];
 					} else if (types[i] == typeof(double)) {
 						stack[i+1].s_double = (double) callMessage.Args[i];
+					} else if (types[i] == typeof(string[])) {
+						unsafe {
+							stack[i+1].s_voidp = (void *) StringArrayToCharStarStar((string[]) callMessage.Args[i]);
+						}
 					}
 					Console.WriteLine(	"\tArgName: {0} Arg: {1} Type: {2}", 
 										callMessage.GetArgName(i),
--- trunk/playground/bindings/kimono/makefile #483797:483798
@@ -1,17 +1,20 @@
 all: doit.exe libqyoto.so
 
 doit.exe:	doit.cs QFont.cs SmokeInvocation.cs
-	mcs --unsafe -o doit.exe doit.cs QFont.cs SmokeInvocation.cs
+	mcs -unsafe -o doit.exe doit.cs QFont.cs SmokeInvocation.cs
 
+hello.exe: Hello.cs SmokeInvocation.cs
+	mcs -unsafe -out:hello.exe Hello.cs SmokeInvocation.cs qt3qyoto/*.cs
 
-libqyoto.so:	qyoto.cpp handlers.cpp
-	gcc -shared -o libqyoto.so \
-	-I/home/duke/src/kde/kde/trunk/KDE/kdebindings/smoke \
-	-I/opt/kde4/include -I/opt/kde4/include/QtCore \
-	-I/opt/kde4/include/QtGui \
-	-L/opt/kde4/lib -lQtCore -lQtGui -lsmokeqt qyoto.cpp handlers.cpp
 
-libqt3qyoto.so:	qt3qyoto.cpp qt3handlers.cpp
+#libqyoto.so:	qyoto.cpp handlers.cpp
+#	gcc -shared -o libqyoto.so \
+#	-I/home/duke/src/kde/kde/trunk/KDE/kdebindings/smoke \
+#	-I/opt/kde4/include -I/opt/kde4/include/QtCore \
+#	-I/opt/kde4/include/QtGui \
+#	-L/opt/kde4/lib -lQtCore -lQtGui -lsmokeqt qyoto.cpp handlers.cpp
+
+libqyoto.so:	qt3qyoto.cpp qt3handlers.cpp
 	gcc -shared -o libqyoto.so \
 	-I/home/duke/src/kde/kde/branches/KDE/3.5/kdebindings/smoke \
 	-I/opt/kde3/include \
--- trunk/playground/bindings/kimono/qt3handlers.cpp #483797:483798
@@ -218,6 +218,16 @@
     return args[0].s_voidp;
 }
 
+extern "C" {
+
+void *
+StringArrayToCharStarStar(char ** strArray)
+{
+	return (void *) strArray;
+}
+
+}
+
 void
 marshall_basetype(Marshall *m)
 {
--- trunk/playground/bindings/kimono/qt3qyoto.cpp #483797:483798
@@ -349,7 +349,7 @@
 int 
 FindMethodId(char * classname, char * methodname) 
 {
-    Smoke::Index meth = qt_Smoke->findMethod(classname, methodname);
+	Smoke::Index meth = qt_Smoke->findMethod(classname, methodname);
 	printf("\t\tIn FindMethodId %s::%s => %d\n", classname, methodname, meth);
 	return meth;
 }
@@ -431,9 +431,9 @@
 void
 Init_qyoto()
 {
-    init_qt_Smoke();
+	init_qt_Smoke();
 	qt_Smoke->binding = new QyotoSmokeBinding(qt_Smoke);
-    install_handlers(Qt_handlers);
+	install_handlers(Qt_handlers);
 }
 
 }
--- trunk/playground/bindings/kimono/qt3qyoto/QApplication.cs #483797:483798
@@ -134,8 +134,11 @@
 			NewQApplication(argv);
 		}
 		private void NewQApplication(string[] argv) {
-			ProxyQApplication().NewQApplication(argv);
+			ProxyQApplication().NewQApplication(argv.Length, argv);
 		}
+		private void NewQApplication(int argc, string[] argv) {
+			ProxyQApplication().NewQApplication(argc, argv);
+		}
 		public QApplication(string[] argv, bool GUIenabled) : this((Type) null) {
 			CreateQApplicationProxy();
 			NewQApplication(argv,GUIenabled);



More information about the Kde-bindings mailing list