Browse Source

Move the AST project to the CppSharp.AST namespace.

pull/13/merge
triton 12 years ago
parent
commit
68ddfbdd6f
  1. 2
      src/AST/ASTVisitor.cs
  2. 2
      src/AST/Class.cs
  3. 6
      src/AST/Comment.cs
  4. 2
      src/AST/Conversions.cs
  5. 2
      src/AST/Declaration.cs
  6. 2
      src/AST/Delegate.cs
  7. 2
      src/AST/Enumeration.cs
  8. 2
      src/AST/Event.cs
  9. 2
      src/AST/Field.cs
  10. 2
      src/AST/Function.cs
  11. 2
      src/AST/Library.cs
  12. 2
      src/AST/Method.cs
  13. 2
      src/AST/Namespace.cs
  14. 2
      src/AST/Preprocessor.cs
  15. 5
      src/AST/Property.cs
  16. 2
      src/AST/Template.cs
  17. 2
      src/AST/TranslationUnit.cs
  18. 2
      src/AST/Type.cs
  19. 2
      src/AST/Variable.cs
  20. 1
      src/Generator.Tests/HeaderTestFixture.cs
  21. 1
      src/Generator.Tests/QueryHelpers.cs
  22. 3
      src/Generator/Driver.cs
  23. 1
      src/Generator/Generators/CLI/CLIForwardReferencePrinter.cs
  24. 1
      src/Generator/Generators/CLI/CLIGenerator.cs
  25. 2
      src/Generator/Generators/CLI/CLIMarshal.cs
  26. 1
      src/Generator/Generators/CLI/CLITextTemplate.cs
  27. 3
      src/Generator/Generators/CLI/CLITypePrinter.cs
  28. 4
      src/Generator/Generators/CSharp/CSharpGenerator.cs
  29. 1
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  30. 2
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  31. 3
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs
  32. 1
      src/Generator/Generators/Generator.cs
  33. 4
      src/Generator/Generators/Marshal.cs
  34. 3
      src/Generator/Generators/Template.cs
  35. 1
      src/Generator/Library.cs
  36. 1
      src/Generator/Parser.cs
  37. 4
      src/Generator/Passes/CheckAbiParameters.cs
  38. 1
      src/Generator/Passes/CheckFlagEnumsPass.cs
  39. 7
      src/Generator/Passes/CheckIgnoredDecls.cs
  40. 1
      src/Generator/Passes/CheckOperatorsOverloads.cs
  41. 4
      src/Generator/Passes/CheckTypeReferencesPass.cs
  42. 1
      src/Generator/Passes/CleanInvalidDeclNamesPass.cs
  43. 2
      src/Generator/Passes/CleanUnitPass.cs
  44. 1
      src/Generator/Passes/DuplicatedNamesCheckerPass.cs
  45. 1
      src/Generator/Passes/FunctionToInstanceMethodPass.cs
  46. 1
      src/Generator/Passes/FunctionToStaticMethodPass.cs
  47. 2
      src/Generator/Passes/Pass.cs
  48. 1
      src/Generator/Passes/RenamePass.cs
  49. 1
      src/Generator/Passes/ResolveIncompleteDeclsPass.cs
  50. 3
      src/Generator/Passes/SortDeclarationsPass.cs
  51. 2
      src/Generator/Types/CppTypePrinter.cs
  52. 1
      src/Generator/Types/ITypePrinter.cs
  53. 1
      src/Generator/Types/Std/Stdlib.cs
  54. 2
      src/Generator/Types/TypeMap.cs
  55. 1
      src/Generator/Types/Types.cs
  56. 1
      src/Generator/Utils/TestsUtils.cs
  57. 1
      src/Generator/Utils/Utils.cs
  58. 238
      src/Parser/Parser.cpp
  59. 44
      src/Parser/Parser.h
  60. 1
      tests/Hello/Hello.cs

2
src/AST/ASTVisitor.cs

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace CppSharp namespace CppSharp.AST
{ {
public interface IAstVisited public interface IAstVisited
{ {

2
src/AST/Class.cs

@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace CppSharp namespace CppSharp.AST
{ {
// A C++ access specifier. // A C++ access specifier.
public enum AccessSpecifier public enum AccessSpecifier

6
src/AST/Comment.cs

@ -1,8 +1,4 @@
using System; namespace CppSharp.AST
using System.Collections.Generic;
using System.Text;
namespace CppSharp
{ {
/// <summary> /// <summary>
/// Represents a C++ comment. /// Represents a C++ comment.

2
src/AST/Conversions.cs

@ -1,4 +1,4 @@
namespace CppSharp namespace CppSharp.AST
{ {
public enum MethodConversionKind public enum MethodConversionKind
{ {

2
src/AST/Declaration.cs

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace CppSharp namespace CppSharp.AST
{ {
public interface IRedeclarableDecl public interface IRedeclarableDecl
{ {

2
src/AST/Delegate.cs

@ -1,4 +1,4 @@
namespace CppSharp namespace CppSharp.AST
{ {
public class Delegate : Declaration public class Delegate : Declaration
{ {

2
src/AST/Enumeration.cs

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace CppSharp namespace CppSharp.AST
{ {
/// <summary> /// <summary>
/// Represents a C/C++ enumeration declaration. /// Represents a C/C++ enumeration declaration.

2
src/AST/Event.cs

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace CppSharp namespace CppSharp.AST
{ {
public class Event : Declaration, ITypedDecl public class Event : Declaration, ITypedDecl
{ {

2
src/AST/Field.cs

@ -1,4 +1,4 @@
namespace CppSharp namespace CppSharp.AST
{ {
/// <summary> /// <summary>
/// Represents a a C/C++ record field Decl. /// Represents a a C/C++ record field Decl.

2
src/AST/Function.cs

@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace CppSharp namespace CppSharp.AST
{ {
public enum CallingConvention public enum CallingConvention
{ {

2
src/AST/Library.cs

@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
namespace CppSharp namespace CppSharp.AST
{ {
public enum CppAbi public enum CppAbi
{ {

2
src/AST/Method.cs

@ -1,4 +1,4 @@
namespace CppSharp namespace CppSharp.AST
{ {
public enum CXXMethodKind public enum CXXMethodKind
{ {

2
src/AST/Namespace.cs

@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace CppSharp namespace CppSharp.AST
{ {
/// <summary> /// <summary>
/// Represents a declaration context. /// Represents a declaration context.

2
src/AST/Preprocessor.cs

@ -1,4 +1,4 @@
namespace CppSharp namespace CppSharp.AST
{ {
public enum MacroLocation public enum MacroLocation
{ {

5
src/AST/Property.cs

@ -1,7 +1,4 @@
using System; namespace CppSharp.AST
using System.Collections.Generic;
namespace CppSharp
{ {
/// <summary> /// <summary>
/// Represents a C++ property. /// Represents a C++ property.

2
src/AST/Template.cs

@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace CppSharp namespace CppSharp.AST
{ {
public struct TemplateParameter public struct TemplateParameter
{ {

2
src/AST/TranslationUnit.cs

@ -2,7 +2,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
namespace CppSharp namespace CppSharp.AST
{ {
/// <summary> /// <summary>
/// Represents a parsed C++ unit. /// Represents a parsed C++ unit.

2
src/AST/Type.cs

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace CppSharp namespace CppSharp.AST
{ {
/// <summary> /// <summary>
/// Represents a C++ type. /// Represents a C++ type.

2
src/AST/Variable.cs

@ -1,5 +1,5 @@
 
namespace CppSharp namespace CppSharp.AST
{ {
public class Variable : Declaration, ITypedDecl, IMangledDecl public class Variable : Declaration, ITypedDecl, IMangledDecl
{ {

1
src/Generator.Tests/HeaderTestFixture.cs

@ -1,6 +1,7 @@
using System; using System;
using System.IO; using System.IO;
using CppSharp; using CppSharp;
using CppSharp.AST;
namespace Generator.Tests namespace Generator.Tests
{ {

1
src/Generator.Tests/QueryHelpers.cs

@ -1,5 +1,6 @@
using System.Linq; using System.Linq;
using CppSharp; using CppSharp;
using CppSharp.AST;
namespace Generator.Tests namespace Generator.Tests
{ {

3
src/Generator/Driver.cs

@ -1,4 +1,5 @@
using CppSharp.Generators; using CppSharp.AST;
using CppSharp.Generators;
using CppSharp.Generators.CLI; using CppSharp.Generators.CLI;
using CppSharp.Generators.CSharp; using CppSharp.Generators.CSharp;
using CppSharp.Passes; using CppSharp.Passes;

1
src/Generator/Generators/CLI/CLIForwardReferencePrinter.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using CppSharp.AST;
namespace CppSharp.Generators.CLI namespace CppSharp.Generators.CLI
{ {

1
src/Generator/Generators/CLI/CLIGenerator.cs

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using CppSharp.AST;
namespace CppSharp.Generators.CLI namespace CppSharp.Generators.CLI
{ {

2
src/Generator/Generators/CLI/CLIMarshal.cs

@ -1,6 +1,8 @@
using System; using System;
using System.Text; using System.Text;
using CppSharp.AST;
using CppSharp.Types; using CppSharp.Types;
using Delegate = CppSharp.AST.Delegate;
namespace CppSharp.Generators.CLI namespace CppSharp.Generators.CLI
{ {

1
src/Generator/Generators/CLI/CLITextTemplate.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using CppSharp.AST;
namespace CppSharp.Generators.CLI namespace CppSharp.Generators.CLI
{ {

3
src/Generator/Generators/CLI/CLITypePrinter.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using CppSharp.AST;
using CppSharp.Types; using CppSharp.Types;
namespace CppSharp.Generators.CLI namespace CppSharp.Generators.CLI
@ -339,7 +340,7 @@ namespace CppSharp.Generators.CLI
throw new NotImplementedException(); throw new NotImplementedException();
} }
public string ToString(Type type) public string ToString(AST.Type type)
{ {
return type.Visit(this); return type.Visit(this);
} }

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

@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using CppSharp.AST;
using CppSharp.Passes; using CppSharp.Passes;
using CppSharp.Generators;
namespace CppSharp.Generators.CSharp namespace CppSharp.Generators.CSharp
{ {
@ -11,7 +13,7 @@ namespace CppSharp.Generators.CSharp
public CSharpGenerator(Driver driver) : base(driver) public CSharpGenerator(Driver driver) : base(driver)
{ {
typePrinter = new CSharpTypePrinter(driver.TypeDatabase, driver.Library); typePrinter = new CSharpTypePrinter(driver.TypeDatabase, driver.Library);
Type.TypePrinterDelegate += type => type.Visit(typePrinter).Type; AST.Type.TypePrinterDelegate += type => type.Visit(typePrinter).Type;
} }
public override List<TextTemplate> Generate(TranslationUnit unit) public override List<TextTemplate> Generate(TranslationUnit unit)

1
src/Generator/Generators/CSharp/CSharpMarshal.cs

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using CppSharp.AST;
using CppSharp.Types; using CppSharp.Types;
namespace CppSharp.Generators.CSharp namespace CppSharp.Generators.CSharp

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

@ -822,7 +822,7 @@ namespace CppSharp.Generators.CSharp
} }
} }
private void GenerateVariable(Class @class, Type type, Variable variable) private void GenerateVariable(Class @class, AST.Type type, Variable variable)
{ {
WriteLine("public static {0} {1}", type, variable.Name); WriteLine("public static {0} {1}", type, variable.Name);
WriteStartBraceIndent(); WriteStartBraceIndent();

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

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using CppSharp.AST;
using CppSharp.Types; using CppSharp.Types;
namespace CppSharp.Generators.CSharp namespace CppSharp.Generators.CSharp
@ -465,7 +466,7 @@ namespace CppSharp.Generators.CSharp
VisitParameters(function.Parameters, hasNames: true)); VisitParameters(function.Parameters, hasNames: true));
} }
public string ToString(Type type) public string ToString(AST.Type type)
{ {
return type.Visit(this).Type; return type.Visit(this).Type;
} }

1
src/Generator/Generators/Generator.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using CppSharp.AST;
namespace CppSharp.Generators namespace CppSharp.Generators
{ {

4
src/Generator/Generators/Marshal.cs

@ -1,4 +1,6 @@
namespace CppSharp.Generators using CppSharp.AST;
namespace CppSharp.Generators
{ {
public class MarshalContext public class MarshalContext
{ {

3
src/Generator/Generators/Template.cs

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using CppSharp.AST;
namespace CppSharp.Generators namespace CppSharp.Generators
{ {

1
src/Generator/Library.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using CppSharp.AST;
namespace CppSharp namespace CppSharp
{ {

1
src/Generator/Parser.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using CppSharp.AST;
namespace CppSharp namespace CppSharp
{ {

4
src/Generator/Passes/CheckAbiParameters.cs

@ -1,4 +1,6 @@
namespace CppSharp.Passes using CppSharp.AST;
namespace CppSharp.Passes
{ {
public class CheckAbiParameters : TranslationUnitPass public class CheckAbiParameters : TranslationUnitPass
{ {

1
src/Generator/Passes/CheckFlagEnumsPass.cs

@ -1,4 +1,5 @@
using System; using System;
using CppSharp.AST;
namespace CppSharp.Passes namespace CppSharp.Passes
{ {

7
src/Generator/Passes/CheckIgnoredDecls.cs

@ -1,4 +1,5 @@
using System; using System;
using CppSharp.AST;
namespace CppSharp.Passes namespace CppSharp.Passes
{ {
@ -203,7 +204,7 @@ namespace CppSharp.Passes
/// reasons: incomplete definitions, being explicitly ignored, or also /// reasons: incomplete definitions, being explicitly ignored, or also
/// by being a type we do not know how to handle. /// by being a type we do not know how to handle.
/// </remarks> /// </remarks>
bool HasInvalidType(Type type, out string msg) bool HasInvalidType(AST.Type type, out string msg)
{ {
if (type == null) if (type == null)
{ {
@ -251,7 +252,7 @@ namespace CppSharp.Passes
return false; return false;
} }
static bool IsTypeComplete(Type type) static bool IsTypeComplete(AST.Type type)
{ {
var checker = new TypeCompletionChecker(); var checker = new TypeCompletionChecker();
return type.Visit(checker); return type.Visit(checker);
@ -263,7 +264,7 @@ namespace CppSharp.Passes
return decl.Visit(checker); return decl.Visit(checker);
} }
bool IsTypeIgnored(Type type) bool IsTypeIgnored(AST.Type type)
{ {
var checker = new TypeIgnoreChecker(Driver.TypeDatabase); var checker = new TypeIgnoreChecker(Driver.TypeDatabase);
type.Visit(checker); type.Visit(checker);

1
src/Generator/Passes/CheckOperatorsOverloads.cs

@ -1,4 +1,5 @@
using System.Linq; using System.Linq;
using CppSharp.AST;
using CppSharp.Generators.CSharp; using CppSharp.Generators.CSharp;
namespace CppSharp.Passes namespace CppSharp.Passes

4
src/Generator/Passes/CheckTypeReferencesPass.cs

@ -1,4 +1,6 @@
namespace CppSharp.Passes using CppSharp.AST;
namespace CppSharp.Passes
{ {
public class CheckTypeReferencesPass : TranslationUnitPass public class CheckTypeReferencesPass : TranslationUnitPass
{ {

1
src/Generator/Passes/CleanInvalidDeclNamesPass.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Linq; using System.Linq;
using CppSharp.AST;
namespace CppSharp.Passes namespace CppSharp.Passes
{ {

2
src/Generator/Passes/CleanUnitPass.cs

@ -1,3 +1,5 @@
using CppSharp.AST;
namespace CppSharp.Passes namespace CppSharp.Passes
{ {
public class CleanUnitPass : TranslationUnitPass public class CleanUnitPass : TranslationUnitPass

1
src/Generator/Passes/DuplicatedNamesCheckerPass.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using CppSharp.AST;
namespace CppSharp.Passes namespace CppSharp.Passes
{ {

1
src/Generator/Passes/FunctionToInstanceMethodPass.cs

@ -1,4 +1,5 @@
using System; using System;
using CppSharp.AST;
namespace CppSharp.Passes namespace CppSharp.Passes
{ {

1
src/Generator/Passes/FunctionToStaticMethodPass.cs

@ -1,4 +1,5 @@
using System; using System;
using CppSharp.AST;
namespace CppSharp.Passes namespace CppSharp.Passes
{ {

2
src/Generator/Passes/Pass.cs

@ -1,4 +1,6 @@
 
using CppSharp.AST;
namespace CppSharp.Passes namespace CppSharp.Passes
{ {
/// <summary> /// <summary>

1
src/Generator/Passes/RenamePass.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using CppSharp.AST;
namespace CppSharp.Passes namespace CppSharp.Passes
{ {

1
src/Generator/Passes/ResolveIncompleteDeclsPass.cs

@ -1,4 +1,5 @@
using System; using System;
using CppSharp.AST;
namespace CppSharp.Passes namespace CppSharp.Passes
{ {

3
src/Generator/Passes/SortDeclarationsPass.cs

@ -1,4 +1,5 @@
using CppSharp.Types; using CppSharp.AST;
using CppSharp.Types;
namespace CppSharp.Passes namespace CppSharp.Passes
{ {

2
src/Generator/Types/CppTypePrinter.cs

@ -1,5 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using CppSharp.AST;
using Type = CppSharp.AST.Type;
namespace CppSharp.Types namespace CppSharp.Types
{ {

1
src/Generator/Types/ITypePrinter.cs

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using CppSharp.AST;
namespace CppSharp.Types namespace CppSharp.Types
{ {

1
src/Generator/Types/Std/Stdlib.cs

@ -1,4 +1,5 @@
using System; using System;
using CppSharp.AST;
using CppSharp.Generators; using CppSharp.Generators;
using CppSharp.Generators.CLI; using CppSharp.Generators.CLI;
using CppSharp.Generators.CSharp; using CppSharp.Generators.CSharp;

2
src/Generator/Types/TypeMap.cs

@ -1,8 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using CppSharp.AST;
using CppSharp.Generators; using CppSharp.Generators;
using CppSharp.Generators.CLI; using CppSharp.Generators.CLI;
using CppSharp.Generators.CSharp; using CppSharp.Generators.CSharp;
using Type = CppSharp.AST.Type;
namespace CppSharp.Types namespace CppSharp.Types
{ {

1
src/Generator/Types/Types.cs

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using CppSharp.AST;
using CppSharp.Types; using CppSharp.Types;
namespace CppSharp namespace CppSharp

1
src/Generator/Utils/TestsUtils.cs

@ -1,4 +1,5 @@
using System.IO; using System.IO;
using CppSharp.AST;
using CppSharp.Generators; using CppSharp.Generators;
namespace CppSharp.Utils namespace CppSharp.Utils

1
src/Generator/Utils/Utils.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using CppSharp.AST;
namespace CppSharp namespace CppSharp
{ {

238
src/Parser/Parser.cpp

@ -332,18 +332,18 @@ std::string Parser::GetTypeName(const clang::Type* Type)
return TypeName; return TypeName;
} }
CppSharp::TypeQualifiers GetTypeQualifiers(clang::QualType Type) CppSharp::AST::TypeQualifiers GetTypeQualifiers(clang::QualType Type)
{ {
CppSharp::TypeQualifiers quals; CppSharp::AST::TypeQualifiers quals;
quals.IsConst = Type.isLocalConstQualified(); quals.IsConst = Type.isLocalConstQualified();
quals.IsRestrict = Type.isLocalRestrictQualified(); quals.IsRestrict = Type.isLocalRestrictQualified();
quals.IsVolatile = Type.isVolatileQualified(); quals.IsVolatile = Type.isVolatileQualified();
return quals; return quals;
} }
CppSharp::QualifiedType GetQualifiedType(clang::QualType qual, CppSharp::Type^ type) CppSharp::AST::QualifiedType GetQualifiedType(clang::QualType qual, CppSharp::AST::Type^ type)
{ {
CppSharp::QualifiedType qualType; CppSharp::AST::QualifiedType qualType;
qualType.Type = type; qualType.Type = type;
qualType.Qualifiers = GetTypeQualifiers(qual); qualType.Qualifiers = GetTypeQualifiers(qual);
return qualType; return qualType;
@ -351,22 +351,22 @@ CppSharp::QualifiedType GetQualifiedType(clang::QualType qual, CppSharp::Type^ t
//-----------------------------------// //-----------------------------------//
static CppSharp::AccessSpecifier ConvertToAccess(clang::AccessSpecifier AS) static CppSharp::AST::AccessSpecifier ConvertToAccess(clang::AccessSpecifier AS)
{ {
switch(AS) switch(AS)
{ {
case clang::AS_private: case clang::AS_private:
return CppSharp::AccessSpecifier::Private; return CppSharp::AST::AccessSpecifier::Private;
case clang::AS_protected: case clang::AS_protected:
return CppSharp::AccessSpecifier::Protected; return CppSharp::AST::AccessSpecifier::Protected;
case clang::AS_public: case clang::AS_public:
return CppSharp::AccessSpecifier::Public; return CppSharp::AST::AccessSpecifier::Public;
} }
return CppSharp::AccessSpecifier::Public; return CppSharp::AST::AccessSpecifier::Public;
} }
CppSharp::Class^ Parser::WalkRecordCXX(clang::CXXRecordDecl* Record) CppSharp::AST::Class^ Parser::WalkRecordCXX(clang::CXXRecordDecl* Record)
{ {
using namespace clang; using namespace clang;
using namespace clix; using namespace clix;
@ -396,8 +396,8 @@ CppSharp::Class^ Parser::WalkRecordCXX(clang::CXXRecordDecl* Record)
auto headRange = clang::SourceRange(headStartLoc, headEndLoc); auto headRange = clang::SourceRange(headStartLoc, headEndLoc);
auto bodyRange = clang::SourceRange(headEndLoc, bodyEndLoc); auto bodyRange = clang::SourceRange(headEndLoc, bodyEndLoc);
HandlePreprocessedEntities(RC, headRange, CppSharp::MacroLocation::ClassHead); HandlePreprocessedEntities(RC, headRange, CppSharp::AST::MacroLocation::ClassHead);
HandlePreprocessedEntities(RC, bodyRange, CppSharp::MacroLocation::ClassBody); HandlePreprocessedEntities(RC, bodyRange, CppSharp::AST::MacroLocation::ClassBody);
RC->IsPOD = Record->isPOD(); RC->IsPOD = Record->isPOD();
RC->IsUnion = Record->isUnion(); RC->IsUnion = Record->isUnion();
@ -417,7 +417,7 @@ CppSharp::Class^ Parser::WalkRecordCXX(clang::CXXRecordDecl* Record)
RC->Layout->DataSize = (int)Layout->getDataSize().getQuantity(); RC->Layout->DataSize = (int)Layout->getDataSize().getQuantity();
} }
CppSharp::AccessSpecifierDecl^ AccessDecl = nullptr; CppSharp::AST::AccessSpecifierDecl^ AccessDecl = nullptr;
for(auto it = Record->decls_begin(); it != Record->decls_end(); ++it) for(auto it = Record->decls_begin(); it != Record->decls_end(); ++it)
{ {
@ -453,14 +453,14 @@ CppSharp::Class^ Parser::WalkRecordCXX(clang::CXXRecordDecl* Record)
{ {
AccessSpecDecl* AS = cast<AccessSpecDecl>(D); AccessSpecDecl* AS = cast<AccessSpecDecl>(D);
AccessDecl = gcnew CppSharp::AccessSpecifierDecl(); AccessDecl = gcnew CppSharp::AST::AccessSpecifierDecl();
AccessDecl->Access = ConvertToAccess(AS->getAccess()); AccessDecl->Access = ConvertToAccess(AS->getAccess());
AccessDecl->Namespace = RC; AccessDecl->Namespace = RC;
auto startLoc = GetDeclStartLocation(C.get(), AS); auto startLoc = GetDeclStartLocation(C.get(), AS);
auto range = SourceRange(startLoc, AS->getColonLoc()); auto range = SourceRange(startLoc, AS->getColonLoc());
HandlePreprocessedEntities(AccessDecl, range, HandlePreprocessedEntities(AccessDecl, range,
CppSharp::MacroLocation::Unknown); CppSharp::AST::MacroLocation::Unknown);
RC->Specifiers->Add(AccessDecl); RC->Specifiers->Add(AccessDecl);
break; break;
@ -478,7 +478,7 @@ CppSharp::Class^ Parser::WalkRecordCXX(clang::CXXRecordDecl* Record)
{ {
clang::CXXBaseSpecifier &BS = *it; clang::CXXBaseSpecifier &BS = *it;
CppSharp::BaseClassSpecifier^ Base = gcnew CppSharp::BaseClassSpecifier(); CppSharp::AST::BaseClassSpecifier^ Base = gcnew CppSharp::AST::BaseClassSpecifier();
Base->Access = ConvertToAccess(BS.getAccessSpecifier()); Base->Access = ConvertToAccess(BS.getAccessSpecifier());
Base->IsVirtual = BS.isVirtual(); Base->IsVirtual = BS.isVirtual();
Base->Type = WalkType(BS.getType(), &BS.getTypeSourceInfo()->getTypeLoc()); Base->Type = WalkType(BS.getType(), &BS.getTypeSourceInfo()->getTypeLoc());
@ -491,34 +491,34 @@ CppSharp::Class^ Parser::WalkRecordCXX(clang::CXXRecordDecl* Record)
//-----------------------------------// //-----------------------------------//
CppSharp::ClassTemplate^ Parser::WalkClassTemplate(clang::ClassTemplateDecl* TD) CppSharp::AST::ClassTemplate^ Parser::WalkClassTemplate(clang::ClassTemplateDecl* TD)
{ {
using namespace clang; using namespace clang;
using namespace clix; using namespace clix;
auto Class = WalkRecordCXX(TD->getTemplatedDecl()); auto Class = WalkRecordCXX(TD->getTemplatedDecl());
CppSharp::ClassTemplate^ CT = gcnew CppSharp::ClassTemplate(Class); CppSharp::AST::ClassTemplate^ CT = gcnew CppSharp::AST::ClassTemplate(Class);
return CT; return CT;
} }
//-----------------------------------// //-----------------------------------//
CppSharp::FunctionTemplate^ Parser::WalkFunctionTemplate(clang::FunctionTemplateDecl* TD) CppSharp::AST::FunctionTemplate^ Parser::WalkFunctionTemplate(clang::FunctionTemplateDecl* TD)
{ {
using namespace clang; using namespace clang;
using namespace clix; using namespace clix;
auto Function = WalkFunction(TD->getTemplatedDecl(), /*IsDependent=*/true, auto Function = WalkFunction(TD->getTemplatedDecl(), /*IsDependent=*/true,
/*AddToNamespace=*/false); /*AddToNamespace=*/false);
CppSharp::FunctionTemplate^ FT = gcnew CppSharp::FunctionTemplate(Function); CppSharp::AST::FunctionTemplate^ FT = gcnew CppSharp::AST::FunctionTemplate(Function);
auto TPL = TD->getTemplateParameters(); auto TPL = TD->getTemplateParameters();
for(auto it = TPL->begin(); it != TPL->end(); ++it) for(auto it = TPL->begin(); it != TPL->end(); ++it)
{ {
auto ND = *it; auto ND = *it;
auto TP = CppSharp::TemplateParameter(); auto TP = CppSharp::AST::TemplateParameter();
TP.Name = clix::marshalString<clix::E_UTF8>(ND->getNameAsString()); TP.Name = clix::marshalString<clix::E_UTF8>(ND->getNameAsString());
FT->Parameters->Add(TP); FT->Parameters->Add(TP);
@ -529,7 +529,7 @@ CppSharp::FunctionTemplate^ Parser::WalkFunctionTemplate(clang::FunctionTemplate
//-----------------------------------// //-----------------------------------//
static CppSharp::CXXMethodKind GetMethodKindFromDecl(clang::DeclarationName Name) static CppSharp::AST::CXXMethodKind GetMethodKindFromDecl(clang::DeclarationName Name)
{ {
using namespace clang; using namespace clang;
@ -539,46 +539,46 @@ static CppSharp::CXXMethodKind GetMethodKindFromDecl(clang::DeclarationName Name
case DeclarationName::ObjCZeroArgSelector: case DeclarationName::ObjCZeroArgSelector:
case DeclarationName::ObjCOneArgSelector: case DeclarationName::ObjCOneArgSelector:
case DeclarationName::ObjCMultiArgSelector: case DeclarationName::ObjCMultiArgSelector:
return CppSharp::CXXMethodKind::Normal; return CppSharp::AST::CXXMethodKind::Normal;
case DeclarationName::CXXConstructorName: case DeclarationName::CXXConstructorName:
return CppSharp::CXXMethodKind::Constructor; return CppSharp::AST::CXXMethodKind::Constructor;
case DeclarationName::CXXDestructorName: case DeclarationName::CXXDestructorName:
return CppSharp::CXXMethodKind::Destructor; return CppSharp::AST::CXXMethodKind::Destructor;
case DeclarationName::CXXConversionFunctionName: case DeclarationName::CXXConversionFunctionName:
return CppSharp::CXXMethodKind::Conversion; return CppSharp::AST::CXXMethodKind::Conversion;
case DeclarationName::CXXOperatorName: case DeclarationName::CXXOperatorName:
case DeclarationName::CXXLiteralOperatorName: case DeclarationName::CXXLiteralOperatorName:
return CppSharp::CXXMethodKind::Operator; return CppSharp::AST::CXXMethodKind::Operator;
case DeclarationName::CXXUsingDirective: case DeclarationName::CXXUsingDirective:
return CppSharp::CXXMethodKind::UsingDirective; return CppSharp::AST::CXXMethodKind::UsingDirective;
} }
return CppSharp::CXXMethodKind::Normal; return CppSharp::AST::CXXMethodKind::Normal;
} }
static CppSharp::CXXOperatorKind GetOperatorKindFromDecl(clang::DeclarationName Name) static CppSharp::AST::CXXOperatorKind GetOperatorKindFromDecl(clang::DeclarationName Name)
{ {
using namespace clang; using namespace clang;
if (Name.getNameKind() != DeclarationName::CXXOperatorName) if (Name.getNameKind() != DeclarationName::CXXOperatorName)
return CppSharp::CXXOperatorKind::None; return CppSharp::AST::CXXOperatorKind::None;
switch(Name.getCXXOverloadedOperator()) switch(Name.getCXXOverloadedOperator())
{ {
#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
case OO_##Name: return CppSharp::CXXOperatorKind::Name; case OO_##Name: return CppSharp::AST::CXXOperatorKind::Name;
#include "clang/Basic/OperatorKinds.def" #include "clang/Basic/OperatorKinds.def"
} }
return CppSharp::CXXOperatorKind::None; return CppSharp::AST::CXXOperatorKind::None;
} }
CppSharp::Method^ Parser::WalkMethodCXX(clang::CXXMethodDecl* MD) CppSharp::AST::Method^ Parser::WalkMethodCXX(clang::CXXMethodDecl* MD)
{ {
using namespace clang; using namespace clang;
DeclarationName Name = MD->getDeclName(); DeclarationName Name = MD->getDeclName();
CppSharp::Method^ Method = gcnew CppSharp::Method(); CppSharp::AST::Method^ Method = gcnew CppSharp::AST::Method();
Method->Access = ConvertToAccess(MD->getAccess()); Method->Access = ConvertToAccess(MD->getAccess());
Method->Kind = GetMethodKindFromDecl(Name); Method->Kind = GetMethodKindFromDecl(Name);
Method->OperatorKind = GetOperatorKindFromDecl(Name); Method->OperatorKind = GetOperatorKindFromDecl(Name);
@ -604,12 +604,12 @@ CppSharp::Method^ Parser::WalkMethodCXX(clang::CXXMethodDecl* MD)
//-----------------------------------// //-----------------------------------//
CppSharp::Field^ Parser::WalkFieldCXX(clang::FieldDecl* FD, CppSharp::Class^ Class) CppSharp::AST::Field^ Parser::WalkFieldCXX(clang::FieldDecl* FD, CppSharp::AST::Class^ Class)
{ {
using namespace clang; using namespace clang;
using namespace clix; using namespace clix;
CppSharp::Field^ F = gcnew CppSharp::Field(); CppSharp::AST::Field^ F = gcnew CppSharp::AST::Field();
F->Namespace = Class; F->Namespace = Class;
F->Name = marshalString<E_UTF8>(FD->getName()); F->Name = marshalString<E_UTF8>(FD->getName());
@ -625,7 +625,7 @@ CppSharp::Field^ Parser::WalkFieldCXX(clang::FieldDecl* FD, CppSharp::Class^ Cla
//-----------------------------------// //-----------------------------------//
CppSharp::TranslationUnit^ Parser::GetTranslationUnit(clang::SourceLocation Loc, CppSharp::AST::TranslationUnit^ Parser::GetTranslationUnit(clang::SourceLocation Loc,
SourceLocationKind *Kind) SourceLocationKind *Kind)
{ {
using namespace clang; using namespace clang;
@ -667,17 +667,17 @@ CppSharp::TranslationUnit^ Parser::GetTranslationUnit(clang::SourceLocation Loc,
//-----------------------------------// //-----------------------------------//
CppSharp::TranslationUnit^ Parser::GetTranslationUnit(const clang::Decl* D) CppSharp::AST::TranslationUnit^ Parser::GetTranslationUnit(const clang::Decl* D)
{ {
clang::SourceLocation Loc = D->getLocation(); clang::SourceLocation Loc = D->getLocation();
SourceLocationKind Kind; SourceLocationKind Kind;
CppSharp::TranslationUnit^ Unit = GetTranslationUnit(Loc, &Kind); CppSharp::AST::TranslationUnit^ Unit = GetTranslationUnit(Loc, &Kind);
return Unit; return Unit;
} }
CppSharp::DeclarationContext^ Parser::GetNamespace(clang::Decl* D, CppSharp::AST::DeclarationContext^ Parser::GetNamespace(clang::Decl* D,
clang::DeclContext *Ctx) clang::DeclContext *Ctx)
{ {
using namespace clang; using namespace clang;
@ -686,7 +686,7 @@ CppSharp::DeclarationContext^ Parser::GetNamespace(clang::Decl* D,
if (Ctx->isTranslationUnit()) if (Ctx->isTranslationUnit())
return GetTranslationUnit(D); return GetTranslationUnit(D);
CppSharp::TranslationUnit^ Unit = GetTranslationUnit(cast<Decl>(Ctx)); CppSharp::AST::TranslationUnit^ Unit = GetTranslationUnit(cast<Decl>(Ctx));
// Else we need to do a more expensive check to get all the namespaces, // Else we need to do a more expensive check to get all the namespaces,
// and then perform a reverse iteration to get the namespaces in order. // and then perform a reverse iteration to get the namespaces in order.
@ -699,7 +699,7 @@ CppSharp::DeclarationContext^ Parser::GetNamespace(clang::Decl* D,
assert(Contexts.back()->isTranslationUnit()); assert(Contexts.back()->isTranslationUnit());
Contexts.pop_back(); Contexts.pop_back();
CppSharp::DeclarationContext^ DC = Unit; CppSharp::AST::DeclarationContext^ DC = Unit;
for (auto I = Contexts.rbegin(), E = Contexts.rend(); I != E; ++I) for (auto I = Contexts.rbegin(), E = Contexts.rend(); I != E; ++I)
{ {
@ -744,14 +744,14 @@ CppSharp::DeclarationContext^ Parser::GetNamespace(clang::Decl* D,
return DC; return DC;
} }
CppSharp::DeclarationContext^ Parser::GetNamespace(clang::Decl *D) CppSharp::AST::DeclarationContext^ Parser::GetNamespace(clang::Decl *D)
{ {
return GetNamespace(D, D->getDeclContext()); return GetNamespace(D, D->getDeclContext());
} }
static CppSharp::PrimitiveType WalkBuiltinType(const clang::BuiltinType* Builtin) static CppSharp::AST::PrimitiveType WalkBuiltinType(const clang::BuiltinType* Builtin)
{ {
using namespace CppSharp; using namespace CppSharp::AST;
assert(Builtin && "Expected a builtin type"); assert(Builtin && "Expected a builtin type");
@ -825,7 +825,7 @@ clang::TypeLoc ResolveTypeLoc(clang::TypeLoc TL, clang::TypeLoc::TypeLocClass Cl
return TL; return TL;
} }
CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, CppSharp::AST::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
bool DesugarType) bool DesugarType)
{ {
using namespace clang; using namespace clang;
@ -851,7 +851,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
auto Builtin = Type->getAs<clang::BuiltinType>(); auto Builtin = Type->getAs<clang::BuiltinType>();
assert(Builtin && "Expected a builtin type"); assert(Builtin && "Expected a builtin type");
auto BT = gcnew CppSharp::BuiltinType(); auto BT = gcnew CppSharp::AST::BuiltinType();
BT->Type = WalkBuiltinType(Builtin); BT->Type = WalkBuiltinType(Builtin);
return BT; return BT;
@ -863,7 +863,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
//auto Name = marshalString<E_UTF8>(GetTagDeclName(ED)); //auto Name = marshalString<E_UTF8>(GetTagDeclName(ED));
auto TT = gcnew CppSharp::TagType(); auto TT = gcnew CppSharp::AST::TagType();
TT->Declaration = WalkDeclaration(ED, 0, /*IgnoreSystemDecls=*/false); TT->Declaration = WalkDeclaration(ED, 0, /*IgnoreSystemDecls=*/false);
return TT; return TT;
@ -872,8 +872,8 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
{ {
auto Pointer = Type->getAs<clang::PointerType>(); auto Pointer = Type->getAs<clang::PointerType>();
auto P = gcnew CppSharp::PointerType(); auto P = gcnew CppSharp::AST::PointerType();
P->Modifier = CppSharp::PointerType::TypeModifier::Pointer; P->Modifier = CppSharp::AST::PointerType::TypeModifier::Pointer;
auto Next = TL->getNextTypeLoc(); auto Next = TL->getNextTypeLoc();
@ -888,10 +888,10 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
TypedefNameDecl* TD = TT->getDecl(); TypedefNameDecl* TD = TT->getDecl();
auto TTL = TD->getTypeSourceInfo()->getTypeLoc(); auto TTL = TD->getTypeSourceInfo()->getTypeLoc();
auto TDD = safe_cast<CppSharp::TypedefDecl^>(WalkDeclaration(TD, auto TDD = safe_cast<CppSharp::AST::TypedefDecl^>(WalkDeclaration(TD,
/*IgnoreSystemDecls=*/false)); /*IgnoreSystemDecls=*/false));
auto Type = gcnew CppSharp::TypedefType(); auto Type = gcnew CppSharp::AST::TypedefType();
Type->Declaration = TDD; Type->Declaration = TDD;
return Type; return Type;
@ -901,7 +901,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
auto DT = Type->getAs<clang::DecayedType>(); auto DT = Type->getAs<clang::DecayedType>();
auto Next = TL->getNextTypeLoc(); auto Next = TL->getNextTypeLoc();
auto Type = gcnew CppSharp::DecayedType(); auto Type = gcnew CppSharp::AST::DecayedType();
Type->Decayed = GetQualifiedType(DT->getDecayedType(), WalkType(DT->getDecayedType(), &Next)); Type->Decayed = GetQualifiedType(DT->getDecayedType(), WalkType(DT->getDecayedType(), &Next));
Type->Original = GetQualifiedType(DT->getOriginalType(), WalkType(DT->getOriginalType(), &Next)); Type->Original = GetQualifiedType(DT->getOriginalType(), WalkType(DT->getOriginalType(), &Next));
Type->Pointee = GetQualifiedType(DT->getPointeeType(), WalkType(DT->getPointeeType(), &Next)); Type->Pointee = GetQualifiedType(DT->getPointeeType(), WalkType(DT->getPointeeType(), &Next));
@ -919,7 +919,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
auto RT = Type->getAs<clang::RecordType>(); auto RT = Type->getAs<clang::RecordType>();
RecordDecl* RD = RT->getDecl(); RecordDecl* RD = RT->getDecl();
auto TT = gcnew CppSharp::TagType(); auto TT = gcnew CppSharp::AST::TagType();
TT->Declaration = WalkDeclaration(RD, /*IgnoreSystemDecls=*/false); TT->Declaration = WalkDeclaration(RD, /*IgnoreSystemDecls=*/false);
return TT; return TT;
@ -934,10 +934,10 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
{ {
auto AT = AST->getAsConstantArrayType(QualType); auto AT = AST->getAsConstantArrayType(QualType);
auto A = gcnew CppSharp::ArrayType(); auto A = gcnew CppSharp::AST::ArrayType();
auto Next = TL->getNextTypeLoc(); auto Next = TL->getNextTypeLoc();
A->Type = WalkType(AT->getElementType(), &Next); A->Type = WalkType(AT->getElementType(), &Next);
A->SizeType = CppSharp::ArrayType::ArraySize::Constant; A->SizeType = CppSharp::AST::ArrayType::ArraySize::Constant;
A->Size = AST->getConstantArrayElementCount(AT); A->Size = AST->getConstantArrayElementCount(AT);
return A; return A;
@ -946,10 +946,10 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
{ {
auto AT = AST->getAsIncompleteArrayType(QualType); auto AT = AST->getAsIncompleteArrayType(QualType);
auto A = gcnew CppSharp::ArrayType(); auto A = gcnew CppSharp::AST::ArrayType();
auto Next = TL->getNextTypeLoc(); auto Next = TL->getNextTypeLoc();
A->Type = WalkType(AT->getElementType(), &Next); A->Type = WalkType(AT->getElementType(), &Next);
A->SizeType = CppSharp::ArrayType::ArraySize::Incomplete; A->SizeType = CppSharp::AST::ArrayType::ArraySize::Incomplete;
return A; return A;
} }
@ -957,10 +957,10 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
{ {
auto AT = AST->getAsDependentSizedArrayType(QualType); auto AT = AST->getAsDependentSizedArrayType(QualType);
auto A = gcnew CppSharp::ArrayType(); auto A = gcnew CppSharp::AST::ArrayType();
auto Next = TL->getNextTypeLoc(); auto Next = TL->getNextTypeLoc();
A->Type = WalkType(AT->getElementType(), &Next); A->Type = WalkType(AT->getElementType(), &Next);
A->SizeType = CppSharp::ArrayType::ArraySize::Dependent; A->SizeType = CppSharp::AST::ArrayType::ArraySize::Dependent;
//A->Size = AT->getSizeExpr(); //A->Size = AT->getSizeExpr();
return A; return A;
@ -972,13 +972,13 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
auto FTL = TL->getAs<FunctionProtoTypeLoc>(); auto FTL = TL->getAs<FunctionProtoTypeLoc>();
auto RL = FTL.getResultLoc(); auto RL = FTL.getResultLoc();
auto F = gcnew CppSharp::FunctionType(); auto F = gcnew CppSharp::AST::FunctionType();
F->ReturnType = GetQualifiedType(FP->getResultType(), F->ReturnType = GetQualifiedType(FP->getResultType(),
WalkType(FP->getResultType(), &RL)); WalkType(FP->getResultType(), &RL));
for (unsigned i = 0; i < FP->getNumArgs(); ++i) for (unsigned i = 0; i < FP->getNumArgs(); ++i)
{ {
auto FA = gcnew CppSharp::Parameter(); auto FA = gcnew CppSharp::AST::Parameter();
auto PVD = FTL.getArg(i); auto PVD = FTL.getArg(i);
auto PTL = PVD->getTypeSourceInfo()->getTypeLoc(); auto PTL = PVD->getTypeSourceInfo()->getTypeLoc();
@ -1006,7 +1006,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
auto MP = Type->getAs<clang::MemberPointerType>(); auto MP = Type->getAs<clang::MemberPointerType>();
auto Next = TL->getNextTypeLoc(); auto Next = TL->getNextTypeLoc();
auto MPT = gcnew CppSharp::MemberPointerType(); auto MPT = gcnew CppSharp::AST::MemberPointerType();
MPT->Pointee = WalkType(MP->getPointeeType(), &Next); MPT->Pointee = WalkType(MP->getPointeeType(), &Next);
return MPT; return MPT;
@ -1014,10 +1014,10 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
case Type::TemplateSpecialization: case Type::TemplateSpecialization:
{ {
auto TS = Type->getAs<clang::TemplateSpecializationType>(); auto TS = Type->getAs<clang::TemplateSpecializationType>();
auto TST = gcnew CppSharp::TemplateSpecializationType(); auto TST = gcnew CppSharp::AST::TemplateSpecializationType();
TemplateName Name = TS->getTemplateName(); TemplateName Name = TS->getTemplateName();
TST->Template = safe_cast<CppSharp::Template^>(WalkDeclaration( TST->Template = safe_cast<CppSharp::AST::Template^>(WalkDeclaration(
Name.getAsTemplateDecl(), 0, /*IgnoreSystemDecls=*/false)); Name.getAsTemplateDecl(), 0, /*IgnoreSystemDecls=*/false));
if (TS->isSugared()) if (TS->isSugared())
TST->Desugared = WalkType(TS->desugar()); TST->Desugared = WalkType(TS->desugar());
@ -1042,7 +1042,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
for (unsigned I = 0, E = TS->getNumArgs(); I != E; ++I) for (unsigned I = 0, E = TS->getNumArgs(); I != E; ++I)
{ {
const TemplateArgument& TA = TS->getArg(I); const TemplateArgument& TA = TS->getArg(I);
auto Arg = CppSharp::TemplateArgument(); auto Arg = CppSharp::AST::TemplateArgument();
TemplateArgumentLoc ArgLoc; TemplateArgumentLoc ArgLoc;
ArgLoc = TSTL.getArgLoc(I); ArgLoc = TSTL.getArgLoc(I);
@ -1051,35 +1051,35 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
{ {
case TemplateArgument::Type: case TemplateArgument::Type:
{ {
Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::Type; Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::Type;
TypeLoc ArgTL; TypeLoc ArgTL;
ArgTL = ArgLoc.getTypeSourceInfo()->getTypeLoc(); ArgTL = ArgLoc.getTypeSourceInfo()->getTypeLoc();
Arg.Type = GetQualifiedType(TA.getAsType(), WalkType(TA.getAsType(), &ArgTL)); Arg.Type = GetQualifiedType(TA.getAsType(), WalkType(TA.getAsType(), &ArgTL));
break; break;
} }
case TemplateArgument::Declaration: case TemplateArgument::Declaration:
Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::Declaration; Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::Declaration;
Arg.Declaration = WalkDeclaration(TA.getAsDecl(), 0); Arg.Declaration = WalkDeclaration(TA.getAsDecl(), 0);
break; break;
case TemplateArgument::NullPtr: case TemplateArgument::NullPtr:
Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::NullPtr; Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::NullPtr;
break; break;
case TemplateArgument::Integral: case TemplateArgument::Integral:
Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::Integral; Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::Integral;
//Arg.Type = WalkType(TA.getIntegralType(), 0); //Arg.Type = WalkType(TA.getIntegralType(), 0);
Arg.Integral = TA.getAsIntegral().getLimitedValue(); Arg.Integral = TA.getAsIntegral().getLimitedValue();
break; break;
case TemplateArgument::Template: case TemplateArgument::Template:
Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::Template; Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::Template;
break; break;
case TemplateArgument::TemplateExpansion: case TemplateArgument::TemplateExpansion:
Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::TemplateExpansion; Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::TemplateExpansion;
break; break;
case TemplateArgument::Expression: case TemplateArgument::Expression:
Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::Expression; Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::Expression;
break; break;
case TemplateArgument::Pack: case TemplateArgument::Pack:
Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::Pack; Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::Pack;
break; break;
} }
@ -1092,7 +1092,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
{ {
auto TP = Type->getAs<TemplateTypeParmType>(); auto TP = Type->getAs<TemplateTypeParmType>();
auto TPT = gcnew CppSharp::TemplateParameterType(); auto TPT = gcnew CppSharp::AST::TemplateParameterType();
if (auto Ident = TP->getIdentifier()) if (auto Ident = TP->getIdentifier())
TPT->Parameter.Name = marshalString<E_UTF8>(Ident->getName()); TPT->Parameter.Name = marshalString<E_UTF8>(Ident->getName());
@ -1103,7 +1103,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
{ {
auto TP = Type->getAs<SubstTemplateTypeParmType>(); auto TP = Type->getAs<SubstTemplateTypeParmType>();
auto Ty = TP->getReplacementType(); auto Ty = TP->getReplacementType();
auto TPT = gcnew CppSharp::TemplateParameterSubstitutionType(); auto TPT = gcnew CppSharp::AST::TemplateParameterSubstitutionType();
auto Next = TL->getNextTypeLoc(); auto Next = TL->getNextTypeLoc();
TPT->Replacement = GetQualifiedType(Ty, WalkType(Ty, &Next)); TPT->Replacement = GetQualifiedType(Ty, WalkType(Ty, &Next));
@ -1113,23 +1113,23 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
case Type::InjectedClassName: case Type::InjectedClassName:
{ {
auto ICN = Type->getAs<InjectedClassNameType>(); auto ICN = Type->getAs<InjectedClassNameType>();
auto ICNT = gcnew CppSharp::InjectedClassNameType(); auto ICNT = gcnew CppSharp::AST::InjectedClassNameType();
ICNT->Class = safe_cast<CppSharp::Class^>(WalkDeclaration( ICNT->Class = safe_cast<CppSharp::AST::Class^>(WalkDeclaration(
ICN->getDecl(), 0, /*IgnoreSystemDecls=*/false)); ICN->getDecl(), 0, /*IgnoreSystemDecls=*/false));
return ICNT; return ICNT;
} }
case Type::DependentName: case Type::DependentName:
{ {
auto DN = Type->getAs<DependentNameType>(); auto DN = Type->getAs<DependentNameType>();
auto DNT = gcnew CppSharp::DependentNameType(); auto DNT = gcnew CppSharp::AST::DependentNameType();
return DNT; return DNT;
} }
case Type::LValueReference: case Type::LValueReference:
{ {
auto LR = Type->getAs<clang::LValueReferenceType>(); auto LR = Type->getAs<clang::LValueReferenceType>();
auto P = gcnew CppSharp::PointerType(); auto P = gcnew CppSharp::AST::PointerType();
P->Modifier = CppSharp::PointerType::TypeModifier::LVReference; P->Modifier = CppSharp::AST::PointerType::TypeModifier::LVReference;
TypeLoc Next; TypeLoc Next;
if (!TL->isNull()) if (!TL->isNull())
@ -1144,8 +1144,8 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
{ {
auto LR = Type->getAs<clang::RValueReferenceType>(); auto LR = Type->getAs<clang::RValueReferenceType>();
auto P = gcnew CppSharp::PointerType(); auto P = gcnew CppSharp::AST::PointerType();
P->Modifier = CppSharp::PointerType::TypeModifier::RVReference; P->Modifier = CppSharp::AST::PointerType::TypeModifier::RVReference;
TypeLoc Next; TypeLoc Next;
if (!TL->isNull()) if (!TL->isNull())
@ -1175,7 +1175,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
//-----------------------------------// //-----------------------------------//
CppSharp::Enumeration^ Parser::WalkEnum(clang::EnumDecl* ED) CppSharp::AST::Enumeration^ Parser::WalkEnum(clang::EnumDecl* ED)
{ {
using namespace clang; using namespace clang;
using namespace clix; using namespace clix;
@ -1193,12 +1193,12 @@ CppSharp::Enumeration^ Parser::WalkEnum(clang::EnumDecl* ED)
E = NS->FindEnum(Name, /*Create=*/true); E = NS->FindEnum(Name, /*Create=*/true);
if (ED->isScoped()) if (ED->isScoped())
E->Modifiers |= CppSharp::Enumeration::EnumModifiers::Scoped; E->Modifiers |= CppSharp::AST::Enumeration::EnumModifiers::Scoped;
// Get the underlying integer backing the enum. // Get the underlying integer backing the enum.
QualType IntType = ED->getIntegerType(); QualType IntType = ED->getIntegerType();
E->Type = WalkType(IntType, 0); E->Type = WalkType(IntType, 0);
E->BuiltinType = safe_cast<CppSharp::BuiltinType^>(WalkType(IntType, 0, E->BuiltinType = safe_cast<CppSharp::AST::BuiltinType^>(WalkType(IntType, 0,
/*DesugarType=*/true)); /*DesugarType=*/true));
if (!ED->isThisDeclarationADefinition()) if (!ED->isThisDeclarationADefinition())
@ -1216,7 +1216,7 @@ CppSharp::Enumeration^ Parser::WalkEnum(clang::EnumDecl* ED)
if (const RawComment* Comment = AST->getRawCommentForAnyRedecl(ECD)) if (const RawComment* Comment = AST->getRawCommentForAnyRedecl(ECD))
BriefText = Comment->getBriefText(*AST); BriefText = Comment->getBriefText(*AST);
auto EnumItem = gcnew CppSharp::Enumeration::Item(); auto EnumItem = gcnew CppSharp::AST::Enumeration::Item();
EnumItem->Name = marshalString<E_UTF8>(ECD->getNameAsString()); EnumItem->Name = marshalString<E_UTF8>(ECD->getNameAsString());
EnumItem->Value = (int) ECD->getInitVal().getLimitedValue(); EnumItem->Value = (int) ECD->getInitVal().getLimitedValue();
EnumItem->Comment = marshalString<E_UTF8>(BriefText); EnumItem->Comment = marshalString<E_UTF8>(BriefText);
@ -1249,7 +1249,7 @@ clang::CallingConv Parser::GetAbiCallConv(clang::CallingConv CC,
return CC; return CC;
} }
static CppSharp::CallingConvention ConvertCallConv(clang::CallingConv CC) static CppSharp::AST::CallingConvention ConvertCallConv(clang::CallingConv CC)
{ {
using namespace clang; using namespace clang;
@ -1257,23 +1257,23 @@ static CppSharp::CallingConvention ConvertCallConv(clang::CallingConv CC)
{ {
case CC_Default: case CC_Default:
case CC_C: case CC_C:
return CppSharp::CallingConvention::C; return CppSharp::AST::CallingConvention::C;
case CC_X86StdCall: case CC_X86StdCall:
return CppSharp::CallingConvention::StdCall; return CppSharp::AST::CallingConvention::StdCall;
case CC_X86FastCall: case CC_X86FastCall:
return CppSharp::CallingConvention::FastCall; return CppSharp::AST::CallingConvention::FastCall;
case CC_X86ThisCall: case CC_X86ThisCall:
return CppSharp::CallingConvention::ThisCall; return CppSharp::AST::CallingConvention::ThisCall;
case CC_X86Pascal: case CC_X86Pascal:
case CC_AAPCS: case CC_AAPCS:
case CC_AAPCS_VFP: case CC_AAPCS_VFP:
return CppSharp::CallingConvention::Unknown; return CppSharp::AST::CallingConvention::Unknown;
} }
return CppSharp::CallingConvention::Default; return CppSharp::AST::CallingConvention::Default;
} }
void Parser::WalkFunction(clang::FunctionDecl* FD, CppSharp::Function^ F, void Parser::WalkFunction(clang::FunctionDecl* FD, CppSharp::AST::Function^ F,
bool IsDependent) bool IsDependent)
{ {
using namespace clang; using namespace clang;
@ -1308,10 +1308,10 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, CppSharp::Function^ F,
auto headEndLoc = SM.getExpansionLoc(FTL.getLParenLoc()); auto headEndLoc = SM.getExpansionLoc(FTL.getLParenLoc());
auto headRange = clang::SourceRange(headStartLoc, headEndLoc); auto headRange = clang::SourceRange(headStartLoc, headEndLoc);
HandlePreprocessedEntities(F, headRange, CppSharp::MacroLocation::FunctionHead); HandlePreprocessedEntities(F, headRange, CppSharp::AST::MacroLocation::FunctionHead);
HandlePreprocessedEntities(F, FTL.getParensRange(), CppSharp::MacroLocation::FunctionParameters); HandlePreprocessedEntities(F, FTL.getParensRange(), CppSharp::AST::MacroLocation::FunctionParameters);
//auto bodyRange = clang::SourceRange(FTL.getRParenLoc(), FD->getLocEnd()); //auto bodyRange = clang::SourceRange(FTL.getRParenLoc(), FD->getLocEnd());
//HandlePreprocessedEntities(F, bodyRange, CppSharp::MacroLocation::FunctionBody); //HandlePreprocessedEntities(F, bodyRange, CppSharp::AST::MacroLocation::FunctionBody);
} }
F->ReturnType = GetQualifiedType(FD->getResultType(), F->ReturnType = GetQualifiedType(FD->getResultType(),
@ -1324,7 +1324,7 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, CppSharp::Function^ F,
{ {
ParmVarDecl* VD = (*it); ParmVarDecl* VD = (*it);
auto P = gcnew CppSharp::Parameter(); auto P = gcnew CppSharp::AST::Parameter();
P->Name = marshalString<E_UTF8>(VD->getNameAsString()); P->Name = marshalString<E_UTF8>(VD->getNameAsString());
TypeLoc PTL; TypeLoc PTL;
@ -1338,7 +1338,7 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, CppSharp::Function^ F,
} }
} }
CppSharp::Function^ Parser::WalkFunction(clang::FunctionDecl* FD, bool IsDependent, CppSharp::AST::Function^ Parser::WalkFunction(clang::FunctionDecl* FD, bool IsDependent,
bool AddToNamespace) bool AddToNamespace)
{ {
using namespace clang; using namespace clang;
@ -1350,12 +1350,12 @@ CppSharp::Function^ Parser::WalkFunction(clang::FunctionDecl* FD, bool IsDepende
assert(NS && "Expected a valid namespace"); assert(NS && "Expected a valid namespace");
auto Name = marshalString<E_UTF8>(FD->getNameAsString()); auto Name = marshalString<E_UTF8>(FD->getNameAsString());
CppSharp::Function^ F = NS->FindFunction(Name, /*Create=*/ false); CppSharp::AST::Function^ F = NS->FindFunction(Name, /*Create=*/ false);
if (F != nullptr) if (F != nullptr)
return F; return F;
F = gcnew CppSharp::Function(); F = gcnew CppSharp::AST::Function();
WalkFunction(FD, F, IsDependent); WalkFunction(FD, F, IsDependent);
if (AddToNamespace) if (AddToNamespace)
@ -1475,7 +1475,7 @@ void Parser::WalkMacros(clang::PreprocessingRecord* PR)
if (Invalid || Expression.empty()) if (Invalid || Expression.empty())
break; break;
auto macro = gcnew CppSharp::MacroDefinition(); auto macro = gcnew CppSharp::AST::MacroDefinition();
macro->Name = marshalString<E_UTF8>(II->getName())->Trim(); macro->Name = marshalString<E_UTF8>(II->getName())->Trim();
macro->Expression = marshalString<E_UTF8>(Expression)->Trim(); macro->Expression = marshalString<E_UTF8>(Expression)->Trim();
@ -1492,12 +1492,12 @@ void Parser::WalkMacros(clang::PreprocessingRecord* PR)
//-----------------------------------// //-----------------------------------//
CppSharp::Variable^ Parser::WalkVariable(clang::VarDecl *VD) CppSharp::AST::Variable^ Parser::WalkVariable(clang::VarDecl *VD)
{ {
using namespace clang; using namespace clang;
using namespace clix; using namespace clix;
auto Var = gcnew CppSharp::Variable(); auto Var = gcnew CppSharp::AST::Variable();
Var->Name = marshalString<E_UTF8>(VD->getName()); Var->Name = marshalString<E_UTF8>(VD->getName());
Var->Access = ConvertToAccess(VD->getAccess()); Var->Access = ConvertToAccess(VD->getAccess());
@ -1512,7 +1512,7 @@ CppSharp::Variable^ Parser::WalkVariable(clang::VarDecl *VD)
//-----------------------------------// //-----------------------------------//
void Parser::HandleComments(clang::Decl* D, CppSharp::Declaration^ Decl) void Parser::HandleComments(clang::Decl* D, CppSharp::AST::Declaration^ Decl)
{ {
using namespace clang; using namespace clang;
using namespace clix; using namespace clix;
@ -1553,9 +1553,9 @@ bool Parser::GetPreprocessedEntityText(clang::PreprocessedEntity* PE, std::strin
return !Invalid && !Text.empty(); return !Invalid && !Text.empty();
} }
void Parser::HandlePreprocessedEntities(CppSharp::Declaration^ Decl, void Parser::HandlePreprocessedEntities(CppSharp::AST::Declaration^ Decl,
clang::SourceRange sourceRange, clang::SourceRange sourceRange,
CppSharp::MacroLocation macroLocation) CppSharp::AST::MacroLocation macroLocation)
{ {
using namespace clang; using namespace clang;
auto PPRecord = C->getPreprocessor().getPreprocessingRecord(); auto PPRecord = C->getPreprocessor().getPreprocessingRecord();
@ -1566,26 +1566,26 @@ void Parser::HandlePreprocessedEntities(CppSharp::Declaration^ Decl,
{ {
PreprocessedEntity* PPEntity = (*it); PreprocessedEntity* PPEntity = (*it);
CppSharp::PreprocessedEntity^ Entity; CppSharp::AST::PreprocessedEntity^ Entity;
switch(PPEntity->getKind()) switch(PPEntity->getKind())
{ {
case PreprocessedEntity::MacroExpansionKind: case PreprocessedEntity::MacroExpansionKind:
{ {
const MacroExpansion* MD = cast<MacroExpansion>(PPEntity); const MacroExpansion* MD = cast<MacroExpansion>(PPEntity);
Entity = gcnew CppSharp::MacroExpansion(); Entity = gcnew CppSharp::AST::MacroExpansion();
std::string Text; std::string Text;
if (!GetPreprocessedEntityText(PPEntity, Text)) if (!GetPreprocessedEntityText(PPEntity, Text))
continue; continue;
static_cast<CppSharp::MacroExpansion^>(Entity)->Text = static_cast<CppSharp::AST::MacroExpansion^>(Entity)->Text =
clix::marshalString<clix::E_UTF8>(Text); clix::marshalString<clix::E_UTF8>(Text);
break; break;
} }
case PreprocessedEntity::MacroDefinitionKind: case PreprocessedEntity::MacroDefinitionKind:
{ {
const MacroDefinition* MD = cast<MacroDefinition>(PPEntity); const MacroDefinition* MD = cast<MacroDefinition>(PPEntity);
Entity = gcnew CppSharp::MacroDefinition(); Entity = gcnew CppSharp::AST::MacroDefinition();
break; break;
} }
default: default:
@ -1600,13 +1600,13 @@ void Parser::HandlePreprocessedEntities(CppSharp::Declaration^ Decl,
//-----------------------------------// //-----------------------------------//
CppSharp::Declaration^ Parser::WalkDeclarationDef(clang::Decl* D) CppSharp::AST::Declaration^ Parser::WalkDeclarationDef(clang::Decl* D)
{ {
return WalkDeclaration(D, /*IgnoreSystemDecls=*/true, return WalkDeclaration(D, /*IgnoreSystemDecls=*/true,
/*CanBeDefinition=*/true); /*CanBeDefinition=*/true);
} }
CppSharp::Declaration^ Parser::WalkDeclaration(clang::Decl* D, CppSharp::AST::Declaration^ Parser::WalkDeclaration(clang::Decl* D,
bool IgnoreSystemDecls, bool IgnoreSystemDecls,
bool CanBeDefinition) bool CanBeDefinition)
{ {
@ -1631,7 +1631,7 @@ CppSharp::Declaration^ Parser::WalkDeclaration(clang::Decl* D,
StringRef AnnotationText = Annotation->getAnnotation(); StringRef AnnotationText = Annotation->getAnnotation();
} }
CppSharp::Declaration^ Decl = nullptr; CppSharp::AST::Declaration^ Decl = nullptr;
auto Kind = D->getKind(); auto Kind = D->getKind();
switch(D->getKind()) switch(D->getKind())
@ -1671,7 +1671,7 @@ CppSharp::Declaration^ Parser::WalkDeclaration(clang::Decl* D,
case Decl::ClassTemplateSpecialization: case Decl::ClassTemplateSpecialization:
{ {
auto TS = cast<ClassTemplateSpecializationDecl>(D); auto TS = cast<ClassTemplateSpecializationDecl>(D);
auto CT = gcnew CppSharp::ClassTemplateSpecialization(); auto CT = gcnew CppSharp::AST::ClassTemplateSpecialization();
Decl = CT; Decl = CT;
break; break;
@ -1679,7 +1679,7 @@ CppSharp::Declaration^ Parser::WalkDeclaration(clang::Decl* D,
case Decl::ClassTemplatePartialSpecialization: case Decl::ClassTemplatePartialSpecialization:
{ {
auto TS = cast<ClassTemplatePartialSpecializationDecl>(D); auto TS = cast<ClassTemplatePartialSpecializationDecl>(D);
auto CT = gcnew CppSharp::ClassTemplatePartialSpecialization(); auto CT = gcnew CppSharp::AST::ClassTemplatePartialSpecialization();
Decl = CT; Decl = CT;
break; break;
@ -1764,7 +1764,7 @@ CppSharp::Declaration^ Parser::WalkDeclaration(clang::Decl* D,
auto NS = GetNamespace(VD); auto NS = GetNamespace(VD);
Decl->Namespace = NS; Decl->Namespace = NS;
NS->Variables->Add(static_cast<CppSharp::Variable^>(Decl)); NS->Variables->Add(static_cast<CppSharp::AST::Variable^>(Decl));
break; break;
} }
// Ignore these declarations since they must have been declared in // Ignore these declarations since they must have been declared in

44
src/Parser/Parser.h

@ -55,7 +55,7 @@ public ref struct ParserOptions
// C/C++ header file name. // C/C++ header file name.
System::String^ FileName; System::String^ FileName;
CppSharp::Library^ Library; CppSharp::AST::Library^ Library;
// Toolset version - 2005 - 8, 2008 - 9, 2010 - 10, 0 - autoprobe for any. // Toolset version - 2005 - 8, 2008 - 9, 2010 - 10, 0 - autoprobe for any.
int ToolSetToUse; int ToolSetToUse;
@ -101,7 +101,7 @@ public ref struct ParserResult
} }
ParserResultKind Kind; ParserResultKind Kind;
CppSharp::Library^ Library; CppSharp::AST::Library^ Library;
List<ParserDiagnostic>^ Diagnostics; List<ParserDiagnostic>^ Diagnostics;
}; };
@ -131,20 +131,20 @@ protected:
// AST traversers // AST traversers
void WalkAST(); void WalkAST();
void WalkMacros(clang::PreprocessingRecord* PR); void WalkMacros(clang::PreprocessingRecord* PR);
CppSharp::Declaration^ WalkDeclaration(clang::Decl* D, CppSharp::AST::Declaration^ WalkDeclaration(clang::Decl* D,
bool IgnoreSystemDecls = true, bool CanBeDefinition = false); bool IgnoreSystemDecls = true, bool CanBeDefinition = false);
CppSharp::Declaration^ WalkDeclarationDef(clang::Decl* D); CppSharp::AST::Declaration^ WalkDeclarationDef(clang::Decl* D);
CppSharp::Enumeration^ WalkEnum(clang::EnumDecl*); CppSharp::AST::Enumeration^ WalkEnum(clang::EnumDecl*);
CppSharp::Function^ WalkFunction(clang::FunctionDecl*, bool IsDependent = false, CppSharp::AST::Function^ WalkFunction(clang::FunctionDecl*, bool IsDependent = false,
bool AddToNamespace = true); bool AddToNamespace = true);
CppSharp::Class^ WalkRecordCXX(clang::CXXRecordDecl*); CppSharp::AST::Class^ WalkRecordCXX(clang::CXXRecordDecl*);
CppSharp::Method^ WalkMethodCXX(clang::CXXMethodDecl*); CppSharp::AST::Method^ WalkMethodCXX(clang::CXXMethodDecl*);
CppSharp::Field^ WalkFieldCXX(clang::FieldDecl*, CppSharp::Class^); CppSharp::AST::Field^ WalkFieldCXX(clang::FieldDecl*, CppSharp::AST::Class^);
CppSharp::ClassTemplate^ Parser::WalkClassTemplate(clang::ClassTemplateDecl*); CppSharp::AST::ClassTemplate^ Parser::WalkClassTemplate(clang::ClassTemplateDecl*);
CppSharp::FunctionTemplate^ Parser::WalkFunctionTemplate( CppSharp::AST::FunctionTemplate^ Parser::WalkFunctionTemplate(
clang::FunctionTemplateDecl*); clang::FunctionTemplateDecl*);
CppSharp::Variable^ WalkVariable(clang::VarDecl*); CppSharp::AST::Variable^ WalkVariable(clang::VarDecl*);
CppSharp::Type^ WalkType(clang::QualType, clang::TypeLoc* = 0, CppSharp::AST::Type^ WalkType(clang::QualType, clang::TypeLoc* = 0,
bool DesugarType = false); bool DesugarType = false);
// Clang helpers // Clang helpers
@ -153,25 +153,25 @@ protected:
std::string GetDeclMangledName(clang::Decl*, clang::TargetCXXABI, std::string GetDeclMangledName(clang::Decl*, clang::TargetCXXABI,
bool IsDependent = false); bool IsDependent = false);
std::string GetTypeName(const clang::Type*); std::string GetTypeName(const clang::Type*);
void HandleComments(clang::Decl* D, CppSharp::Declaration^); void HandleComments(clang::Decl* D, CppSharp::AST::Declaration^);
void WalkFunction(clang::FunctionDecl* FD, CppSharp::Function^ F, void WalkFunction(clang::FunctionDecl* FD, CppSharp::AST::Function^ F,
bool IsDependent = false); bool IsDependent = false);
void HandlePreprocessedEntities(CppSharp::Declaration^ Decl, clang::SourceRange sourceRange, void HandlePreprocessedEntities(CppSharp::AST::Declaration^ Decl, clang::SourceRange sourceRange,
CppSharp::MacroLocation macroLocation = CppSharp::MacroLocation::Unknown); CppSharp::AST::MacroLocation macroLocation = CppSharp::AST::MacroLocation::Unknown);
bool GetPreprocessedEntityText(clang::PreprocessedEntity*, std::string& Text); bool GetPreprocessedEntityText(clang::PreprocessedEntity*, std::string& Text);
CppSharp::TranslationUnit^ GetTranslationUnit(clang::SourceLocation Loc, CppSharp::AST::TranslationUnit^ GetTranslationUnit(clang::SourceLocation Loc,
SourceLocationKind *Kind = 0); SourceLocationKind *Kind = 0);
CppSharp::TranslationUnit^ GetTranslationUnit(const clang::Decl*); CppSharp::AST::TranslationUnit^ GetTranslationUnit(const clang::Decl*);
CppSharp::DeclarationContext^ GetNamespace(clang::Decl*, clang::DeclContext*); CppSharp::AST::DeclarationContext^ GetNamespace(clang::Decl*, clang::DeclContext*);
CppSharp::DeclarationContext^ GetNamespace(clang::Decl*); CppSharp::AST::DeclarationContext^ GetNamespace(clang::Decl*);
clang::CallingConv GetAbiCallConv(clang::CallingConv CC, clang::CallingConv GetAbiCallConv(clang::CallingConv CC,
bool IsInstMethod, bool IsVariadic); bool IsInstMethod, bool IsVariadic);
int Index; int Index;
gcroot<CppSharp::Library^> Lib; gcroot<CppSharp::AST::Library^> Lib;
gcroot<ParserOptions^> Opts; gcroot<ParserOptions^> Opts;
llvm::OwningPtr<clang::CompilerInstance> C; llvm::OwningPtr<clang::CompilerInstance> C;
clang::ASTContext* AST; clang::ASTContext* AST;

1
tests/Hello/Hello.cs

@ -1,3 +1,4 @@
using CppSharp.AST;
using CppSharp.Generators; using CppSharp.Generators;
using CppSharp.Utils; using CppSharp.Utils;

Loading…
Cancel
Save