Browse Source

Added an option to parse all headers at once - much faster.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/656/head
Dimitar Dobrev 10 years ago
parent
commit
dc84c9b765
  1. 33
      src/Core/Parser/Parser.cs
  2. 33
      src/CppParser/Bindings/CLI/CppParser.cpp
  3. 13
      src/CppParser/Bindings/CLI/CppParser.h
  4. 87
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppParser.cs
  5. 87
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppParser.cs
  6. 87
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppParser.cs
  7. 87
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppParser.cs
  8. 87
      src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppParser.cs
  9. 3
      src/CppParser/CppParser.cpp
  10. 5
      src/CppParser/CppParser.h
  11. 33
      src/CppParser/Parser.cpp
  12. 2
      src/CppParser/Parser.h
  13. 33
      src/Generator/Driver.cs
  14. 5
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs
  15. 6
      src/Generator/Options.cs
  16. 5
      src/Generator/Passes/CleanUnitPass.cs

33
src/Core/Parser/Parser.cs

@ -18,7 +18,7 @@ namespace CppSharp
/// <summary> /// <summary>
/// Fired when source files are parsed. /// Fired when source files are parsed.
/// </summary> /// </summary>
public Action<SourceFile, ParserResult> SourceParsed = delegate {}; public Action<IList<SourceFile>, ParserResult> SourcesParsed = delegate {};
/// <summary> /// <summary>
/// Fired when library files are parsed. /// Fired when library files are parsed.
@ -50,28 +50,45 @@ namespace CppSharp
/// <summary> /// <summary>
/// Parses a C++ source file to a translation unit. /// Parses a C++ source file to a translation unit.
/// </summary> /// </summary>
public ParserResult ParseSourceFile(SourceFile file) private ParserResult ParseSourceFile(SourceFile file)
{ {
var options = file.Options; var options = file.Options;
options.ASTContext = ASTContext; options.ASTContext = ASTContext;
options.FileName = file.Path; options.addSourceFiles(file.Path);
var result = Parser.ClangParser.ParseHeader(options); var result = Parser.ClangParser.ParseHeader(options);
SourceParsed(file, result); SourcesParsed(new[] { file }, result);
return result; return result;
} }
/// <summary>
/// Parses C++ source files to a translation unit.
/// </summary>
private void ParseSourceFiles(IList<SourceFile> files)
{
var options = files[0].Options;
options.ASTContext = ASTContext;
foreach (var file in files)
options.addSourceFiles(file.Path);
using (var result = Parser.ClangParser.ParseHeader(options))
SourcesParsed(files, result);
}
/// <summary> /// <summary>
/// Parses the project source files. /// Parses the project source files.
/// </summary> /// </summary>
public void ParseProject(Project project) public void ParseProject(Project project, bool unityBuild)
{ {
// TODO: Search for cached AST trees on disk // TODO: Search for cached AST trees on disk
// TODO: Do multi-threaded parsing of source files // TODO: Do multi-threaded parsing of source files
foreach (var parserResult in project.Sources.Select(s => ParseSourceFile(s)).ToList()) if (unityBuild)
parserResult.Dispose(); ParseSourceFiles(project.Sources);
else
foreach (var parserResult in project.Sources.Select(s => ParseSourceFile(s)).ToList())
parserResult.Dispose();
} }
/// <summary> /// <summary>
@ -79,7 +96,7 @@ namespace CppSharp
/// </summary> /// </summary>
public ParserResult ParseLibrary(string file, ParserOptions options) public ParserResult ParseLibrary(string file, ParserOptions options)
{ {
options.FileName = file; options.LibraryFile = file;
var result = Parser.ClangParser.ParseLibrary(options); var result = Parser.ClangParser.ParseLibrary(options);
LibraryParsed(file, result); LibraryParsed(file, result);

33
src/CppParser/Bindings/CLI/CppParser.cpp

@ -46,6 +46,25 @@ void CppSharp::Parser::ParserOptions::clearArguments()
((::CppSharp::CppParser::ParserOptions*)NativePtr)->clearArguments(); ((::CppSharp::CppParser::ParserOptions*)NativePtr)->clearArguments();
} }
System::String^ CppSharp::Parser::ParserOptions::getSourceFiles(unsigned int i)
{
auto __ret = ((::CppSharp::CppParser::ParserOptions*)NativePtr)->getSourceFiles(i);
if (__ret == nullptr) return nullptr;
return (__ret == 0 ? nullptr : clix::marshalString<clix::E_UTF8>(__ret));
}
void CppSharp::Parser::ParserOptions::addSourceFiles(System::String^ s)
{
auto _arg0 = clix::marshalString<clix::E_UTF8>(s);
auto arg0 = _arg0.c_str();
((::CppSharp::CppParser::ParserOptions*)NativePtr)->addSourceFiles(arg0);
}
void CppSharp::Parser::ParserOptions::clearSourceFiles()
{
((::CppSharp::CppParser::ParserOptions*)NativePtr)->clearSourceFiles();
}
System::String^ CppSharp::Parser::ParserOptions::getIncludeDirs(unsigned int i) System::String^ CppSharp::Parser::ParserOptions::getIncludeDirs(unsigned int i)
{ {
auto __ret = ((::CppSharp::CppParser::ParserOptions*)NativePtr)->getIncludeDirs(i); auto __ret = ((::CppSharp::CppParser::ParserOptions*)NativePtr)->getIncludeDirs(i);
@ -166,18 +185,24 @@ unsigned int CppSharp::Parser::ParserOptions::ArgumentsCount::get()
return __ret; return __ret;
} }
System::String^ CppSharp::Parser::ParserOptions::FileName::get() System::String^ CppSharp::Parser::ParserOptions::LibraryFile::get()
{ {
auto __ret = ((::CppSharp::CppParser::ParserOptions*)NativePtr)->getFileName(); auto __ret = ((::CppSharp::CppParser::ParserOptions*)NativePtr)->getLibraryFile();
if (__ret == nullptr) return nullptr; if (__ret == nullptr) return nullptr;
return (__ret == 0 ? nullptr : clix::marshalString<clix::E_UTF8>(__ret)); return (__ret == 0 ? nullptr : clix::marshalString<clix::E_UTF8>(__ret));
} }
void CppSharp::Parser::ParserOptions::FileName::set(System::String^ s) void CppSharp::Parser::ParserOptions::LibraryFile::set(System::String^ s)
{ {
auto _arg0 = clix::marshalString<clix::E_UTF8>(s); auto _arg0 = clix::marshalString<clix::E_UTF8>(s);
auto arg0 = _arg0.c_str(); auto arg0 = _arg0.c_str();
((::CppSharp::CppParser::ParserOptions*)NativePtr)->setFileName(arg0); ((::CppSharp::CppParser::ParserOptions*)NativePtr)->setLibraryFile(arg0);
}
unsigned int CppSharp::Parser::ParserOptions::SourceFilesCount::get()
{
auto __ret = ((::CppSharp::CppParser::ParserOptions*)NativePtr)->getSourceFilesCount();
return __ret;
} }
unsigned int CppSharp::Parser::ParserOptions::IncludeDirsCount::get() unsigned int CppSharp::Parser::ParserOptions::IncludeDirsCount::get()

13
src/CppParser/Bindings/CLI/CppParser.h

@ -89,12 +89,17 @@ namespace CppSharp
unsigned int get(); unsigned int get();
} }
property System::String^ FileName property System::String^ LibraryFile
{ {
System::String^ get(); System::String^ get();
void set(System::String^); void set(System::String^);
} }
property unsigned int SourceFilesCount
{
unsigned int get();
}
property unsigned int IncludeDirsCount property unsigned int IncludeDirsCount
{ {
unsigned int get(); unsigned int get();
@ -186,6 +191,12 @@ namespace CppSharp
void clearArguments(); void clearArguments();
System::String^ getSourceFiles(unsigned int i);
void addSourceFiles(System::String^ s);
void clearSourceFiles();
System::String^ getIncludeDirs(unsigned int i); System::String^ getIncludeDirs(unsigned int i);
void addIncludeDirs(System::String^ s); void addIncludeDirs(System::String^ s);

87
src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppParser.cs

@ -49,34 +49,34 @@ namespace CppSharp
public unsafe partial class ParserOptions : IDisposable public unsafe partial class ParserOptions : IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 120)] [StructLayout(LayoutKind.Explicit, Size = 132)]
public partial struct Internal public partial struct Internal
{ {
[FieldOffset(84)] [FieldOffset(96)]
public global::System.IntPtr ASTContext; public global::System.IntPtr ASTContext;
[FieldOffset(88)] [FieldOffset(100)]
public int ToolSetToUse; public int ToolSetToUse;
[FieldOffset(104)] [FieldOffset(116)]
public CppSharp.Parser.AST.CppAbi Abi; public CppSharp.Parser.AST.CppAbi Abi;
[FieldOffset(108)] [FieldOffset(120)]
public byte NoStandardIncludes; public byte NoStandardIncludes;
[FieldOffset(109)] [FieldOffset(121)]
public byte NoBuiltinIncludes; public byte NoBuiltinIncludes;
[FieldOffset(110)] [FieldOffset(122)]
public byte MicrosoftMode; public byte MicrosoftMode;
[FieldOffset(111)] [FieldOffset(123)]
public byte Verbose; public byte Verbose;
[FieldOffset(112)] [FieldOffset(124)]
public CppSharp.Parser.LanguageVersion LanguageVersion; public CppSharp.Parser.LanguageVersion LanguageVersion;
[FieldOffset(116)] [FieldOffset(128)]
public global::System.IntPtr TargetInfo; public global::System.IntPtr TargetInfo;
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
@ -109,6 +109,21 @@ namespace CppSharp
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14clearArgumentsEv")] EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14clearArgumentsEv")]
internal static extern void clearArguments_0(global::System.IntPtr instance); internal static extern void clearArguments_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14getSourceFilesEj")]
internal static extern global::System.IntPtr getSourceFiles_0(global::System.IntPtr instance, uint i);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14addSourceFilesEPKc")]
internal static extern void addSourceFiles_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions16clearSourceFilesEv")]
internal static extern void clearSourceFiles_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14getIncludeDirsEj")] EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14getIncludeDirsEj")]
@ -191,13 +206,18 @@ namespace CppSharp
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions11getFileNameEv")] EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14getLibraryFileEv")]
internal static extern global::System.IntPtr getFileName_0(global::System.IntPtr instance); internal static extern global::System.IntPtr getLibraryFile_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions11setFileNameEPKc")] EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14setLibraryFileEPKc")]
internal static extern void setFileName_0(global::System.IntPtr instance, global::System.IntPtr s); internal static extern void setLibraryFile_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions19getSourceFilesCountEv")]
internal static extern uint getSourceFilesCount_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
@ -255,7 +275,7 @@ namespace CppSharp
private static void* __CopyValue(ParserOptions.Internal native) private static void* __CopyValue(ParserOptions.Internal native)
{ {
var ret = Marshal.AllocHGlobal(120); var ret = Marshal.AllocHGlobal(132);
CppSharp.Parser.ParserOptions.Internal.cctor_2(ret, new global::System.IntPtr(&native)); CppSharp.Parser.ParserOptions.Internal.cctor_2(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -276,7 +296,7 @@ namespace CppSharp
public ParserOptions() public ParserOptions()
{ {
__Instance = Marshal.AllocHGlobal(120); __Instance = Marshal.AllocHGlobal(132);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -284,7 +304,7 @@ namespace CppSharp
public ParserOptions(CppSharp.Parser.ParserOptions _0) public ParserOptions(CppSharp.Parser.ParserOptions _0)
{ {
__Instance = Marshal.AllocHGlobal(120); __Instance = Marshal.AllocHGlobal(132);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -325,6 +345,24 @@ namespace CppSharp
Internal.clearArguments_0((__Instance + __PointerAdjustment)); Internal.clearArguments_0((__Instance + __PointerAdjustment));
} }
public string getSourceFiles(uint i)
{
var __ret = Internal.getSourceFiles_0((__Instance + __PointerAdjustment), i);
return Marshal.PtrToStringAnsi(__ret);
}
public void addSourceFiles(string s)
{
var arg0 = Marshal.StringToHGlobalAnsi(s);
Internal.addSourceFiles_0((__Instance + __PointerAdjustment), arg0);
Marshal.FreeHGlobal(arg0);
}
public void clearSourceFiles()
{
Internal.clearSourceFiles_0((__Instance + __PointerAdjustment));
}
public string getIncludeDirs(uint i) public string getIncludeDirs(uint i)
{ {
var __ret = Internal.getIncludeDirs_0((__Instance + __PointerAdjustment), i); var __ret = Internal.getIncludeDirs_0((__Instance + __PointerAdjustment), i);
@ -424,22 +462,31 @@ namespace CppSharp
} }
} }
public string FileName public string LibraryFile
{ {
get get
{ {
var __ret = Internal.getFileName_0((__Instance + __PointerAdjustment)); var __ret = Internal.getLibraryFile_0((__Instance + __PointerAdjustment));
return Marshal.PtrToStringAnsi(__ret); return Marshal.PtrToStringAnsi(__ret);
} }
set set
{ {
var arg0 = Marshal.StringToHGlobalAnsi(value); var arg0 = Marshal.StringToHGlobalAnsi(value);
Internal.setFileName_0((__Instance + __PointerAdjustment), arg0); Internal.setLibraryFile_0((__Instance + __PointerAdjustment), arg0);
Marshal.FreeHGlobal(arg0); Marshal.FreeHGlobal(arg0);
} }
} }
public uint SourceFilesCount
{
get
{
var __ret = Internal.getSourceFilesCount_0((__Instance + __PointerAdjustment));
return __ret;
}
}
public uint IncludeDirsCount public uint IncludeDirsCount
{ {
get get

87
src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppParser.cs

@ -49,34 +49,34 @@ namespace CppSharp
public unsafe partial class ParserOptions : IDisposable public unsafe partial class ParserOptions : IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 144)] [StructLayout(LayoutKind.Explicit, Size = 156)]
public partial struct Internal public partial struct Internal
{ {
[FieldOffset(96)] [FieldOffset(108)]
public global::System.IntPtr ASTContext; public global::System.IntPtr ASTContext;
[FieldOffset(100)] [FieldOffset(112)]
public int ToolSetToUse; public int ToolSetToUse;
[FieldOffset(128)] [FieldOffset(140)]
public CppSharp.Parser.AST.CppAbi Abi; public CppSharp.Parser.AST.CppAbi Abi;
[FieldOffset(132)] [FieldOffset(144)]
public byte NoStandardIncludes; public byte NoStandardIncludes;
[FieldOffset(133)] [FieldOffset(145)]
public byte NoBuiltinIncludes; public byte NoBuiltinIncludes;
[FieldOffset(134)] [FieldOffset(146)]
public byte MicrosoftMode; public byte MicrosoftMode;
[FieldOffset(135)] [FieldOffset(147)]
public byte Verbose; public byte Verbose;
[FieldOffset(136)] [FieldOffset(148)]
public CppSharp.Parser.LanguageVersion LanguageVersion; public CppSharp.Parser.LanguageVersion LanguageVersion;
[FieldOffset(140)] [FieldOffset(152)]
public global::System.IntPtr TargetInfo; public global::System.IntPtr TargetInfo;
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
@ -109,6 +109,21 @@ namespace CppSharp
EntryPoint="?clearArguments@ParserOptions@CppParser@CppSharp@@QAEXXZ")] EntryPoint="?clearArguments@ParserOptions@CppParser@CppSharp@@QAEXXZ")]
internal static extern void clearArguments_0(global::System.IntPtr instance); internal static extern void clearArguments_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="?getSourceFiles@ParserOptions@CppParser@CppSharp@@QAEPBDI@Z")]
internal static extern global::System.IntPtr getSourceFiles_0(global::System.IntPtr instance, uint i);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="?addSourceFiles@ParserOptions@CppParser@CppSharp@@QAEXPBD@Z")]
internal static extern void addSourceFiles_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="?clearSourceFiles@ParserOptions@CppParser@CppSharp@@QAEXXZ")]
internal static extern void clearSourceFiles_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="?getIncludeDirs@ParserOptions@CppParser@CppSharp@@QAEPBDI@Z")] EntryPoint="?getIncludeDirs@ParserOptions@CppParser@CppSharp@@QAEPBDI@Z")]
@ -191,13 +206,18 @@ namespace CppSharp
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="?getFileName@ParserOptions@CppParser@CppSharp@@QAEPBDXZ")] EntryPoint="?getLibraryFile@ParserOptions@CppParser@CppSharp@@QAEPBDXZ")]
internal static extern global::System.IntPtr getFileName_0(global::System.IntPtr instance); internal static extern global::System.IntPtr getLibraryFile_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="?setFileName@ParserOptions@CppParser@CppSharp@@QAEXPBD@Z")] EntryPoint="?setLibraryFile@ParserOptions@CppParser@CppSharp@@QAEXPBD@Z")]
internal static extern void setFileName_0(global::System.IntPtr instance, global::System.IntPtr s); internal static extern void setLibraryFile_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
EntryPoint="?getSourceFilesCount@ParserOptions@CppParser@CppSharp@@QAEIXZ")]
internal static extern uint getSourceFilesCount_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall,
@ -255,7 +275,7 @@ namespace CppSharp
private static void* __CopyValue(ParserOptions.Internal native) private static void* __CopyValue(ParserOptions.Internal native)
{ {
var ret = Marshal.AllocHGlobal(144); var ret = Marshal.AllocHGlobal(156);
CppSharp.Parser.ParserOptions.Internal.cctor_2(ret, new global::System.IntPtr(&native)); CppSharp.Parser.ParserOptions.Internal.cctor_2(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -276,7 +296,7 @@ namespace CppSharp
public ParserOptions() public ParserOptions()
{ {
__Instance = Marshal.AllocHGlobal(144); __Instance = Marshal.AllocHGlobal(156);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -284,7 +304,7 @@ namespace CppSharp
public ParserOptions(CppSharp.Parser.ParserOptions _0) public ParserOptions(CppSharp.Parser.ParserOptions _0)
{ {
__Instance = Marshal.AllocHGlobal(144); __Instance = Marshal.AllocHGlobal(156);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -325,6 +345,24 @@ namespace CppSharp
Internal.clearArguments_0((__Instance + __PointerAdjustment)); Internal.clearArguments_0((__Instance + __PointerAdjustment));
} }
public string getSourceFiles(uint i)
{
var __ret = Internal.getSourceFiles_0((__Instance + __PointerAdjustment), i);
return Marshal.PtrToStringAnsi(__ret);
}
public void addSourceFiles(string s)
{
var arg0 = Marshal.StringToHGlobalAnsi(s);
Internal.addSourceFiles_0((__Instance + __PointerAdjustment), arg0);
Marshal.FreeHGlobal(arg0);
}
public void clearSourceFiles()
{
Internal.clearSourceFiles_0((__Instance + __PointerAdjustment));
}
public string getIncludeDirs(uint i) public string getIncludeDirs(uint i)
{ {
var __ret = Internal.getIncludeDirs_0((__Instance + __PointerAdjustment), i); var __ret = Internal.getIncludeDirs_0((__Instance + __PointerAdjustment), i);
@ -424,22 +462,31 @@ namespace CppSharp
} }
} }
public string FileName public string LibraryFile
{ {
get get
{ {
var __ret = Internal.getFileName_0((__Instance + __PointerAdjustment)); var __ret = Internal.getLibraryFile_0((__Instance + __PointerAdjustment));
return Marshal.PtrToStringAnsi(__ret); return Marshal.PtrToStringAnsi(__ret);
} }
set set
{ {
var arg0 = Marshal.StringToHGlobalAnsi(value); var arg0 = Marshal.StringToHGlobalAnsi(value);
Internal.setFileName_0((__Instance + __PointerAdjustment), arg0); Internal.setLibraryFile_0((__Instance + __PointerAdjustment), arg0);
Marshal.FreeHGlobal(arg0); Marshal.FreeHGlobal(arg0);
} }
} }
public uint SourceFilesCount
{
get
{
var __ret = Internal.getSourceFilesCount_0((__Instance + __PointerAdjustment));
return __ret;
}
}
public uint IncludeDirsCount public uint IncludeDirsCount
{ {
get get

87
src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppParser.cs

@ -49,34 +49,34 @@ namespace CppSharp
public unsafe partial class ParserOptions : IDisposable public unsafe partial class ParserOptions : IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 232)] [StructLayout(LayoutKind.Explicit, Size = 256)]
public partial struct Internal public partial struct Internal
{ {
[FieldOffset(168)] [FieldOffset(192)]
public global::System.IntPtr ASTContext; public global::System.IntPtr ASTContext;
[FieldOffset(176)] [FieldOffset(200)]
public int ToolSetToUse; public int ToolSetToUse;
[FieldOffset(208)] [FieldOffset(232)]
public CppSharp.Parser.AST.CppAbi Abi; public CppSharp.Parser.AST.CppAbi Abi;
[FieldOffset(212)] [FieldOffset(236)]
public byte NoStandardIncludes; public byte NoStandardIncludes;
[FieldOffset(213)] [FieldOffset(237)]
public byte NoBuiltinIncludes; public byte NoBuiltinIncludes;
[FieldOffset(214)] [FieldOffset(238)]
public byte MicrosoftMode; public byte MicrosoftMode;
[FieldOffset(215)] [FieldOffset(239)]
public byte Verbose; public byte Verbose;
[FieldOffset(216)] [FieldOffset(240)]
public CppSharp.Parser.LanguageVersion LanguageVersion; public CppSharp.Parser.LanguageVersion LanguageVersion;
[FieldOffset(224)] [FieldOffset(248)]
public global::System.IntPtr TargetInfo; public global::System.IntPtr TargetInfo;
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
@ -109,6 +109,21 @@ namespace CppSharp
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14clearArgumentsEv")] EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14clearArgumentsEv")]
internal static extern void clearArguments_0(global::System.IntPtr instance); internal static extern void clearArguments_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14getSourceFilesEj")]
internal static extern global::System.IntPtr getSourceFiles_0(global::System.IntPtr instance, uint i);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14addSourceFilesEPKc")]
internal static extern void addSourceFiles_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions16clearSourceFilesEv")]
internal static extern void clearSourceFiles_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14getIncludeDirsEj")] EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14getIncludeDirsEj")]
@ -191,13 +206,18 @@ namespace CppSharp
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions11getFileNameEv")] EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14getLibraryFileEv")]
internal static extern global::System.IntPtr getFileName_0(global::System.IntPtr instance); internal static extern global::System.IntPtr getLibraryFile_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions11setFileNameEPKc")] EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14setLibraryFileEPKc")]
internal static extern void setFileName_0(global::System.IntPtr instance, global::System.IntPtr s); internal static extern void setLibraryFile_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions19getSourceFilesCountEv")]
internal static extern uint getSourceFilesCount_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
@ -255,7 +275,7 @@ namespace CppSharp
private static void* __CopyValue(ParserOptions.Internal native) private static void* __CopyValue(ParserOptions.Internal native)
{ {
var ret = Marshal.AllocHGlobal(232); var ret = Marshal.AllocHGlobal(256);
CppSharp.Parser.ParserOptions.Internal.cctor_2(ret, new global::System.IntPtr(&native)); CppSharp.Parser.ParserOptions.Internal.cctor_2(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -276,7 +296,7 @@ namespace CppSharp
public ParserOptions() public ParserOptions()
{ {
__Instance = Marshal.AllocHGlobal(232); __Instance = Marshal.AllocHGlobal(256);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -284,7 +304,7 @@ namespace CppSharp
public ParserOptions(CppSharp.Parser.ParserOptions _0) public ParserOptions(CppSharp.Parser.ParserOptions _0)
{ {
__Instance = Marshal.AllocHGlobal(232); __Instance = Marshal.AllocHGlobal(256);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -325,6 +345,24 @@ namespace CppSharp
Internal.clearArguments_0((__Instance + __PointerAdjustment)); Internal.clearArguments_0((__Instance + __PointerAdjustment));
} }
public string getSourceFiles(uint i)
{
var __ret = Internal.getSourceFiles_0((__Instance + __PointerAdjustment), i);
return Marshal.PtrToStringAnsi(__ret);
}
public void addSourceFiles(string s)
{
var arg0 = Marshal.StringToHGlobalAnsi(s);
Internal.addSourceFiles_0((__Instance + __PointerAdjustment), arg0);
Marshal.FreeHGlobal(arg0);
}
public void clearSourceFiles()
{
Internal.clearSourceFiles_0((__Instance + __PointerAdjustment));
}
public string getIncludeDirs(uint i) public string getIncludeDirs(uint i)
{ {
var __ret = Internal.getIncludeDirs_0((__Instance + __PointerAdjustment), i); var __ret = Internal.getIncludeDirs_0((__Instance + __PointerAdjustment), i);
@ -424,22 +462,31 @@ namespace CppSharp
} }
} }
public string FileName public string LibraryFile
{ {
get get
{ {
var __ret = Internal.getFileName_0((__Instance + __PointerAdjustment)); var __ret = Internal.getLibraryFile_0((__Instance + __PointerAdjustment));
return Marshal.PtrToStringAnsi(__ret); return Marshal.PtrToStringAnsi(__ret);
} }
set set
{ {
var arg0 = Marshal.StringToHGlobalAnsi(value); var arg0 = Marshal.StringToHGlobalAnsi(value);
Internal.setFileName_0((__Instance + __PointerAdjustment), arg0); Internal.setLibraryFile_0((__Instance + __PointerAdjustment), arg0);
Marshal.FreeHGlobal(arg0); Marshal.FreeHGlobal(arg0);
} }
} }
public uint SourceFilesCount
{
get
{
var __ret = Internal.getSourceFilesCount_0((__Instance + __PointerAdjustment));
return __ret;
}
}
public uint IncludeDirsCount public uint IncludeDirsCount
{ {
get get

87
src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppParser.cs

@ -49,34 +49,34 @@ namespace CppSharp
public unsafe partial class ParserOptions : IDisposable public unsafe partial class ParserOptions : IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 200)] [StructLayout(LayoutKind.Explicit, Size = 224)]
public partial struct Internal public partial struct Internal
{ {
[FieldOffset(152)] [FieldOffset(176)]
public global::System.IntPtr ASTContext; public global::System.IntPtr ASTContext;
[FieldOffset(160)] [FieldOffset(184)]
public int ToolSetToUse; public int ToolSetToUse;
[FieldOffset(176)] [FieldOffset(200)]
public CppSharp.Parser.AST.CppAbi Abi; public CppSharp.Parser.AST.CppAbi Abi;
[FieldOffset(180)] [FieldOffset(204)]
public byte NoStandardIncludes; public byte NoStandardIncludes;
[FieldOffset(181)] [FieldOffset(205)]
public byte NoBuiltinIncludes; public byte NoBuiltinIncludes;
[FieldOffset(182)] [FieldOffset(206)]
public byte MicrosoftMode; public byte MicrosoftMode;
[FieldOffset(183)] [FieldOffset(207)]
public byte Verbose; public byte Verbose;
[FieldOffset(184)] [FieldOffset(208)]
public CppSharp.Parser.LanguageVersion LanguageVersion; public CppSharp.Parser.LanguageVersion LanguageVersion;
[FieldOffset(192)] [FieldOffset(216)]
public global::System.IntPtr TargetInfo; public global::System.IntPtr TargetInfo;
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
@ -109,6 +109,21 @@ namespace CppSharp
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14clearArgumentsEv")] EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14clearArgumentsEv")]
internal static extern void clearArguments_0(global::System.IntPtr instance); internal static extern void clearArguments_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14getSourceFilesEj")]
internal static extern global::System.IntPtr getSourceFiles_0(global::System.IntPtr instance, uint i);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14addSourceFilesEPKc")]
internal static extern void addSourceFiles_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions16clearSourceFilesEv")]
internal static extern void clearSourceFiles_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14getIncludeDirsEj")] EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14getIncludeDirsEj")]
@ -191,13 +206,18 @@ namespace CppSharp
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions11getFileNameEv")] EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14getLibraryFileEv")]
internal static extern global::System.IntPtr getFileName_0(global::System.IntPtr instance); internal static extern global::System.IntPtr getLibraryFile_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions11setFileNameEPKc")] EntryPoint="_ZN8CppSharp9CppParser13ParserOptions14setLibraryFileEPKc")]
internal static extern void setFileName_0(global::System.IntPtr instance, global::System.IntPtr s); internal static extern void setLibraryFile_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="_ZN8CppSharp9CppParser13ParserOptions19getSourceFilesCountEv")]
internal static extern uint getSourceFilesCount_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
@ -255,7 +275,7 @@ namespace CppSharp
private static void* __CopyValue(ParserOptions.Internal native) private static void* __CopyValue(ParserOptions.Internal native)
{ {
var ret = Marshal.AllocHGlobal(200); var ret = Marshal.AllocHGlobal(224);
CppSharp.Parser.ParserOptions.Internal.cctor_1(ret, new global::System.IntPtr(&native)); CppSharp.Parser.ParserOptions.Internal.cctor_1(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -276,7 +296,7 @@ namespace CppSharp
public ParserOptions() public ParserOptions()
{ {
__Instance = Marshal.AllocHGlobal(200); __Instance = Marshal.AllocHGlobal(224);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -284,7 +304,7 @@ namespace CppSharp
public ParserOptions(CppSharp.Parser.ParserOptions _0) public ParserOptions(CppSharp.Parser.ParserOptions _0)
{ {
__Instance = Marshal.AllocHGlobal(200); __Instance = Marshal.AllocHGlobal(224);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -325,6 +345,24 @@ namespace CppSharp
Internal.clearArguments_0((__Instance + __PointerAdjustment)); Internal.clearArguments_0((__Instance + __PointerAdjustment));
} }
public string getSourceFiles(uint i)
{
var __ret = Internal.getSourceFiles_0((__Instance + __PointerAdjustment), i);
return Marshal.PtrToStringAnsi(__ret);
}
public void addSourceFiles(string s)
{
var arg0 = Marshal.StringToHGlobalAnsi(s);
Internal.addSourceFiles_0((__Instance + __PointerAdjustment), arg0);
Marshal.FreeHGlobal(arg0);
}
public void clearSourceFiles()
{
Internal.clearSourceFiles_0((__Instance + __PointerAdjustment));
}
public string getIncludeDirs(uint i) public string getIncludeDirs(uint i)
{ {
var __ret = Internal.getIncludeDirs_0((__Instance + __PointerAdjustment), i); var __ret = Internal.getIncludeDirs_0((__Instance + __PointerAdjustment), i);
@ -424,22 +462,31 @@ namespace CppSharp
} }
} }
public string FileName public string LibraryFile
{ {
get get
{ {
var __ret = Internal.getFileName_0((__Instance + __PointerAdjustment)); var __ret = Internal.getLibraryFile_0((__Instance + __PointerAdjustment));
return Marshal.PtrToStringAnsi(__ret); return Marshal.PtrToStringAnsi(__ret);
} }
set set
{ {
var arg0 = Marshal.StringToHGlobalAnsi(value); var arg0 = Marshal.StringToHGlobalAnsi(value);
Internal.setFileName_0((__Instance + __PointerAdjustment), arg0); Internal.setLibraryFile_0((__Instance + __PointerAdjustment), arg0);
Marshal.FreeHGlobal(arg0); Marshal.FreeHGlobal(arg0);
} }
} }
public uint SourceFilesCount
{
get
{
var __ret = Internal.getSourceFilesCount_0((__Instance + __PointerAdjustment));
return __ret;
}
}
public uint IncludeDirsCount public uint IncludeDirsCount
{ {
get get

87
src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppParser.cs

@ -49,34 +49,34 @@ namespace CppSharp
public unsafe partial class ParserOptions : IDisposable public unsafe partial class ParserOptions : IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 248)] [StructLayout(LayoutKind.Explicit, Size = 272)]
public partial struct Internal public partial struct Internal
{ {
[FieldOffset(176)] [FieldOffset(200)]
public global::System.IntPtr ASTContext; public global::System.IntPtr ASTContext;
[FieldOffset(184)] [FieldOffset(208)]
public int ToolSetToUse; public int ToolSetToUse;
[FieldOffset(224)] [FieldOffset(248)]
public CppSharp.Parser.AST.CppAbi Abi; public CppSharp.Parser.AST.CppAbi Abi;
[FieldOffset(228)] [FieldOffset(252)]
public byte NoStandardIncludes; public byte NoStandardIncludes;
[FieldOffset(229)] [FieldOffset(253)]
public byte NoBuiltinIncludes; public byte NoBuiltinIncludes;
[FieldOffset(230)] [FieldOffset(254)]
public byte MicrosoftMode; public byte MicrosoftMode;
[FieldOffset(231)] [FieldOffset(255)]
public byte Verbose; public byte Verbose;
[FieldOffset(232)] [FieldOffset(256)]
public CppSharp.Parser.LanguageVersion LanguageVersion; public CppSharp.Parser.LanguageVersion LanguageVersion;
[FieldOffset(240)] [FieldOffset(264)]
public global::System.IntPtr TargetInfo; public global::System.IntPtr TargetInfo;
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
@ -109,6 +109,21 @@ namespace CppSharp
EntryPoint="?clearArguments@ParserOptions@CppParser@CppSharp@@QEAAXXZ")] EntryPoint="?clearArguments@ParserOptions@CppParser@CppSharp@@QEAAXXZ")]
internal static extern void clearArguments_0(global::System.IntPtr instance); internal static extern void clearArguments_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?getSourceFiles@ParserOptions@CppParser@CppSharp@@QEAAPEBDI@Z")]
internal static extern global::System.IntPtr getSourceFiles_0(global::System.IntPtr instance, uint i);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?addSourceFiles@ParserOptions@CppParser@CppSharp@@QEAAXPEBD@Z")]
internal static extern void addSourceFiles_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?clearSourceFiles@ParserOptions@CppParser@CppSharp@@QEAAXXZ")]
internal static extern void clearSourceFiles_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?getIncludeDirs@ParserOptions@CppParser@CppSharp@@QEAAPEBDI@Z")] EntryPoint="?getIncludeDirs@ParserOptions@CppParser@CppSharp@@QEAAPEBDI@Z")]
@ -191,13 +206,18 @@ namespace CppSharp
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?getFileName@ParserOptions@CppParser@CppSharp@@QEAAPEBDXZ")] EntryPoint="?getLibraryFile@ParserOptions@CppParser@CppSharp@@QEAAPEBDXZ")]
internal static extern global::System.IntPtr getFileName_0(global::System.IntPtr instance); internal static extern global::System.IntPtr getLibraryFile_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?setFileName@ParserOptions@CppParser@CppSharp@@QEAAXPEBD@Z")] EntryPoint="?setLibraryFile@ParserOptions@CppParser@CppSharp@@QEAAXPEBD@Z")]
internal static extern void setFileName_0(global::System.IntPtr instance, global::System.IntPtr s); internal static extern void setLibraryFile_0(global::System.IntPtr instance, global::System.IntPtr s);
[SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="?getSourceFilesCount@ParserOptions@CppParser@CppSharp@@QEAAIXZ")]
internal static extern uint getSourceFilesCount_0(global::System.IntPtr instance);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
@ -255,7 +275,7 @@ namespace CppSharp
private static void* __CopyValue(ParserOptions.Internal native) private static void* __CopyValue(ParserOptions.Internal native)
{ {
var ret = Marshal.AllocHGlobal(248); var ret = Marshal.AllocHGlobal(272);
CppSharp.Parser.ParserOptions.Internal.cctor_2(ret, new global::System.IntPtr(&native)); CppSharp.Parser.ParserOptions.Internal.cctor_2(ret, new global::System.IntPtr(&native));
return ret.ToPointer(); return ret.ToPointer();
} }
@ -276,7 +296,7 @@ namespace CppSharp
public ParserOptions() public ParserOptions()
{ {
__Instance = Marshal.AllocHGlobal(248); __Instance = Marshal.AllocHGlobal(272);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
Internal.ctor_0((__Instance + __PointerAdjustment)); Internal.ctor_0((__Instance + __PointerAdjustment));
@ -284,7 +304,7 @@ namespace CppSharp
public ParserOptions(CppSharp.Parser.ParserOptions _0) public ParserOptions(CppSharp.Parser.ParserOptions _0)
{ {
__Instance = Marshal.AllocHGlobal(248); __Instance = Marshal.AllocHGlobal(272);
__ownsNativeInstance = true; __ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this; NativeToManagedMap[__Instance] = this;
if (ReferenceEquals(_0, null)) if (ReferenceEquals(_0, null))
@ -325,6 +345,24 @@ namespace CppSharp
Internal.clearArguments_0((__Instance + __PointerAdjustment)); Internal.clearArguments_0((__Instance + __PointerAdjustment));
} }
public string getSourceFiles(uint i)
{
var __ret = Internal.getSourceFiles_0((__Instance + __PointerAdjustment), i);
return Marshal.PtrToStringAnsi(__ret);
}
public void addSourceFiles(string s)
{
var arg0 = Marshal.StringToHGlobalAnsi(s);
Internal.addSourceFiles_0((__Instance + __PointerAdjustment), arg0);
Marshal.FreeHGlobal(arg0);
}
public void clearSourceFiles()
{
Internal.clearSourceFiles_0((__Instance + __PointerAdjustment));
}
public string getIncludeDirs(uint i) public string getIncludeDirs(uint i)
{ {
var __ret = Internal.getIncludeDirs_0((__Instance + __PointerAdjustment), i); var __ret = Internal.getIncludeDirs_0((__Instance + __PointerAdjustment), i);
@ -424,22 +462,31 @@ namespace CppSharp
} }
} }
public string FileName public string LibraryFile
{ {
get get
{ {
var __ret = Internal.getFileName_0((__Instance + __PointerAdjustment)); var __ret = Internal.getLibraryFile_0((__Instance + __PointerAdjustment));
return Marshal.PtrToStringAnsi(__ret); return Marshal.PtrToStringAnsi(__ret);
} }
set set
{ {
var arg0 = Marshal.StringToHGlobalAnsi(value); var arg0 = Marshal.StringToHGlobalAnsi(value);
Internal.setFileName_0((__Instance + __PointerAdjustment), arg0); Internal.setLibraryFile_0((__Instance + __PointerAdjustment), arg0);
Marshal.FreeHGlobal(arg0); Marshal.FreeHGlobal(arg0);
} }
} }
public uint SourceFilesCount
{
get
{
var __ret = Internal.getSourceFilesCount_0((__Instance + __PointerAdjustment));
return __ret;
}
}
public uint IncludeDirsCount public uint IncludeDirsCount
{ {
get get

3
src/CppParser/CppParser.cpp

@ -24,7 +24,8 @@ ParserOptions::ParserOptions()
} }
DEF_VECTOR_STRING(ParserOptions, Arguments) DEF_VECTOR_STRING(ParserOptions, Arguments)
DEF_STRING(ParserOptions, FileName) DEF_STRING(ParserOptions, LibraryFile)
DEF_VECTOR_STRING(ParserOptions, SourceFiles)
DEF_VECTOR_STRING(ParserOptions, IncludeDirs) DEF_VECTOR_STRING(ParserOptions, IncludeDirs)
DEF_VECTOR_STRING(ParserOptions, SystemIncludeDirs) DEF_VECTOR_STRING(ParserOptions, SystemIncludeDirs)
DEF_VECTOR_STRING(ParserOptions, Defines) DEF_VECTOR_STRING(ParserOptions, Defines)

5
src/CppParser/CppParser.h

@ -37,8 +37,9 @@ struct CS_API ParserOptions
VECTOR_STRING(Arguments) VECTOR_STRING(Arguments)
// C/C++ header file name. STRING(LibraryFile)
STRING(FileName) // C/C++ header file names.
VECTOR_STRING(SourceFiles)
// Include directories // Include directories
VECTOR_STRING(IncludeDirs) VECTOR_STRING(IncludeDirs)

33
src/CppParser/Parser.cpp

@ -3222,13 +3222,13 @@ void Parser::HandleDiagnostics(ParserResult* res)
} }
} }
ParserResult* Parser::ParseHeader(const std::string& File, ParserResult* res) ParserResult* Parser::ParseHeader(const std::vector<std::string>& SourceFiles, ParserResult* res)
{ {
assert(Opts->ASTContext && "Expected a valid ASTContext"); assert(Opts->ASTContext && "Expected a valid ASTContext");
res->ASTContext = Lib; res->ASTContext = Lib;
if (File.empty()) if (SourceFiles.empty())
{ {
res->Kind = ParserResultKind::FileNotFound; res->Kind = ParserResultKind::FileNotFound;
return res; return res;
@ -3250,20 +3250,28 @@ ParserResult* Parser::ParseHeader(const std::string& File, ParserResult* res)
std::pair<const clang::FileEntry *, const clang::DirectoryEntry *>, std::pair<const clang::FileEntry *, const clang::DirectoryEntry *>,
0> Includers; 0> Includers;
auto FileEntry = C->getPreprocessor().getHeaderSearchInfo().LookupFile(File, std::vector<const clang::FileEntry*> FileEntries;
clang::SourceLocation(), /*isAngled*/true, for (const auto& SourceFile : SourceFiles)
nullptr, Dir, Includers, nullptr, nullptr, nullptr, nullptr);
if (!FileEntry)
{ {
res->Kind = ParserResultKind::FileNotFound; auto FileEntry = C->getPreprocessor().getHeaderSearchInfo().LookupFile(SourceFile,
return res; clang::SourceLocation(), /*isAngled*/true,
nullptr, Dir, Includers, nullptr, nullptr, nullptr, nullptr);
if (!FileEntry)
{
res->Kind = ParserResultKind::FileNotFound;
return res;
}
FileEntries.push_back(FileEntry);
} }
// Create a virtual file that includes the header. This gets rid of some // Create a virtual file that includes the header. This gets rid of some
// Clang warnings about parsing an header file as the main file. // Clang warnings about parsing an header file as the main file.
std::string str; std::string str;
str += "#include \"" + File + "\"" + "\n"; for (const auto& SourceFile : SourceFiles)
{
str += "#include \"" + SourceFile + "\"" + "\n";
}
str += "\0"; str += "\0";
auto buffer = llvm::MemoryBuffer::getMemBuffer(str); auto buffer = llvm::MemoryBuffer::getMemBuffer(str);
@ -3287,6 +3295,7 @@ ParserResult* Parser::ParseHeader(const std::string& File, ParserResult* res)
AST = &C->getASTContext(); AST = &C->getASTContext();
auto FileEntry = FileEntries[0];
auto FileName = FileEntry->getName(); auto FileName = FileEntry->getName();
auto Unit = Lib->FindOrCreateModule(FileName); auto Unit = Lib->FindOrCreateModule(FileName);
@ -3294,7 +3303,7 @@ ParserResult* Parser::ParseHeader(const std::string& File, ParserResult* res)
HandleDeclaration(TU, Unit); HandleDeclaration(TU, Unit);
if (Unit->OriginalPtr == nullptr) if (Unit->OriginalPtr == nullptr)
Unit->OriginalPtr = (void*) FileEntry; Unit->OriginalPtr = (void*)FileEntry;
// Initialize enough Clang codegen machinery so we can get at ABI details. // Initialize enough Clang codegen machinery so we can get at ABI details.
llvm::LLVMContext Ctx; llvm::LLVMContext Ctx;
@ -3524,7 +3533,7 @@ ParserResult* ClangParser::ParseHeader(ParserOptions* Opts)
auto res = new ParserResult(); auto res = new ParserResult();
res->CodeParser = new Parser(Opts); res->CodeParser = new Parser(Opts);
return res->CodeParser->ParseHeader(Opts->FileName, res); return res->CodeParser->ParseHeader(Opts->SourceFiles, res);
} }
ParserResult* ClangParser::ParseLibrary(ParserOptions* Opts) ParserResult* ClangParser::ParseLibrary(ParserOptions* Opts)
@ -3534,7 +3543,7 @@ ParserResult* ClangParser::ParseLibrary(ParserOptions* Opts)
auto res = new ParserResult(); auto res = new ParserResult();
res->CodeParser = new Parser(Opts); res->CodeParser = new Parser(Opts);
return res->CodeParser->ParseLibrary(Opts->FileName, res); return res->CodeParser->ParseLibrary(Opts->LibraryFile, res);
} }
ParserTargetInfo* ClangParser::GetTargetInfo(ParserOptions* Opts) ParserTargetInfo* ClangParser::GetTargetInfo(ParserOptions* Opts)

2
src/CppParser/Parser.h

@ -48,7 +48,7 @@ public:
Parser(ParserOptions* Opts); Parser(ParserOptions* Opts);
void SetupHeader(); void SetupHeader();
ParserResult* ParseHeader(const std::string& File, ParserResult* res); ParserResult* ParseHeader(const std::vector<std::string>& SourceFiles, ParserResult* res);
ParserResult* ParseLibrary(const std::string& File, ParserResult* res); ParserResult* ParseLibrary(const std::string& File, ParserResult* res);
ParserResultKind ParseArchive(llvm::StringRef File, ParserResultKind ParseArchive(llvm::StringRef File,
llvm::object::Archive* Archive, llvm::object::Archive* Archive,

33
src/Generator/Driver.cs

@ -12,7 +12,6 @@ using CppSharp.Passes;
using CppSharp.Types; using CppSharp.Types;
using Microsoft.CSharp; using Microsoft.CSharp;
using CppSharp.Parser; using CppSharp.Parser;
using System.CodeDom;
using System; using System;
using System.Reflection; using System.Reflection;
@ -99,24 +98,29 @@ namespace CppSharp
Options.SetupMSVC(); Options.SetupMSVC();
} }
void OnSourceFileParsed(SourceFile file, ParserResult result) void OnSourceFileParsed(IList<SourceFile> files, ParserResult result)
{ {
OnFileParsed(file.Path, result); OnFileParsed(files.Select(f => f.Path), result);
} }
void OnFileParsed(string file, ParserResult result) void OnFileParsed(string file, ParserResult result)
{
OnFileParsed(new[] { file }, result);
}
void OnFileParsed(IEnumerable<string> files, ParserResult result)
{ {
switch (result.Kind) switch (result.Kind)
{ {
case ParserResultKind.Success: case ParserResultKind.Success:
Diagnostics.Message("Parsed '{0}'", file); Diagnostics.Message("Parsed '{0}'", string.Join(", ", files));
break; break;
case ParserResultKind.Error: case ParserResultKind.Error:
Diagnostics.Error("Error parsing '{0}'", file); Diagnostics.Error("Error parsing '{0}'", string.Join(", ", files));
hasParsingErrors = true; hasParsingErrors = true;
break; break;
case ParserResultKind.FileNotFound: case ParserResultKind.FileNotFound:
Diagnostics.Error("File '{0}' was not found", file); Diagnostics.Error("A file from '{0}' was not found", string.Join(",", files));
break; break;
} }
@ -137,11 +141,10 @@ namespace CppSharp
} }
} }
public ParserOptions BuildParseOptions(SourceFile file) public ParserOptions BuildParserOptions()
{ {
var options = new ParserOptions var options = new ParserOptions
{ {
FileName = file.Path,
Abi = Options.Abi, Abi = Options.Abi,
ToolSetToUse = Options.ToolSetToUse, ToolSetToUse = Options.ToolSetToUse,
TargetTriple = Options.TargetTriple, TargetTriple = Options.TargetTriple,
@ -197,7 +200,7 @@ namespace CppSharp
options.addLibraryDirs(lib); options.addLibraryDirs(lib);
} }
foreach (var module in Options.Modules.Where(m => m.Headers.Contains(file.Path))) foreach (var module in Options.Modules)
{ {
foreach (var include in module.IncludeDirs) foreach (var include in module.IncludeDirs)
options.addIncludeDirs(include); options.addIncludeDirs(include);
@ -219,8 +222,8 @@ namespace CppSharp
{ {
var parser = new ClangParser(new Parser.AST.ASTContext()); var parser = new ClangParser(new Parser.AST.ASTContext());
parser.SourceParsed += OnSourceFileParsed; parser.SourcesParsed += OnSourceFileParsed;
parser.ParseProject(Project); parser.ParseProject(Project, Options.UnityBuild);
TargetInfo = parser.GetTargetInfo(Options); TargetInfo = parser.GetTargetInfo(Options);
@ -234,7 +237,7 @@ namespace CppSharp
foreach (var header in Options.Modules.SelectMany(m => m.Headers)) foreach (var header in Options.Modules.SelectMany(m => m.Headers))
{ {
var source = Project.AddFile(header); var source = Project.AddFile(header);
source.Options = BuildParseOptions(source); source.Options = BuildParserOptions();
} }
} }
@ -416,7 +419,7 @@ namespace CppSharp
!compilerParameters.ReferencedAssemblies.Contains(libraryMappings[d])) !compilerParameters.ReferencedAssemblies.Contains(libraryMappings[d]))
.Select(l => libraryMappings[l])).ToArray()); .Select(l => libraryMappings[l])).ToArray());
Diagnostics.Message("Compiling generated code..."); Diagnostics.Message("Compiling {0}...", module.LibraryName);
CompilerResults compilerResults; CompilerResults compilerResults;
using (var codeProvider = new CSharpCodeProvider( using (var codeProvider = new CSharpCodeProvider(
new Dictionary<string, string> { { "CompilerVersion", "v4.0" } })) new Dictionary<string, string> { { "CompilerVersion", "v4.0" } }))
@ -523,7 +526,11 @@ namespace CppSharp
driver.SaveCode(outputs); driver.SaveCode(outputs);
if (driver.Options.IsCSharpGenerator && driver.Options.CompileCode) if (driver.Options.IsCSharpGenerator && driver.Options.CompileCode)
foreach (var module in driver.Options.Modules) foreach (var module in driver.Options.Modules)
{
driver.CompileCode(module); driver.CompileCode(module);
if (driver.HasCompilationErrors)
break;
}
} }
driver.Generator.Dispose(); driver.Generator.Dispose();

5
src/Generator/Generators/CSharp/CSharpTypePrinter.cs

@ -5,7 +5,6 @@ using CppSharp.AST.Extensions;
using CppSharp.Types; using CppSharp.Types;
using Type = CppSharp.AST.Type; using Type = CppSharp.AST.Type;
using ParserTargetInfo = CppSharp.Parser.ParserTargetInfo; using ParserTargetInfo = CppSharp.Parser.ParserTargetInfo;
using System.Linq;
namespace CppSharp.Generators.CSharp namespace CppSharp.Generators.CSharp
{ {
@ -142,7 +141,7 @@ namespace CppSharp.Generators.CSharp
Class @class; Class @class;
if (arrayType.TryGetClass(out @class)) if (arrayType.TryGetClass(out @class))
{ {
return new CSharpTypePrinterResult() return new CSharpTypePrinterResult
{ {
Type = "fixed byte", Type = "fixed byte",
NameSuffix = string.Format("[{0}]", array.Size * @class.Layout.Size) NameSuffix = string.Format("[{0}]", array.Size * @class.Layout.Size)
@ -158,7 +157,7 @@ namespace CppSharp.Generators.CSharp
// Do not write the fixed keyword multiple times for nested array types // Do not write the fixed keyword multiple times for nested array types
var fixedKeyword = array.Type is ArrayType ? string.Empty : "fixed "; var fixedKeyword = array.Type is ArrayType ? string.Empty : "fixed ";
return new CSharpTypePrinterResult() return new CSharpTypePrinterResult
{ {
Type = string.Format("{0}{1}", fixedKeyword, arrayElemType), Type = string.Format("{0}{1}", fixedKeyword, arrayElemType),
NameSuffix = string.Format("[{0}]", array.Size) NameSuffix = string.Format("[{0}]", array.Size)

6
src/Generator/Options.cs

@ -156,6 +156,12 @@ namespace CppSharp
/// </summary> /// </summary>
public bool GenerateFinalizers; public bool GenerateFinalizers;
/// <summary>
/// If this option is off (the default), each header is parsed separately which is much slower
/// but safer because of a clean state of the preprocessor for each header.
/// </summary>
public bool UnityBuild { get; set; }
public string IncludePrefix; public string IncludePrefix;
public bool WriteOnlyWhenChanged; public bool WriteOnlyWhenChanged;
public Func<TranslationUnit, string> GenerateName; public Func<TranslationUnit, string> GenerateName;

5
src/Generator/Passes/CleanUnitPass.cs

@ -18,9 +18,10 @@ namespace CppSharp.Passes
{ {
if (unit.IsValid && !unit.IsSystemHeader && unit.HasDeclarations) if (unit.IsValid && !unit.IsSystemHeader && unit.HasDeclarations)
{ {
var includeDir = Path.GetDirectoryName(unit.FilePath); var includeDir = Path.GetFullPath(Path.GetDirectoryName(unit.FilePath));
unit.Module = DriverOptions.Modules.FirstOrDefault( unit.Module = DriverOptions.Modules.FirstOrDefault(
m => m.IncludeDirs.Contains(includeDir)) ?? DriverOptions.MainModule; m => m.IncludeDirs.Any(i => Path.GetFullPath(i) == includeDir)) ??
DriverOptions.MainModule;
unit.Module.Units.Add(unit); unit.Module.Units.Add(unit);
} }

Loading…
Cancel
Save