Browse Source

Merged the passes for properties and made the result non-optional.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/719/head 0.7.7
Dimitar Dobrev 9 years ago
parent
commit
b2a872f431
  1. 2
      examples/SDL/SDL.cs
  2. 1014
      src/CppParser/Bindings/CLI/AST.cpp
  3. 696
      src/CppParser/Bindings/CLI/AST.h
  4. 256
      src/CppParser/Bindings/CLI/CppParser.cpp
  5. 176
      src/CppParser/Bindings/CLI/CppParser.h
  6. 6
      src/CppParser/Bindings/CLI/Sources.cpp
  7. 2
      src/CppParser/Bindings/CLI/Sources.h
  8. 28
      src/CppParser/Bindings/CLI/Target.cpp
  9. 12
      src/CppParser/Bindings/CLI/Target.h
  10. 2952
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs
  11. 794
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/Std.cs
  12. 2952
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs
  13. 692
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/Std.cs
  14. 2952
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs
  15. 794
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/Std.cs
  16. 2952
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs
  17. 602
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/Std.cs
  18. 2952
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs
  19. 596
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Std.cs
  20. 2952
      src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs
  21. 692
      src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/Std.cs
  22. 23
      src/CppParser/ParserGen/ParserGen.cs
  23. 2
      src/Generator.Tests/ASTTestFixture.cs
  24. 2
      src/Generator.Tests/GeneratorTest.cs
  25. 4
      src/Generator.Tests/Passes/TestPasses.cs
  26. 2
      src/Generator.Tests/ReadNativeDependenciesTest.cs
  27. 44
      src/Generator/Driver.cs
  28. 4
      src/Generator/Generators/CSharp/CSharpSources.cs
  29. 14
      src/Generator/Options.cs
  30. 2
      src/Generator/Passes/CleanUnitPass.cs
  31. 345
      src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs
  32. 429
      src/Generator/Passes/GetterSetterToPropertyPass.cs
  33. 84
      src/Parser/ASTConverter.cs
  34. 8
      src/Parser/Parser.cs
  35. 16
      src/Parser/ParserOptions.cs
  36. 1
      tests/CSharp/CSharp.cs
  37. 42
      tests/Common/Common.Tests.cs
  38. 10
      tests/Common/Common.cs
  39. 4
      tests/Common/Common.h
  40. 1
      tests/NamespacesDerived/NamespacesDerived.cs
  41. 2
      tests/StandardLib/StandardLib.Tests.cs
  42. 1
      tests/TypeMaps/TypeMaps.cs
  43. 17
      tests/VTables/VTables.Tests.cs

2
examples/SDL/SDL.cs

@ -14,7 +14,7 @@ namespace CppSharp
options.LibraryName = "SDL"; options.LibraryName = "SDL";
options.Headers.Add("SDL.h"); options.Headers.Add("SDL.h");
var sdlPath = Path.Combine(GetExamplesDirectory("SDL"), "SDL-2.0/include"); var sdlPath = Path.Combine(GetExamplesDirectory("SDL"), "SDL-2.0/include");
parserOptions.addIncludeDirs(sdlPath); parserOptions.AddIncludeDirs(sdlPath);
options.OutputDir = "SDL"; options.OutputDir = "SDL";
} }

1014
src/CppParser/Bindings/CLI/AST.cpp

File diff suppressed because it is too large Load Diff

696
src/CppParser/Bindings/CLI/AST.h

File diff suppressed because it is too large Load Diff

256
src/CppParser/Bindings/CLI/CppParser.cpp

@ -27,135 +27,135 @@ CppSharp::Parser::CppParserOptions::CppParserOptions()
NativePtr = new ::CppSharp::CppParser::CppParserOptions(); NativePtr = new ::CppSharp::CppParser::CppParserOptions();
} }
System::String^ CppSharp::Parser::CppParserOptions::getArguments(unsigned int i) System::String^ CppSharp::Parser::CppParserOptions::GetArguments(unsigned int i)
{ {
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getArguments(i); auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getArguments(i);
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::CppParserOptions::addArguments(System::String^ s) void CppSharp::Parser::CppParserOptions::AddArguments(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::CppParserOptions*)NativePtr)->addArguments(__arg0); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->addArguments(__arg0);
} }
void CppSharp::Parser::CppParserOptions::clearArguments() void CppSharp::Parser::CppParserOptions::ClearArguments()
{ {
((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearArguments(); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearArguments();
} }
System::String^ CppSharp::Parser::CppParserOptions::getSourceFiles(unsigned int i) System::String^ CppSharp::Parser::CppParserOptions::GetSourceFiles(unsigned int i)
{ {
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getSourceFiles(i); auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getSourceFiles(i);
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::CppParserOptions::addSourceFiles(System::String^ s) void CppSharp::Parser::CppParserOptions::AddSourceFiles(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::CppParserOptions*)NativePtr)->addSourceFiles(__arg0); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->addSourceFiles(__arg0);
} }
void CppSharp::Parser::CppParserOptions::clearSourceFiles() void CppSharp::Parser::CppParserOptions::ClearSourceFiles()
{ {
((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearSourceFiles(); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearSourceFiles();
} }
System::String^ CppSharp::Parser::CppParserOptions::getIncludeDirs(unsigned int i) System::String^ CppSharp::Parser::CppParserOptions::GetIncludeDirs(unsigned int i)
{ {
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getIncludeDirs(i); auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getIncludeDirs(i);
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::CppParserOptions::addIncludeDirs(System::String^ s) void CppSharp::Parser::CppParserOptions::AddIncludeDirs(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::CppParserOptions*)NativePtr)->addIncludeDirs(__arg0); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->addIncludeDirs(__arg0);
} }
void CppSharp::Parser::CppParserOptions::clearIncludeDirs() void CppSharp::Parser::CppParserOptions::ClearIncludeDirs()
{ {
((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearIncludeDirs(); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearIncludeDirs();
} }
System::String^ CppSharp::Parser::CppParserOptions::getSystemIncludeDirs(unsigned int i) System::String^ CppSharp::Parser::CppParserOptions::GetSystemIncludeDirs(unsigned int i)
{ {
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getSystemIncludeDirs(i); auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getSystemIncludeDirs(i);
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::CppParserOptions::addSystemIncludeDirs(System::String^ s) void CppSharp::Parser::CppParserOptions::AddSystemIncludeDirs(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::CppParserOptions*)NativePtr)->addSystemIncludeDirs(__arg0); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->addSystemIncludeDirs(__arg0);
} }
void CppSharp::Parser::CppParserOptions::clearSystemIncludeDirs() void CppSharp::Parser::CppParserOptions::ClearSystemIncludeDirs()
{ {
((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearSystemIncludeDirs(); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearSystemIncludeDirs();
} }
System::String^ CppSharp::Parser::CppParserOptions::getDefines(unsigned int i) System::String^ CppSharp::Parser::CppParserOptions::GetDefines(unsigned int i)
{ {
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getDefines(i); auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getDefines(i);
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::CppParserOptions::addDefines(System::String^ s) void CppSharp::Parser::CppParserOptions::AddDefines(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::CppParserOptions*)NativePtr)->addDefines(__arg0); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->addDefines(__arg0);
} }
void CppSharp::Parser::CppParserOptions::clearDefines() void CppSharp::Parser::CppParserOptions::ClearDefines()
{ {
((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearDefines(); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearDefines();
} }
System::String^ CppSharp::Parser::CppParserOptions::getUndefines(unsigned int i) System::String^ CppSharp::Parser::CppParserOptions::GetUndefines(unsigned int i)
{ {
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getUndefines(i); auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getUndefines(i);
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::CppParserOptions::addUndefines(System::String^ s) void CppSharp::Parser::CppParserOptions::AddUndefines(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::CppParserOptions*)NativePtr)->addUndefines(__arg0); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->addUndefines(__arg0);
} }
void CppSharp::Parser::CppParserOptions::clearUndefines() void CppSharp::Parser::CppParserOptions::ClearUndefines()
{ {
((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearUndefines(); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearUndefines();
} }
System::String^ CppSharp::Parser::CppParserOptions::getLibraryDirs(unsigned int i) System::String^ CppSharp::Parser::CppParserOptions::GetLibraryDirs(unsigned int i)
{ {
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getLibraryDirs(i); auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getLibraryDirs(i);
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::CppParserOptions::addLibraryDirs(System::String^ s) void CppSharp::Parser::CppParserOptions::AddLibraryDirs(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::CppParserOptions*)NativePtr)->addLibraryDirs(__arg0); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->addLibraryDirs(__arg0);
} }
void CppSharp::Parser::CppParserOptions::clearLibraryDirs() void CppSharp::Parser::CppParserOptions::ClearLibraryDirs()
{ {
((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearLibraryDirs(); ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->clearLibraryDirs();
} }
@ -179,76 +179,6 @@ void CppSharp::Parser::CppParserOptions::__Instance::set(System::IntPtr object)
NativePtr = (::CppSharp::CppParser::CppParserOptions*)object.ToPointer(); NativePtr = (::CppSharp::CppParser::CppParserOptions*)object.ToPointer();
} }
unsigned int CppSharp::Parser::CppParserOptions::ArgumentsCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getArgumentsCount();
return __ret;
}
System::String^ CppSharp::Parser::CppParserOptions::LibraryFile::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getLibraryFile();
if (__ret == nullptr) return nullptr;
return (__ret == 0 ? nullptr : clix::marshalString<clix::E_UTF8>(__ret));
}
void CppSharp::Parser::CppParserOptions::LibraryFile::set(System::String^ s)
{
auto ___arg0 = clix::marshalString<clix::E_UTF8>(s);
auto __arg0 = ___arg0.c_str();
((::CppSharp::CppParser::CppParserOptions*)NativePtr)->setLibraryFile(__arg0);
}
unsigned int CppSharp::Parser::CppParserOptions::SourceFilesCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getSourceFilesCount();
return __ret;
}
unsigned int CppSharp::Parser::CppParserOptions::IncludeDirsCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getIncludeDirsCount();
return __ret;
}
unsigned int CppSharp::Parser::CppParserOptions::SystemIncludeDirsCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getSystemIncludeDirsCount();
return __ret;
}
unsigned int CppSharp::Parser::CppParserOptions::DefinesCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getDefinesCount();
return __ret;
}
unsigned int CppSharp::Parser::CppParserOptions::UndefinesCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getUndefinesCount();
return __ret;
}
unsigned int CppSharp::Parser::CppParserOptions::LibraryDirsCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getLibraryDirsCount();
return __ret;
}
System::String^ CppSharp::Parser::CppParserOptions::TargetTriple::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getTargetTriple();
if (__ret == nullptr) return nullptr;
return (__ret == 0 ? nullptr : clix::marshalString<clix::E_UTF8>(__ret));
}
void CppSharp::Parser::CppParserOptions::TargetTriple::set(System::String^ s)
{
auto ___arg0 = clix::marshalString<clix::E_UTF8>(s);
auto __arg0 = ___arg0.c_str();
((::CppSharp::CppParser::CppParserOptions*)NativePtr)->setTargetTriple(__arg0);
}
CppSharp::Parser::AST::ASTContext^ CppSharp::Parser::CppParserOptions::ASTContext::get() CppSharp::Parser::AST::ASTContext^ CppSharp::Parser::CppParserOptions::ASTContext::get()
{ {
return (((::CppSharp::CppParser::CppParserOptions*)NativePtr)->ASTContext == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::ASTContext((::CppSharp::CppParser::AST::ASTContext*)((::CppSharp::CppParser::CppParserOptions*)NativePtr)->ASTContext); return (((::CppSharp::CppParser::CppParserOptions*)NativePtr)->ASTContext == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::ASTContext((::CppSharp::CppParser::AST::ASTContext*)((::CppSharp::CppParser::CppParserOptions*)NativePtr)->ASTContext);
@ -339,6 +269,76 @@ void CppSharp::Parser::CppParserOptions::TargetInfo::set(CppSharp::Parser::Parse
((::CppSharp::CppParser::CppParserOptions*)NativePtr)->TargetInfo = (::CppSharp::CppParser::ParserTargetInfo*)value->NativePtr; ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->TargetInfo = (::CppSharp::CppParser::ParserTargetInfo*)value->NativePtr;
} }
System::String^ CppSharp::Parser::CppParserOptions::LibraryFile::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getLibraryFile();
if (__ret == nullptr) return nullptr;
return (__ret == 0 ? nullptr : clix::marshalString<clix::E_UTF8>(__ret));
}
void CppSharp::Parser::CppParserOptions::LibraryFile::set(System::String^ s)
{
auto ___arg0 = clix::marshalString<clix::E_UTF8>(s);
auto __arg0 = ___arg0.c_str();
((::CppSharp::CppParser::CppParserOptions*)NativePtr)->setLibraryFile(__arg0);
}
System::String^ CppSharp::Parser::CppParserOptions::TargetTriple::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getTargetTriple();
if (__ret == nullptr) return nullptr;
return (__ret == 0 ? nullptr : clix::marshalString<clix::E_UTF8>(__ret));
}
void CppSharp::Parser::CppParserOptions::TargetTriple::set(System::String^ s)
{
auto ___arg0 = clix::marshalString<clix::E_UTF8>(s);
auto __arg0 = ___arg0.c_str();
((::CppSharp::CppParser::CppParserOptions*)NativePtr)->setTargetTriple(__arg0);
}
unsigned int CppSharp::Parser::CppParserOptions::ArgumentsCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getArgumentsCount();
return __ret;
}
unsigned int CppSharp::Parser::CppParserOptions::SourceFilesCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getSourceFilesCount();
return __ret;
}
unsigned int CppSharp::Parser::CppParserOptions::IncludeDirsCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getIncludeDirsCount();
return __ret;
}
unsigned int CppSharp::Parser::CppParserOptions::SystemIncludeDirsCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getSystemIncludeDirsCount();
return __ret;
}
unsigned int CppSharp::Parser::CppParserOptions::DefinesCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getDefinesCount();
return __ret;
}
unsigned int CppSharp::Parser::CppParserOptions::UndefinesCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getUndefinesCount();
return __ret;
}
unsigned int CppSharp::Parser::CppParserOptions::LibraryDirsCount::get()
{
auto __ret = ((::CppSharp::CppParser::CppParserOptions*)NativePtr)->getLibraryDirsCount();
return __ret;
}
CppSharp::Parser::ParserDiagnostic::ParserDiagnostic(::CppSharp::CppParser::ParserDiagnostic* native) CppSharp::Parser::ParserDiagnostic::ParserDiagnostic(::CppSharp::CppParser::ParserDiagnostic* native)
: __ownsNativeInstance(false) : __ownsNativeInstance(false)
{ {
@ -380,34 +380,6 @@ void CppSharp::Parser::ParserDiagnostic::__Instance::set(System::IntPtr object)
NativePtr = (::CppSharp::CppParser::ParserDiagnostic*)object.ToPointer(); NativePtr = (::CppSharp::CppParser::ParserDiagnostic*)object.ToPointer();
} }
System::String^ CppSharp::Parser::ParserDiagnostic::FileName::get()
{
auto __ret = ((::CppSharp::CppParser::ParserDiagnostic*)NativePtr)->getFileName();
if (__ret == nullptr) return nullptr;
return (__ret == 0 ? nullptr : clix::marshalString<clix::E_UTF8>(__ret));
}
void CppSharp::Parser::ParserDiagnostic::FileName::set(System::String^ s)
{
auto ___arg0 = clix::marshalString<clix::E_UTF8>(s);
auto __arg0 = ___arg0.c_str();
((::CppSharp::CppParser::ParserDiagnostic*)NativePtr)->setFileName(__arg0);
}
System::String^ CppSharp::Parser::ParserDiagnostic::Message::get()
{
auto __ret = ((::CppSharp::CppParser::ParserDiagnostic*)NativePtr)->getMessage();
if (__ret == nullptr) return nullptr;
return (__ret == 0 ? nullptr : clix::marshalString<clix::E_UTF8>(__ret));
}
void CppSharp::Parser::ParserDiagnostic::Message::set(System::String^ s)
{
auto ___arg0 = clix::marshalString<clix::E_UTF8>(s);
auto __arg0 = ___arg0.c_str();
((::CppSharp::CppParser::ParserDiagnostic*)NativePtr)->setMessage(__arg0);
}
CppSharp::Parser::ParserDiagnosticLevel CppSharp::Parser::ParserDiagnostic::Level::get() CppSharp::Parser::ParserDiagnosticLevel CppSharp::Parser::ParserDiagnostic::Level::get()
{ {
return (CppSharp::Parser::ParserDiagnosticLevel)((::CppSharp::CppParser::ParserDiagnostic*)NativePtr)->Level; return (CppSharp::Parser::ParserDiagnosticLevel)((::CppSharp::CppParser::ParserDiagnostic*)NativePtr)->Level;
@ -438,6 +410,34 @@ void CppSharp::Parser::ParserDiagnostic::ColumnNumber::set(int value)
((::CppSharp::CppParser::ParserDiagnostic*)NativePtr)->ColumnNumber = value; ((::CppSharp::CppParser::ParserDiagnostic*)NativePtr)->ColumnNumber = value;
} }
System::String^ CppSharp::Parser::ParserDiagnostic::FileName::get()
{
auto __ret = ((::CppSharp::CppParser::ParserDiagnostic*)NativePtr)->getFileName();
if (__ret == nullptr) return nullptr;
return (__ret == 0 ? nullptr : clix::marshalString<clix::E_UTF8>(__ret));
}
void CppSharp::Parser::ParserDiagnostic::FileName::set(System::String^ s)
{
auto ___arg0 = clix::marshalString<clix::E_UTF8>(s);
auto __arg0 = ___arg0.c_str();
((::CppSharp::CppParser::ParserDiagnostic*)NativePtr)->setFileName(__arg0);
}
System::String^ CppSharp::Parser::ParserDiagnostic::Message::get()
{
auto __ret = ((::CppSharp::CppParser::ParserDiagnostic*)NativePtr)->getMessage();
if (__ret == nullptr) return nullptr;
return (__ret == 0 ? nullptr : clix::marshalString<clix::E_UTF8>(__ret));
}
void CppSharp::Parser::ParserDiagnostic::Message::set(System::String^ s)
{
auto ___arg0 = clix::marshalString<clix::E_UTF8>(s);
auto __arg0 = ___arg0.c_str();
((::CppSharp::CppParser::ParserDiagnostic*)NativePtr)->setMessage(__arg0);
}
CppSharp::Parser::ParserResult::ParserResult(::CppSharp::CppParser::ParserResult* native) CppSharp::Parser::ParserResult::ParserResult(::CppSharp::CppParser::ParserResult* native)
: __ownsNativeInstance(false) : __ownsNativeInstance(false)
{ {
@ -469,14 +469,14 @@ CppSharp::Parser::ParserResult::ParserResult(CppSharp::Parser::ParserResult^ _0)
NativePtr = new ::CppSharp::CppParser::ParserResult(__arg0); NativePtr = new ::CppSharp::CppParser::ParserResult(__arg0);
} }
CppSharp::Parser::ParserDiagnostic^ CppSharp::Parser::ParserResult::getDiagnostics(unsigned int i) CppSharp::Parser::ParserDiagnostic^ CppSharp::Parser::ParserResult::GetDiagnostics(unsigned int i)
{ {
auto __ret = ((::CppSharp::CppParser::ParserResult*)NativePtr)->getDiagnostics(i); auto __ret = ((::CppSharp::CppParser::ParserResult*)NativePtr)->getDiagnostics(i);
auto ____ret = new ::CppSharp::CppParser::ParserDiagnostic(__ret); auto ____ret = new ::CppSharp::CppParser::ParserDiagnostic(__ret);
return (____ret == nullptr) ? nullptr : gcnew CppSharp::Parser::ParserDiagnostic((::CppSharp::CppParser::ParserDiagnostic*)____ret); return (____ret == nullptr) ? nullptr : gcnew CppSharp::Parser::ParserDiagnostic((::CppSharp::CppParser::ParserDiagnostic*)____ret);
} }
void CppSharp::Parser::ParserResult::addDiagnostics(CppSharp::Parser::ParserDiagnostic^ s) void CppSharp::Parser::ParserResult::AddDiagnostics(CppSharp::Parser::ParserDiagnostic^ s)
{ {
if (ReferenceEquals(s, nullptr)) if (ReferenceEquals(s, nullptr))
throw gcnew ::System::ArgumentNullException("s", "Cannot be null because it is a C++ reference (&)."); throw gcnew ::System::ArgumentNullException("s", "Cannot be null because it is a C++ reference (&).");
@ -484,7 +484,7 @@ void CppSharp::Parser::ParserResult::addDiagnostics(CppSharp::Parser::ParserDiag
((::CppSharp::CppParser::ParserResult*)NativePtr)->addDiagnostics(__arg0); ((::CppSharp::CppParser::ParserResult*)NativePtr)->addDiagnostics(__arg0);
} }
void CppSharp::Parser::ParserResult::clearDiagnostics() void CppSharp::Parser::ParserResult::ClearDiagnostics()
{ {
((::CppSharp::CppParser::ParserResult*)NativePtr)->clearDiagnostics(); ((::CppSharp::CppParser::ParserResult*)NativePtr)->clearDiagnostics();
} }
@ -499,12 +499,6 @@ void CppSharp::Parser::ParserResult::__Instance::set(System::IntPtr object)
NativePtr = (::CppSharp::CppParser::ParserResult*)object.ToPointer(); NativePtr = (::CppSharp::CppParser::ParserResult*)object.ToPointer();
} }
unsigned int CppSharp::Parser::ParserResult::DiagnosticsCount::get()
{
auto __ret = ((::CppSharp::CppParser::ParserResult*)NativePtr)->getDiagnosticsCount();
return __ret;
}
CppSharp::Parser::ParserResultKind CppSharp::Parser::ParserResult::Kind::get() CppSharp::Parser::ParserResultKind CppSharp::Parser::ParserResult::Kind::get()
{ {
return (CppSharp::Parser::ParserResultKind)((::CppSharp::CppParser::ParserResult*)NativePtr)->Kind; return (CppSharp::Parser::ParserResultKind)((::CppSharp::CppParser::ParserResult*)NativePtr)->Kind;
@ -535,6 +529,12 @@ void CppSharp::Parser::ParserResult::Library::set(CppSharp::Parser::AST::NativeL
((::CppSharp::CppParser::ParserResult*)NativePtr)->Library = (::CppSharp::CppParser::AST::NativeLibrary*)value->NativePtr; ((::CppSharp::CppParser::ParserResult*)NativePtr)->Library = (::CppSharp::CppParser::AST::NativeLibrary*)value->NativePtr;
} }
unsigned int CppSharp::Parser::ParserResult::DiagnosticsCount::get()
{
auto __ret = ((::CppSharp::CppParser::ParserResult*)NativePtr)->getDiagnosticsCount();
return __ret;
}
CppSharp::Parser::ClangParser::ClangParser(::CppSharp::CppParser::ClangParser* native) CppSharp::Parser::ClangParser::ClangParser(::CppSharp::CppParser::ClangParser* native)
: __ownsNativeInstance(false) : __ownsNativeInstance(false)
{ {

176
src/CppParser/Bindings/CLI/CppParser.h

@ -90,53 +90,6 @@ namespace CppSharp
~CppParserOptions(); ~CppParserOptions();
property unsigned int ArgumentsCount
{
unsigned int get();
}
property System::String^ LibraryFile
{
System::String^ get();
void set(System::String^);
}
property unsigned int SourceFilesCount
{
unsigned int get();
}
property unsigned int IncludeDirsCount
{
unsigned int get();
}
property unsigned int SystemIncludeDirsCount
{
unsigned int get();
}
property unsigned int DefinesCount
{
unsigned int get();
}
property unsigned int UndefinesCount
{
unsigned int get();
}
property unsigned int LibraryDirsCount
{
unsigned int get();
}
property System::String^ TargetTriple
{
System::String^ get();
void set(System::String^);
}
property CppSharp::Parser::AST::ASTContext^ ASTContext property CppSharp::Parser::AST::ASTContext^ ASTContext
{ {
CppSharp::Parser::AST::ASTContext^ get(); CppSharp::Parser::AST::ASTContext^ get();
@ -191,47 +144,94 @@ namespace CppSharp
void set(CppSharp::Parser::ParserTargetInfo^); void set(CppSharp::Parser::ParserTargetInfo^);
} }
System::String^ getArguments(unsigned int i); property System::String^ LibraryFile
{
System::String^ get();
void set(System::String^);
}
property System::String^ TargetTriple
{
System::String^ get();
void set(System::String^);
}
property unsigned int ArgumentsCount
{
unsigned int get();
}
property unsigned int SourceFilesCount
{
unsigned int get();
}
property unsigned int IncludeDirsCount
{
unsigned int get();
}
property unsigned int SystemIncludeDirsCount
{
unsigned int get();
}
property unsigned int DefinesCount
{
unsigned int get();
}
property unsigned int UndefinesCount
{
unsigned int get();
}
void addArguments(System::String^ s); property unsigned int LibraryDirsCount
{
unsigned int get();
}
void clearArguments(); System::String^ GetArguments(unsigned int i);
System::String^ getSourceFiles(unsigned int i); void AddArguments(System::String^ s);
void addSourceFiles(System::String^ s); void ClearArguments();
void clearSourceFiles(); System::String^ GetSourceFiles(unsigned int i);
System::String^ getIncludeDirs(unsigned int i); void AddSourceFiles(System::String^ s);
void addIncludeDirs(System::String^ s); void ClearSourceFiles();
void clearIncludeDirs(); System::String^ GetIncludeDirs(unsigned int i);
System::String^ getSystemIncludeDirs(unsigned int i); void AddIncludeDirs(System::String^ s);
void addSystemIncludeDirs(System::String^ s); void ClearIncludeDirs();
void clearSystemIncludeDirs(); System::String^ GetSystemIncludeDirs(unsigned int i);
System::String^ getDefines(unsigned int i); void AddSystemIncludeDirs(System::String^ s);
void addDefines(System::String^ s); void ClearSystemIncludeDirs();
void clearDefines(); System::String^ GetDefines(unsigned int i);
System::String^ getUndefines(unsigned int i); void AddDefines(System::String^ s);
void addUndefines(System::String^ s); void ClearDefines();
void clearUndefines(); System::String^ GetUndefines(unsigned int i);
System::String^ getLibraryDirs(unsigned int i); void AddUndefines(System::String^ s);
void addLibraryDirs(System::String^ s); void ClearUndefines();
void clearLibraryDirs(); System::String^ GetLibraryDirs(unsigned int i);
void AddLibraryDirs(System::String^ s);
void ClearLibraryDirs();
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
@ -256,18 +256,6 @@ namespace CppSharp
~ParserDiagnostic(); ~ParserDiagnostic();
property System::String^ FileName
{
System::String^ get();
void set(System::String^);
}
property System::String^ Message
{
System::String^ get();
void set(System::String^);
}
property CppSharp::Parser::ParserDiagnosticLevel Level property CppSharp::Parser::ParserDiagnosticLevel Level
{ {
CppSharp::Parser::ParserDiagnosticLevel get(); CppSharp::Parser::ParserDiagnosticLevel get();
@ -286,6 +274,18 @@ namespace CppSharp
void set(int); void set(int);
} }
property System::String^ FileName
{
System::String^ get();
void set(System::String^);
}
property System::String^ Message
{
System::String^ get();
void set(System::String^);
}
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };
@ -309,11 +309,6 @@ namespace CppSharp
~ParserResult(); ~ParserResult();
property unsigned int DiagnosticsCount
{
unsigned int get();
}
property CppSharp::Parser::ParserResultKind Kind property CppSharp::Parser::ParserResultKind Kind
{ {
CppSharp::Parser::ParserResultKind get(); CppSharp::Parser::ParserResultKind get();
@ -332,11 +327,16 @@ namespace CppSharp
void set(CppSharp::Parser::AST::NativeLibrary^); void set(CppSharp::Parser::AST::NativeLibrary^);
} }
CppSharp::Parser::ParserDiagnostic^ getDiagnostics(unsigned int i); property unsigned int DiagnosticsCount
{
unsigned int get();
}
CppSharp::Parser::ParserDiagnostic^ GetDiagnostics(unsigned int i);
void addDiagnostics(CppSharp::Parser::ParserDiagnostic^ s); void AddDiagnostics(CppSharp::Parser::ParserDiagnostic^ s);
void clearDiagnostics(); void ClearDiagnostics();
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;

6
src/CppParser/Bindings/CLI/Sources.cpp

@ -19,6 +19,12 @@ CppSharp::Parser::SourceLocation::SourceLocation(unsigned int ID)
this->ID = _native.ID; this->ID = _native.ID;
} }
CppSharp::Parser::SourceLocation::operator CppSharp::Parser::SourceLocation(unsigned int ID)
{
auto __ret = (::CppSharp::CppParser::SourceLocation) ID;
return CppSharp::Parser::SourceLocation((::CppSharp::CppParser::SourceLocation*)&__ret);
}
unsigned int CppSharp::Parser::SourceLocation::ID::get() unsigned int CppSharp::Parser::SourceLocation::ID::get()
{ {
return __ID; return __ID;

2
src/CppParser/Bindings/CLI/Sources.h

@ -29,6 +29,8 @@ namespace CppSharp
void set(unsigned int); void set(unsigned int);
} }
static operator CppSharp::Parser::SourceLocation(unsigned int ID);
private: private:
unsigned int __ID; unsigned int __ID;
}; };

28
src/CppParser/Bindings/CLI/Target.cpp

@ -44,20 +44,6 @@ void CppSharp::Parser::ParserTargetInfo::__Instance::set(System::IntPtr object)
NativePtr = (::CppSharp::CppParser::ParserTargetInfo*)object.ToPointer(); NativePtr = (::CppSharp::CppParser::ParserTargetInfo*)object.ToPointer();
} }
System::String^ CppSharp::Parser::ParserTargetInfo::ABI::get()
{
auto __ret = ((::CppSharp::CppParser::ParserTargetInfo*)NativePtr)->getABI();
if (__ret == nullptr) return nullptr;
return (__ret == 0 ? nullptr : clix::marshalString<clix::E_UTF8>(__ret));
}
void CppSharp::Parser::ParserTargetInfo::ABI::set(System::String^ s)
{
auto ___arg0 = clix::marshalString<clix::E_UTF8>(s);
auto __arg0 = ___arg0.c_str();
((::CppSharp::CppParser::ParserTargetInfo*)NativePtr)->setABI(__arg0);
}
CppSharp::Parser::ParserIntType CppSharp::Parser::ParserTargetInfo::Char16Type::get() CppSharp::Parser::ParserIntType CppSharp::Parser::ParserTargetInfo::Char16Type::get()
{ {
return (CppSharp::Parser::ParserIntType)((::CppSharp::CppParser::ParserTargetInfo*)NativePtr)->Char16Type; return (CppSharp::Parser::ParserIntType)((::CppSharp::CppParser::ParserTargetInfo*)NativePtr)->Char16Type;
@ -438,3 +424,17 @@ void CppSharp::Parser::ParserTargetInfo::WCharWidth::set(unsigned int value)
((::CppSharp::CppParser::ParserTargetInfo*)NativePtr)->WCharWidth = value; ((::CppSharp::CppParser::ParserTargetInfo*)NativePtr)->WCharWidth = value;
} }
System::String^ CppSharp::Parser::ParserTargetInfo::ABI::get()
{
auto __ret = ((::CppSharp::CppParser::ParserTargetInfo*)NativePtr)->getABI();
if (__ret == nullptr) return nullptr;
return (__ret == 0 ? nullptr : clix::marshalString<clix::E_UTF8>(__ret));
}
void CppSharp::Parser::ParserTargetInfo::ABI::set(System::String^ s)
{
auto ___arg0 = clix::marshalString<clix::E_UTF8>(s);
auto __arg0 = ___arg0.c_str();
((::CppSharp::CppParser::ParserTargetInfo*)NativePtr)->setABI(__arg0);
}

12
src/CppParser/Bindings/CLI/Target.h

@ -50,12 +50,6 @@ namespace CppSharp
~ParserTargetInfo(); ~ParserTargetInfo();
property System::String^ ABI
{
System::String^ get();
void set(System::String^);
}
property CppSharp::Parser::ParserIntType Char16Type property CppSharp::Parser::ParserIntType Char16Type
{ {
CppSharp::Parser::ParserIntType get(); CppSharp::Parser::ParserIntType get();
@ -284,6 +278,12 @@ namespace CppSharp
void set(unsigned int); void set(unsigned int);
} }
property System::String^ ABI
{
System::String^ get();
void set(System::String^);
}
protected: protected:
bool __ownsNativeInstance; bool __ownsNativeInstance;
}; };

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

2952
src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs

File diff suppressed because it is too large Load Diff

602
src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/Std.cs

File diff suppressed because it is too large Load Diff

2952
src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs

File diff suppressed because it is too large Load Diff

596
src/CppParser/Bindings/CSharp/x86_64-linux-gnu/Std.cs

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

23
src/CppParser/ParserGen/ParserGen.cs

@ -76,8 +76,8 @@ namespace CppSharp
SetupLinuxOptions(parserOptions); SetupLinuxOptions(parserOptions);
var basePath = Path.Combine(GetSourceDirectory("src"), "CppParser"); var basePath = Path.Combine(GetSourceDirectory("src"), "CppParser");
parserOptions.addIncludeDirs(basePath); parserOptions.AddIncludeDirs(basePath);
parserOptions.addLibraryDirs("."); parserOptions.AddLibraryDirs(".");
options.OutputDir = Path.Combine(GetSourceDirectory("src"), "CppParser", options.OutputDir = Path.Combine(GetSourceDirectory("src"), "CppParser",
"Bindings", Kind.ToString()); "Bindings", Kind.ToString());
@ -122,9 +122,9 @@ namespace CppSharp
}; };
foreach (var dir in systemIncludeDirs) foreach (var dir in systemIncludeDirs)
options.addSystemIncludeDirs(Path.Combine(headersPath, dir)); options.AddSystemIncludeDirs(Path.Combine(headersPath, dir));
options.addDefines("_GLIBCXX_USE_CXX11_ABI=" + (IsGnuCpp11Abi ? "1" : "0")); options.AddDefines("_GLIBCXX_USE_CXX11_ABI=" + (IsGnuCpp11Abi ? "1" : "0"));
} }
private static void SetupMacOptions(ParserOptions options) private static void SetupMacOptions(ParserOptions options)
@ -144,23 +144,22 @@ namespace CppSharp
Console.WriteLine(header); Console.WriteLine(header);
foreach (var header in headersPaths) foreach (var header in headersPaths)
options.addSystemIncludeDirs(header); options.AddSystemIncludeDirs(header);
} }
var headersPath = Path.Combine(GetSourceDirectory("build"), "headers", var headersPath = Path.Combine(GetSourceDirectory("build"), "headers",
"osx"); "osx");
options.addSystemIncludeDirs(Path.Combine(headersPath, "include")); options.AddSystemIncludeDirs(Path.Combine(headersPath, "include"));
options.addSystemIncludeDirs(Path.Combine(headersPath, "clang", "4.2", "include")); options.AddSystemIncludeDirs(Path.Combine(headersPath, "clang", "4.2", "include"));
options.addSystemIncludeDirs(Path.Combine(headersPath, "libcxx", "include")); options.AddSystemIncludeDirs(Path.Combine(headersPath, "libcxx", "include"));
options.addArguments("-stdlib=libc++"); options.AddArguments("-stdlib=libc++");
} }
public void SetupPasses(Driver driver) public void SetupPasses(Driver driver)
{ {
driver.AddTranslationUnitPass(new CheckMacroPass()); driver.AddTranslationUnitPass(new CheckMacroPass());
driver.AddTranslationUnitPass(new IgnoreStdFieldsPass()); driver.AddTranslationUnitPass(new IgnoreStdFieldsPass());
driver.AddTranslationUnitPass(new GetterSetterToPropertyPass());
} }
public void Preprocess(Driver driver, ASTContext ctx) public void Preprocess(Driver driver, ASTContext ctx)
@ -170,6 +169,10 @@ namespace CppSharp
public void Postprocess(Driver driver, ASTContext ctx) public void Postprocess(Driver driver, ASTContext ctx)
{ {
new CaseRenamePass(
RenameTargets.Function | RenameTargets.Method | RenameTargets.Property | RenameTargets.Delegate |
RenameTargets.Field | RenameTargets.Variable,
RenameCasePattern.UpperCamelCase).VisitASTContext(driver.Context.ASTContext);
} }
public static void Main(string[] args) public static void Main(string[] args)

2
src/Generator.Tests/ASTTestFixture.cs

@ -18,7 +18,7 @@ namespace CppSharp.Generator.Tests
ParserOptions = new ParserOptions(); ParserOptions = new ParserOptions();
var testsPath = GeneratorTest.GetTestsDirectory("Native"); var testsPath = GeneratorTest.GetTestsDirectory("Native");
ParserOptions.addIncludeDirs(testsPath); ParserOptions.AddIncludeDirs(testsPath);
Options.Headers.AddRange(files); Options.Headers.AddRange(files);

2
src/Generator.Tests/GeneratorTest.cs

@ -46,7 +46,7 @@ namespace CppSharp.Utils
parserOptions.TargetTriple = Environment.Is64BitProcess ? "x86_64-apple-darwin" : "i686-apple-darwin"; parserOptions.TargetTriple = Environment.Is64BitProcess ? "x86_64-apple-darwin" : "i686-apple-darwin";
var path = Path.GetFullPath(GetTestsDirectory(name)); var path = Path.GetFullPath(GetTestsDirectory(name));
parserOptions.addIncludeDirs(path); parserOptions.AddIncludeDirs(path);
driver.Diagnostics.Message("Looking for tests in: {0}", path); driver.Diagnostics.Message("Looking for tests in: {0}", path);
var files = Directory.EnumerateFiles(path, "*.h"); var files = Directory.EnumerateFiles(path, "*.h");

4
src/Generator.Tests/Passes/TestPasses.cs

@ -162,9 +162,9 @@ namespace CppSharp.Generator.Tests.Passes
AstContext.SetPropertyAsReadOnly(className, "readOnlyProperty"); AstContext.SetPropertyAsReadOnly(className, "readOnlyProperty");
Assert.IsFalse(AstContext.FindClass(className).First().Properties.Find( Assert.IsFalse(AstContext.FindClass(className).First().Properties.Find(
m => m.Name == "readOnlyProperty").HasSetter); m => m.Name == "readOnlyProperty").HasSetter);
AstContext.SetPropertyAsReadOnly(className, "ReadOnlyPropertyMethod"); AstContext.SetPropertyAsReadOnly(className, "readOnlyPropertyMethod");
Assert.IsFalse(AstContext.FindClass(className).First().Properties.Find( Assert.IsFalse(AstContext.FindClass(className).First().Properties.Find(
m => m.Name == "ReadOnlyPropertyMethod").HasSetter); m => m.Name == "readOnlyPropertyMethod").HasSetter);
} }
[Test] [Test]

2
src/Generator.Tests/ReadNativeDependenciesTest.cs

@ -39,7 +39,7 @@ namespace CppSharp.Generator.Tests
private static IList<string> GetDependencies(string library) private static IList<string> GetDependencies(string library)
{ {
var parserOptions = new ParserOptions(); var parserOptions = new ParserOptions();
parserOptions.addLibraryDirs(GeneratorTest.GetTestsDirectory("Native")); parserOptions.AddLibraryDirs(GeneratorTest.GetTestsDirectory("Native"));
var driverOptions = new DriverOptions(); var driverOptions = new DriverOptions();
driverOptions.Libraries.Add(library); driverOptions.Libraries.Add(library);
var driver = new Driver(driverOptions, new TextDiagnosticPrinter()) var driver = new Driver(driverOptions, new TextDiagnosticPrinter())

44
src/Generator/Driver.cs

@ -63,7 +63,7 @@ namespace CppSharp
if (Options.NoGenIncludeDirs != null) if (Options.NoGenIncludeDirs != null)
foreach (var incDir in Options.NoGenIncludeDirs) foreach (var incDir in Options.NoGenIncludeDirs)
ParserOptions.addIncludeDirs(incDir); ParserOptions.AddIncludeDirs(incDir);
} }
public void Setup() public void Setup()
@ -102,7 +102,7 @@ namespace CppSharp
for (uint i = 0; i < result.DiagnosticsCount; ++i) for (uint i = 0; i < result.DiagnosticsCount; ++i)
{ {
var diag = result.getDiagnostics(i); var diag = result.GetDiagnostics(i);
if (Options.IgnoreParseWarnings if (Options.IgnoreParseWarnings
&& diag.Level == ParserDiagnosticLevel.Warning) && diag.Level == ParserDiagnosticLevel.Warning)
@ -142,54 +142,54 @@ namespace CppSharp
for (uint i = 0; i < ParserOptions.ArgumentsCount; ++i) for (uint i = 0; i < ParserOptions.ArgumentsCount; ++i)
{ {
var arg = ParserOptions.getArguments(i); var arg = ParserOptions.GetArguments(i);
options.addArguments(arg); options.AddArguments(arg);
} }
for (uint i = 0; i < ParserOptions.IncludeDirsCount; ++i) for (uint i = 0; i < ParserOptions.IncludeDirsCount; ++i)
{ {
var include = ParserOptions.getIncludeDirs(i); var include = ParserOptions.GetIncludeDirs(i);
options.addIncludeDirs(include); options.AddIncludeDirs(include);
} }
for (uint i = 0; i < ParserOptions.SystemIncludeDirsCount; ++i) for (uint i = 0; i < ParserOptions.SystemIncludeDirsCount; ++i)
{ {
var include = ParserOptions.getSystemIncludeDirs(i); var include = ParserOptions.GetSystemIncludeDirs(i);
options.addSystemIncludeDirs(include); options.AddSystemIncludeDirs(include);
} }
for (uint i = 0; i < ParserOptions.DefinesCount; ++i) for (uint i = 0; i < ParserOptions.DefinesCount; ++i)
{ {
var define = ParserOptions.getDefines(i); var define = ParserOptions.GetDefines(i);
options.addDefines(define); options.AddDefines(define);
} }
for (uint i = 0; i < ParserOptions.UndefinesCount; ++i) for (uint i = 0; i < ParserOptions.UndefinesCount; ++i)
{ {
var define = ParserOptions.getUndefines(i); var define = ParserOptions.GetUndefines(i);
options.addUndefines(define); options.AddUndefines(define);
} }
for (uint i = 0; i < ParserOptions.LibraryDirsCount; ++i) for (uint i = 0; i < ParserOptions.LibraryDirsCount; ++i)
{ {
var lib = ParserOptions.getLibraryDirs(i); var lib = ParserOptions.GetLibraryDirs(i);
options.addLibraryDirs(lib); options.AddLibraryDirs(lib);
} }
foreach (var module in Options.Modules.Where( foreach (var module in Options.Modules.Where(
m => file == null || m.Headers.Contains(file.Path))) m => file == null || m.Headers.Contains(file.Path)))
{ {
foreach (var include in module.IncludeDirs) foreach (var include in module.IncludeDirs)
options.addIncludeDirs(include); options.AddIncludeDirs(include);
foreach (var define in module.Defines) foreach (var define in module.Defines)
options.addDefines(define); options.AddDefines(define);
foreach (var undefine in module.Undefines) foreach (var undefine in module.Undefines)
options.addUndefines(undefine); options.AddUndefines(undefine);
foreach (var libraryDir in module.LibraryDirs) foreach (var libraryDir in module.LibraryDirs)
options.addLibraryDirs(libraryDir); options.AddLibraryDirs(libraryDir);
} }
return options; return options;
@ -242,7 +242,7 @@ namespace CppSharp
foreach (var module in Options.Modules) foreach (var module in Options.Modules)
{ {
foreach (var libraryDir in module.LibraryDirs) foreach (var libraryDir in module.LibraryDirs)
ParserOptions.addLibraryDirs(libraryDir); ParserOptions.AddLibraryDirs(libraryDir);
foreach (var library in module.Libraries) foreach (var library in module.Libraries)
{ {
@ -330,11 +330,7 @@ namespace CppSharp
if (Options.IsCSharpGenerator) if (Options.IsCSharpGenerator)
TranslationUnitPasses.AddPass(new DelegatesPass()); TranslationUnitPasses.AddPass(new DelegatesPass());
if (Options.GenerateProperties) TranslationUnitPasses.AddPass(new GetterSetterToPropertyPass());
TranslationUnitPasses.AddPass(new GetterSetterToPropertyPass());
if (Options.GeneratePropertiesAdvanced)
TranslationUnitPasses.AddPass(new GetterSetterToPropertyAdvancedPass());
} }
public void ProcessCode() public void ProcessCode()

4
src/Generator/Generators/CSharp/CSharpSources.cs

@ -1345,7 +1345,7 @@ namespace CppSharp.Generators.CSharp
{ {
var isIndexer = prop.Parameters.Count != 0; var isIndexer = prop.Parameters.Count != 0;
if (!isIndexer) if (!isIndexer)
return prop.Name; return Helpers.SafeIdentifier(prop.Name);
var @params = prop.Parameters.Select(param => { var @params = prop.Parameters.Select(param => {
var p = new Parameter(param); var p = new Parameter(param);
@ -3184,7 +3184,7 @@ namespace CppSharp.Generators.CSharp
var framework = libName + ".framework"; var framework = libName + ".framework";
for (uint i = 0; i < Context.ParserOptions.LibraryDirsCount; i++) for (uint i = 0; i < Context.ParserOptions.LibraryDirsCount; i++)
{ {
var libDir = Context.ParserOptions.getLibraryDirs(i); var libDir = Context.ParserOptions.GetLibraryDirs(i);
if (Path.GetFileName(libDir) == framework && File.Exists(Path.Combine(libDir, libName))) if (Path.GetFileName(libDir) == framework && File.Exists(Path.Combine(libDir, libName)))
{ {
libName = string.Format("@executable_path/../Frameworks/{0}/{1}", framework, libName); libName = string.Format("@executable_path/../Frameworks/{0}/{1}", framework, libName);

14
src/Generator/Options.cs

@ -88,20 +88,6 @@ namespace CppSharp
public bool GenerateInternalImports; public bool GenerateInternalImports;
public bool UseHeaderDirectories; public bool UseHeaderDirectories;
/// <summary>
/// If set to true the generator will use GetterSetterToPropertyPass to
/// convert matching getter/setter pairs to properties.
/// </summary>
public bool GenerateProperties;
/// <summary>
/// If set to true the generator will use GetterSetterToPropertyAdvancedPass to
/// convert matching getter/setter pairs to properties. This pass has slightly
/// different semantics from GetterSetterToPropertyPass, it will more agressively
/// try to match for matching properties.
/// </summary>
public bool GeneratePropertiesAdvanced;
/// <summary> /// <summary>
/// If set to true the CLI generator will use ObjectOverridesPass to create /// If set to true the CLI generator will use ObjectOverridesPass to create
/// Equals, GetHashCode and (if the insertion operator &lt;&lt; is overloaded) ToString /// Equals, GetHashCode and (if the insertion operator &lt;&lt; is overloaded) ToString

2
src/Generator/Passes/CleanUnitPass.cs

@ -40,7 +40,7 @@ namespace CppSharp.Passes
for (uint i = 0; i < Context.ParserOptions.IncludeDirsCount; ++i) for (uint i = 0; i < Context.ParserOptions.IncludeDirsCount; ++i)
{ {
var path = Context.ParserOptions.getIncludeDirs(i); var path = Context.ParserOptions.GetIncludeDirs(i);
int idx = filePath.IndexOf(path, System.StringComparison.Ordinal); int idx = filePath.IndexOf(path, System.StringComparison.Ordinal);
if (idx == -1) if (idx == -1)

345
src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs

@ -1,345 +0,0 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using CppSharp.AST;
using CppSharp.AST.Extensions;
using Type = CppSharp.AST.Type;
namespace CppSharp.Passes
{
public class GetterSetterToPropertyAdvancedPass : TranslationUnitPass
{
private class PropertyGenerator
{
private readonly IDiagnostics Diagnostics;
private readonly List<Method> getters = new List<Method>();
private readonly List<Method> setters = new List<Method>();
private readonly List<Method> setMethods = new List<Method>();
private readonly List<Method> nonSetters = new List<Method>();
public PropertyGenerator(Class @class, IDiagnostics diags)
{
Diagnostics = diags;
foreach (var method in @class.Methods.Where(
m => !m.IsConstructor && !m.IsDestructor && !m.IsOperator && m.IsGenerated))
DistributeMethod(method);
}
public void GenerateProperties()
{
GenerateProperties(setters, false);
GenerateProperties(setMethods, true);
foreach (Method getter in
from getter in getters
where getter.IsGenerated &&
((Class) getter.Namespace).Methods.All(m => m == getter || !m.IsGenerated || m.Name != getter.Name)
select getter)
{
// Make it a read-only property
GenerateProperty(getter.Namespace, getter);
}
}
private void GenerateProperties(IEnumerable<Method> settersToUse, bool readOnly)
{
foreach (var setter in settersToUse)
{
var type = (Class) setter.Namespace;
var firstWord = GetFirstWord(setter.Name);
var nameBuilder = new StringBuilder(setter.Name.Substring(firstWord.Length));
if (char.IsLower(setter.Name[0]))
nameBuilder[0] = char.ToLowerInvariant(nameBuilder[0]);
string afterSet = nameBuilder.ToString();
var s = setter;
foreach (var getter in nonSetters.Where(m => m.Namespace == type &&
m.ExplicitInterfaceImpl == s.ExplicitInterfaceImpl))
{
var name = GetReadWritePropertyName(getter, afterSet);
if (name == afterSet &&
GetUnderlyingType(getter.OriginalReturnType).Equals(
GetUnderlyingType(setter.Parameters[0].QualifiedType)))
{
Method g = getter;
foreach (var method in type.Methods.Where(m => m != g && m.Name == name))
{
var oldName = method.Name;
method.Name = string.Format("get{0}{1}",
char.ToUpperInvariant(method.Name[0]), method.Name.Substring(1));
Diagnostics.Debug("Method {0}::{1} renamed to {2}", method.Namespace.Name, oldName, method.Name);
}
foreach (var @event in type.Events.Where(e => e.Name == name))
{
var oldName = @event.Name;
@event.Name = string.Format("on{0}{1}",
char.ToUpperInvariant(@event.Name[0]), @event.Name.Substring(1));
Diagnostics.Debug("Event {0}::{1} renamed to {2}", @event.Namespace.Name, oldName, @event.Name);
}
getter.Name = name;
GenerateProperty(getter.Namespace, getter, readOnly ? null : setter);
goto next;
}
}
Property baseProperty = type.GetBaseProperty(new Property { Name = afterSet }, getTopmost: true);
if (!type.IsInterface && baseProperty != null && baseProperty.IsVirtual && setter.IsVirtual)
{
bool isReadOnly = baseProperty.SetMethod == null;
GenerateProperty(setter.Namespace, baseProperty.GetMethod,
readOnly || isReadOnly ? null : setter);
}
next:
;
}
foreach (Method nonSetter in nonSetters)
{
Class type = (Class) nonSetter.Namespace;
string name = GetPropertyName(nonSetter.Name);
Property baseProperty = type.GetBaseProperty(new Property { Name = name }, getTopmost: true);
if (!type.IsInterface && baseProperty != null && baseProperty.IsVirtual)
{
bool isReadOnly = baseProperty.SetMethod == null;
if (readOnly == isReadOnly)
{
GenerateProperty(nonSetter.Namespace, nonSetter,
readOnly ? null : baseProperty.SetMethod);
}
}
}
}
private static string GetReadWritePropertyName(INamedDecl getter, string afterSet)
{
string name = GetPropertyName(getter.Name);
if (name != afterSet && name.StartsWith("is", StringComparison.Ordinal))
{
name = char.ToLowerInvariant(name[2]) + name.Substring(3);
}
return name;
}
private static Type GetUnderlyingType(QualifiedType type)
{
TagType tagType = type.Type as TagType;
if (tagType != null)
return type.Type;
// TODO: we should normally check pointer types for const;
// however, there's some bug, probably in the parser, that returns IsConst = false for "const Type& arg"
// so skip the check for the time being
PointerType pointerType = type.Type as PointerType;
return pointerType != null ? pointerType.Pointee : type.Type;
}
private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null)
{
var type = (Class) context;
var name = GetPropertyName(getter.Name);
if (type.Properties.Any(p => p.Name == name &&
p.ExplicitInterfaceImpl == getter.ExplicitInterfaceImpl))
return;
var property = new Property
{
Access = getter.Access == AccessSpecifier.Public ||
(setter != null && setter.Access == AccessSpecifier.Public) ?
AccessSpecifier.Public : AccessSpecifier.Protected,
Name = name,
Namespace = type,
QualifiedType = getter.OriginalReturnType,
OriginalNamespace = getter.OriginalNamespace
};
if (getter.IsOverride || (setter != null && setter.IsOverride))
{
var baseVirtualProperty = type.GetBaseProperty(property, getTopmost: true);
if (baseVirtualProperty == null && type.GetBaseMethod(getter, getTopmost: true).IsGenerated)
throw new Exception(string.Format(
"Property {0} has a base property null but its getter has a generated base method.",
getter.QualifiedOriginalName));
if (baseVirtualProperty != null && !baseVirtualProperty.IsVirtual)
{
// the only way the above can happen is if we are generating properties in abstract implementations
// in which case we can have less naming conflicts since the abstract base can also contain non-virtual properties
if (getter.SynthKind == FunctionSynthKind.AbstractImplCall)
return;
throw new Exception(string.Format(
"Base of property {0} is not virtual while the getter is.",
getter.QualifiedOriginalName));
}
if (baseVirtualProperty != null && baseVirtualProperty.SetMethod == null)
setter = null;
}
property.GetMethod = getter;
property.SetMethod = setter;
property.ExplicitInterfaceImpl = getter.ExplicitInterfaceImpl;
if (property.ExplicitInterfaceImpl == null && setter != null)
{
property.ExplicitInterfaceImpl = setter.ExplicitInterfaceImpl;
}
if (getter.Comment != null)
{
property.Comment = CombineComments(getter, setter);
}
type.Properties.Add(property);
getter.GenerationKind = GenerationKind.Internal;
if (setter != null)
setter.GenerationKind = GenerationKind.Internal;
}
private static RawComment CombineComments(Declaration getter, Declaration setter)
{
var comment = new RawComment
{
Kind = getter.Comment.Kind,
BriefText = getter.Comment.BriefText,
Text = getter.Comment.Text
};
if (getter.Comment.FullComment != null)
{
comment.FullComment = new FullComment();
comment.FullComment.Blocks.AddRange(getter.Comment.FullComment.Blocks);
if (setter != null && setter.Comment != null)
{
comment.BriefText += Environment.NewLine + setter.Comment.BriefText;
comment.Text += Environment.NewLine + setter.Comment.Text;
comment.FullComment.Blocks.AddRange(setter.Comment.FullComment.Blocks);
}
}
return comment;
}
private static string GetPropertyName(string name)
{
var firstWord = GetFirstWord(name);
if (Match(firstWord, new[] { "get" }) && name != firstWord)
{
if (char.IsLower(name[0]))
{
if (name.Length == 4)
{
return char.ToLowerInvariant(
name[3]).ToString(CultureInfo.InvariantCulture);
}
return char.ToLowerInvariant(
name[3]).ToString(CultureInfo.InvariantCulture) +
name.Substring(4);
}
return name.Substring(3);
}
return name;
}
private void DistributeMethod(Method method)
{
var firstWord = GetFirstWord(method.Name);
if (Match(firstWord, new[] { "set" }) && method.Name.Length > firstWord.Length &&
method.OriginalReturnType.Type.IsPrimitiveType(PrimitiveType.Void))
{
if (method.Parameters.Count == 1)
setters.Add(method);
else if (method.Parameters.Count > 1)
setMethods.Add(method);
}
else
{
if (IsGetter(method))
getters.Add(method);
if (method.Parameters.All(p => p.Kind == ParameterKind.IndirectReturnType))
nonSetters.Add(method);
}
}
private static bool IsGetter(Method method)
{
if (method.IsDestructor ||
(method.OriginalReturnType.Type.IsPrimitiveType(PrimitiveType.Void)) ||
method.Parameters.Any(p => p.Kind != ParameterKind.IndirectReturnType))
return false;
var firstWord = GetFirstWord(method.Name);
return (firstWord.Length < method.Name.Length &&
Match(firstWord, new[] { "get", "is", "has" })) ||
(!Match(firstWord, new[] { "to", "new" }) && !verbs.Contains(firstWord));
}
private static bool Match(string prefix, IEnumerable<string> prefixes)
{
return prefixes.Any(p => prefix == p || prefix == p + '_');
}
private static string GetFirstWord(string name)
{
var firstWord = new List<char> { char.ToLowerInvariant(name[0]) };
for (int i = 1; i < name.Length; i++)
{
var c = name[i];
if (char.IsLower(c))
{
firstWord.Add(c);
continue;
}
if (c == '_')
{
firstWord.Add(c);
break;
}
if (char.IsUpper(c))
break;
}
return new string(firstWord.ToArray());
}
}
private static readonly HashSet<string> verbs = new HashSet<string>();
static GetterSetterToPropertyAdvancedPass()
{
LoadVerbs();
}
private static void LoadVerbs()
{
var assembly = Assembly.GetExecutingAssembly();
using (var resourceStream = GetResourceStream(assembly))
{
// For some reason, embedded resources are not working when compiling the
// Premake-generated VS project files with xbuild under OSX. Workaround this for now.
if (resourceStream == null)
return;
using (var streamReader = new StreamReader(resourceStream))
while (!streamReader.EndOfStream)
verbs.Add(streamReader.ReadLine());
}
}
private static Stream GetResourceStream(Assembly assembly)
{
var stream = assembly.GetManifestResourceStream("CppSharp.Generator.Passes.verbs.txt");
// HACK: a bug in premake for OS X causes resources to be embedded with an incorrect location
return stream ?? assembly.GetManifestResourceStream("verbs.txt");
}
public GetterSetterToPropertyAdvancedPass()
{
VisitOptions.VisitClassProperties = false;
VisitOptions.VisitFunctionParameters = false;
}
public override bool VisitClassDecl(Class @class)
{
if (VisitDeclarationContext(@class))
{
if (VisitOptions.VisitClassBases)
foreach (var baseClass in @class.Bases)
if (baseClass.IsClass)
VisitClassDecl(baseClass.Class);
new PropertyGenerator(@class, Diagnostics).GenerateProperties();
}
return false;
}
}
}

429
src/Generator/Passes/GetterSetterToPropertyPass.cs

@ -1,149 +1,362 @@
using System; using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text;
using CppSharp.AST; using CppSharp.AST;
using CppSharp.AST.Extensions; using CppSharp.AST.Extensions;
using Type = CppSharp.AST.Type;
namespace CppSharp.Passes namespace CppSharp.Passes
{ {
/// <summary>
/// This pass checks for compatible combinations of getters/setters methods
/// and creates matching properties that call back into the methods.
/// </summary>
public class GetterSetterToPropertyPass : TranslationUnitPass public class GetterSetterToPropertyPass : TranslationUnitPass
{ {
public GetterSetterToPropertyPass() private class PropertyGenerator
{
VisitOptions.VisitClassFields = false;
VisitOptions.VisitClassProperties = false;
VisitOptions.VisitNamespaceEnums = false;
VisitOptions.VisitNamespaceTemplates = false;
VisitOptions.VisitNamespaceTypedefs = false;
VisitOptions.VisitNamespaceEvents = false;
VisitOptions.VisitNamespaceVariables = false;
VisitOptions.VisitFunctionParameters = false;
VisitOptions.VisitTemplateArguments = false;
}
static bool IsSetter(Function method)
{
var isRetVoid = method.ReturnType.Type.IsPrimitiveType(
PrimitiveType.Void);
var isSetter = method.OriginalName.StartsWith("set",
StringComparison.InvariantCultureIgnoreCase);
return isRetVoid && isSetter && method.Parameters.Count == 1;
}
static bool IsGetter(Function method)
{
var isRetVoid = method.ReturnType.Type.IsPrimitiveType(
PrimitiveType.Void);
var isGetter = method.OriginalName.StartsWith("get",
StringComparison.InvariantCultureIgnoreCase);
return !isRetVoid && isGetter && method.Parameters.Count == 0;
}
Property GetOrCreateProperty(Class @class, string name, QualifiedType type)
{ {
var prop = @class.Properties.FirstOrDefault(property => property.Name == name private readonly IDiagnostics Diagnostics;
&& property.QualifiedType.Equals(type)); private readonly List<Method> getters = new List<Method>();
private readonly List<Method> setters = new List<Method>();
var prop2 = @class.Properties.FirstOrDefault(property => property.Name == name); private readonly List<Method> setMethods = new List<Method>();
private readonly List<Method> nonSetters = new List<Method>();
if (prop == null && prop2 != null) public PropertyGenerator(Class @class, IDiagnostics diags)
Diagnostics.Debug("Property {0}::{1} already exists (type: {2})",
@class.Name, name, type.Type.ToString());
if (prop != null)
return prop;
prop = new Property
{ {
Name = name, Diagnostics = diags;
Namespace = @class, foreach (var method in @class.Methods.Where(
QualifiedType = type m => !m.IsConstructor && !m.IsDestructor && !m.IsOperator && m.IsGenerated))
}; DistributeMethod(method);
}
@class.Properties.Add(prop);
return prop;
}
public override bool VisitMethodDecl(Method method) public void GenerateProperties()
{ {
if (!VisitDeclaration(method)) GenerateProperties(setters, false);
return false; GenerateProperties(setMethods, true);
foreach (Method getter in
from getter in getters
where getter.IsGenerated && getter.SynthKind != FunctionSynthKind.ComplementOperator &&
((Class) getter.Namespace).Methods.All(m => m == getter ||!m.IsGenerated || m.Name != getter.Name)
select getter)
{
// Make it a read-only property
GenerateProperty(getter.Namespace, getter);
}
}
if (ASTUtils.CheckIgnoreMethod(method, Options)) private void GenerateProperties(IEnumerable<Method> settersToUse, bool readOnly)
return false; {
foreach (var setter in settersToUse)
{
var type = (Class) setter.Namespace;
var firstWord = GetFirstWord(setter.Name);
var nameBuilder = new StringBuilder(setter.Name.Substring(firstWord.Length));
if (char.IsLower(setter.Name[0]))
nameBuilder[0] = char.ToLowerInvariant(nameBuilder[0]);
string afterSet = nameBuilder.ToString();
var s = setter;
foreach (var getter in nonSetters.Where(m => m.Namespace == type &&
m.ExplicitInterfaceImpl == s.ExplicitInterfaceImpl))
{
var name = GetReadWritePropertyName(getter, afterSet);
if (name == afterSet &&
GetUnderlyingType(getter.OriginalReturnType).Equals(
GetUnderlyingType(setter.Parameters[0].QualifiedType)))
{
Method g = getter;
foreach (var method in type.Methods.Where(m => m != g && m.Name == name))
{
var oldName = method.Name;
method.Name = string.Format("get{0}{1}",
char.ToUpperInvariant(method.Name[0]), method.Name.Substring(1));
Diagnostics.Debug("Method {0}::{1} renamed to {2}", method.Namespace.Name, oldName, method.Name);
}
foreach (var @event in type.Events.Where(e => e.Name == name))
{
var oldName = @event.Name;
@event.Name = string.Format("on{0}{1}",
char.ToUpperInvariant(@event.Name[0]), @event.Name.Substring(1));
Diagnostics.Debug("Event {0}::{1} renamed to {2}", @event.Namespace.Name, oldName, @event.Name);
}
getter.Name = name;
GenerateProperty(getter.Namespace, getter, readOnly ? null : setter);
goto next;
}
}
Property baseProperty = type.GetBaseProperty(new Property { Name = afterSet }, getTopmost: true);
if (!type.IsInterface && baseProperty != null && baseProperty.IsVirtual && setter.IsVirtual)
{
bool isReadOnly = baseProperty.SetMethod == null;
GenerateProperty(setter.Namespace, baseProperty.GetMethod,
readOnly || isReadOnly ? null : setter);
}
next:
;
}
foreach (Method nonSetter in nonSetters)
{
Class type = (Class) nonSetter.Namespace;
string name = GetPropertyName(nonSetter.Name);
Property baseProperty = type.GetBaseProperty(new Property { Name = name }, getTopmost: true);
if (!type.IsInterface && baseProperty != null && baseProperty.IsVirtual)
{
bool isReadOnly = baseProperty.SetMethod == null;
if (readOnly == isReadOnly)
{
GenerateProperty(nonSetter.Namespace, nonSetter,
readOnly ? null : baseProperty.SetMethod);
}
}
}
}
var @class = method.Namespace as Class; private static string GetReadWritePropertyName(INamedDecl getter, string afterSet)
{
string name = GetPropertyName(getter.Name);
if (name != afterSet && name.StartsWith("is", StringComparison.Ordinal))
{
name = char.ToLowerInvariant(name[2]) + name.Substring(3);
}
return name;
}
if (@class == null || @class.IsIncomplete) private static Type GetUnderlyingType(QualifiedType type)
return false; {
TagType tagType = type.Type as TagType;
if (tagType != null)
return type.Type;
// TODO: we should normally check pointer types for const;
// however, there's some bug, probably in the parser, that returns IsConst = false for "const Type& arg"
// so skip the check for the time being
PointerType pointerType = type.Type as PointerType;
return pointerType != null ? pointerType.Pointee : type.Type;
}
if (method.IsConstructor) private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null)
return false; {
var type = (Class) context;
var name = GetPropertyName(getter.Name);
if (type.Properties.Any(p => p.Name == name &&
p.ExplicitInterfaceImpl == getter.ExplicitInterfaceImpl))
return;
var property = new Property
{
Access = getter.Access == AccessSpecifier.Public ||
(setter != null && setter.Access == AccessSpecifier.Public) ?
AccessSpecifier.Public : AccessSpecifier.Protected,
Name = name,
Namespace = type,
QualifiedType = getter.OriginalReturnType,
OriginalNamespace = getter.OriginalNamespace
};
if (getter.IsOverride || (setter != null && setter.IsOverride))
{
var baseVirtualProperty = type.GetBaseProperty(property, getTopmost: true);
if (baseVirtualProperty == null && type.GetBaseMethod(getter, getTopmost: true).IsGenerated)
throw new Exception(string.Format(
"Property {0} has a base property null but its getter has a generated base method.",
getter.QualifiedOriginalName));
if (baseVirtualProperty != null && !baseVirtualProperty.IsVirtual)
{
// the only way the above can happen is if we are generating properties in abstract implementations
// in which case we can have less naming conflicts since the abstract base can also contain non-virtual properties
if (getter.SynthKind == FunctionSynthKind.AbstractImplCall)
return;
throw new Exception(string.Format(
"Base of property {0} is not virtual while the getter is.",
getter.QualifiedOriginalName));
}
if (baseVirtualProperty != null && baseVirtualProperty.SetMethod == null)
setter = null;
}
property.GetMethod = getter;
property.SetMethod = setter;
property.ExplicitInterfaceImpl = getter.ExplicitInterfaceImpl;
if (property.ExplicitInterfaceImpl == null && setter != null)
{
property.ExplicitInterfaceImpl = setter.ExplicitInterfaceImpl;
}
if (getter.Comment != null)
{
property.Comment = CombineComments(getter, setter);
}
type.Properties.Add(property);
getter.GenerationKind = GenerationKind.Internal;
if (setter != null)
setter.GenerationKind = GenerationKind.Internal;
}
if (method.IsSynthetized) private static RawComment CombineComments(Declaration getter, Declaration setter)
return false; {
var comment = new RawComment
{
Kind = getter.Comment.Kind,
BriefText = getter.Comment.BriefText,
Text = getter.Comment.Text
};
if (getter.Comment.FullComment != null)
{
comment.FullComment = new FullComment();
comment.FullComment.Blocks.AddRange(getter.Comment.FullComment.Blocks);
if (getter != setter && setter != null && setter.Comment != null)
{
comment.BriefText += Environment.NewLine + setter.Comment.BriefText;
comment.Text += Environment.NewLine + setter.Comment.Text;
comment.FullComment.Blocks.AddRange(setter.Comment.FullComment.Blocks);
}
}
return comment;
}
if (IsGetter(method)) private static string GetPropertyName(string name)
{ {
var name = method.Name.Substring("get".Length); var firstWord = GetFirstWord(name);
var prop = GetOrCreateProperty(@class, name, method.ReturnType); if (Match(firstWord, new[] { "get" }) && name != firstWord)
prop.GetMethod = method; {
prop.Access = method.Access; if (char.IsLower(name[0]))
{
if (name.Length == 4)
{
return char.ToLowerInvariant(
name[3]).ToString(CultureInfo.InvariantCulture);
}
return char.ToLowerInvariant(
name[3]).ToString(CultureInfo.InvariantCulture) +
name.Substring(4);
}
return name.Substring(3);
}
return name;
}
// Do not generate the original method now that we know it is a getter. private static string GetPropertyNameFromSetter(Method setter)
method.GenerationKind = GenerationKind.Internal; {
var name = setter.Name.Substring("set".Length);
if (string.IsNullOrEmpty(name))
return name;
if (char.IsLower(setter.Name[0]) && !char.IsLower(name[0]))
return char.ToLowerInvariant(name[0]) + name.Substring(1);
return name;
}
Diagnostics.Debug("Getter created: {0}::{1}", @class.Name, name); private void DistributeMethod(Method method)
{
var firstWord = GetFirstWord(method.Name);
if (Match(firstWord, new[] { "set" }) && method.Name.Length > firstWord.Length &&
method.OriginalReturnType.Type.IsPrimitiveType(PrimitiveType.Void))
{
if (method.Parameters.Count == 1)
setters.Add(method);
else if (method.Parameters.Count > 1)
setMethods.Add(method);
}
else
{
if (IsGetter(method))
getters.Add(method);
if (method.Parameters.All(p => p.Kind == ParameterKind.IndirectReturnType))
nonSetters.Add(method);
}
}
return false; private static bool IsGetter(Method method)
{
if (method.IsDestructor ||
(method.OriginalReturnType.Type.IsPrimitiveType(PrimitiveType.Void)) ||
method.Parameters.Any(p => p.Kind != ParameterKind.IndirectReturnType))
return false;
var firstWord = GetFirstWord(method.Name);
return (firstWord.Length < method.Name.Length &&
Match(firstWord, new[] { "get", "is", "has" })) ||
(!Match(firstWord, new[] { "to", "new" }) && !verbs.Contains(firstWord));
} }
if (IsSetter(method) && IsValidSetter(method)) private static bool Match(string prefix, IEnumerable<string> prefixes)
{ {
var name = method.Name.Substring("set".Length); return prefixes.Any(p => prefix == p || prefix == p + '_');
}
var type = method.Parameters[0].QualifiedType; private static string GetFirstWord(string name)
var prop = GetOrCreateProperty(@class, name, type); {
prop.SetMethod = method; var firstWord = new List<char> { char.ToLowerInvariant(name[0]) };
prop.Access = method.Access; for (int i = 1; i < name.Length; i++)
{
var c = name[i];
if (char.IsLower(c))
{
firstWord.Add(c);
continue;
}
if (c == '_')
{
firstWord.Add(c);
break;
}
if (char.IsUpper(c))
break;
}
return new string(firstWord.ToArray());
}
}
// Ignore the original method now that we know it is a setter. private static readonly HashSet<string> verbs = new HashSet<string>();
method.GenerationKind = GenerationKind.Internal;
Diagnostics.Debug("Setter created: {0}::{1}", @class.Name, name); static GetterSetterToPropertyPass()
{
LoadVerbs();
}
return false; private static void LoadVerbs()
{
var assembly = Assembly.GetExecutingAssembly();
using (var resourceStream = GetResourceStream(assembly))
{
// For some reason, embedded resources are not working when compiling the
// Premake-generated VS project files with xbuild under OSX. Workaround this for now.
if (resourceStream == null)
return;
using (var streamReader = new StreamReader(resourceStream))
while (!streamReader.EndOfStream)
verbs.Add(streamReader.ReadLine());
} }
return false;
} }
// Check if a matching getter exist or no other setter exists. private static Stream GetResourceStream(Assembly assembly)
private bool IsValidSetter(Method method)
{ {
var @class = method.Namespace as Class; var stream = assembly.GetManifestResourceStream("CppSharp.Generator.Passes.verbs.txt");
var name = method.Name.Substring("set".Length); // HACK: a bug in premake for OS X causes resources to be embedded with an incorrect location
return stream ?? assembly.GetManifestResourceStream("verbs.txt");
if (method.Parameters.Count == 0) }
return false;
var type = method.Parameters[0].Type;
var getter = @class.Methods.FirstOrDefault(m => m.Name == "Get" + name public GetterSetterToPropertyPass()
&& m.Type.Equals(type)); {
VisitOptions.VisitClassFields = false;
VisitOptions.VisitClassProperties = false;
VisitOptions.VisitNamespaceEnums = false;
VisitOptions.VisitNamespaceTemplates = false;
VisitOptions.VisitNamespaceTypedefs = false;
VisitOptions.VisitNamespaceEvents = false;
VisitOptions.VisitNamespaceVariables = false;
VisitOptions.VisitFunctionParameters = false;
VisitOptions.VisitTemplateArguments = false;
}
var otherSetter = @class.Methods.FirstOrDefault(m => m.Name == method.Name public override bool VisitClassDecl(Class @class)
&& m.Parameters.Count == 1 {
&& !m.Parameters[0].Type.Equals(type)); if (VisitDeclarationContext(@class))
{
if (VisitOptions.VisitClassBases)
foreach (var baseClass in @class.Bases)
if (baseClass.IsClass)
VisitClassDecl(baseClass.Class);
return getter != null || otherSetter == null; new PropertyGenerator(@class, Diagnostics).GenerateProperties();
}
return false;
} }
} }
} }

84
src/Parser/ASTConverter.cs

@ -397,7 +397,7 @@ namespace CppSharp
for (uint i = 0; i < Context.TranslationUnitsCount; ++i) for (uint i = 0; i < Context.TranslationUnitsCount; ++i)
{ {
var unit = Context.getTranslationUnits(i); var unit = Context.GetTranslationUnits(i);
var _unit = declConverter.Visit(unit) as AST.TranslationUnit; var _unit = declConverter.Visit(unit) as AST.TranslationUnit;
_ctx.TranslationUnits.Add(_unit); _ctx.TranslationUnits.Add(_unit);
declConverter.VisitDeclContext(unit, _unit); declConverter.VisitDeclContext(unit, _unit);
@ -496,7 +496,7 @@ namespace CppSharp
for (uint i = 0; i < type.ParametersCount; ++i) for (uint i = 0; i < type.ParametersCount; ++i)
{ {
var param = type.getParameters(i); var param = type.GetParameters(i);
var _param = declConverter.Visit(param) as AST.Parameter; var _param = declConverter.Visit(param) as AST.Parameter;
_type.Parameters.Add(_param); _type.Parameters.Add(_param);
} }
@ -607,7 +607,7 @@ namespace CppSharp
for (uint i = 0; i < type.ArgumentsCount; ++i) for (uint i = 0; i < type.ArgumentsCount; ++i)
{ {
var arg = type.getArguments(i); var arg = type.GetArguments(i);
var _arg = VisitTemplateArgument(arg); var _arg = VisitTemplateArgument(arg);
_type.Arguments.Add(_arg); _type.Arguments.Add(_arg);
} }
@ -627,7 +627,7 @@ namespace CppSharp
for (uint i = 0; i < type.ArgumentsCount; ++i) for (uint i = 0; i < type.ArgumentsCount; ++i)
{ {
var arg = type.getArguments(i); var arg = type.GetArguments(i);
var _arg = VisitTemplateArgument(arg); var _arg = VisitTemplateArgument(arg);
_type.Arguments.Add(_arg); _type.Arguments.Add(_arg);
} }
@ -900,7 +900,7 @@ namespace CppSharp
_decl.Access = VisitAccessSpecifier(decl.Access); _decl.Access = VisitAccessSpecifier(decl.Access);
_decl.Name = decl.Name; _decl.Name = decl.Name;
_decl.USR = decl.USR; _decl.USR = decl.USR;
_decl.Namespace = Visit(decl._Namespace) as AST.DeclarationContext; _decl.Namespace = Visit(decl.Namespace) as AST.DeclarationContext;
_decl.Location = new SourceLocation(decl.Location.ID); _decl.Location = new SourceLocation(decl.Location.ID);
_decl.LineNumberStart = decl.LineNumberStart; _decl.LineNumberStart = decl.LineNumberStart;
_decl.LineNumberEnd = decl.LineNumberEnd; _decl.LineNumberEnd = decl.LineNumberEnd;
@ -915,7 +915,7 @@ namespace CppSharp
for (uint i = 0; i < decl.PreprocessedEntitiesCount; ++i) for (uint i = 0; i < decl.PreprocessedEntitiesCount; ++i)
{ {
var entity = decl.getPreprocessedEntities(i); var entity = decl.GetPreprocessedEntities(i);
var _entity = VisitPreprocessedEntity(entity); var _entity = VisitPreprocessedEntity(entity);
_decl.PreprocessedEntities.Add(_entity); _decl.PreprocessedEntities.Add(_entity);
} }
@ -931,7 +931,7 @@ namespace CppSharp
for (uint i = 0; i < ctx.NamespacesCount; ++i) for (uint i = 0; i < ctx.NamespacesCount; ++i)
{ {
var decl = ctx.getNamespaces(i); var decl = ctx.GetNamespaces(i);
var _decl = Visit(decl) as AST.Namespace; var _decl = Visit(decl) as AST.Namespace;
namespaces.Add(decl, _decl); namespaces.Add(decl, _decl);
_ctx.Namespaces.Add(_decl); _ctx.Namespaces.Add(_decl);
@ -939,28 +939,28 @@ namespace CppSharp
for (uint i = 0; i < ctx.EnumsCount; ++i) for (uint i = 0; i < ctx.EnumsCount; ++i)
{ {
var decl = ctx.getEnums(i); var decl = ctx.GetEnums(i);
var _decl = Visit(decl) as AST.Enumeration; var _decl = Visit(decl) as AST.Enumeration;
_ctx.Enums.Add(_decl); _ctx.Enums.Add(_decl);
} }
for (uint i = 0; i < ctx.FunctionsCount; ++i) for (uint i = 0; i < ctx.FunctionsCount; ++i)
{ {
var decl = ctx.getFunctions(i); var decl = ctx.GetFunctions(i);
var _decl = Visit(decl) as AST.Function; var _decl = Visit(decl) as AST.Function;
_ctx.Functions.Add(_decl); _ctx.Functions.Add(_decl);
} }
for (uint i = 0; i < ctx.TemplatesCount; ++i) for (uint i = 0; i < ctx.TemplatesCount; ++i)
{ {
var decl = ctx.getTemplates(i); var decl = ctx.GetTemplates(i);
var _decl = Visit(decl) as AST.Template; var _decl = Visit(decl) as AST.Template;
_ctx.Templates.Add(_decl); _ctx.Templates.Add(_decl);
} }
for (uint i = 0; i < ctx.ClassesCount; ++i) for (uint i = 0; i < ctx.ClassesCount; ++i)
{ {
var decl = ctx.getClasses(i); var decl = ctx.GetClasses(i);
var _decl = Visit(decl) as AST.Class; var _decl = Visit(decl) as AST.Class;
if (!_decl.IsIncomplete) if (!_decl.IsIncomplete)
_ctx.Classes.Add(_decl); _ctx.Classes.Add(_decl);
@ -968,28 +968,28 @@ namespace CppSharp
for (uint i = 0; i < ctx.TypedefsCount; ++i) for (uint i = 0; i < ctx.TypedefsCount; ++i)
{ {
var decl = ctx.getTypedefs(i); var decl = ctx.GetTypedefs(i);
var _decl = Visit(decl) as AST.TypedefDecl; var _decl = Visit(decl) as AST.TypedefDecl;
_ctx.Typedefs.Add(_decl); _ctx.Typedefs.Add(_decl);
} }
for (uint i = 0; i < ctx.TypeAliasesCount; ++i) for (uint i = 0; i < ctx.TypeAliasesCount; ++i)
{ {
var decl = ctx.getTypeAliases(i); var decl = ctx.GetTypeAliases(i);
var _decl = Visit(decl) as AST.TypeAlias; var _decl = Visit(decl) as AST.TypeAlias;
_ctx.Typedefs.Add(_decl); _ctx.Typedefs.Add(_decl);
} }
for (uint i = 0; i < ctx.VariablesCount; ++i) for (uint i = 0; i < ctx.VariablesCount; ++i)
{ {
var decl = ctx.getVariables(i); var decl = ctx.GetVariables(i);
var _decl = Visit(decl) as AST.Variable; var _decl = Visit(decl) as AST.Variable;
_ctx.Variables.Add(_decl); _ctx.Variables.Add(_decl);
} }
for (uint i = 0; i < ctx.FriendsCount; ++i) for (uint i = 0; i < ctx.FriendsCount; ++i)
{ {
var decl = ctx.getFriends(i); var decl = ctx.GetFriends(i);
var _decl = Visit(decl) as AST.Friend; var _decl = Visit(decl) as AST.Friend;
_ctx.Declarations.Add(_decl); _ctx.Declarations.Add(_decl);
} }
@ -1012,7 +1012,7 @@ namespace CppSharp
for (uint i = 0; i < decl.MacrosCount; ++i) for (uint i = 0; i < decl.MacrosCount; ++i)
{ {
var macro = decl.getMacros(i); var macro = decl.GetMacros(i);
var _macro = VisitMacroDefinition(macro); var _macro = VisitMacroDefinition(macro);
_unit.Macros.Add(_macro); _unit.Macros.Add(_macro);
} }
@ -1082,7 +1082,7 @@ namespace CppSharp
var callExpr = CallExpr.__CreateInstance(statement.__Instance); var callExpr = CallExpr.__CreateInstance(statement.__Instance);
for (uint i = 0; i < callExpr.ArgumentsCount; i++) for (uint i = 0; i < callExpr.ArgumentsCount; i++)
{ {
var argument = VisitStatement(callExpr.getArguments(i)); var argument = VisitStatement(callExpr.GetArguments(i));
callExpression.Arguments.Add(argument); callExpression.Arguments.Add(argument);
} }
expression = callExpression; expression = callExpression;
@ -1100,7 +1100,7 @@ namespace CppSharp
var constructorExpr = CXXConstructExpr.__CreateInstance(statement.__Instance); var constructorExpr = CXXConstructExpr.__CreateInstance(statement.__Instance);
for (uint i = 0; i < constructorExpr.ArgumentsCount; i++) for (uint i = 0; i < constructorExpr.ArgumentsCount; i++)
{ {
var argument = VisitStatement(constructorExpr.getArguments(i)); var argument = VisitStatement(constructorExpr.GetArguments(i));
constructorExpression.Arguments.Add(argument); constructorExpression.Arguments.Add(argument);
} }
expression = constructorExpression; expression = constructorExpression;
@ -1135,7 +1135,7 @@ namespace CppSharp
for (uint i = 0; i < function.ParametersCount; ++i) for (uint i = 0; i < function.ParametersCount; ++i)
{ {
var param = function.getParameters(i); var param = function.GetParameters(i);
var _param = Visit(param) as AST.Parameter; var _param = Visit(param) as AST.Parameter;
_function.Parameters.Add(_param); _function.Parameters.Add(_param);
} }
@ -1338,7 +1338,7 @@ namespace CppSharp
for (uint i = 0; i < decl.ItemsCount; ++i) for (uint i = 0; i < decl.ItemsCount; ++i)
{ {
var item = decl.getItems(i); var item = decl.GetItems(i);
var _item = Visit(item) as AST.Enumeration.Item; var _item = Visit(item) as AST.Enumeration.Item;
_enum.AddItem(_item); _enum.AddItem(_item);
} }
@ -1419,28 +1419,28 @@ namespace CppSharp
for (uint i = 0; i < @class.BasesCount; ++i) for (uint i = 0; i < @class.BasesCount; ++i)
{ {
var @base = @class.getBases(i); var @base = @class.GetBases(i);
var _base = VisitBaseClassSpecifier(@base); var _base = VisitBaseClassSpecifier(@base);
_class.Bases.Add(_base); _class.Bases.Add(_base);
} }
for (uint i = 0; i < @class.FieldsCount; ++i) for (uint i = 0; i < @class.FieldsCount; ++i)
{ {
var field = @class.getFields(i); var field = @class.GetFields(i);
var _field = Visit(field) as AST.Field; var _field = Visit(field) as AST.Field;
_class.Fields.Add(_field); _class.Fields.Add(_field);
} }
for (uint i = 0; i < @class.MethodsCount; ++i) for (uint i = 0; i < @class.MethodsCount; ++i)
{ {
var method = @class.getMethods(i); var method = @class.GetMethods(i);
var _method = Visit(method) as AST.Method; var _method = Visit(method) as AST.Method;
_class.Methods.Add(_method); _class.Methods.Add(_method);
} }
for (uint i = 0; i < @class.SpecifiersCount; ++i) for (uint i = 0; i < @class.SpecifiersCount; ++i)
{ {
var spec = @class.getSpecifiers(i); var spec = @class.GetSpecifiers(i);
var _spec = Visit(spec) as AST.AccessSpecifierDecl; var _spec = Visit(spec) as AST.AccessSpecifierDecl;
_class.Specifiers.Add(_spec); _class.Specifiers.Add(_spec);
} }
@ -1482,14 +1482,14 @@ namespace CppSharp
for (uint i = 0; i < layout.VFTablesCount; ++i) for (uint i = 0; i < layout.VFTablesCount; ++i)
{ {
var vftableInfo = layout.getVFTables(i); var vftableInfo = layout.GetVFTables(i);
var _vftableInfo = VisitVFTableInfo(vftableInfo); var _vftableInfo = VisitVFTableInfo(vftableInfo);
_layout.VFTables.Add(_vftableInfo); _layout.VFTables.Add(_vftableInfo);
} }
for (uint i = 0; i < layout.FieldsCount; i++) for (uint i = 0; i < layout.FieldsCount; i++)
{ {
var field = layout.getFields(i); var field = layout.GetFields(i);
var _field = new AST.LayoutField(); var _field = new AST.LayoutField();
_field.Offset = field.Offset; _field.Offset = field.Offset;
_field.Name = field.Name; _field.Name = field.Name;
@ -1500,7 +1500,7 @@ namespace CppSharp
for (uint i = 0; i < layout.BasesCount; i++) for (uint i = 0; i < layout.BasesCount; i++)
{ {
var @base = layout.getBases(i); var @base = layout.GetBases(i);
var _base = new AST.LayoutBase(); var _base = new AST.LayoutBase();
_base.Offset = @base.Offset; _base.Offset = @base.Offset;
_base.Class = (AST.Class) Visit(@base.Class); _base.Class = (AST.Class) Visit(@base.Class);
@ -1550,7 +1550,7 @@ namespace CppSharp
for (uint i = 0; i < layout.ComponentsCount; ++i) for (uint i = 0; i < layout.ComponentsCount; ++i)
{ {
var component = layout.getComponents(i); var component = layout.GetComponents(i);
var _component = VisitVTableComponent(component); var _component = VisitVTableComponent(component);
_layout.Components.Add(_component); _layout.Components.Add(_component);
} }
@ -1605,7 +1605,7 @@ namespace CppSharp
for (uint i = 0; i < template.ParametersCount; ++i) for (uint i = 0; i < template.ParametersCount; ++i)
{ {
var param = template.getParameters(i); var param = template.GetParameters(i);
var _param = Visit(param); var _param = Visit(param);
_template.Parameters.Add(_param); _template.Parameters.Add(_param);
} }
@ -1625,7 +1625,7 @@ namespace CppSharp
VisitTemplate(decl, _decl); VisitTemplate(decl, _decl);
for (uint i = 0; i < decl.SpecializationsCount; ++i) for (uint i = 0; i < decl.SpecializationsCount; ++i)
{ {
var spec = decl.getSpecializations(i); var spec = decl.GetSpecializations(i);
var _spec = (AST.ClassTemplateSpecialization)Visit(spec); var _spec = (AST.ClassTemplateSpecialization)Visit(spec);
_decl.Specializations.Add(_spec); _decl.Specializations.Add(_spec);
} }
@ -1648,7 +1648,7 @@ namespace CppSharp
_decl.TemplatedDecl = (AST.ClassTemplate)Visit(decl.TemplatedDecl); _decl.TemplatedDecl = (AST.ClassTemplate)Visit(decl.TemplatedDecl);
for (uint i = 0; i < decl.ArgumentsCount; ++i) for (uint i = 0; i < decl.ArgumentsCount; ++i)
{ {
var arg = decl.getArguments(i); var arg = decl.GetArguments(i);
var _arg = VisitTemplateArgument(arg); var _arg = VisitTemplateArgument(arg);
_decl.Arguments.Add(_arg); _decl.Arguments.Add(_arg);
} }
@ -1725,7 +1725,7 @@ namespace CppSharp
VisitTemplate(decl, _decl); VisitTemplate(decl, _decl);
for (uint i = 0; i < decl.SpecializationsCount; ++i) for (uint i = 0; i < decl.SpecializationsCount; ++i)
{ {
var _spec = VisitFunctionTemplateSpecialization(decl.getSpecializations(i)); var _spec = VisitFunctionTemplateSpecialization(decl.GetSpecializations(i));
_decl.Specializations.Add(_spec); _decl.Specializations.Add(_spec);
} }
return _decl; return _decl;
@ -1743,7 +1743,7 @@ namespace CppSharp
_spec.SpecializationKind = VisitSpecializationKind(spec.SpecializationKind); _spec.SpecializationKind = VisitSpecializationKind(spec.SpecializationKind);
for (uint i = 0; i < spec.ArgumentsCount; ++i) for (uint i = 0; i < spec.ArgumentsCount; ++i)
{ {
var _arg = VisitTemplateArgument(spec.getArguments(i)); var _arg = VisitTemplateArgument(spec.GetArguments(i));
_spec.Arguments.Add(_arg); _spec.Arguments.Add(_arg);
} }
FunctionTemplateSpecializations.Add(spec.__Instance, _spec); FunctionTemplateSpecializations.Add(spec.__Instance, _spec);
@ -1757,7 +1757,7 @@ namespace CppSharp
VisitTemplate(decl, _decl); VisitTemplate(decl, _decl);
for (uint i = 0; i < decl.SpecializationsCount; ++i) for (uint i = 0; i < decl.SpecializationsCount; ++i)
{ {
var spec = decl.getSpecializations(i); var spec = decl.GetSpecializations(i);
var _spec = (AST.VarTemplateSpecialization)Visit(spec); var _spec = (AST.VarTemplateSpecialization)Visit(spec);
_decl.Specializations.Add(_spec); _decl.Specializations.Add(_spec);
} }
@ -1780,7 +1780,7 @@ namespace CppSharp
_decl.TemplatedDecl = (AST.VarTemplate)Visit(decl.TemplatedDecl); _decl.TemplatedDecl = (AST.VarTemplate)Visit(decl.TemplatedDecl);
for (uint i = 0; i < decl.ArgumentsCount; ++i) for (uint i = 0; i < decl.ArgumentsCount; ++i)
{ {
var arg = decl.getArguments(i); var arg = decl.GetArguments(i);
var _arg = VisitTemplateArgument(arg); var _arg = VisitTemplateArgument(arg);
_decl.Arguments.Add(_arg); _decl.Arguments.Add(_arg);
} }
@ -1905,7 +1905,7 @@ namespace CppSharp
{ {
var fullComment = new AST.FullComment(); var fullComment = new AST.FullComment();
for (uint i = 0; i < comment.BlocksCount; i++) for (uint i = 0; i < comment.BlocksCount; i++)
fullComment.Blocks.Add((AST.BlockContentComment) Visit(comment.getBlocks(i))); fullComment.Blocks.Add((AST.BlockContentComment) Visit(comment.GetBlocks(i)));
return fullComment; return fullComment;
} }
@ -1940,7 +1940,7 @@ namespace CppSharp
{ {
var paramCommandComment = new AST.TParamCommandComment(); var paramCommandComment = new AST.TParamCommandComment();
for (uint i = 0; i < comment.PositionCount; i++) for (uint i = 0; i < comment.PositionCount; i++)
paramCommandComment.Position.Add(comment.getPosition(i)); paramCommandComment.Position.Add(comment.GetPosition(i));
VisitBlockCommandComment(paramCommandComment, comment); VisitBlockCommandComment(paramCommandComment, comment);
return paramCommandComment; return paramCommandComment;
} }
@ -1949,7 +1949,7 @@ namespace CppSharp
{ {
var verbatimBlockComment = new AST.VerbatimBlockComment(); var verbatimBlockComment = new AST.VerbatimBlockComment();
for (uint i = 0; i < comment.LinesCount; i++) for (uint i = 0; i < comment.LinesCount; i++)
verbatimBlockComment.Lines.Add((AST.VerbatimBlockLineComment) Visit(comment.getLines(i))); verbatimBlockComment.Lines.Add((AST.VerbatimBlockLineComment) Visit(comment.GetLines(i)));
VisitBlockCommandComment(verbatimBlockComment, comment); VisitBlockCommandComment(verbatimBlockComment, comment);
return verbatimBlockComment; return verbatimBlockComment;
} }
@ -1965,7 +1965,7 @@ namespace CppSharp
{ {
var paragraphComment = new AST.ParagraphComment(); var paragraphComment = new AST.ParagraphComment();
for (uint i = 0; i < comment.ContentCount; i++) for (uint i = 0; i < comment.ContentCount; i++)
paragraphComment.Content.Add((AST.InlineContentComment) Visit(comment.getContent(i))); paragraphComment.Content.Add((AST.InlineContentComment) Visit(comment.GetContent(i)));
paragraphComment.IsWhitespace = comment.IsWhitespace; paragraphComment.IsWhitespace = comment.IsWhitespace;
return paragraphComment; return paragraphComment;
} }
@ -1976,7 +1976,7 @@ namespace CppSharp
for (uint i = 0; i < comment.AttributesCount; i++) for (uint i = 0; i < comment.AttributesCount; i++)
{ {
var attribute = new AST.HTMLStartTagComment.Attribute(); var attribute = new AST.HTMLStartTagComment.Attribute();
var _attribute = comment.getAttributes(i); var _attribute = comment.GetAttributes(i);
attribute.Name = _attribute.Name; attribute.Name = _attribute.Name;
attribute.Value = _attribute.Value; attribute.Value = _attribute.Value;
htmlStartTagComment.Attributes.Add(attribute); htmlStartTagComment.Attributes.Add(attribute);
@ -2011,7 +2011,7 @@ namespace CppSharp
inlineCommandComment.CommandId = comment.CommandId; inlineCommandComment.CommandId = comment.CommandId;
for (uint i = 0; i < comment.ArgumentsCount; i++) for (uint i = 0; i < comment.ArgumentsCount; i++)
{ {
var argument = new AST.InlineCommandComment.Argument { Text = comment.getArguments(i).Text }; var argument = new AST.InlineCommandComment.Argument { Text = comment.GetArguments(i).Text };
inlineCommandComment.Arguments.Add(argument); inlineCommandComment.Arguments.Add(argument);
} }
return inlineCommandComment; return inlineCommandComment;
@ -2029,7 +2029,7 @@ namespace CppSharp
blockCommandComment.ParagraphComment = (AST.ParagraphComment) Visit(comment.ParagraphComment); blockCommandComment.ParagraphComment = (AST.ParagraphComment) Visit(comment.ParagraphComment);
for (uint i = 0; i < comment.ArgumentsCount; i++) for (uint i = 0; i < comment.ArgumentsCount; i++)
{ {
var argument = new AST.BlockCommandComment.Argument { Text = comment.getArguments(i).Text }; var argument = new AST.BlockCommandComment.Argument { Text = comment.GetArguments(i).Text };
blockCommandComment.Arguments.Add(argument); blockCommandComment.Arguments.Add(argument);
} }
} }

8
src/Parser/Parser.cs

@ -54,7 +54,7 @@ namespace CppSharp
{ {
var options = file.Options; var options = file.Options;
options.ASTContext = ASTContext; options.ASTContext = ASTContext;
options.addSourceFiles(file.Path); options.AddSourceFiles(file.Path);
var result = Parser.ClangParser.ParseHeader(options); var result = Parser.ClangParser.ParseHeader(options);
SourcesParsed(new[] { file }, result); SourcesParsed(new[] { file }, result);
@ -71,7 +71,7 @@ namespace CppSharp
options.ASTContext = ASTContext; options.ASTContext = ASTContext;
foreach (var file in files) foreach (var file in files)
options.addSourceFiles(file.Path); options.AddSourceFiles(file.Path);
using (var result = Parser.ClangParser.ParseHeader(options)) using (var result = Parser.ClangParser.ParseHeader(options))
SourcesParsed(files, result); SourcesParsed(files, result);
} }
@ -123,12 +123,12 @@ namespace CppSharp
for (uint i = 0; i < library.SymbolsCount; ++i) for (uint i = 0; i < library.SymbolsCount; ++i)
{ {
var symbol = library.getSymbols(i); var symbol = library.GetSymbols(i);
newLibrary.Symbols.Add(symbol); newLibrary.Symbols.Add(symbol);
} }
for (uint i = 0; i < library.DependenciesCount; i++) for (uint i = 0; i < library.DependenciesCount; i++)
{ {
newLibrary.Dependencies.Add(library.getDependencies(i)); newLibrary.Dependencies.Add(library.GetDependencies(i));
} }
return newLibrary; return newLibrary;

16
src/Parser/ParserOptions.cs

@ -22,30 +22,30 @@ namespace CppSharp.Parser
Abi = CppAbi.Microsoft; Abi = CppAbi.Microsoft;
ToolSetToUse = MSVCToolchain.GetCLVersion(vsVersion) * 10000000; ToolSetToUse = MSVCToolchain.GetCLVersion(vsVersion) * 10000000;
addArguments("-fms-extensions"); AddArguments("-fms-extensions");
addArguments("-fms-compatibility"); AddArguments("-fms-compatibility");
addArguments("-fdelayed-template-parsing"); AddArguments("-fdelayed-template-parsing");
var includes = MSVCToolchain.GetSystemIncludes(vsVersion); var includes = MSVCToolchain.GetSystemIncludes(vsVersion);
foreach (var include in includes) foreach (var include in includes)
addSystemIncludeDirs(include); AddSystemIncludeDirs(include);
} }
public void SetupXcode() public void SetupXcode()
{ {
var builtinsPath = XcodeToolchain.GetXcodeBuiltinIncludesFolder(); var builtinsPath = XcodeToolchain.GetXcodeBuiltinIncludesFolder();
addSystemIncludeDirs(builtinsPath); AddSystemIncludeDirs(builtinsPath);
var cppIncPath = XcodeToolchain.GetXcodeCppIncludesFolder(); var cppIncPath = XcodeToolchain.GetXcodeCppIncludesFolder();
addSystemIncludeDirs(cppIncPath); AddSystemIncludeDirs(cppIncPath);
var includePath = XcodeToolchain.GetXcodeIncludesFolder(); var includePath = XcodeToolchain.GetXcodeIncludesFolder();
addSystemIncludeDirs(includePath); AddSystemIncludeDirs(includePath);
NoBuiltinIncludes = true; NoBuiltinIncludes = true;
NoStandardIncludes = true; NoStandardIncludes = true;
addArguments("-stdlib=libc++"); AddArguments("-stdlib=libc++");
} }
public void SetupIncludes() public void SetupIncludes()

1
tests/CSharp/CSharp.cs

@ -150,7 +150,6 @@ namespace CppSharp.Tests
public override void SetupPasses(Driver driver) public override void SetupPasses(Driver driver)
{ {
driver.Options.GeneratePropertiesAdvanced = true;
driver.Context.TranslationUnitPasses.AddPass(new TestAttributesPass()); driver.Context.TranslationUnitPasses.AddPass(new TestAttributesPass());
driver.Context.TranslationUnitPasses.AddPass(new CheckMacroPass()); driver.Context.TranslationUnitPasses.AddPass(new CheckMacroPass());
driver.Options.MarshalCharAsManagedChar = true; driver.Options.MarshalCharAsManagedChar = true;

42
tests/Common/Common.Tests.cs

@ -10,7 +10,7 @@ public class CommonTests : GeneratorTestFixture
[Test] [Test]
public void TestCodeGeneration() public void TestCodeGeneration()
{ {
Assert.That(new ChangedAccessOfInheritedProperty().Property, Is.EqualTo(2)); Assert.That(new ChangedAccessOfInheritedProperty().property, Is.EqualTo(2));
Foo.NestedAbstract a; Foo.NestedAbstract a;
var renamedEmptyEnum = Foo.RenamedEmptyEnum.EmptyEnum1; var renamedEmptyEnum = Foo.RenamedEmptyEnum.EmptyEnum1;
using (var foo = new Foo()) using (var foo = new Foo())
@ -215,9 +215,9 @@ public class CommonTests : GeneratorTestFixture
public void TestAbstractReturnType() public void TestAbstractReturnType()
{ {
var returnsAbstractFoo = new ReturnsAbstractFoo(); var returnsAbstractFoo = new ReturnsAbstractFoo();
var abstractFoo = returnsAbstractFoo.Foo; var abstractFoo = returnsAbstractFoo.foo;
Assert.AreEqual(abstractFoo.pureFunction(1), 5); Assert.AreEqual(abstractFoo.pureFunction(1), 5);
Assert.AreEqual(abstractFoo.pureFunction1(), 10); Assert.AreEqual(abstractFoo.pureFunction1, 10);
var ok = false; var ok = false;
Assert.AreEqual(abstractFoo.pureFunction2(ref ok), 15); Assert.AreEqual(abstractFoo.pureFunction2(ref ok), 15);
} }
@ -263,7 +263,7 @@ public class CommonTests : GeneratorTestFixture
public void TestMethodWithFixedInstance() public void TestMethodWithFixedInstance()
{ {
var bar = new Bar2 { A = 1, B = 2, C = 3 }; var bar = new Bar2 { A = 1, B = 2, C = 3 };
Foo2 foo = bar.needFixedInstance(); Foo2 foo = bar.needFixedInstance;
Assert.AreEqual(foo.A, 1); Assert.AreEqual(foo.A, 1);
Assert.AreEqual(foo.B, 2); Assert.AreEqual(foo.B, 2);
Assert.AreEqual(foo.C, 3); Assert.AreEqual(foo.C, 3);
@ -318,8 +318,8 @@ public class CommonTests : GeneratorTestFixture
{ {
Assert.That(TestStaticClass.Add(1, 2), Is.EqualTo(3)); Assert.That(TestStaticClass.Add(1, 2), Is.EqualTo(3));
Assert.That(TestStaticClass.OneTwoThree, Is.EqualTo(123)); Assert.That(TestStaticClass.OneTwoThree, Is.EqualTo(123));
Assert.That(TestStaticClassDerived.Foo(), Is.EqualTo(0)); Assert.That(TestStaticClassDerived.Foo, Is.EqualTo(0));
TestNotStaticClass.StaticFunction(); TestNotStaticClass.StaticFunction.GetHashCode();
} }
[Test] [Test]
@ -386,7 +386,7 @@ public class CommonTests : GeneratorTestFixture
[Test] [Test]
public void TestFunctions() public void TestFunctions()
{ {
var ret = common.Function(); var ret = common.Function;
Assert.That(ret, Is.EqualTo(5)); Assert.That(ret, Is.EqualTo(5));
common.FuncWithTypeAlias(0); common.FuncWithTypeAlias(0);
@ -403,9 +403,9 @@ public class CommonTests : GeneratorTestFixture
// Test getter/setter property // Test getter/setter property
prop.Field = 20; prop.Field = 20;
Assert.That(prop.FieldValue, Is.EqualTo(20)); Assert.That(prop.fieldValue, Is.EqualTo(20));
prop.FieldValue = 10; prop.fieldValue = 10;
Assert.That(prop.FieldValue, Is.EqualTo(10)); Assert.That(prop.fieldValue, Is.EqualTo(10));
} }
[Test] [Test]
@ -413,7 +413,7 @@ public class CommonTests : GeneratorTestFixture
{ {
// Test field property // Test field property
var @var = new TestVariables(); var @var = new TestVariables();
@var.Value = 10; @var.SetValue(10);
Assert.That(TestVariables.VALUE, Is.EqualTo(10)); Assert.That(TestVariables.VALUE, Is.EqualTo(10));
} }
@ -438,8 +438,8 @@ public class CommonTests : GeneratorTestFixture
public unsafe void TestGetterSetterToProperties() public unsafe void TestGetterSetterToProperties()
{ {
var @class = new TestGetterSetterToProperties(); var @class = new TestGetterSetterToProperties();
Assert.That(@class.Width, Is.EqualTo(640)); Assert.That(@class.width, Is.EqualTo(640));
Assert.That(@class.Height, Is.EqualTo(480)); Assert.That(@class.height, Is.EqualTo(480));
} }
[Test] [Test]
@ -455,14 +455,14 @@ public class CommonTests : GeneratorTestFixture
[Test] [Test]
public unsafe void TestDecltype() public unsafe void TestDecltype()
{ {
var ret = common.TestDecltype(); var ret = common.TestDecltype;
Assert.AreEqual(0, ret); Assert.AreEqual(0, ret);
} }
[Test] [Test]
public unsafe void TestNullPtrType() public unsafe void TestNullPtrType()
{ {
var ret = common.TestNullPtrTypeRet(); var ret = common.TestNullPtrTypeRet;
Assert.AreEqual(IntPtr.Zero, new IntPtr(ret)); Assert.AreEqual(IntPtr.Zero, new IntPtr(ret));
} }
@ -496,7 +496,7 @@ public class CommonTests : GeneratorTestFixture
public void TestGetAnonymousDelegate() public void TestGetAnonymousDelegate()
{ {
var testDelegates = new TestDelegates(); var testDelegates = new TestDelegates();
var @delegate = testDelegates.MarshalAnonymousDelegate4(); var @delegate = testDelegates.MarshalAnonymousDelegate4;
int value = @delegate.Invoke(1); int value = @delegate.Invoke(1);
Assert.AreEqual(2, value); Assert.AreEqual(2, value);
} }
@ -543,8 +543,8 @@ public class CommonTests : GeneratorTestFixture
{ {
HasFriend h1 = 5; HasFriend h1 = 5;
HasFriend h2 = 10; HasFriend h2 = 10;
Assert.AreEqual(15, (h1 + h2).M); Assert.AreEqual(15, (h1 + h2).m);
Assert.AreEqual(-5, (h1 - h2).M); Assert.AreEqual(-5, (h1 - h2).m);
} }
[Test] [Test]
@ -564,7 +564,7 @@ public class CommonTests : GeneratorTestFixture
[Test] [Test]
public void TestMarshallingEmptyType() public void TestMarshallingEmptyType()
{ {
var empty = new ReturnsEmpty().Empty; var empty = new ReturnsEmpty().empty;
} }
[Test] [Test]
@ -584,7 +584,7 @@ public class CommonTests : GeneratorTestFixture
{ {
using (var hasVirtualReturningHasProblematicFields = new HasVirtualReturningHasProblematicFields()) using (var hasVirtualReturningHasProblematicFields = new HasVirtualReturningHasProblematicFields())
{ {
var hasProblematicFields = hasVirtualReturningHasProblematicFields.returnsProblematicFields(); var hasProblematicFields = hasVirtualReturningHasProblematicFields.returnsProblematicFields;
Assert.That(hasProblematicFields.b, Is.EqualTo(false)); Assert.That(hasProblematicFields.b, Is.EqualTo(false));
hasProblematicFields.b = true; hasProblematicFields.b = true;
Assert.That(hasProblematicFields.b, Is.EqualTo(true)); Assert.That(hasProblematicFields.b, Is.EqualTo(true));
@ -623,7 +623,7 @@ public class CommonTests : GeneratorTestFixture
using (var nonTrivialDtor = new NonTrivialDtor()) using (var nonTrivialDtor = new NonTrivialDtor())
{ {
} }
Assert.IsTrue(NonTrivialDtor.DtorCalled); Assert.IsTrue(NonTrivialDtor.dtorCalled);
} }
[Test] [Test]

10
tests/Common/Common.cs

@ -62,13 +62,11 @@ namespace CppSharp.Tests
public override void SetupPasses(Driver driver) public override void SetupPasses(Driver driver)
{ {
driver.Options.MarshalCharAsManagedChar = true; driver.Options.MarshalCharAsManagedChar = true;
driver.Options.GenerateProperties = true;
driver.Options.GenerateDefaultValuesForArguments = true; driver.Options.GenerateDefaultValuesForArguments = true;
} }
public override void Preprocess(Driver driver, ASTContext ctx) public override void Preprocess(Driver driver, ASTContext ctx)
{ {
driver.AddTranslationUnitPass(new GetterSetterToPropertyPass());
driver.AddTranslationUnitPass(new CheckMacroPass()); driver.AddTranslationUnitPass(new CheckMacroPass());
ctx.SetClassAsValueType("Bar"); ctx.SetClassAsValueType("Bar");
ctx.SetClassAsValueType("Bar2"); ctx.SetClassAsValueType("Bar2");
@ -80,14 +78,6 @@ namespace CppSharp.Tests
public override void Postprocess(Driver driver, ASTContext ctx) public override void Postprocess(Driver driver, ASTContext ctx)
{ {
// HACK: as seen above, GetterSetterToPropertyPass is called before all other passes
// that is a hack in order for the pass to generate properties in Common.h
// it is incapable of generating them in the proper manner
// so it generates a property in system type from a member which is later ignored
// so let's ignore that property manually
var @class = ctx.FindCompleteClass("basic_string");
foreach (var property in @class.Specializations.SelectMany(c => c.Properties))
property.ExplicitlyIgnore();
} }
public static void Main(string[] args) public static void Main(string[] args)

4
tests/Common/Common.h

@ -602,8 +602,8 @@ int TestIndexedPropertiesInValueType::operator[](int i) { return i; }
// Tests variables // Tests variables
struct DLL_API TestVariables struct DLL_API TestVariables
{ {
static int VALUE; static int VALUE;
void SetValue(int value = VALUE); void SetValue(int value = VALUE);
}; };
int TestVariables::VALUE; int TestVariables::VALUE;

1
tests/NamespacesDerived/NamespacesDerived.cs

@ -17,7 +17,6 @@ namespace CppSharp.Tests
{ {
base.Setup(driver); base.Setup(driver);
driver.Options.GenerateDefaultValuesForArguments = true; driver.Options.GenerateDefaultValuesForArguments = true;
driver.Options.GeneratePropertiesAdvanced = true;
driver.Options.Modules[1].IncludeDirs.Add(GetTestsDirectory("NamespacesDerived")); driver.Options.Modules[1].IncludeDirs.Add(GetTestsDirectory("NamespacesDerived"));
var @base = "NamespacesBase"; var @base = "NamespacesBase";

2
tests/StandardLib/StandardLib.Tests.cs

@ -16,7 +16,7 @@ public class StandardLibTests : GeneratorTestFixture
var sum = vectors.SumIntVector(new List<int> { 1, 2, 3 }); var sum = vectors.SumIntVector(new List<int> { 1, 2, 3 });
Assert.AreEqual(sum, 6); Assert.AreEqual(sum, 6);
var list = vectors.GetIntVector(); var list = vectors.IntVector;
Assert.True(list.SequenceEqual(new List<int> { 2, 3, 4 })); Assert.True(list.SequenceEqual(new List<int> { 2, 3, 4 }));
var ptrList = vectors.IntPtrVector; var ptrList = vectors.IntPtrVector;

1
tests/TypeMaps/TypeMaps.cs

@ -16,7 +16,6 @@ namespace CppSharp.Tests
public override void SetupPasses(Driver driver) public override void SetupPasses(Driver driver)
{ {
driver.Options.MarshalCharAsManagedChar = true; driver.Options.MarshalCharAsManagedChar = true;
driver.Options.GenerateProperties = true;
} }
public override void Preprocess(Driver driver, ASTContext ctx) public override void Preprocess(Driver driver, ASTContext ctx)

17
tests/VTables/VTables.Tests.cs

@ -5,10 +5,13 @@ using VTables;
public class FooDerived : Foo public class FooDerived : Foo
{ {
public override int vfoo() public override int vfoo
{ {
Console.WriteLine("Hello from FooDerived"); get
return 10; {
Console.WriteLine("Hello from FooDerived");
return 10;
}
} }
} }
@ -34,8 +37,8 @@ public class VTablesTests : GeneratorTestFixture
public void TestFoo() public void TestFoo()
{ {
var foo = new Foo(); var foo = new Foo();
Assert.That(foo.vfoo(), Is.EqualTo(5)); Assert.That(foo.vfoo, Is.EqualTo(5));
Assert.That(foo.Vbar(), Is.EqualTo(5)); Assert.That(foo.Vbar, Is.EqualTo(5));
Assert.That(foo.CallFoo(), Is.EqualTo(7)); Assert.That(foo.CallFoo(), Is.EqualTo(7));
Assert.That(foo.CallVirtualWithParameter(6514), Is.EqualTo(6514 + 1)); Assert.That(foo.CallVirtualWithParameter(6514), Is.EqualTo(6514 + 1));
@ -57,13 +60,13 @@ public class VTablesTests : GeneratorTestFixture
{ {
// Virtual Functions Object Slicing case // Virtual Functions Object Slicing case
// See http://stackoverflow.com/questions/3479712/virtual-functions-object-slicing // See http://stackoverflow.com/questions/3479712/virtual-functions-object-slicing
var baseVirtual = BaseClassVirtual.GetBase(); var baseVirtual = BaseClassVirtual.Base;
TestVirtualFunction(baseVirtual, 5); TestVirtualFunction(baseVirtual, 5);
BaseClassVirtual baseClass = new DerivedClassVirtual(); BaseClassVirtual baseClass = new DerivedClassVirtual();
TestVirtualFunction(baseClass, 10); TestVirtualFunction(baseClass, 10);
var basePtr = BaseClassVirtual.GetBasePtr(); var basePtr = BaseClassVirtual.BasePtr;
TestVirtualFunction(basePtr, 10); TestVirtualFunction(basePtr, 10);
var managed = new ManagedDerivedClassVirtual(); var managed = new ManagedDerivedClassVirtual();

Loading…
Cancel
Save