[Kde-bindings] Qyoto on Windows

SE1 ikruis at gmail.com
Fri Jun 6 15:30:50 UTC 2008


After quite some messing around I finally have a Hello World running using
Qyoto on Windows!!! I'll try to make a binary package when I've time. 

Now for those interested on how to do it: 
Build Qyoto on Linux as usual (Qyoto only). Then go through the header_list
and adapt it to your Qt/Win configuration (I had to strip UITools, DBus and
Accessibility headers for the default MinGW32-based installer, if I remember
correctly). Rebuild and copy the smokeqt sources to Windows and build the
libraries manually (I used MinGW at first, but switched to MSVC++ later for
debugging, so both should work). Here you might encounter one or two compile
errors because of the difference between Qt/Win and Qt/X11, if you get a lot
of externals not found, find the Qt header, strip it from header_list and
you can repeat the process. When you've got a smokeqt.dll, compiling
libqyotoshared.dll and libqyoto.dll (leave the lib...dll here! otherwise
.NET can't find it) shouldn't be much trouble, you just need to define
SMOKE_EXPORTS as __declspec(dllimport) instead of __declspec(dllexport) in
smoke.h and do something similar with qyoto.h. For the C# part I pasted my
diff below as it's also usefull for the main tree. I had to update a couple
of imports and set the proper calling convention for the delegates (Ms.NET
defaults to stdcall, while MSVC++ defaults to cdecl :-|)

__________________

Index: SmokeMarshallers.cs
===================================================================
--- SmokeMarshallers.cs	(revision 817553)
+++ SmokeMarshallers.cs	(working copy)
@@ -25,20 +25,21 @@
 	using System.Runtime.InteropServices;
 	using System.Text;
 
-	public class SmokeMarshallers : object {
-		
+	public class SmokeMarshallers : object {
+	    private const CallingConvention CallConv = CallingConvention.Cdecl;
+
 #region C++ functions
 		/** Marshalling functions begin **/
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern IntPtr StringArrayToCharStarStar(int length,
string[] strArray);
 		
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern IntPtr StringToQString(string str);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern string StringFromQString(IntPtr ptr);
 		
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern IntPtr StringArrayToQStringList(int length, string[]
strArray);
 		/** Marshalling functions end **/
 		
@@ -121,25 +122,25 @@
 		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
 		public static extern bool InstallSetProperty(SetPropertyFn callback);
 		
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void InstallIntPtrToCharStarStar(GetIntPtr
callback);
 		
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void InstallIntPtrToCharStar(GetStringFromIntPtr
callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void InstallIntPtrFromCharStar(GetIntPtrFromString
callback);
 		
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void InstallIntPtrToQString(GetIntPtr callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void InstallIntPtrFromQString(GetIntPtr callback);
 		
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void InstallStringBuilderToQString(GetIntPtr
callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void
InstallStringBuilderFromQString(SetIntPtrFromCharStar callback);
 
 		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
@@ -148,68 +149,89 @@
 		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
 		public static extern void InstallInvokeMethod(InvokeMethodFn callback);
 		
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern IntPtr InstallConstructList(CreateListFn callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern IntPtr InstallStringListToQStringList(GetIntPtr
callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern IntPtr InstallListToPointerList(GetIntPtr callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern IntPtr InstallListIntToQListInt(GetIntPtr callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern IntPtr InstallListUIntToQListQRgb(GetIntPtr
callback);
 		
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void
InstallListWizardButtonToQListWizardButton(GetIntPtr callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void InstallAddIntPtrToList(SetIntPtr callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void InstallAddIntToListInt(AddInt callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern IntPtr InstallConstructDictionary(ConstructDict
callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void
InstallAddObjectObjectToDictionary(InvokeMethodFn callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void InstallAddIntObjectToDictionary(AddIntObject
callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void InstallDictionaryToQMap(DictToMap callback);
 
-		[DllImport("libqyoto", CharSet=CharSet.Ansi)]
+		[DllImport("libqyotoshared", CharSet=CharSet.Ansi)]
 		public static extern void InstallAddUIntToListUInt(AddUInt callback);
 #endregion
 		
 #region delegates
-		public delegate IntPtr NoArgs();
-		public delegate IntPtr GetIntPtr(IntPtr instance);
-		public delegate void SetIntPtr(IntPtr instance, IntPtr ptr);
-		public delegate void FromIntPtr(IntPtr ptr);
-		public delegate void MapPointerFn(IntPtr instance, IntPtr ptr, bool
createGlobalReference);
-		public delegate IntPtr CreateListFn(string className);
-		public delegate IntPtr CreateInstanceFn(string className, IntPtr
smokeObjectPtr);
-		public delegate IntPtr GetInstanceFn(IntPtr ptr, bool allInstances);
-		public delegate void InvokeCustomSlotFn(IntPtr obj, string slot, IntPtr
stack, IntPtr ret);
-		public delegate IntPtr GetIntPtrFromString(string str);
-		public delegate string GetStringFromIntPtr(IntPtr ptr);
-		public delegate void SetIntPtrFromCharStar(IntPtr ptr, string str);
-		public delegate IntPtr OverridenMethodFn(IntPtr instance, string method);
-		public delegate void InvokeMethodFn(IntPtr instance, IntPtr method,
IntPtr args);
-		public delegate void AddInt(IntPtr obj, int i);
-		public delegate void AddUInt(IntPtr obj, uint i);
-		public delegate void AddIntObject(IntPtr hash, int key, IntPtr val);
-		public delegate IntPtr DictToMap(IntPtr ptr, int type);
-		public delegate IntPtr ConstructDict(string type1, string type2);
-		public delegate void SetPropertyFn(IntPtr obj, string name, IntPtr
variant);
-		public delegate void InvokeDelegateFn(Delegate d, IntPtr stack);
+        [UnmanagedFunctionPointer(CallConv)]
+		public delegate IntPtr NoArgs();
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate IntPtr GetIntPtr(IntPtr instance);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate void SetIntPtr(IntPtr instance, IntPtr ptr);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate void FromIntPtr(IntPtr ptr);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate void MapPointerFn(IntPtr instance, IntPtr ptr, bool
createGlobalReference);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate IntPtr CreateListFn(string className);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate IntPtr CreateInstanceFn(string className, IntPtr
smokeObjectPtr);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate IntPtr GetInstanceFn(IntPtr ptr, bool
allInstances);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate void InvokeCustomSlotFn(IntPtr obj, string slot,
IntPtr stack, IntPtr ret);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate IntPtr GetIntPtrFromString(string str);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate string GetStringFromIntPtr(IntPtr ptr);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate void SetIntPtrFromCharStar(IntPtr ptr, string str);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate IntPtr OverridenMethodFn(IntPtr instance, string
method);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate void InvokeMethodFn(IntPtr instance, IntPtr method,
IntPtr args);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate void AddInt(IntPtr obj, int i);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate void AddUInt(IntPtr obj, uint i);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate void AddIntObject(IntPtr hash, int key, IntPtr
val);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate IntPtr DictToMap(IntPtr ptr, int type);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate IntPtr ConstructDict(string type1, string type2);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate void SetPropertyFn(IntPtr obj, string name, IntPtr
variant);
+        [UnmanagedFunctionPointer(CallConv)]
+        public delegate void InvokeDelegateFn(Delegate d, IntPtr stack);
 #endregion
 		
 #region marshalling functions


-- 
View this message in context: http://www.nabble.com/Qyoto-on-Windows-tp17040536p17695030.html
Sent from the kde-bindings mailing list archive at Nabble.com.




More information about the Kde-bindings mailing list