Browse Source

Fixed library parsing by passing SymbolContext to the native parser.

pull/86/head
triton 12 years ago
parent
commit
d61f6f1a53
  1. 13
      src/Core/Parser/Parser.cs
  2. 5
      src/Core/Project.cs
  3. 1
      src/Parser/Options.h
  4. 6
      src/Parser/Parser.cpp

13
src/Core/Parser/Parser.cs

@ -16,6 +16,11 @@ namespace CppSharp
/// </summary> /// </summary>
public ASTContext ASTContext { get; private set; } public ASTContext ASTContext { get; private set; }
/// <summary>
/// Context with library symbols.
/// </summary>
public SymbolContext SymbolsContext { get; private set; }
/// <summary> /// <summary>
/// Fired when source files are parsed. /// Fired when source files are parsed.
/// </summary> /// </summary>
@ -29,6 +34,7 @@ namespace CppSharp
public ClangParser() public ClangParser()
{ {
ASTContext = new ASTContext(); ASTContext = new ASTContext();
SymbolsContext = new SymbolContext();
} }
/// <summary> /// <summary>
@ -36,10 +42,9 @@ namespace CppSharp
/// </summary> /// </summary>
public ParserResult ParseSourceFile(SourceFile file, ParserOptions options) public ParserResult ParseSourceFile(SourceFile file, ParserOptions options)
{ {
//if (options.ASTContext == null) options.ASTContext = ASTContext;
options.ASTContext = ASTContext;
options.FileName = file.Path; options.FileName = file.Path;
var result = Parser.ClangParser.ParseHeader(options); var result = Parser.ClangParser.ParseHeader(options);
SourceParsed(file, result); SourceParsed(file, result);
@ -63,7 +68,9 @@ namespace CppSharp
/// </summary> /// </summary>
public ParserResult ParseLibrary(string file, ParserOptions options) public ParserResult ParseLibrary(string file, ParserOptions options)
{ {
options.SymbolsContext = SymbolsContext;
options.FileName = file; options.FileName = file;
var result = Parser.ClangParser.ParseLibrary(options); var result = Parser.ClangParser.ParseLibrary(options);
LibraryParsed(file, result); LibraryParsed(file, result);

5
src/Core/Project.cs

@ -72,6 +72,11 @@ namespace CppSharp
/// Main AST context with translation units for the sources. /// Main AST context with translation units for the sources.
/// </summary> /// </summary>
public ASTContext ASTContext { get; private set; } public ASTContext ASTContext { get; private set; }
/// <summary>
/// Main symbols context with indexed library symbols.
/// </summary>
public SymbolContext SymbolsContext { get; private set; }
public Project() public Project()
{ {

1
src/Parser/Options.h

@ -38,6 +38,7 @@ public ref struct ParserOptions
System::String^ FileName; System::String^ FileName;
CppSharp::AST::ASTContext^ ASTContext; CppSharp::AST::ASTContext^ ASTContext;
CppSharp::AST::SymbolContext^ SymbolsContext;
int ToolSetToUse; int ToolSetToUse;
System::String^ TargetTriple; System::String^ TargetTriple;

6
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)
{ {
} }

Loading…
Cancel
Save