Example #1
0
        public bool ParseCode()
        {
            foreach (var header in Options.Headers)
            {
                var source = Project.AddFile(header);
                source.Options = BuildParseOptions(source);
            }

#if !OLD_PARSER
            var parser = new ClangParser(new Parser.AST.ASTContext());
#else
            var parser = new ClangParser(ASTContext);
#endif

            parser.SourceParsed += OnSourceFileParsed;
            parser.ParseProject(Project, Options);

            TargetInfo = parser.GetTargetInfo(Options);

#if !OLD_PARSER
            ASTContext = ClangParser.ConvertASTContext(parser.ASTContext);
#endif

            return(true);
        }
Example #2
0
        private ASTContext ParseInternal(string[] sourceFiles)
        {
            var parserOptions = new ParserOptions
            {
                Verbose         = true,
                ASTContext      = new CppSharp.Parser.AST.ASTContext(),
                LanguageVersion = LanguageVersion.GNUC
            };

            parserOptions.SetupIncludes();

            foreach (var includeDir in IncludeDirs)
            {
                parserOptions.AddIncludeDirs(includeDir);
            }

            foreach (var define in Defines)
            {
                parserOptions.AddDefines(define);
            }

            var project = new Project();

            foreach (var filePath in sourceFiles)
            {
                var sourceFile = project.AddFile(filePath);
                sourceFile.Options = parserOptions;
            }

            var clangParser = new ClangParser(new CppSharp.Parser.AST.ASTContext());

            clangParser.SourcesParsed += OnSourceFileParsed;
            clangParser.ParseProject(project, false);
            return(ClangParser.ConvertASTContext(clangParser.ASTContext));
        }
Example #3
0
        public void ParseHeader(string file)
        {
            var parserProject = new Project();
            var parser        = new CppSharp.ClangParser();
            var sourceFile    = parserProject.AddFile(file);
            var options       = new ParserOptions();

            parser.SourcesParsed = OnParserResult;

            options.SetupMSVC(VisualStudioVersion.VS2012);

            foreach (var includeDirectory in includeDirectories.Values)
            {
                options.addSystemIncludeDirs(includeDirectory.FullName);
            }

            sourceFile.Options = options;

            try
            {
                parser.ParseProject(parserProject, false);
            }
            catch (Exception ex)
            {
                SetDiagnosticsStatus("Error parsing {0}, Error:{1}", file, ex.Message);
            }

            parser.ASTContext.Dispose();

            entities.SaveChanges();
        }
Example #4
0
        public bool ParseCode()
        {
            var parser = new ClangParser(new Parser.AST.ASTContext());

            parser.SourcesParsed += OnSourceFileParsed;
            parser.ParseProject(Project, Options.UnityBuild);

            Context.TargetInfo = parser.GetTargetInfo(ParserOptions);
            Context.ASTContext = ClangParser.ConvertASTContext(parser.ASTContext);

            return(!hasParsingErrors);
        }
Example #5
0
        public bool ParseCode()
        {
            var parser = new ClangParser(new Parser.AST.ASTContext());

            parser.SourceParsed += OnSourceFileParsed;
            parser.ParseProject(Project);

            TargetInfo = parser.GetTargetInfo(Options);

            ASTContext = ClangParser.ConvertASTContext(parser.ASTContext);

            return(true);
        }
Example #6
0
        public bool ParseCode()
        {
            var parser = new ClangParser(new Parser.AST.ASTContext());

            parser.SourcesParsed += OnSourceFileParsed;
            parser.ParseProject(Project, Options.UnityBuild);

            foreach (var source in Project.Sources.Where(s => s.Options != null))
            {
                source.Options.Dispose();
            }

            Context.TargetInfo = parser.GetTargetInfo(ParserOptions);
            Context.ASTContext = ClangParser.ConvertASTContext(parser.ASTContext);

            return(!hasParsingErrors);
        }
Example #7
0
        public bool ParseCode()
        {
            var parser = new ClangParser(new Parser.AST.ASTContext());

            parser.SourceParsed += OnSourceFileParsed;
            parser.ParseProject(Project);

            TargetInfo = parser.GetTargetInfo(Options);

            ASTContext = ClangParser.ConvertASTContext(parser.ASTContext);

            return true;
        }
Example #8
0
        public bool ParseCode()
        {
            var parser = new ClangParser(new Parser.AST.ASTContext());

            parser.SourcesParsed += OnSourceFileParsed;
            parser.ParseProject(Project, Options.UnityBuild);

            TargetInfo = parser.GetTargetInfo(Options);

            ASTContext = ClangParser.ConvertASTContext(parser.ASTContext);

            return !hasParsingErrors;
        }
Example #9
0
        public bool ParseCode()
        {
            foreach (var header in Options.Headers)
            {
                var source = Project.AddFile(header);
                source.Options = BuildParseOptions(source);
            }

            #if !OLD_PARSER
            var parser = new ClangParser(new Parser.AST.ASTContext());
            #else
            var parser = new ClangParser(ASTContext);
            #endif

            parser.SourceParsed += OnSourceFileParsed;
            parser.ParseProject(Project, Options);

            TargetInfo = parser.GetTargetInfo(Options);

            #if !OLD_PARSER
            ASTContext = ClangParser.ConvertASTContext(parser.ASTContext);
            #endif

            return true;
        }