diff --git a/src/Core/Parser/Parser.cs b/src/Core/Parser/Parser.cs index 7a1bd7f0..6aa1c63e 100644 --- a/src/Core/Parser/Parser.cs +++ b/src/Core/Parser/Parser.cs @@ -16,6 +16,11 @@ namespace CppSharp /// public ASTContext ASTContext { get; private set; } + /// + /// Context with library symbols. + /// + public SymbolContext SymbolsContext { get; private set; } + /// /// Fired when source files are parsed. /// @@ -29,6 +34,7 @@ namespace CppSharp public ClangParser() { ASTContext = new ASTContext(); + SymbolsContext = new SymbolContext(); } /// @@ -36,10 +42,9 @@ namespace CppSharp /// public ParserResult ParseSourceFile(SourceFile file, ParserOptions options) { - //if (options.ASTContext == null) - options.ASTContext = ASTContext; - + options.ASTContext = ASTContext; options.FileName = file.Path; + var result = Parser.ClangParser.ParseHeader(options); SourceParsed(file, result); @@ -63,7 +68,9 @@ namespace CppSharp /// public ParserResult ParseLibrary(string file, ParserOptions options) { + options.SymbolsContext = SymbolsContext; options.FileName = file; + var result = Parser.ClangParser.ParseLibrary(options); LibraryParsed(file, result); diff --git a/src/Core/Project.cs b/src/Core/Project.cs index a2f4523a..b679ed1a 100644 --- a/src/Core/Project.cs +++ b/src/Core/Project.cs @@ -72,6 +72,11 @@ namespace CppSharp /// Main AST context with translation units for the sources. /// public ASTContext ASTContext { get; private set; } + + /// + /// Main symbols context with indexed library symbols. + /// + public SymbolContext SymbolsContext { get; private set; } public Project() { diff --git a/src/Parser/Options.h b/src/Parser/Options.h index 5e14cd84..c52aca7f 100644 --- a/src/Parser/Options.h +++ b/src/Parser/Options.h @@ -38,6 +38,7 @@ public ref struct ParserOptions System::String^ FileName; CppSharp::AST::ASTContext^ ASTContext; + CppSharp::AST::SymbolContext^ SymbolsContext; int ToolSetToUse; System::String^ TargetTriple; diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index 9e1f08ad..588d6cde 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -33,7 +33,11 @@ //-----------------------------------// -Parser::Parser(ParserOptions^ Opts) : Lib(Opts->ASTContext), Opts(Opts), Index(0) +Parser::Parser(ParserOptions^ Opts) + : Opts(Opts) + , Lib(Opts->ASTContext) + , Symbols(Opts->SymbolsContext) + , Index(0) { }