Browse Source

Fixed driver code to work with the new parser.

pull/123/head
triton 12 years ago
parent
commit
4aab472af5
  1. 5
      src/Core/Parser/Parser.cs
  2. 16
      src/Generator/Driver.cs

5
src/Core/Parser/Parser.cs

@ -31,6 +31,11 @@ namespace CppSharp
ASTContext = new ASTContext(); ASTContext = new ASTContext();
} }
public ClangParser(ASTContext context)
{
ASTContext = context;
}
/// <summary> /// <summary>
/// Parses a C++ source file to a translation unit. /// Parses a C++ source file to a translation unit.
/// </summary> /// </summary>

16
src/Generator/Driver.cs

@ -14,7 +14,7 @@ using System.IO;
using Microsoft.CSharp; using Microsoft.CSharp;
#if !OLD_PARSER #if !OLD_PARSER
using Std; using CppSharp.Parser;
#endif #endif
namespace CppSharp namespace CppSharp
@ -38,6 +38,7 @@ namespace CppSharp
Options = options; Options = options;
Diagnostics = diagnostics; Diagnostics = diagnostics;
Project = new Project(); Project = new Project();
ASTContext = new ASTContext();
Symbols = new SymbolContext(); Symbols = new SymbolContext();
TypeDatabase = new TypeMapDatabase(); TypeDatabase = new TypeMapDatabase();
TranslationUnitPasses = new PassBuilder<TranslationUnitPass>(this); TranslationUnitPasses = new PassBuilder<TranslationUnitPass>(this);
@ -120,12 +121,7 @@ namespace CppSharp
var options = new ParserOptions var options = new ParserOptions
{ {
FileName = file.Path, FileName = file.Path,
#if !OLD_PARSER #if OLD_PARSER
IncludeDirs = Options.IncludeDirs.ToStd(),
SystemIncludeDirs = Options.SystemIncludeDirs.ToStd(),
Defines = Options.Defines.ToStd(),
LibraryDirs = Options.LibraryDirs.ToStd(),
#else
IncludeDirs = Options.IncludeDirs, IncludeDirs = Options.IncludeDirs,
SystemIncludeDirs = Options.SystemIncludeDirs, SystemIncludeDirs = Options.SystemIncludeDirs,
Defines = Options.Defines, Defines = Options.Defines,
@ -151,7 +147,11 @@ namespace CppSharp
source.Options = BuildParseOptions(source); source.Options = BuildParseOptions(source);
} }
var parser = new ClangParser(); #if !OLD_PARSER
var parser = new ClangParser(new Parser.AST.ASTContext());
#else
var parser = new ClangParser(ASTContext);
#endif
parser.SourceParsed += OnSourceFileParsed; parser.SourceParsed += OnSourceFileParsed;
parser.ParseProject(Project, Options); parser.ParseProject(Project, Options);

Loading…
Cancel
Save