Example #1
0
 public override void Preprocess(Driver driver, ASTContext ctx)
 {
     ctx.SetClassAsValueType("Bar");
     ctx.SetClassAsValueType("Bar2");
     ctx.SetMethodParameterUsage("Hello", "TestPrimitiveOut", 1, ParameterUsage.Out);
     ctx.SetMethodParameterUsage("Hello", "TestPrimitiveOutRef", 1, ParameterUsage.Out);
 }
Example #2
0
 public void Preprocess(Driver driver, ASTContext lib)
 {
     string qtModule = "Qt" + this.module;
     string moduleIncludes = Path.Combine(this.includePath, qtModule);
     foreach (TranslationUnit unit in lib.TranslationUnits.Where(u => u.FilePath != "<invalid>"))
     {
         if (Path.GetDirectoryName(unit.FilePath) != moduleIncludes)
         {
             unit.ExplicityIgnored = true;
         }
         else
         {
             IgnorePrivateDeclarations(unit);
         }
     }
     lib.SetClassAsValueType("QByteArray");
     lib.SetClassAsValueType("QListData");
     lib.SetClassAsValueType("QListData::Data");
     lib.SetClassAsValueType("QLocale");
     lib.SetClassAsValueType("QModelIndex");
     lib.SetClassAsValueType("QPoint");
     lib.SetClassAsValueType("QPointF");
     lib.SetClassAsValueType("QSize");
     lib.SetClassAsValueType("QSizeF");
     lib.SetClassAsValueType("QRect");
     lib.SetClassAsValueType("QRectF");
     lib.SetClassAsValueType("QGenericArgument");
     lib.SetClassAsValueType("QVariant");
     // TODO: remove these when their symbols have been replaced or included
     lib.IgnoreClassMethodWithName("QXmlStreamReader", "attributes");
     lib.IgnoreClassMethodWithName("QTimeZone", "offsetData");
     lib.IgnoreClassMethodWithName("QTimeZone", "nextTransition");
     lib.IgnoreClassMethodWithName("QTimeZone", "previousTransition");
 }
Example #3
0
 public override void Preprocess(Driver driver, ASTContext ctx)
 {
     driver.AddTranslationUnitPass(new GetterSetterToPropertyPass());
     driver.AddTranslationUnitPass(new CheckMacroPass());
     ctx.SetClassAsValueType("Bar");
     ctx.SetClassAsValueType("Bar2");
 }
Example #4
0
        public void Preprocess(Driver driver, ASTContext ctx)
        {
            ctx.IgnoreEnumWithMatchingItem("SDL_FALSE");
            ctx.IgnoreEnumWithMatchingItem("DUMMY_ENUM_VALUE");

            ctx.SetNameOfEnumWithMatchingItem("SDL_SCANCODE_UNKNOWN", "ScanCode");
            ctx.SetNameOfEnumWithMatchingItem("SDLK_UNKNOWN", "Key");
            ctx.SetNameOfEnumWithMatchingItem("KMOD_NONE", "KeyModifier");
            ctx.SetNameOfEnumWithMatchingItem("SDL_LOG_CATEGORY_CUSTOM", "LogCategory");

            ctx.GenerateEnumFromMacros("InitFlags", "SDL_INIT_(.*)").SetFlags();
            ctx.GenerateEnumFromMacros("Endianness", "SDL_(.*)_ENDIAN");
            ctx.GenerateEnumFromMacros("InputState", "SDL_RELEASED", "SDL_PRESSED");
            ctx.GenerateEnumFromMacros("AlphaState", "SDL_ALPHA_(.*)");
            ctx.GenerateEnumFromMacros("HatState", "SDL_HAT_(.*)");

            ctx.IgnoreHeadersWithName("SDL_atomic*");
            ctx.IgnoreHeadersWithName("SDL_endian*");
            ctx.IgnoreHeadersWithName("SDL_main*");
            ctx.IgnoreHeadersWithName("SDL_mutex*");
            ctx.IgnoreHeadersWithName("SDL_stdinc*");
            ctx.IgnoreHeadersWithName("SDL_error");

            ctx.IgnoreEnumWithMatchingItem("SDL_ENOMEM");
            ctx.IgnoreFunctionWithName("SDL_Error");
        }
Example #5
0
        public virtual bool VisitASTContext(ASTContext context)
        {
            foreach (var unit in context.TranslationUnits)
                VisitTranslationUnit(unit);

            return true;
        }
Example #6
0
        public virtual bool VisitLibrary(ASTContext context)
        {
            AstContext = context;
            foreach (var unit in context.TranslationUnits)
                VisitTranslationUnit(unit);

            return true;
        }
 public override bool VisitLibrary(ASTContext context)
 {
     bool result = base.VisitLibrary(context);
     Directory.CreateDirectory(Driver.Options.OutputDir);
     WriteInlinesIncludes();
     WriteInlinedSymbols();
     return result;
 }
Example #8
0
        public void Preprocess(Driver driver, ASTContext lib)
        {
            lib.SetClassAsValueType("CppSharp::ParserOptions");
            lib.SetClassAsValueType("CppSharp::ParserDiagnostic");
            lib.SetClassAsValueType("CppSharp::ParserResult");

            lib.RenameNamespace("CppSharp::CppParser", "Parser");
        }
Example #9
0
        public override void Preprocess(Driver driver, ASTContext ctx)
        {
            ctx.SetClassAsValueType("TestCopyConstructorVal");
            ctx.SetClassAsValueType("QGenericArgument");
            ctx.SetClassAsValueType("StructWithPrivateFields");
            ctx.SetClassAsValueType("QSize");

            ctx.IgnoreClassWithName("IgnoredTypeInheritingNonIgnoredWithNoEmptyCtor");
        }
Example #10
0
 public void Postprocess(Driver driver, ASTContext lib)
 {
     CollectTypeDefsPerTypePass collectTypeDefsPerTypePass = new CollectTypeDefsPerTypePass();
     collectTypeDefsPerTypePass.VisitLibrary(driver.ASTContext);
     new ClearCommentsPass().VisitLibrary(driver.ASTContext);
     new GetCommentsFromQtDocsPass(this.docs, this.module, collectTypeDefsPerTypePass.TypeDefsPerType).VisitLibrary(driver.ASTContext);
     new CaseRenamePass(
         RenameTargets.Function | RenameTargets.Method | RenameTargets.Property | RenameTargets.Delegate | RenameTargets.Field,
         RenameCasePattern.UpperCamelCase).VisitLibrary(driver.ASTContext);
 }
Example #11
0
 public override void Preprocess(Driver driver, ASTContext ctx)
 {
     foreach (TranslationUnit unit in ctx.TranslationUnits)
     {
         if (unit.FileName != "NamespacesDerived.h")
         {
             unit.GenerationKind = GenerationKind.Link;
         }
     }
 }
Example #12
0
        public override void Preprocess(Driver driver, ASTContext ctx)
        {
            driver.AddTranslationUnitPass(new CheckMacroPass());
            ctx.SetClassAsValueType("Bar");
            ctx.SetClassAsValueType("Bar2");
            ctx.IgnoreClassWithName("IgnoredType");

            ctx.FindCompleteClass("Foo").Enums.First(
                e => string.IsNullOrEmpty(e.Name)).Name = "RenamedEmptyEnum";
        }
Example #13
0
 public override void Postprocess(Driver driver, ASTContext ctx)
 {
     // HACK: as seen above, GetterSetterToPropertyPass is called before all other passes
     // that is a hack in order for the pass to generate properties in Common.h
     // it is incapable of generating them in the proper manner
     // so it generates a property in system type from a member which is later ignored
     // so let's ignore that property manually
     var @class = ctx.FindCompleteClass("basic_string");
     foreach (var property in @class.Specializations.SelectMany(c => c.Properties))
         property.ExplicitlyIgnore();
 }
Example #14
0
 public Driver(DriverOptions options, IDiagnosticConsumer diagnostics)
 {
     Options = options;
     Diagnostics = diagnostics;
     Project = new Project();
     ASTContext = new ASTContext();
     Symbols = new SymbolContext();
     Delegates = new Dictionary<Function, DelegatesPass.DelegateDefinition>();
     TypeDatabase = new TypeMapDatabase();
     TranslationUnitPasses = new PassBuilder<TranslationUnitPass>(this);
     GeneratorOutputPasses = new PassBuilder<GeneratorOutputPass>(this);
 }
Example #15
0
 public override void Preprocess(Driver driver, ASTContext ctx)
 {
     driver.AddTranslationUnitPass(new GetterSetterToPropertyPass());
     ctx.SetClassAsValueType("Bar");
     ctx.SetClassAsValueType("Bar2");
     ctx.SetMethodParameterUsage("Hello", "TestPrimitiveOut", 1, ParameterUsage.Out);
     ctx.SetMethodParameterUsage("Hello", "TestPrimitiveOutRef", 1, ParameterUsage.Out);
     ctx.SetMethodParameterUsage("Hello", "TestPrimitiveInOut", 1, ParameterUsage.InOut);
     ctx.SetMethodParameterUsage("Hello", "TestPrimitiveInOutRef", 1, ParameterUsage.InOut);
     ctx.SetMethodParameterUsage("Hello", "EnumOut", 2, ParameterUsage.Out);
     ctx.SetMethodParameterUsage("Hello", "EnumOutRef", 2, ParameterUsage.Out);
 }
Example #16
0
        public void Preprocess(Driver driver, ASTContext ctx)
        {
            ctx.RenameNamespace("CppSharp::CppParser", "Parser");

            var exprClass = ctx.FindCompleteClass ("clang::Expr");

            var exprUnit = ctx.TranslationUnits [0];
            var subclassVisitor = new SubclassVisitor (exprClass);
            exprUnit.Visit (subclassVisitor);

            var subclasses = subclassVisitor.Classes;
        }
Example #17
0
 public void Postprocess(Driver driver, ASTContext ctx)
 {
     ctx.SetNameOfEnumWithName("PIXELTYPE", "PixelType");
     ctx.SetNameOfEnumWithName("BITMAPORDER", "BitmapOrder");
     ctx.SetNameOfEnumWithName("PACKEDORDER", "PackedOrder");
     ctx.SetNameOfEnumWithName("ARRAYORDER", "ArrayOrder");
     ctx.SetNameOfEnumWithName("PACKEDLAYOUT", "PackedLayout");
     ctx.SetNameOfEnumWithName("PIXELFORMAT", "PixelFormats");
     ctx.SetNameOfEnumWithName("assert_state", "AssertState");
     ctx.SetClassBindName("assert_data", "AssertData");
     ctx.SetNameOfEnumWithName("eventaction", "EventAction");
     ctx.SetNameOfEnumWithName("LOG_CATEGORY", "LogCategory");
 }
Example #18
0
 public void Preprocess(Driver driver, ASTContext lib)
 {
     var qtModule = "Qt" + this.module;
     var moduleIncludes = Path.Combine(this.includePath, qtModule);
     foreach (var unit in lib.TranslationUnits.Where(u => u.FilePath != "<invalid>"))
     {
         if (Path.GetDirectoryName(unit.FilePath) != moduleIncludes)
         {
             LinkDeclaration(unit);
         }
         else
         {
             IgnorePrivateDeclarations(unit);
         }
     }
     lib.SetClassAsValueType("QByteArray");
     lib.SetClassAsValueType("QListData");
     lib.SetClassAsValueType("QListData::Data");
     lib.SetClassAsValueType("QLocale");
     lib.SetClassAsValueType("QModelIndex");
     lib.SetClassAsValueType("QPoint");
     lib.SetClassAsValueType("QPointF");
     lib.SetClassAsValueType("QSize");
     lib.SetClassAsValueType("QSizeF");
     lib.SetClassAsValueType("QRect");
     lib.SetClassAsValueType("QRectF");
     lib.SetClassAsValueType("QGenericArgument");
     lib.SetClassAsValueType("QGenericReturnArgument");
     lib.SetClassAsValueType("QVariant");
     lib.IgnoreClassMethodWithName("QString", "fromStdWString");
     lib.IgnoreClassMethodWithName("QString", "toStdWString");
     if (this.module == "Widgets")
     {
         // HACK: work around https://llvm.org/bugs/show_bug.cgi?id=24655
         foreach (var method in lib.FindCompleteClass("QAbstractSlider").Methods.Where(m => m.Access == AccessSpecifier.Protected))
         {
             method.AccessDecl.PreprocessedEntities.Clear();
         }
         string[] classesWithTypeEnums =
         {
             "QGraphicsEllipseItem", "QGraphicsItemGroup", "QGraphicsLineItem",
             "QGraphicsPathItem", "QGraphicsPixmapItem", "QGraphicsPolygonItem", "QGraphicsProxyWidget",
             "QGraphicsRectItem", "QGraphicsSimpleTextItem", "QGraphicsTextItem", "QGraphicsWidget"
         };
         foreach (var enumeration in classesWithTypeEnums.Select(c => lib.FindCompleteClass(c)).SelectMany(
             @class => @class.Enums.Where(e => string.IsNullOrEmpty(e.Name))))
         {
             enumeration.Name = "TypeEnum";
         }
     }
 }
Example #19
0
        protected void ParseLibrary(string file)
        {
            Options = new DriverOptions();

            var testsPath = LibraryTest.GetTestsDirectory("Native");
            Options.IncludeDirs.Add(testsPath);
            Options.Headers.Add(file);

            Driver = new Driver(Options, new TextDiagnosticPrinter());
            if (!Driver.ParseCode())
                throw new Exception("Error parsing the code");

            AstContext = Driver.ASTContext;
        }
        public override bool VisitASTContext(ASTContext context)
        {
            bool result = base.VisitASTContext(context);

            foreach (var typedef in allTypedefs)
            {
                foreach (var foo in typedef.Value)
                {
                    foo.Context.Declarations.Add(foo.Declaration);
                }
            }
            allTypedefs.Clear();

            return result;
        }
Example #21
0
        public override bool VisitLibrary(ASTContext context)
        {
            foreach (var library in Driver.Options.Libraries.Where(l => !libsDelegates.ContainsKey(l)))
                libsDelegates.Add(library, new Dictionary<string, DelegateDefinition>());

            var unit = context.TranslationUnits.Last(u => u.IsValid && u.IsGenerated &&
                !u.IsSystemHeader && u.HasDeclarations);
            namespaceDelegates = new Namespace { Name = DelegatesNamespace, Namespace = unit };

            var result = base.VisitLibrary(context);

            if (namespaceDelegates.Declarations.Count > 0)
                unit.Declarations.Add(namespaceDelegates);

            return result;
        }
Example #22
0
        protected void ParseLibrary(params string[] files)
        {
            Options = new DriverOptions();

            var testsPath = GeneratorTest.GetTestsDirectory("Native");
            Options.addIncludeDirs(testsPath);

            Options.Headers.AddRange(files);

            Driver = new Driver(Options, new TextDiagnosticPrinter());
            Driver.BuildParseOptions();
            if (!Driver.ParseCode())
                throw new Exception("Error parsing the code");

            AstContext = Driver.ASTContext;
        }
Example #23
0
        public override bool VisitASTContext(ASTContext context)
        {
            foreach (var library in Options.Modules.SelectMany(m => m.Libraries))
                libsDelegates[library] = new Dictionary<string, DelegateDefinition>();

            var unit = context.TranslationUnits.GetGenerated().LastOrDefault();

            if (unit == null)
                return false;

            var result = base.VisitASTContext(context);

            foreach (var module in Options.Modules.Where(m => namespacesDelegates.ContainsKey(m)))
                module.Units.Last(u => u.HasDeclarations).Declarations.Add(namespacesDelegates[module]);

            return result;
        }
Example #24
0
 public override bool VisitLibrary(ASTContext library)
 {
     bool result = base.VisitLibrary(library);
     string pro = string.Format("{0}.pro", this.Driver.Options.InlinesLibraryName);
     string path = Path.Combine(this.Driver.Options.OutputDir, pro);
     StringBuilder proBuilder = new StringBuilder();
     proBuilder.Append("QT += widgets\n");
     // HACK: work around https://bugreports.qt.io/browse/QTBUG-47569
     if (this.Driver.Options.InlinesLibraryName.StartsWith("QtWidgets"))
     {
         proBuilder.Append("DEFINES += QT_NO_ACCESSIBILITY\n");
     }
     proBuilder.Append("QMAKE_CXXFLAGS += -fkeep-inline-functions -std=c++0x\n");
     proBuilder.AppendFormat("TARGET = {0}\n", this.Driver.Options.InlinesLibraryName);
     proBuilder.Append("TEMPLATE = lib\n");
     proBuilder.AppendFormat("SOURCES += {0}\n", Path.ChangeExtension(pro, "cpp"));
     if (Environment.OSVersion.Platform == PlatformID.Win32NT)
     {
         proBuilder.Append("LIBS += -loleaut32 -lole32");
     }
     File.WriteAllText(path, proBuilder.ToString());
     string error;
     ProcessHelper.Run(this.qmake, string.Format("\"{0}\"", path), out error);
     if (!string.IsNullOrEmpty(error))
     {
         Console.WriteLine(error);
         return false;
     }
     ProcessHelper.Run(this.make, "-f Makefile.Release", out error, true);
     if (!string.IsNullOrEmpty(error))
     {
         Console.WriteLine(error);
         return false;
     }
     var parserOptions = new ParserOptions();
     parserOptions.addLibraryDirs(Path.Combine(this.Driver.Options.OutputDir, "release"));
     parserOptions.FileName = Path.GetFileName(string.Format("lib{0}.a", Path.GetFileNameWithoutExtension(pro)));
     var parserResult = ClangParser.ParseLibrary(parserOptions);
     if (parserResult.Kind == ParserResultKind.Success)
     {
         var nativeLibrary = CppSharp.ClangParser.ConvertLibrary(parserResult.Library);
         this.Driver.Symbols.Libraries.Add(nativeLibrary);
         this.Driver.Symbols.IndexSymbols();
     }
     return result;
 }
 public override bool VisitLibrary(ASTContext context)
 {
     var result = base.VisitLibrary(context);
     foreach (var entry in movedClassTemplates)
     {
         foreach (var template in entry.Value)
         {
             foreach (var decl in new[] { template, template.TemplatedDecl })
             {
                 int index = entry.Key.Declarations.IndexOf(decl.Namespace);
                 decl.Namespace.Declarations.Remove(decl);
                 decl.Namespace = entry.Key;
                 entry.Key.Declarations.Insert(index, decl);
             }
         }
     }
     return result;
 }
Example #26
0
 public override bool VisitASTContext(ASTContext context)
 {
     string error;
     const string qtVersionVariable = "QT_VERSION";
     var qtVersion = ProcessHelper.Run(this.qmake, string.Format("-query {0}", qtVersionVariable), out error);
     var qtVersionFile = Path.Combine(this.Context.Options.OutputDir, qtVersionVariable);
     var qtVersionFileInfo = new FileInfo(qtVersionFile);
     var text = string.Empty;
     if (!qtVersionFileInfo.Exists || (text = File.ReadAllText(qtVersionFile)) != qtVersion)
     {
         File.WriteAllText(qtVersionFile, qtVersion);
         qtVersionFileInfo = new FileInfo(qtVersionFile);
     }
     var dir = Platform.IsMacOS ? this.Context.Options.OutputDir : Path.Combine(this.Context.Options.OutputDir, "release");
     foreach (var module in this.Context.Options.Modules)
     {
         var inlines = Path.GetFileName(string.Format("{0}{1}.{2}", Platform.IsWindows ? string.Empty : "lib",
             module.InlinesLibraryName, Platform.IsMacOS ? "dylib" : "dll"));
         var libFile = Path.Combine(dir, inlines);
         var inlinesFileInfo = new FileInfo(libFile);
         if (!inlinesFileInfo.Exists || qtVersionFileInfo.LastWriteTimeUtc > inlinesFileInfo.LastWriteTimeUtc)
         {
             if (!this.CompileInlines(module))
             {
                 continue;
             }
         }
         var parserOptions = new ParserOptions();
         parserOptions.AddLibraryDirs(dir);
         parserOptions.LibraryFile = inlines;
         using (var parserResult = CppSharp.Parser.ClangParser.ParseLibrary(parserOptions))
         {
             if (parserResult.Kind == ParserResultKind.Success)
             {
                 var nativeLibrary = CppSharp.ClangParser.ConvertLibrary(parserResult.Library);
                 this.Context.Symbols.Libraries.Add(nativeLibrary);
                 this.Context.Symbols.IndexSymbols();
                 parserResult.Library.Dispose();
             }
         }
     }
     return true;
 }
Example #27
0
 public void Postprocess(Driver driver, ASTContext lib)
 {
     new ClearCommentsPass().VisitLibrary(driver.ASTContext);
     new GetCommentsFromQtDocsPass(this.docs, this.module).VisitLibrary(driver.ASTContext);
     new CaseRenamePass(
         RenameTargets.Function | RenameTargets.Method | RenameTargets.Property | RenameTargets.Delegate |
         RenameTargets.Field | RenameTargets.Variable,
         RenameCasePattern.UpperCamelCase).VisitLibrary(driver.ASTContext);
     switch (this.module)
     {
         case "Core":
             var qChar = lib.FindCompleteClass("QChar");
             qChar.FindOperator(CXXOperatorKind.ExplicitConversion)
                 .First(o => o.Parameters[0].Type.IsPrimitiveType(PrimitiveType.Char))
                 .ExplicitlyIgnore();
             qChar.FindOperator(CXXOperatorKind.Conversion)
                 .First(o => o.Parameters[0].Type.IsPrimitiveType(PrimitiveType.Int))
                 .ExplicitlyIgnore();
             break;
     }
 }
 public override bool VisitLibrary(ASTContext library)
 {
     bool result = base.VisitLibrary(library);
     string pro = string.Format("{0}.pro", this.Driver.Options.InlinesLibraryName);
     string path = Path.Combine(this.Driver.Options.OutputDir, pro);
     StringBuilder proBuilder = new StringBuilder();
     proBuilder.Append("QMAKE_CXXFLAGS += -fkeep-inline-functions -std=c++0x\n");
     proBuilder.AppendFormat("TARGET = {0}\n", Path.GetFileNameWithoutExtension(pro));
     proBuilder.Append("TEMPLATE = lib\n");
     string cpp = Path.ChangeExtension(pro, "cpp");
     string inlinesCode = File.ReadAllText(cpp);
     File.WriteAllText(cpp, inlinesCode.Replace("#include \"qatomic_msvc.h\"", string.Empty));
     proBuilder.AppendFormat("SOURCES += {0}\n", cpp);
     File.WriteAllText(path, proBuilder.ToString());
     string error;
     ProcessHelper.Run(this.qmake, string.Format("\"{0}\"", path), out error);
     if (!string.IsNullOrEmpty(error))
     {
         Console.WriteLine(error);
         return false;
     }
     ProcessHelper.Run(this.make, "-f Makefile.Release", out error);
     if (!string.IsNullOrEmpty(error))
     {
         Console.WriteLine(error);
         return false;
     }
     this.Driver.Options.LibraryDirs.Add(Path.Combine(this.Driver.Options.OutputDir, "release"));
     this.Driver.Options.Libraries.Add(string.Format("lib{0}.a", Path.GetFileNameWithoutExtension(pro)));
     this.Driver.ParseLibraries();
     NativeLibrary inlines = this.Driver.Symbols.Libraries.Last();
     foreach (string symbol in this.Driver.Symbols.Libraries.Take(
         this.Driver.Symbols.Libraries.Count - 1).SelectMany(
             nativeLibrary => nativeLibrary.Symbols))
     {
         inlines.Symbols.Remove(symbol);
     }
     this.Driver.Symbols.IndexSymbols();
     return result;
 }
Example #29
0
        public void Postprocess(Driver driver, ASTContext lib)
        {
            new ClearCommentsPass().VisitASTContext(driver.Context.ASTContext);
            var modules = this.qtInfo.LibFiles.Select(l => GetModuleNameFromLibFile(l));
            var s = System.Diagnostics.Stopwatch.StartNew();
            new GetCommentsFromQtDocsPass(this.qtInfo.Docs, modules).VisitASTContext(driver.Context.ASTContext);
            System.Console.WriteLine("Documentation done in: {0}", s.Elapsed);
            new CaseRenamePass(
                RenameTargets.Function | RenameTargets.Method | RenameTargets.Property | RenameTargets.Delegate |
                RenameTargets.Field | RenameTargets.Variable,
                RenameCasePattern.UpperCamelCase).VisitASTContext(driver.Context.ASTContext);

            var qChar = lib.FindCompleteClass("QChar");
            var op = qChar.FindOperator(CXXOperatorKind.ExplicitConversion)
                .FirstOrDefault(o => o.Parameters[0].Type.IsPrimitiveType(PrimitiveType.Char));
            if (op != null)
                op.ExplicitlyIgnore();
            op = qChar.FindOperator(CXXOperatorKind.Conversion)
                .FirstOrDefault(o => o.Parameters[0].Type.IsPrimitiveType(PrimitiveType.Int));
            if (op != null)
                op.ExplicitlyIgnore();
            // QString is type-mapped to string so we only need two methods for the conversion
            // go through the methods a second time to ignore free operators moved to the class
            var qString = lib.FindCompleteClass("QString");
            foreach (var method in qString.Methods.Where(
                m => !m.Ignore && m.OriginalName != "utf16" && m.OriginalName != "fromUtf16"))
            {
                method.ExplicitlyIgnore();
            }

            foreach (var module in driver.Options.Modules)
            {
                var prefix = Platform.IsWindows ? string.Empty : "lib";
                var extension = Platform.IsWindows ? ".dll" : Platform.IsMacOS ? ".dylib" : ".so";
                var inlinesLibraryFile = string.Format("{0}{1}{2}", prefix, module.InlinesLibraryName, extension);
                var inlinesLibraryPath = Path.Combine(driver.Options.OutputDir, Platform.IsWindows ? "release" : string.Empty, inlinesLibraryFile);
                this.wrappedModules.Add(new KeyValuePair<string, string>(module.LibraryName + ".dll", inlinesLibraryPath));
            }
        }
Example #30
0
        public void Preprocess(Driver driver, ASTContext ctx)
        {
            ctx.IgnoreHeadersWithName("lldb/lldb-forward.h");
            ctx.IgnoreHeadersWithName("lldb/API/SBDefines.h");

            ctx.SetMethodParameterUsage("lldb::SBTarget", "Launch", 2, 2, ParameterUsage.Out);
            ctx.SetMethodParameterUsage("lldb::SBTarget", "Launch", 10, 10, ParameterUsage.Out);

            ctx.RemoveEnumItemsPrefix("lldb::StateType", "eState");
            ctx.RemoveEnumItemsPrefix("lldb::LaunchFlags", "eLaunchFlag");
            ctx.RemoveEnumItemsPrefix("lldb::RunMode", "e");
            ctx.RemoveEnumItemsPrefix("lldb::ExpressionResults", "eExpression");
            ctx.RemoveEnumItemsPrefix("lldb::SymbolContextItem", "eSymbolContext");
            ctx.RemoveEnumItemsPrefix("lldb::InputReaderAction", "eInputReader");
            ctx.RemoveEnumItemsPrefix("lldb::DynamicValueType", "e");
            ctx.RemoveEnumItemsPrefix("lldb::InputReaderAction", "eInputReader");
            ctx.RemoveEnumItemsPrefix("lldb::AccessType", "eAccess");
            ctx.RemoveEnumItemsPrefix("lldb::CommandArgumentType", "eArgType");
            ctx.RemoveEnumItemsPrefix("lldb::EmulateInstructionOptions", "eEmulateInstructionOption");
            ctx.RemoveEnumItemsPrefix("lldb::TypeOptions", "eTypeOption");
            ctx.RemoveEnumItemsPrefix("lldb::FrameComparison", "eFrameCompare");
            ctx.RemoveEnumItemsPrefix("lldb::ExpressionEvaluationPhase", "eExpressionEvaluation");
            ctx.RemoveEnumItemsPrefix("lldb::TypeFlags", "eType");
            ctx.RemoveEnumItemsPrefix("lldb::CommandFlags", "eCommand");
            ctx.RemoveEnumItemsPrefix("lldb::TypeSummaryCapping", "eTypeSummary");

            ctx.SetNameOfClassMethod("lldb::SBError", "GetError", "GetErrorCode");
            ctx.SetNameOfClassMethod("lldb::SBValue", "GetValue", "GetValueAsString");

            ctx.GenerateEnumFromMacros("BreakpointId", "LLDB_BREAK_*", "LLDB_INVALID_BREAK_ID",
                "LLDB_DEFAULT_BREAK_SIZE");
            ctx.GenerateEnumFromMacros("WatchpointId", "LLDB_WATCH_*", "LLDB_INVALID_WATCH_ID");
            ctx.GenerateEnumFromMacros("GenericRegister", "LLDB_REGNUM_GENERIC_*");
            ctx.GenerateEnumFromMacros("InvalidValue", "LLDB_INVALID_*");
            ctx.GenerateEnumFromMacros("CPUType", "LLDB_ARCH_*", "LLDB_INVALID_CPUTYPE");
            ctx.GenerateEnumFromMacros("OptionSet", "LDB_OPT_SET_*", "LLDB_MAX_NUM_OPTION_SETS");

            ctx.RenameNamespace("lldb", "LLDB");
        }