From b2e708d720b5510f8a0a199fc28973d034741ede Mon Sep 17 00:00:00 2001 From: triton Date: Thu, 4 Apr 2013 16:05:29 +0100 Subject: [PATCH] Removed the Qt example binding code. --- examples/qt/Qt.cs | 96 ----------------------------- examples/qt/cpp/qt-gui-filters.xml | 41 ------------ examples/qt/cpp/qt-gui.cpp | 21 ------- examples/qt/cpp/qt-gui.h | 3 - examples/qt/demos/hello.cs | 25 -------- examples/qt/premake4.lua | 11 ---- examples/qt/src/QApplication.cs | 20 ------ examples/qt/src/QCoreApplication.cs | 50 --------------- examples/qt/src/QFlags.cs | 13 ---- examples/qt/src/QPoint.cs | 20 ------ examples/qt/src/QPushButton.cs | 20 ------ examples/qt/src/QSize.cs | 20 ------ examples/qt/src/QString.cs | 71 --------------------- examples/qt/src/QWidget.cs | 16 ----- 14 files changed, 427 deletions(-) delete mode 100644 examples/qt/Qt.cs delete mode 100644 examples/qt/cpp/qt-gui-filters.xml delete mode 100644 examples/qt/cpp/qt-gui.cpp delete mode 100644 examples/qt/cpp/qt-gui.h delete mode 100644 examples/qt/demos/hello.cs delete mode 100644 examples/qt/premake4.lua delete mode 100644 examples/qt/src/QApplication.cs delete mode 100644 examples/qt/src/QCoreApplication.cs delete mode 100644 examples/qt/src/QFlags.cs delete mode 100644 examples/qt/src/QPoint.cs delete mode 100644 examples/qt/src/QPushButton.cs delete mode 100644 examples/qt/src/QSize.cs delete mode 100644 examples/qt/src/QString.cs delete mode 100644 examples/qt/src/QWidget.cs diff --git a/examples/qt/Qt.cs b/examples/qt/Qt.cs deleted file mode 100644 index 307a4d45..00000000 --- a/examples/qt/Qt.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.Collections.Generic; -using Cxxi.Generators; -using Cxxi.Generators.CLI; -using Cxxi.Passes; -using Cxxi.Types; - -namespace Cxxi.Libraries -{ - class Qt : ILibrary - { - public void Preprocess(Library lib) - { - // Qt Base - lib.IgnoreFile("qalgorithms.h"); - lib.IgnoreFile("qarraydata.h"); - lib.IgnoreFile("qatomic.h"); - lib.IgnoreFile("qatomic_x86.h"); - lib.IgnoreFile("qbytearray.h"); - lib.IgnoreFile("qbasicatomic.h"); - lib.IgnoreFile("qflags.h"); - lib.IgnoreFile("qglobal.h"); - lib.IgnoreFile("qstring.h"); - lib.IgnoreFile("qrefcount.h"); - lib.IgnoreFile("qtypeinfo.h"); - lib.IgnoreFile("qtypetraits.h"); - - lib.IgnoreClassWithName("QForeachContainer"); - lib.IgnoreClassWithName("QFlags"); - lib.IgnoreClassWithName("QUrlTwoFlags"); - - lib.SetClassAsValueType("QChar"); - lib.SetClassAsValueType("QPair"); - lib.SetClassAsValueType("QPoint"); - lib.SetClassAsValueType("QPointF"); - } - - public void Postprocess(Library lib) - { - } - - public void Setup(DriverOptions options) - { - options.LibraryName = "Qt"; - options.OutputNamespace = "Qt"; - options.OutputDir = @"C:\Users\triton\Development\cxxi\examples\qt\wrappers"; - options.IncludeDirs.Add(@"C:\Qt\Qt5.0.1\5.0.1\msvc2010\include"); - options.GeneratorKind = LanguageGeneratorKind.CPlusPlusCLI; - - SetupHeaders(options.Headers); - } - - public void SetupHeaders(List headers) - { - var sources = new string[] - { - "QtCore/QPoint", - "QtCore/QUrl", - }; - - headers.AddRange(sources); - } - - public void SetupPasses(PassBuilder p) - { - p.RemovePrefix("Q"); - - const RenameTargets renameTargets = RenameTargets.Function - | RenameTargets.Method | RenameTargets.Field; - p.RenameDeclsCase(renameTargets, RenameCasePattern.UpperCamelCase); - - p.FunctionToInstanceMethod(); - p.FunctionToStaticMethod(); - p.CheckDuplicateNames(); - } - - public void GenerateStart(TextTemplate template) - { - if (template is CLISourcesTemplate) - template.WriteLine("#include \"_Marshal.h\""); - } - - public void GenerateAfterNamespaces(TextTemplate template) - { - if (template is CLISourcesTemplate) - template.WriteLine("using namespace clix;"); - } - } - - static class Program - { - public static void Main(string[] args) - { - Cxxi.Program.Run(new Libraries.Qt()); - } - } -} diff --git a/examples/qt/cpp/qt-gui-filters.xml b/examples/qt/cpp/qt-gui-filters.xml deleted file mode 100644 index 48866a5d..00000000 --- a/examples/qt/cpp/qt-gui-filters.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - QObject - Qt - Qt::ConnectionType - Qt::KeyboardModifier - Qt::MouseButton - Qt::ButtonState - - QApplication - QCoreApplication - QWidget - QAbstractButton - QPushButton - QPaintDevice - - QEvent - QInputEvent - QMouseEvent - QTimerEvent - - QString - QSize - QPoint - QFlags<Qt::KeyboardModifier> - diff --git a/examples/qt/cpp/qt-gui.cpp b/examples/qt/cpp/qt-gui.cpp deleted file mode 100644 index 19a4bc32..00000000 --- a/examples/qt/cpp/qt-gui.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -/* - * These are not in the unix version of qt, and -fkeep-inline-functions will generate - * references to their vtables etc., making the library unloadable. - */ -#define QT_NO_STYLE_WINDOWSVISTA -#define QT_NO_STYLE_WINDOWSXP -#define QT_NO_STYLE_S60 -#define QT_NO_STYLE_WINDOWSCE -#define QT_NO_STYLE_WINDOWSMOBILE -#define QT_NO_QWSEMBEDWIDGET - -// this one was annoying to track down! -#define QT_NO_TRANSLATION - -#include "QtGui/QApplication" -#include "QtGui/QPushButton" - -int main () -{ -} diff --git a/examples/qt/cpp/qt-gui.h b/examples/qt/cpp/qt-gui.h deleted file mode 100644 index 958db03b..00000000 --- a/examples/qt/cpp/qt-gui.h +++ /dev/null @@ -1,3 +0,0 @@ -#include "QApplication" -#include "qevent.h" -#include "QPushButton" diff --git a/examples/qt/demos/hello.cs b/examples/qt/demos/hello.cs deleted file mode 100644 index dc52527b..00000000 --- a/examples/qt/demos/hello.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Diagnostics; -using Qt.Gui; -using Qt.Gui.Qt; - -using Mono.Cxxi; - -namespace QtTest { - class MainClass { - public static void Main (string[] args) - { - using (QApplication app = new QApplication ()) { - using (QPushButton hello = new QPushButton ("Hello world!")) { - - hello.Resize (200, 30); - QObject.Connect (hello, "2clicked()", app, "1aboutQt()", ConnectionType.AutoConnection); - - hello.SetVisible (true); - QApplication.Exec (); - } - } - } - } -} - diff --git a/examples/qt/premake4.lua b/examples/qt/premake4.lua deleted file mode 100644 index ce88ca10..00000000 --- a/examples/qt/premake4.lua +++ /dev/null @@ -1,11 +0,0 @@ -project "Qt" - - kind "ConsoleApp" - language "C#" - location "." - - files { "**.cs", "./*.lua" } - - links { "Bridge", "Generator" } - - diff --git a/examples/qt/src/QApplication.cs b/examples/qt/src/QApplication.cs deleted file mode 100644 index 99fb8336..00000000 --- a/examples/qt/src/QApplication.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Mono.Cxxi; - -namespace Qt.Gui { - public partial class QApplication { - - public partial interface IQApplication { - [Constructor] CppInstancePtr QApplication (CppInstancePtr @this, [MangleAs ("int&")] IntPtr argc, [MangleAs ("char**")] IntPtr argv, int version); - } - - public QApplication () : base (impl.TypeInfo) - { - InitArgcAndArgv (); - Native = impl.QApplication (impl.Alloc (this), argc, argv, 0x040602); - } - - } -} - diff --git a/examples/qt/src/QCoreApplication.cs b/examples/qt/src/QCoreApplication.cs deleted file mode 100644 index 399ee49b..00000000 --- a/examples/qt/src/QCoreApplication.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Mono.Cxxi; - -namespace Qt.Gui { - public partial class QCoreApplication { - - public partial interface IQCoreApplication { - [Constructor] CppInstancePtr QCoreApplication (CppInstancePtr @this, [MangleAs ("int&")] IntPtr argc, [MangleAs ("char**")] IntPtr argv); - } - - protected IntPtr argc, argv; - - public QCoreApplication () : base (impl.TypeInfo) - { - InitArgcAndArgv (); - Native = impl.QCoreApplication (impl.Alloc (this), argc, argv); - } - - partial void AfterDestruct () - { - FreeArgcAndArgv (); - } - - protected void InitArgcAndArgv () - { - var args = Environment.GetCommandLineArgs (); - var argCount = args.Length; - - argc = Marshal.AllocHGlobal (sizeof(int)); - Marshal.WriteInt32 (argc, argCount); - - argv = Marshal.AllocHGlobal (Marshal.SizeOf (typeof(IntPtr)) * argCount); - for (var i = 0; i < argCount; i++) { - IntPtr arg = Marshal.StringToHGlobalAnsi (args [i]); - Marshal.WriteIntPtr (argv, i * Marshal.SizeOf (typeof(IntPtr)), arg); - } - } - - protected void FreeArgcAndArgv () - { - Marshal.FreeHGlobal (argc); - for (var i = 0; i < Environment.GetCommandLineArgs ().Length; i++) - Marshal.FreeHGlobal (Marshal.ReadIntPtr (argv, i * Marshal.SizeOf (typeof(IntPtr)))); - Marshal.FreeHGlobal (argv); - } - - } -} - diff --git a/examples/qt/src/QFlags.cs b/examples/qt/src/QFlags.cs deleted file mode 100644 index eb796ded..00000000 --- a/examples/qt/src/QFlags.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Mono.Cxxi; - -namespace Qt.Gui { - - [StructLayout (LayoutKind.Sequential)] - public struct QFlags where T : struct { - - public T Value; - } -} - diff --git a/examples/qt/src/QPoint.cs b/examples/qt/src/QPoint.cs deleted file mode 100644 index 2cba62b2..00000000 --- a/examples/qt/src/QPoint.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Mono.Cxxi; - -namespace Qt.Gui { - - [StructLayout (LayoutKind.Sequential)] - public struct QPoint { - - private int xy, yx; //Wtf.. on Mac the order is y, x; elsewhere x, y - - public QPoint (int x, int y) - { - //FIXME: do some snazzy stuff to get this right.. for now, I'm a mac user :P - this.yx = x; - this.xy = y; - } - } -} - diff --git a/examples/qt/src/QPushButton.cs b/examples/qt/src/QPushButton.cs deleted file mode 100644 index 3e615fdf..00000000 --- a/examples/qt/src/QPushButton.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Mono.Cxxi; - -namespace Qt.Gui { - public partial class QPushButton { - - public QPushButton (QString text, QWidget parent) - : this (ref text, parent) - { - } - - public QPushButton (QString text) - : this (ref text, null) - { - } - - } -} - diff --git a/examples/qt/src/QSize.cs b/examples/qt/src/QSize.cs deleted file mode 100644 index a5b9eb7e..00000000 --- a/examples/qt/src/QSize.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Mono.Cxxi; - -namespace Qt.Gui { - - [StructLayout (LayoutKind.Sequential)] - public struct QSize { - - public int Width; - public int Height; - - public QSize (int w, int h) - { - this.Width = w; - this.Height = h; - } - } -} - diff --git a/examples/qt/src/QString.cs b/examples/qt/src/QString.cs deleted file mode 100644 index 1a326c07..00000000 --- a/examples/qt/src/QString.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Text; -using System.Runtime.InteropServices; - -using Mono.Cxxi; - -namespace Qt.Gui { - //TODO: Will this leak? - [StructLayout (LayoutKind.Sequential)] - public unsafe struct QString { - #region Sync with qstring.h - public interface IQString : ICppClass { - [Constructor] void QString(ref QString @this, [MangleAs ("const QChar*")] IntPtr unicode, int size); - } - - [StructLayout (LayoutKind.Sequential)] - public struct Data { - public int @ref; - public int alloc, size; - public IntPtr data; - public ushort clean; - public ushort simpletext; - public ushort righttoleft; - public ushort asciiCache; - public ushort capacity; - public ushort reserved; - public IntPtr array; - } - - - public Data* d; - #endregion - - private static IQString impl = Libs.QtGui.GetClass ("QString"); - - public QString (string str) : this () - { - var strPtr = Marshal.StringToHGlobalUni (str); - impl.QString (ref this, strPtr, str.Length); - Marshal.FreeHGlobal (strPtr); - - // TODO: I deref this on construction to let Qt free it when it's done with it. - // My assumption is that this struct will only be used to interop with Qt and - // no managed class is going to hold on to it. - this.DeRef (); - } - - public static implicit operator QString (string str) - { - return new QString (str); - } - - public override string ToString () - { - return Marshal.PtrToStringUni (d->data, d->size); - } - - public QString AddRef () - { - d->@ref++; - return this; - } - - public QString DeRef () - { - d->@ref--; - return this; - } - } -} - diff --git a/examples/qt/src/QWidget.cs b/examples/qt/src/QWidget.cs deleted file mode 100644 index b7a92c45..00000000 --- a/examples/qt/src/QWidget.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Mono.Cxxi; - -namespace Qt.Gui { - public partial class QWidget { - - public void Resize (int width, int height) - { - var size = new QSize (width, height); - impl.resize (Native, ref size); - } - - } -} -