From 6b2e558fd8b2f8434bcb264c9132a79ff920c136 Mon Sep 17 00:00:00 2001 From: triton Date: Wed, 27 Feb 2013 16:23:27 +0000 Subject: [PATCH] Added very preliminary bindings for some basic classes of Qt. --- examples/qt/Qt.cs | 96 ++++++++++++++++++++++++++++++++++++++++ examples/qt/premake4.lua | 11 +++++ 2 files changed, 107 insertions(+) create mode 100644 examples/qt/Qt.cs create mode 100644 examples/qt/premake4.lua diff --git a/examples/qt/Qt.cs b/examples/qt/Qt.cs new file mode 100644 index 00000000..307a4d45 --- /dev/null +++ b/examples/qt/Qt.cs @@ -0,0 +1,96 @@ +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/premake4.lua b/examples/qt/premake4.lua new file mode 100644 index 00000000..ce88ca10 --- /dev/null +++ b/examples/qt/premake4.lua @@ -0,0 +1,11 @@ +project "Qt" + + kind "ConsoleApp" + language "C#" + location "." + + files { "**.cs", "./*.lua" } + + links { "Bridge", "Generator" } + +