Browse Source

Fixed bug caused by a type in the new parser.

pull/123/head
triton 12 years ago
parent
commit
f1f6c2e5e9
  1. 4
      src/AST/Declaration.cs
  2. 116
      src/Core/Parser/ASTConverter.cs
  3. 31
      src/Core/Parser/Parser.cs
  4. 5
      src/Core/Project.cs
  5. 552
      src/CppParser/Bindings/CSharp/AST.cs
  6. 56
      src/CppParser/Bindings/CSharp/CppParser.cs
  7. 1
      src/CppParser/CppParser.h
  8. 2
      src/CppParser/Parser.cpp
  9. 15
      src/Generator/Driver.cs
  10. 3
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  11. 8
      src/Generator/Passes/CheckAmbiguousFunctions.cs
  12. 7
      src/Generator/Passes/CheckIgnoredDecls.cs
  13. 5
      src/Generator/Utils/TestsUtils.cs
  14. 21
      src/Parser/Main.cpp
  15. 18
      src/Parser/Parser.cpp
  16. 6
      src/Parser/Parser.h
  17. 6
      tests/Basic/Basic.cs
  18. 9
      tests/Basic/Basic.h

4
src/AST/Declaration.cs

@ -200,6 +200,9 @@ namespace CppSharp.AST @@ -200,6 +200,9 @@ namespace CppSharp.AST
public IntPtr OriginalPtr;
private string originalName;
// Reference to a data object associated with this declaration.
public object Data;
protected Declaration()
{
Access = AccessSpecifier.Public;
@ -233,6 +236,7 @@ namespace CppSharp.AST @@ -233,6 +236,7 @@ namespace CppSharp.AST
PreprocessedEntities = new List<PreprocessedEntity>(
declaration.PreprocessedEntities);
OriginalPtr = declaration.OriginalPtr;
Data = declaration.Data;
}
public override string ToString()

116
src/Core/Parser/ASTConverter.cs

@ -0,0 +1,116 @@ @@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using CppSharp.AST;
#if !OLD_PARSER
namespace CppSharp.Parser
{
/// <summary>
/// Converts from native parser ASTs to managed ASTs.
/// </summary>
public class ASTConverter
{
public AST.ASTContext OriginalContext;
public ASTContext NewContext;
public ASTConverter(AST.ASTContext context)
{
OriginalContext = context;
}
public ASTContext Convert()
{
NewContext = new ASTContext();
foreach (var unit in OriginalContext.TranslationUnits)
{
var newUnit = ConvertTranslationUnit(unit);
NewContext.TranslationUnits.Add(newUnit);
}
return NewContext;
}
public TranslationUnit ConvertTranslationUnit(AST.TranslationUnit unit)
{
var newUnit = ConvertDeclaration<TranslationUnit>(unit);
newUnit.FilePath = unit.FileName;
foreach (var macro in unit.Macros)
{
var newMacro = ConvertMacroDefinition(macro);
newUnit.Macros.Add(newMacro);
}
return newUnit;
}
public T ConvertDeclaration<T>(AST.Declaration decl)
where T : Declaration, new()
{
var newDecl = new T
{
Access = ConvertAccessSpecifier(decl.Access),
//Comment = ConvertRawComment(),
//CompleteDeclaration =
// ConvertDeclaration<Declaration>(decl.CompleteDeclaration)
DebugText = decl.DebugText,
DefinitionOrder = decl.DefinitionOrder,
IsDependent = decl.IsDependent,
IsIncomplete = decl.IsIncomplete,
Name = decl.Name,
PreprocessedEntities =
ConvertPreprocessedEntities(decl.PreprocessedEntities),
Namespace = ConvertNamespace(decl._Namespace),
};
return newDecl;
}
IList<PreprocessedEntity>
ConvertPreprocessedEntities(IEnumerable<AST.PreprocessedEntity> entities)
{
var newEntities = new List<PreprocessedEntity>();
foreach (var entity in entities)
{
//var newEntity = ConvertDeclaration<PreprocessedEntity>(entity);
//newEntities.Add(newEntity);
}
return newEntities;
}
DeclarationContext ConvertNamespace(AST.DeclarationContext context)
{
var newNamespace = new Namespace();
return newNamespace;
}
AccessSpecifier ConvertAccessSpecifier(AST.AccessSpecifier access)
{
switch (access)
{
case AST.AccessSpecifier.Private:
return AccessSpecifier.Private;
case AST.AccessSpecifier.Protected:
return AccessSpecifier.Protected;
case AST.AccessSpecifier.Public:
return AccessSpecifier.Public;
}
throw new NotSupportedException();
}
MacroDefinition ConvertMacroDefinition(AST.MacroDefinition macro)
{
var newMacro = ConvertDeclaration<MacroDefinition>(macro);
newMacro.Expression = macro.Expression;
return newMacro;
}
}
}
#endif

31
src/Core/Parser/Parser.cs

@ -31,10 +31,10 @@ namespace CppSharp @@ -31,10 +31,10 @@ namespace CppSharp
/// </summary>
public Action<string, ParserResult> LibraryParsed = delegate {};
public ClangParser()
public ClangParser(ASTContext astContext, SymbolContext symbolContext)
{
ASTContext = new ASTContext();
SymbolsContext = new SymbolContext();
ASTContext = astContext;
SymbolsContext = symbolContext;
}
/// <summary>
@ -51,6 +51,20 @@ namespace CppSharp @@ -51,6 +51,20 @@ namespace CppSharp
return result;
}
/// <summary>
/// Parses a serialized AST file to a translation unit.
/// </summary>
public ParserResult ParseASTFile(SourceFile file, ParserOptions options)
{
options.ASTContext = ASTContext;
options.FileName = file.Path;
var result = Parser.ClangParser.ParseHeader(options);
SourceParsed(file, result);
return result;
}
/// <summary>
/// Parses the project source files.
/// </summary>
@ -60,7 +74,18 @@ namespace CppSharp @@ -60,7 +74,18 @@ namespace CppSharp
// TODO: Do multi-threaded parsing of source files
foreach (var source in project.Sources)
{
// Search for a serialized AST of the source file.
var path = LookupSerializedAST(project, source);
ParseSourceFile(source, options);
}
}
private string LookupSerializedAST(Project project, SourceFile source)
{
var cachePath = project.Cache;
return string.Empty;
}
/// <summary>

5
src/Core/Project.cs

@ -48,6 +48,11 @@ namespace CppSharp @@ -48,6 +48,11 @@ namespace CppSharp
/// </summary>
public class Project
{
/// <summary>
/// Path to the cache repository.
/// </summary>
public string Cache { get; private set; }
/// <summary>
/// List of per-project C/C++ preprocessor defines.
/// </summary>

552
src/CppParser/Bindings/CSharp/AST.cs

File diff suppressed because it is too large Load Diff

56
src/CppParser/Bindings/CSharp/CppParser.cs

@ -80,14 +80,14 @@ namespace CppSharp @@ -80,14 +80,14 @@ namespace CppSharp
public bool Verbose;
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.ThisCall,
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="??0ParserOptions@CppParser@CppSharp@@QAE@XZ")]
public static extern global::System.IntPtr ParserOptions0(global::System.IntPtr instance);
public static extern global::System.IntPtr ParserOptions_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.ThisCall,
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="??0ParserOptions@CppParser@CppSharp@@QAE@ABU012@@Z")]
public static extern global::System.IntPtr ParserOptions2(global::System.IntPtr instance, global::System.IntPtr _0);
public static extern global::System.IntPtr ParserOptions_2(global::System.IntPtr instance, global::System.IntPtr _0);
}
public global::System.IntPtr __Instance { get; protected set; }
@ -123,7 +123,7 @@ namespace CppSharp @@ -123,7 +123,7 @@ namespace CppSharp
public ParserOptions()
{
__Instance = Marshal.AllocHGlobal(112);
Internal.ParserOptions0(__Instance);
Internal.ParserOptions_0(__Instance);
}
public void Dispose()
@ -224,7 +224,7 @@ namespace CppSharp @@ -224,7 +224,7 @@ namespace CppSharp
set
{
var __ptr = (Internal*)__Instance.ToPointer();
__ptr->ASTContext = value.__Instance;
__ptr->ASTContext = value == (CppSharp.Parser.AST.ASTContext) null ? global::System.IntPtr.Zero : value.__Instance;
}
}
@ -355,14 +355,14 @@ namespace CppSharp @@ -355,14 +355,14 @@ namespace CppSharp
public int ColumnNumber;
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.ThisCall,
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="??0ParserDiagnostic@CppParser@CppSharp@@QAE@XZ")]
public static extern global::System.IntPtr ParserDiagnostic1(global::System.IntPtr instance);
public static extern global::System.IntPtr ParserDiagnostic_1(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.ThisCall,
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="??0ParserDiagnostic@CppParser@CppSharp@@QAE@ABU012@@Z")]
public static extern global::System.IntPtr ParserDiagnostic2(global::System.IntPtr instance, global::System.IntPtr _0);
public static extern global::System.IntPtr ParserDiagnostic_2(global::System.IntPtr instance, global::System.IntPtr _0);
}
public global::System.IntPtr __Instance { get; protected set; }
@ -398,7 +398,7 @@ namespace CppSharp @@ -398,7 +398,7 @@ namespace CppSharp
public ParserDiagnostic()
{
__Instance = Marshal.AllocHGlobal(60);
Internal.ParserDiagnostic1(__Instance);
Internal.ParserDiagnostic_1(__Instance);
}
public void Dispose()
@ -506,14 +506,14 @@ namespace CppSharp @@ -506,14 +506,14 @@ namespace CppSharp
public global::System.IntPtr Library;
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.ThisCall,
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="??0ParserResult@CppParser@CppSharp@@QAE@XZ")]
public static extern global::System.IntPtr ParserResult1(global::System.IntPtr instance);
public static extern global::System.IntPtr ParserResult_1(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.ThisCall,
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="??0ParserResult@CppParser@CppSharp@@QAE@ABU012@@Z")]
public static extern global::System.IntPtr ParserResult2(global::System.IntPtr instance, global::System.IntPtr _0);
public static extern global::System.IntPtr ParserResult_2(global::System.IntPtr instance, global::System.IntPtr _0);
}
public global::System.IntPtr __Instance { get; protected set; }
@ -549,7 +549,7 @@ namespace CppSharp @@ -549,7 +549,7 @@ namespace CppSharp
public ParserResult()
{
__Instance = Marshal.AllocHGlobal(24);
Internal.ParserResult1(__Instance);
Internal.ParserResult_1(__Instance);
}
public void Dispose()
@ -605,7 +605,7 @@ namespace CppSharp @@ -605,7 +605,7 @@ namespace CppSharp
set
{
var __ptr = (Internal*)__Instance.ToPointer();
__ptr->ASTContext = value.__Instance;
__ptr->ASTContext = value == (CppSharp.Parser.AST.ASTContext) null ? global::System.IntPtr.Zero : value.__Instance;
}
}
@ -621,7 +621,7 @@ namespace CppSharp @@ -621,7 +621,7 @@ namespace CppSharp
set
{
var __ptr = (Internal*)__Instance.ToPointer();
__ptr->Library = value.__Instance;
__ptr->Library = value == (CppSharp.Parser.AST.NativeLibrary) null ? global::System.IntPtr.Zero : value.__Instance;
}
}
}
@ -632,19 +632,19 @@ namespace CppSharp @@ -632,19 +632,19 @@ namespace CppSharp
public struct Internal
{
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.ThisCall,
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="??0ClangParser@CppParser@CppSharp@@QAE@ABV012@@Z")]
public static extern global::System.IntPtr ClangParser1(global::System.IntPtr instance, global::System.IntPtr _0);
public static extern global::System.IntPtr ClangParser_1(global::System.IntPtr instance, global::System.IntPtr _0);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl,
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?ParseHeader@ClangParser@CppParser@CppSharp@@SAPAUParserResult@23@PAUParserOptions@23@@Z")]
public static extern global::System.IntPtr ParseHeader0(global::System.IntPtr Opts);
public static extern global::System.IntPtr ParseHeader_0(global::System.IntPtr Opts);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl,
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?ParseLibrary@ClangParser@CppParser@CppSharp@@SAPAUParserResult@23@PAUParserOptions@23@@Z")]
public static extern global::System.IntPtr ParseLibrary0(global::System.IntPtr Opts);
public static extern global::System.IntPtr ParseLibrary_0(global::System.IntPtr Opts);
}
public global::System.IntPtr __Instance { get; protected set; }
@ -695,16 +695,16 @@ namespace CppSharp @@ -695,16 +695,16 @@ namespace CppSharp
public static CppSharp.Parser.ParserResult ParseHeader(CppSharp.Parser.ParserOptions Opts)
{
var arg0 = Opts.__Instance;
var __ret = Internal.ParseHeader0(arg0);
var arg0 = Opts == (CppSharp.Parser.ParserOptions) null ? global::System.IntPtr.Zero : Opts.__Instance;
var __ret = Internal.ParseHeader_0(arg0);
if (__ret == global::System.IntPtr.Zero) return null;
return new CppSharp.Parser.ParserResult(__ret);
}
public static CppSharp.Parser.ParserResult ParseLibrary(CppSharp.Parser.ParserOptions Opts)
{
var arg0 = Opts.__Instance;
var __ret = Internal.ParseLibrary0(arg0);
var arg0 = Opts == (CppSharp.Parser.ParserOptions) null ? global::System.IntPtr.Zero : Opts.__Instance;
var __ret = Internal.ParseLibrary_0(arg0);
if (__ret == global::System.IntPtr.Zero) return null;
return new CppSharp.Parser.ParserResult(__ret);
}

1
src/CppParser/CppParser.h

@ -36,6 +36,7 @@ struct CS_API ParserOptions @@ -36,6 +36,7 @@ struct CS_API ParserOptions
std::vector<std::string> LibraryDirs;
CppSharp::CppParser::AST::ASTContext* ASTContext;
//CppSharp::CppParser::AST::SymbolContext* SymbolsContext;
int ToolSetToUse;
std::string TargetTriple;

2
src/CppParser/Parser.cpp

@ -1527,7 +1527,7 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, Function* F, @@ -1527,7 +1527,7 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, Function* F,
F->IsInline = FD->isInlined();
F->IsDependent = FD->isDependentContext();
F->IsPure = FD->isPure();
F->IsPure = FD->isDeleted();
F->IsDeleted = FD->isDeleted();
auto CC = FT->getCallConv();
F->CallingConvention = ConvertCallConv(CC);

15
src/Generator/Driver.cs

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
using System.CodeDom.Compiler;
using System;
using System.CodeDom.Compiler;
using System.Linq;
using System.Reflection;
using System.Text;
@ -37,6 +38,7 @@ namespace CppSharp @@ -37,6 +38,7 @@ namespace CppSharp
Options = options;
Diagnostics = diagnostics;
Project = new Project();
ASTContext = new ASTContext();
Symbols = new SymbolContext();
TypeDatabase = new TypeMapDatabase();
TranslationUnitPasses = new PassBuilder<TranslationUnitPass>(this);
@ -150,16 +152,13 @@ namespace CppSharp @@ -150,16 +152,13 @@ namespace CppSharp
source.Options = BuildParseOptions(source);
}
var parser = new ClangParser();
var parser = new ClangParser(ASTContext, Symbols);
parser.SourceParsed += OnSourceFileParsed;
parser.LibraryParsed += OnFileParsed;
parser.ParseProject(Project, Options);
#if !OLD_PARSER
ASTContext = ClangParser.ConvertASTContext(parser.ASTContext);
#else
ASTContext = parser.ASTContext;
#endif
return true;
@ -169,7 +168,9 @@ namespace CppSharp @@ -169,7 +168,9 @@ namespace CppSharp
{
foreach (var library in Options.Libraries)
{
var parser = new ClangParser();
var parser = new ClangParser(ASTContext, Symbols);
parser.LibraryParsed += OnFileParsed;
var res = parser.ParseLibrary(library, Options);
if (res.Kind != ParserResultKind.Success)
@ -308,6 +309,8 @@ namespace CppSharp @@ -308,6 +309,8 @@ namespace CppSharp
{
public static void Run(ILibrary library)
{
try { Console.BufferHeight = 2000; } catch (Exception ex) { }
var options = new DriverOptions();
var driver = new Driver(options, new TextDiagnosticPrinter());
library.Setup(driver);

3
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -333,6 +333,9 @@ namespace CppSharp.Generators.CSharp @@ -333,6 +333,9 @@ namespace CppSharp.Generators.CSharp
if (@class.Ignore || @class.IsIncomplete)
return;
//if (@class.Name == "ISceneNodeAnimator")
// System.Diagnostics.Debugger.Break();
PushBlock(CSharpBlockKind.Class);
GenerateDeclarationCommon(@class);

8
src/Generator/Passes/CheckAmbiguousFunctions.cs

@ -23,6 +23,14 @@ namespace CppSharp.Passes @@ -23,6 +23,14 @@ namespace CppSharp.Passes
/// </summary>
public class CheckAmbiguousFunctions : TranslationUnitPass
{
public override bool VisitMethodDecl(Method method)
{
//if (method.Kind != CXXMethodKind.Normal)
// return false;
return base.VisitMethodDecl(method);
}
public override bool VisitFunctionDecl(AST.Function function)
{
if (AlreadyVisited(function))

7
src/Generator/Passes/CheckIgnoredDecls.cs

@ -7,13 +7,16 @@ namespace CppSharp.Passes @@ -7,13 +7,16 @@ namespace CppSharp.Passes
{
public override bool VisitDeclaration(Declaration decl)
{
//if (AlreadyVisited(decl))
// return false;
if (decl.ExplicityIgnored)
return false;
if (decl.Access == AccessSpecifier.Private)
if (decl.Access != AccessSpecifier.Public)
{
Method method = decl as Method;
if (method == null || !method.IsOverride)
//if (method == null || !method.IsOverride)
{
decl.ExplicityIgnored = true;
return false;

5
src/Generator/Utils/TestsUtils.cs

@ -61,6 +61,7 @@ namespace CppSharp.Utils @@ -61,6 +61,7 @@ namespace CppSharp.Utils
options.GenerateLibraryNamespace = true;
options.Quiet = true;
options.IgnoreParseWarnings = true;
SetupOptions(options);
driver.Diagnostics.EmitMessage("Generating bindings for {0} in {1} mode",
options.LibraryName, options.GeneratorKind.ToString());
@ -80,6 +81,10 @@ namespace CppSharp.Utils @@ -80,6 +81,10 @@ namespace CppSharp.Utils
options.Headers.Add(Path.GetFileName(file));
}
public virtual void SetupOptions(DriverOptions options)
{
}
public virtual void Preprocess(Driver driver, ASTContext lib)
{
}

21
src/Parser/Main.cpp

@ -14,6 +14,27 @@ public ref class ClangParser @@ -14,6 +14,27 @@ public ref class ClangParser
{
public:
static ParserResult^ ReadAST(ParserOptions^ Opts)
{
if (!Opts->FileName) return nullptr;
using namespace clix;
std::string File = marshalString<E_UTF8>(Opts->FileName);
::Parser parser(Opts);
return parser.ParseHeader(File);
}
static bool WriteAST(ParserOptions^ Opts)
{
if (!Opts->FileName) return false;
using namespace clix;
std::string File = marshalString<E_UTF8>(Opts->FileName);
return true;
}
static ParserResult^ ParseHeader(ParserOptions^ Opts)
{
if (!Opts->FileName) return nullptr;

18
src/Parser/Parser.cpp

@ -2292,7 +2292,8 @@ ParserResult^ Parser::ParseHeader(const std::string& File) @@ -2292,7 +2292,8 @@ ParserResult^ Parser::ParseHeader(const std::string& File)
}
ParserResultKind Parser::ParseArchive(llvm::StringRef File,
llvm::MemoryBuffer *Buffer)
llvm::MemoryBuffer *Buffer,
CppSharp::AST::NativeLibrary^ NativeLib)
{
llvm::error_code Code;
llvm::object::Archive Archive(Buffer, Code);
@ -2301,7 +2302,7 @@ ParserResultKind Parser::ParseArchive(llvm::StringRef File, @@ -2301,7 +2302,7 @@ ParserResultKind Parser::ParseArchive(llvm::StringRef File,
return ParserResultKind::Error;
auto LibName = clix::marshalString<clix::E_UTF8>(File);
auto NativeLib = Symbols->FindOrCreateLibrary(LibName);
NativeLib->FileName = LibName;
for(auto it = Archive.begin_symbols(); it != Archive.end_symbols(); ++it)
{
@ -2318,7 +2319,8 @@ ParserResultKind Parser::ParseArchive(llvm::StringRef File, @@ -2318,7 +2319,8 @@ ParserResultKind Parser::ParseArchive(llvm::StringRef File,
}
ParserResultKind Parser::ParseSharedLib(llvm::StringRef File,
llvm::MemoryBuffer *Buffer)
llvm::MemoryBuffer *Buffer,
CppSharp::AST::NativeLibrary^ NativeLib)
{
auto Object = llvm::object::ObjectFile::createObjectFile(Buffer);
@ -2326,7 +2328,7 @@ ParserResultKind Parser::ParseSharedLib(llvm::StringRef File, @@ -2326,7 +2328,7 @@ ParserResultKind Parser::ParseSharedLib(llvm::StringRef File,
return ParserResultKind::Error;
auto LibName = clix::marshalString<clix::E_UTF8>(File);
auto NativeLib = Symbols->FindOrCreateLibrary(LibName);
NativeLib->FileName = LibName;
llvm::error_code ec;
for(auto it = Object->begin_symbols(); it != Object->end_symbols(); it.increment(ec))
@ -2389,11 +2391,15 @@ ParserResult^ Parser::ParseLibrary(const std::string& File) @@ -2389,11 +2391,15 @@ ParserResult^ Parser::ParseLibrary(const std::string& File)
return res;
}
res->Kind = ParseArchive(File, FM.getBufferForFile(FileEntry));
res->Kind = ParseArchive(File, FM.getBufferForFile(FileEntry),
res->Library);
if (res->Kind == ParserResultKind::Success)
return res;
res->Kind = ParseSharedLib(File, FM.getBufferForFile(FileEntry));
res->Kind = ParseSharedLib(File, FM.getBufferForFile(FileEntry),
res->Library);
if (res->Kind == ParserResultKind::Success)
return res;

6
src/Parser/Parser.h

@ -49,9 +49,11 @@ struct Parser @@ -49,9 +49,11 @@ struct Parser
ParserResult^ ParseHeader(const std::string& File);
ParserResult^ ParseLibrary(const std::string& File);
ParserResultKind ParseArchive(llvm::StringRef File,
llvm::MemoryBuffer *Buffer);
llvm::MemoryBuffer *Buffer,
CppSharp::AST::NativeLibrary^ NativeLib);
ParserResultKind ParseSharedLib(llvm::StringRef File,
llvm::MemoryBuffer *Buffer);
llvm::MemoryBuffer *Buffer,
CppSharp::AST::NativeLibrary^ NativeLib);
protected:

6
tests/Basic/Basic.cs

@ -13,6 +13,12 @@ namespace CppSharp.Tests @@ -13,6 +13,12 @@ namespace CppSharp.Tests
{
}
public override void SetupOptions(DriverOptions options)
{
options.Libraries.Add("Basic.Native.lib");
options.CheckSymbols = true;
}
public override void Preprocess(Driver driver, ASTContext lib)
{
lib.SetClassAsValueType("Bar");

9
tests/Basic/Basic.h

@ -164,3 +164,12 @@ class Base @@ -164,3 +164,12 @@ class Base
class Derived : public Base<Derived>
{
};
// Const and non-const constructor overloads
// https://github.com/mono/CppSharp/issues/102
struct Overloaded
{
Overloaded(void* p) {}
Overloaded(const void* p) {}
};
Loading…
Cancel
Save