Esempio n. 1
0
        private void OnFileParsed(IEnumerable <string> files, CppSharp.Parser.ParserResult result)
        {
            switch (result.Kind)
            {
            case ParserResultKind.Success:
                if (!Options.Quiet)
                {
                    Diagnostics.Message("Parsed '{0}'", string.Join(", ", files));
                }

                break;

            case ParserResultKind.Error:
                Diagnostics.Error("Error parsing '{0}'", string.Join(", ", files));
                HasParsingErrors = true;
                break;

            case ParserResultKind.FileNotFound:
                Diagnostics.Error("File{0} not found: '{1}'"
                                  , (files.Count() > 1) ? "s" : string.Empty
                                  , string.Join(",", files)
                                  );
                HasParsingErrors = true;
                break;
            }

            for (uint i = 0; i < result.DiagnosticsCount; ++i)
            {
                var diag = result.GetDiagnostics(i);

                if (diag.Level == ParserDiagnosticLevel.Warning && !Options.Verbose)
                {
                    continue;
                }

                if (diag.Level == ParserDiagnosticLevel.Note)
                {
                    continue;
                }

                Diagnostics.Message("{0}({1},{2}): {3}: {4}"
                                    , diag.FileName
                                    , diag.LineNumber
                                    , diag.ColumnNumber
                                    , diag.Level.ToString().ToUpperInvariant()
                                    , diag.Message
                                    );
            }
        }
Esempio n. 2
0
        public bool ParseCode()
        {
            ClangParser.SourcesParsed += OnSourceFileParsed;

            var files = Options.Modules.SelectMany(m => m.Headers);

            ParserOptions.BuildForSourceFile(Options.Modules);

            using (CppSharp.Parser.ParserResult result = ClangParser.ParseSourceFiles(files, ParserOptions))
            {
                Context.TargetInfo = result.TargetInfo;
            }

            Context.ASTContext         = ClangParser.ConvertASTContext(ParserOptions.ASTContext);
            ClangParser.SourcesParsed -= OnSourceFileParsed;
            return(!HasParsingErrors);
        }
Esempio n. 3
0
 private void OnFileParsed(string file, CppSharp.Parser.ParserResult result)
 {
     OnFileParsed(new[] { file }, result);
 }
Esempio n. 4
0
 private void OnSourceFileParsed(IEnumerable <string> files, CppSharp.Parser.ParserResult result)
 {
     OnFileParsed(files, result);
 }