コード例 #1
0
        protected void ParseLibrary(params string[] files)
        {
            Options       = new DriverOptions();
            ParserOptions = new ParserOptions();

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

            ParserOptions.AddIncludeDirs(testsPath);

            var module = Options.AddModule("Test");

            module.Headers.AddRange(files);

            Driver = new Driver(Options)
            {
                ParserOptions = this.ParserOptions
            };

            Driver.Setup();
            Driver.BuildParseOptions();
            if (!Driver.ParseCode())
            {
                throw new Exception("Error parsing the code");
            }

            AstContext = Driver.Context.ASTContext;
            new CleanUnitPass {
                Context = Driver.Context
            }.VisitASTContext(AstContext);
            new ResolveIncompleteDeclsPass {
                Context = Driver.Context
            }.VisitASTContext(AstContext);
        }
コード例 #2
0
        /// Setup the driver options here.
        public virtual void Setup(Driver driver)
        {
            DriverOptions options = driver.Options;

            options.GeneratorKind            = GeneratorKind.CSharp;
            options.Verbose                  = this.Verbose;
            options.MarshalCharAsManagedChar = false;
            Module = options.AddModule(ModuleName);
            Module.OutputNamespace           = Namespace;
            options.OutputDir                = OutputDirName;
            options.GenerateSingleCSharpFile = true;
        }
コード例 #3
0
        private static IList <string> GetSymbols(string library)
        {
            var    driverOptions = new DriverOptions();
            Module module        = driverOptions.AddModule("Test");

            module.LibraryDirs.Add(GeneratorTest.GetTestsDirectory("Native"));
            module.Libraries.Add(library);
            using (var driver = new Driver(driverOptions))
            {
                driver.Setup();
                Assert.IsTrue(driver.ParseLibraries());
                return(driver.Context.Symbols.Libraries[0].Symbols);
            }
        }
コード例 #4
0
        protected void ParseLibrary(params string[] files)
        {
            if (files.Length == 0)
            {
                return;
            }

            var options = new DriverOptions {
                GeneratorKind = GeneratorKind.CSharp
            };

            var module = options.AddModule("Test");

            module.IncludeDirs.Add(GeneratorTest.GetTestsDirectory("Native"));
            module.Headers.AddRange(files);

            Driver = new Driver(options)
            {
                ParserOptions = new ParserOptions {
                    SkipPrivateDeclarations = true
                }
            };

            Driver.Setup();
            if (!Driver.ParseCode())
            {
                throw new Exception("Error parsing the code");
            }

            Driver.SetupTypeMaps();
            AstContext = Driver.Context.ASTContext;
            new CleanUnitPass {
                Context = Driver.Context
            }.VisitASTContext(AstContext);
            new ResolveIncompleteDeclsPass {
                Context = Driver.Context
            }.VisitASTContext(AstContext);

            Context          = new BindingContext(options, Driver.ParserOptions);
            Context.TypeMaps = new Types.TypeMapDatabase(Context);

            CppSharp.AST.Type.TypePrinterDelegate = type =>
            {
                PrimitiveType primitiveType;
                return(type.IsPrimitiveType(out primitiveType) ? primitiveType.ToString() : string.Empty);
            };
        }
コード例 #5
0
        /// Setup the driver options here.
        public void Setup(Driver driver)
        {
            DriverOptions options = driver.Options;

            options.GeneratorKind = GeneratorKind.CSharp;
            Module module = options.AddModule("jemalloc");

            module.Defines.AddRange(@"JEMALLOC_NO_PRIVATE_NAMESPACE;REENTRANT;WINDLL;DLLEXPORT;JEMALLOC_DEBUG;DEBUG".Split(';'));
            module.IncludeDirs.Add(@"..\..\jemalloc\include\jemalloc");
            module.IncludeDirs.Add(@"..\..\jemalloc\include\jemalloc\internal");
            module.IncludeDirs.Add(@"..\..\jemalloc\include\msvc_compat");
            module.IncludeDirs.Add(@".\");
            module.Headers.Add("jemalloc-win-msvc.h");
            module.LibraryDirs.Add(@".\");
            module.Libraries.Add("jemallocd.lib");
            module.OutputNamespace = "jemalloc";
            options.OutputDir      = @".\";
            options.Verbose        = true;
        }
コード例 #6
0
        private static IList <string> GetSymbols(string library)
        {
            var parserOptions = new ParserOptions();

            parserOptions.AddLibraryDirs(GeneratorTest.GetTestsDirectory("Native"));
            var driverOptions = new DriverOptions();
            var module        = driverOptions.AddModule("Test");

            module.Libraries.Add(library);
            var driver = new Driver(driverOptions)
            {
                ParserOptions = parserOptions
            };

            driver.Setup();
            Assert.IsTrue(driver.ParseLibraries());
            var symbols = driver.Context.Symbols.Libraries[0].Symbols;

            return(symbols);
        }
コード例 #7
0
ファイル: ASTTestFixture.cs プロジェクト: wenkeliu/CppSharp
        protected void ParseLibrary(params string[] files)
        {
            var options = new DriverOptions {
                GeneratorKind = GeneratorKind.CSharp
            };
            var parserOptions = new ParserOptions();

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

            parserOptions.AddIncludeDirs(testsPath);
            parserOptions.SkipPrivateDeclarations = true;

            var module = options.AddModule("Test");

            module.Headers.AddRange(files);

            Driver = new Driver(options)
            {
                ParserOptions = parserOptions
            };

            Driver.Setup();
            if (!Driver.ParseCode())
            {
                throw new Exception("Error parsing the code");
            }

            Driver.SetupTypeMaps();
            AstContext = Driver.Context.ASTContext;
            new CleanUnitPass {
                Context = Driver.Context
            }.VisitASTContext(AstContext);
            new ResolveIncompleteDeclsPass {
                Context = Driver.Context
            }.VisitASTContext(AstContext);
        }