From 68ddfbdd6f417ffaaffd9167bcc5151eef66368e Mon Sep 17 00:00:00 2001 From: triton Date: Wed, 17 Jul 2013 20:56:34 +0100 Subject: [PATCH] Move the AST project to the CppSharp.AST namespace. --- src/AST/ASTVisitor.cs | 2 +- src/AST/Class.cs | 2 +- src/AST/Comment.cs | 6 +- src/AST/Conversions.cs | 2 +- src/AST/Declaration.cs | 2 +- src/AST/Delegate.cs | 2 +- src/AST/Enumeration.cs | 2 +- src/AST/Event.cs | 2 +- src/AST/Field.cs | 2 +- src/AST/Function.cs | 2 +- src/AST/Library.cs | 2 +- src/AST/Method.cs | 2 +- src/AST/Namespace.cs | 2 +- src/AST/Preprocessor.cs | 2 +- src/AST/Property.cs | 5 +- src/AST/Template.cs | 2 +- src/AST/TranslationUnit.cs | 2 +- src/AST/Type.cs | 2 +- src/AST/Variable.cs | 2 +- src/Generator.Tests/HeaderTestFixture.cs | 1 + src/Generator.Tests/QueryHelpers.cs | 1 + src/Generator/Driver.cs | 3 +- .../CLI/CLIForwardReferencePrinter.cs | 1 + src/Generator/Generators/CLI/CLIGenerator.cs | 1 + src/Generator/Generators/CLI/CLIMarshal.cs | 2 + .../Generators/CLI/CLITextTemplate.cs | 1 + .../Generators/CLI/CLITypePrinter.cs | 3 +- .../Generators/CSharp/CSharpGenerator.cs | 4 +- .../Generators/CSharp/CSharpMarshal.cs | 1 + .../Generators/CSharp/CSharpTextTemplate.cs | 2 +- .../Generators/CSharp/CSharpTypePrinter.cs | 3 +- src/Generator/Generators/Generator.cs | 1 + src/Generator/Generators/Marshal.cs | 4 +- src/Generator/Generators/Template.cs | 3 +- src/Generator/Library.cs | 1 + src/Generator/Parser.cs | 1 + src/Generator/Passes/CheckAbiParameters.cs | 4 +- src/Generator/Passes/CheckFlagEnumsPass.cs | 1 + src/Generator/Passes/CheckIgnoredDecls.cs | 7 +- .../Passes/CheckOperatorsOverloads.cs | 1 + .../Passes/CheckTypeReferencesPass.cs | 4 +- .../Passes/CleanInvalidDeclNamesPass.cs | 1 + src/Generator/Passes/CleanUnitPass.cs | 2 + .../Passes/DuplicatedNamesCheckerPass.cs | 1 + .../Passes/FunctionToInstanceMethodPass.cs | 1 + .../Passes/FunctionToStaticMethodPass.cs | 1 + src/Generator/Passes/Pass.cs | 2 + src/Generator/Passes/RenamePass.cs | 1 + .../Passes/ResolveIncompleteDeclsPass.cs | 1 + src/Generator/Passes/SortDeclarationsPass.cs | 3 +- src/Generator/Types/CppTypePrinter.cs | 2 + src/Generator/Types/ITypePrinter.cs | 1 + src/Generator/Types/Std/Stdlib.cs | 1 + src/Generator/Types/TypeMap.cs | 2 + src/Generator/Types/Types.cs | 1 + src/Generator/Utils/TestsUtils.cs | 1 + src/Generator/Utils/Utils.cs | 1 + src/Parser/Parser.cpp | 238 +++++++++--------- src/Parser/Parser.h | 44 ++-- tests/Hello/Hello.cs | 1 + 60 files changed, 220 insertions(+), 180 deletions(-) diff --git a/src/AST/ASTVisitor.cs b/src/AST/ASTVisitor.cs index 616f6570..7589f842 100644 --- a/src/AST/ASTVisitor.cs +++ b/src/AST/ASTVisitor.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace CppSharp +namespace CppSharp.AST { public interface IAstVisited { diff --git a/src/AST/Class.cs b/src/AST/Class.cs index 80533d23..2ac4c626 100644 --- a/src/AST/Class.cs +++ b/src/AST/Class.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace CppSharp +namespace CppSharp.AST { // A C++ access specifier. public enum AccessSpecifier diff --git a/src/AST/Comment.cs b/src/AST/Comment.cs index 42df951c..5e26aeff 100644 --- a/src/AST/Comment.cs +++ b/src/AST/Comment.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace CppSharp +namespace CppSharp.AST { /// /// Represents a C++ comment. diff --git a/src/AST/Conversions.cs b/src/AST/Conversions.cs index c64c9346..0d42545a 100644 --- a/src/AST/Conversions.cs +++ b/src/AST/Conversions.cs @@ -1,4 +1,4 @@ -namespace CppSharp +namespace CppSharp.AST { public enum MethodConversionKind { diff --git a/src/AST/Declaration.cs b/src/AST/Declaration.cs index 56cdb00f..f794b39e 100644 --- a/src/AST/Declaration.cs +++ b/src/AST/Declaration.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace CppSharp +namespace CppSharp.AST { public interface IRedeclarableDecl { diff --git a/src/AST/Delegate.cs b/src/AST/Delegate.cs index 4e704935..b71d34a1 100644 --- a/src/AST/Delegate.cs +++ b/src/AST/Delegate.cs @@ -1,4 +1,4 @@ -namespace CppSharp +namespace CppSharp.AST { public class Delegate : Declaration { diff --git a/src/AST/Enumeration.cs b/src/AST/Enumeration.cs index 6635d87a..dc98b888 100644 --- a/src/AST/Enumeration.cs +++ b/src/AST/Enumeration.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace CppSharp +namespace CppSharp.AST { /// /// Represents a C/C++ enumeration declaration. diff --git a/src/AST/Event.cs b/src/AST/Event.cs index d0557617..a9d69d90 100644 --- a/src/AST/Event.cs +++ b/src/AST/Event.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace CppSharp +namespace CppSharp.AST { public class Event : Declaration, ITypedDecl { diff --git a/src/AST/Field.cs b/src/AST/Field.cs index 4f7a0016..9d24a8c2 100644 --- a/src/AST/Field.cs +++ b/src/AST/Field.cs @@ -1,4 +1,4 @@ -namespace CppSharp +namespace CppSharp.AST { /// /// Represents a a C/C++ record field Decl. diff --git a/src/AST/Function.cs b/src/AST/Function.cs index e6d9b40e..26a7322a 100644 --- a/src/AST/Function.cs +++ b/src/AST/Function.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; -namespace CppSharp +namespace CppSharp.AST { public enum CallingConvention { diff --git a/src/AST/Library.cs b/src/AST/Library.cs index 42d53f2c..99140a6b 100644 --- a/src/AST/Library.cs +++ b/src/AST/Library.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.IO; -namespace CppSharp +namespace CppSharp.AST { public enum CppAbi { diff --git a/src/AST/Method.cs b/src/AST/Method.cs index b9e582af..8ab3cc8d 100644 --- a/src/AST/Method.cs +++ b/src/AST/Method.cs @@ -1,4 +1,4 @@ -namespace CppSharp +namespace CppSharp.AST { public enum CXXMethodKind { diff --git a/src/AST/Namespace.cs b/src/AST/Namespace.cs index b348ff27..f951dc21 100644 --- a/src/AST/Namespace.cs +++ b/src/AST/Namespace.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace CppSharp +namespace CppSharp.AST { /// /// Represents a declaration context. diff --git a/src/AST/Preprocessor.cs b/src/AST/Preprocessor.cs index 177a9ce0..4cbd4491 100644 --- a/src/AST/Preprocessor.cs +++ b/src/AST/Preprocessor.cs @@ -1,4 +1,4 @@ -namespace CppSharp +namespace CppSharp.AST { public enum MacroLocation { diff --git a/src/AST/Property.cs b/src/AST/Property.cs index 4f1c8ced..8367cc07 100644 --- a/src/AST/Property.cs +++ b/src/AST/Property.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; - -namespace CppSharp +namespace CppSharp.AST { /// /// Represents a C++ property. diff --git a/src/AST/Template.cs b/src/AST/Template.cs index 9d1ee2a6..dbce1df7 100644 --- a/src/AST/Template.cs +++ b/src/AST/Template.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace CppSharp +namespace CppSharp.AST { public struct TemplateParameter { diff --git a/src/AST/TranslationUnit.cs b/src/AST/TranslationUnit.cs index 7c530d21..ae3574ff 100644 --- a/src/AST/TranslationUnit.cs +++ b/src/AST/TranslationUnit.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; -namespace CppSharp +namespace CppSharp.AST { /// /// Represents a parsed C++ unit. diff --git a/src/AST/Type.cs b/src/AST/Type.cs index 60b3402d..074bcfe5 100644 --- a/src/AST/Type.cs +++ b/src/AST/Type.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace CppSharp +namespace CppSharp.AST { /// /// Represents a C++ type. diff --git a/src/AST/Variable.cs b/src/AST/Variable.cs index ed68aec4..4002b68f 100644 --- a/src/AST/Variable.cs +++ b/src/AST/Variable.cs @@ -1,5 +1,5 @@  -namespace CppSharp +namespace CppSharp.AST { public class Variable : Declaration, ITypedDecl, IMangledDecl { diff --git a/src/Generator.Tests/HeaderTestFixture.cs b/src/Generator.Tests/HeaderTestFixture.cs index fa36e29d..bf998ad0 100644 --- a/src/Generator.Tests/HeaderTestFixture.cs +++ b/src/Generator.Tests/HeaderTestFixture.cs @@ -1,6 +1,7 @@ using System; using System.IO; using CppSharp; +using CppSharp.AST; namespace Generator.Tests { diff --git a/src/Generator.Tests/QueryHelpers.cs b/src/Generator.Tests/QueryHelpers.cs index 6bb43aae..37189676 100644 --- a/src/Generator.Tests/QueryHelpers.cs +++ b/src/Generator.Tests/QueryHelpers.cs @@ -1,5 +1,6 @@ using System.Linq; using CppSharp; +using CppSharp.AST; namespace Generator.Tests { diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs index 04a620da..ff3b4368 100644 --- a/src/Generator/Driver.cs +++ b/src/Generator/Driver.cs @@ -1,4 +1,5 @@ -using CppSharp.Generators; +using CppSharp.AST; +using CppSharp.Generators; using CppSharp.Generators.CLI; using CppSharp.Generators.CSharp; using CppSharp.Passes; diff --git a/src/Generator/Generators/CLI/CLIForwardReferencePrinter.cs b/src/Generator/Generators/CLI/CLIForwardReferencePrinter.cs index 64c037de..5b767234 100644 --- a/src/Generator/Generators/CLI/CLIForwardReferencePrinter.cs +++ b/src/Generator/Generators/CLI/CLIForwardReferencePrinter.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using CppSharp.AST; namespace CppSharp.Generators.CLI { diff --git a/src/Generator/Generators/CLI/CLIGenerator.cs b/src/Generator/Generators/CLI/CLIGenerator.cs index d52e2909..5bf9735b 100644 --- a/src/Generator/Generators/CLI/CLIGenerator.cs +++ b/src/Generator/Generators/CLI/CLIGenerator.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using CppSharp.AST; namespace CppSharp.Generators.CLI { diff --git a/src/Generator/Generators/CLI/CLIMarshal.cs b/src/Generator/Generators/CLI/CLIMarshal.cs index 6ed16890..72b4900b 100644 --- a/src/Generator/Generators/CLI/CLIMarshal.cs +++ b/src/Generator/Generators/CLI/CLIMarshal.cs @@ -1,6 +1,8 @@ using System; using System.Text; +using CppSharp.AST; using CppSharp.Types; +using Delegate = CppSharp.AST.Delegate; namespace CppSharp.Generators.CLI { diff --git a/src/Generator/Generators/CLI/CLITextTemplate.cs b/src/Generator/Generators/CLI/CLITextTemplate.cs index 63336bf7..1fdfa258 100644 --- a/src/Generator/Generators/CLI/CLITextTemplate.cs +++ b/src/Generator/Generators/CLI/CLITextTemplate.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CppSharp.AST; namespace CppSharp.Generators.CLI { diff --git a/src/Generator/Generators/CLI/CLITypePrinter.cs b/src/Generator/Generators/CLI/CLITypePrinter.cs index ec115f5c..ca98abdd 100644 --- a/src/Generator/Generators/CLI/CLITypePrinter.cs +++ b/src/Generator/Generators/CLI/CLITypePrinter.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CppSharp.AST; using CppSharp.Types; namespace CppSharp.Generators.CLI @@ -339,7 +340,7 @@ namespace CppSharp.Generators.CLI throw new NotImplementedException(); } - public string ToString(Type type) + public string ToString(AST.Type type) { return type.Visit(this); } diff --git a/src/Generator/Generators/CSharp/CSharpGenerator.cs b/src/Generator/Generators/CSharp/CSharpGenerator.cs index b178e149..43f8331b 100644 --- a/src/Generator/Generators/CSharp/CSharpGenerator.cs +++ b/src/Generator/Generators/CSharp/CSharpGenerator.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using CppSharp.AST; using CppSharp.Passes; +using CppSharp.Generators; namespace CppSharp.Generators.CSharp { @@ -11,7 +13,7 @@ namespace CppSharp.Generators.CSharp public CSharpGenerator(Driver driver) : base(driver) { 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 Generate(TranslationUnit unit) diff --git a/src/Generator/Generators/CSharp/CSharpMarshal.cs b/src/Generator/Generators/CSharp/CSharpMarshal.cs index f9a1b812..1642d31d 100644 --- a/src/Generator/Generators/CSharp/CSharpMarshal.cs +++ b/src/Generator/Generators/CSharp/CSharpMarshal.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Text; +using CppSharp.AST; using CppSharp.Types; namespace CppSharp.Generators.CSharp diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 70de478f..b3d04a30 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/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); WriteStartBraceIndent(); diff --git a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs index a1d902ac..1f714e15 100644 --- a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs +++ b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CppSharp.AST; using CppSharp.Types; namespace CppSharp.Generators.CSharp @@ -465,7 +466,7 @@ namespace CppSharp.Generators.CSharp VisitParameters(function.Parameters, hasNames: true)); } - public string ToString(Type type) + public string ToString(AST.Type type) { return type.Visit(this).Type; } diff --git a/src/Generator/Generators/Generator.cs b/src/Generator/Generators/Generator.cs index 47ab0fa8..33d4f638 100644 --- a/src/Generator/Generators/Generator.cs +++ b/src/Generator/Generators/Generator.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CppSharp.AST; namespace CppSharp.Generators { diff --git a/src/Generator/Generators/Marshal.cs b/src/Generator/Generators/Marshal.cs index b252b5fa..783179f5 100644 --- a/src/Generator/Generators/Marshal.cs +++ b/src/Generator/Generators/Marshal.cs @@ -1,4 +1,6 @@ -namespace CppSharp.Generators +using CppSharp.AST; + +namespace CppSharp.Generators { public class MarshalContext { diff --git a/src/Generator/Generators/Template.cs b/src/Generator/Generators/Template.cs index 87f41954..8d6c94b6 100644 --- a/src/Generator/Generators/Template.cs +++ b/src/Generator/Generators/Template.cs @@ -1,5 +1,6 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Text; +using CppSharp.AST; namespace CppSharp.Generators { diff --git a/src/Generator/Library.cs b/src/Generator/Library.cs index eca7734f..e53c86e9 100644 --- a/src/Generator/Library.cs +++ b/src/Generator/Library.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text.RegularExpressions; +using CppSharp.AST; namespace CppSharp { diff --git a/src/Generator/Parser.cs b/src/Generator/Parser.cs index 552ad599..28e46fcc 100644 --- a/src/Generator/Parser.cs +++ b/src/Generator/Parser.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CppSharp.AST; namespace CppSharp { diff --git a/src/Generator/Passes/CheckAbiParameters.cs b/src/Generator/Passes/CheckAbiParameters.cs index ab8cc24e..1133605d 100644 --- a/src/Generator/Passes/CheckAbiParameters.cs +++ b/src/Generator/Passes/CheckAbiParameters.cs @@ -1,4 +1,6 @@ -namespace CppSharp.Passes +using CppSharp.AST; + +namespace CppSharp.Passes { public class CheckAbiParameters : TranslationUnitPass { diff --git a/src/Generator/Passes/CheckFlagEnumsPass.cs b/src/Generator/Passes/CheckFlagEnumsPass.cs index 3aa3a3b4..3bb09989 100644 --- a/src/Generator/Passes/CheckFlagEnumsPass.cs +++ b/src/Generator/Passes/CheckFlagEnumsPass.cs @@ -1,4 +1,5 @@ using System; +using CppSharp.AST; namespace CppSharp.Passes { diff --git a/src/Generator/Passes/CheckIgnoredDecls.cs b/src/Generator/Passes/CheckIgnoredDecls.cs index 32080c40..e77566f0 100644 --- a/src/Generator/Passes/CheckIgnoredDecls.cs +++ b/src/Generator/Passes/CheckIgnoredDecls.cs @@ -1,4 +1,5 @@ using System; +using CppSharp.AST; namespace CppSharp.Passes { @@ -203,7 +204,7 @@ namespace CppSharp.Passes /// reasons: incomplete definitions, being explicitly ignored, or also /// by being a type we do not know how to handle. /// - bool HasInvalidType(Type type, out string msg) + bool HasInvalidType(AST.Type type, out string msg) { if (type == null) { @@ -251,7 +252,7 @@ namespace CppSharp.Passes return false; } - static bool IsTypeComplete(Type type) + static bool IsTypeComplete(AST.Type type) { var checker = new TypeCompletionChecker(); return type.Visit(checker); @@ -263,7 +264,7 @@ namespace CppSharp.Passes return decl.Visit(checker); } - bool IsTypeIgnored(Type type) + bool IsTypeIgnored(AST.Type type) { var checker = new TypeIgnoreChecker(Driver.TypeDatabase); type.Visit(checker); diff --git a/src/Generator/Passes/CheckOperatorsOverloads.cs b/src/Generator/Passes/CheckOperatorsOverloads.cs index 1944a62f..7c6006b6 100644 --- a/src/Generator/Passes/CheckOperatorsOverloads.cs +++ b/src/Generator/Passes/CheckOperatorsOverloads.cs @@ -1,4 +1,5 @@ using System.Linq; +using CppSharp.AST; using CppSharp.Generators.CSharp; namespace CppSharp.Passes diff --git a/src/Generator/Passes/CheckTypeReferencesPass.cs b/src/Generator/Passes/CheckTypeReferencesPass.cs index 80fe340c..64617bdd 100644 --- a/src/Generator/Passes/CheckTypeReferencesPass.cs +++ b/src/Generator/Passes/CheckTypeReferencesPass.cs @@ -1,4 +1,6 @@ -namespace CppSharp.Passes +using CppSharp.AST; + +namespace CppSharp.Passes { public class CheckTypeReferencesPass : TranslationUnitPass { diff --git a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs index 469c4c92..490913b6 100644 --- a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs +++ b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using CppSharp.AST; namespace CppSharp.Passes { diff --git a/src/Generator/Passes/CleanUnitPass.cs b/src/Generator/Passes/CleanUnitPass.cs index e6b917cb..f0421faa 100644 --- a/src/Generator/Passes/CleanUnitPass.cs +++ b/src/Generator/Passes/CleanUnitPass.cs @@ -1,3 +1,5 @@ +using CppSharp.AST; + namespace CppSharp.Passes { public class CleanUnitPass : TranslationUnitPass diff --git a/src/Generator/Passes/DuplicatedNamesCheckerPass.cs b/src/Generator/Passes/DuplicatedNamesCheckerPass.cs index 32d5155f..3424cad2 100644 --- a/src/Generator/Passes/DuplicatedNamesCheckerPass.cs +++ b/src/Generator/Passes/DuplicatedNamesCheckerPass.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using CppSharp.AST; namespace CppSharp.Passes { diff --git a/src/Generator/Passes/FunctionToInstanceMethodPass.cs b/src/Generator/Passes/FunctionToInstanceMethodPass.cs index 5135ef14..23231fdc 100644 --- a/src/Generator/Passes/FunctionToInstanceMethodPass.cs +++ b/src/Generator/Passes/FunctionToInstanceMethodPass.cs @@ -1,4 +1,5 @@ using System; +using CppSharp.AST; namespace CppSharp.Passes { diff --git a/src/Generator/Passes/FunctionToStaticMethodPass.cs b/src/Generator/Passes/FunctionToStaticMethodPass.cs index 8fc5d26a..cdc02baf 100644 --- a/src/Generator/Passes/FunctionToStaticMethodPass.cs +++ b/src/Generator/Passes/FunctionToStaticMethodPass.cs @@ -1,4 +1,5 @@ using System; +using CppSharp.AST; namespace CppSharp.Passes { diff --git a/src/Generator/Passes/Pass.cs b/src/Generator/Passes/Pass.cs index 33173734..974fcabe 100644 --- a/src/Generator/Passes/Pass.cs +++ b/src/Generator/Passes/Pass.cs @@ -1,4 +1,6 @@  +using CppSharp.AST; + namespace CppSharp.Passes { /// diff --git a/src/Generator/Passes/RenamePass.cs b/src/Generator/Passes/RenamePass.cs index d37020d8..ab553830 100644 --- a/src/Generator/Passes/RenamePass.cs +++ b/src/Generator/Passes/RenamePass.cs @@ -1,6 +1,7 @@ using System; using System.Text; using System.Text.RegularExpressions; +using CppSharp.AST; namespace CppSharp.Passes { diff --git a/src/Generator/Passes/ResolveIncompleteDeclsPass.cs b/src/Generator/Passes/ResolveIncompleteDeclsPass.cs index 948fce1e..577bce07 100644 --- a/src/Generator/Passes/ResolveIncompleteDeclsPass.cs +++ b/src/Generator/Passes/ResolveIncompleteDeclsPass.cs @@ -1,4 +1,5 @@ using System; +using CppSharp.AST; namespace CppSharp.Passes { diff --git a/src/Generator/Passes/SortDeclarationsPass.cs b/src/Generator/Passes/SortDeclarationsPass.cs index 4f153261..2b30e1ce 100644 --- a/src/Generator/Passes/SortDeclarationsPass.cs +++ b/src/Generator/Passes/SortDeclarationsPass.cs @@ -1,4 +1,5 @@ -using CppSharp.Types; +using CppSharp.AST; +using CppSharp.Types; namespace CppSharp.Passes { diff --git a/src/Generator/Types/CppTypePrinter.cs b/src/Generator/Types/CppTypePrinter.cs index 52af9f41..a9f9a92f 100644 --- a/src/Generator/Types/CppTypePrinter.cs +++ b/src/Generator/Types/CppTypePrinter.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using CppSharp.AST; +using Type = CppSharp.AST.Type; namespace CppSharp.Types { diff --git a/src/Generator/Types/ITypePrinter.cs b/src/Generator/Types/ITypePrinter.cs index 3f11c6c3..dd6c3fb2 100644 --- a/src/Generator/Types/ITypePrinter.cs +++ b/src/Generator/Types/ITypePrinter.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using CppSharp.AST; namespace CppSharp.Types { diff --git a/src/Generator/Types/Std/Stdlib.cs b/src/Generator/Types/Std/Stdlib.cs index a9382d59..8969241f 100644 --- a/src/Generator/Types/Std/Stdlib.cs +++ b/src/Generator/Types/Std/Stdlib.cs @@ -1,4 +1,5 @@ using System; +using CppSharp.AST; using CppSharp.Generators; using CppSharp.Generators.CLI; using CppSharp.Generators.CSharp; diff --git a/src/Generator/Types/TypeMap.cs b/src/Generator/Types/TypeMap.cs index edaad915..5f63b6ba 100644 --- a/src/Generator/Types/TypeMap.cs +++ b/src/Generator/Types/TypeMap.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; +using CppSharp.AST; using CppSharp.Generators; using CppSharp.Generators.CLI; using CppSharp.Generators.CSharp; +using Type = CppSharp.AST.Type; namespace CppSharp.Types { diff --git a/src/Generator/Types/Types.cs b/src/Generator/Types/Types.cs index 1d53d501..38f0de57 100644 --- a/src/Generator/Types/Types.cs +++ b/src/Generator/Types/Types.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using CppSharp.AST; using CppSharp.Types; namespace CppSharp diff --git a/src/Generator/Utils/TestsUtils.cs b/src/Generator/Utils/TestsUtils.cs index 9b2ac4b7..10bf26cd 100644 --- a/src/Generator/Utils/TestsUtils.cs +++ b/src/Generator/Utils/TestsUtils.cs @@ -1,4 +1,5 @@ using System.IO; +using CppSharp.AST; using CppSharp.Generators; namespace CppSharp.Utils diff --git a/src/Generator/Utils/Utils.cs b/src/Generator/Utils/Utils.cs index 87c55e6d..6c21a470 100644 --- a/src/Generator/Utils/Utils.cs +++ b/src/Generator/Utils/Utils.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text.RegularExpressions; +using CppSharp.AST; namespace CppSharp { diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index dfb6c847..2bce8e5d 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -332,18 +332,18 @@ std::string Parser::GetTypeName(const clang::Type* Type) 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.IsRestrict = Type.isLocalRestrictQualified(); quals.IsVolatile = Type.isVolatileQualified(); 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.Qualifiers = GetTypeQualifiers(qual); 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) { case clang::AS_private: - return CppSharp::AccessSpecifier::Private; + return CppSharp::AST::AccessSpecifier::Private; case clang::AS_protected: - return CppSharp::AccessSpecifier::Protected; + return CppSharp::AST::AccessSpecifier::Protected; 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 clix; @@ -396,8 +396,8 @@ CppSharp::Class^ Parser::WalkRecordCXX(clang::CXXRecordDecl* Record) auto headRange = clang::SourceRange(headStartLoc, headEndLoc); auto bodyRange = clang::SourceRange(headEndLoc, bodyEndLoc); - HandlePreprocessedEntities(RC, headRange, CppSharp::MacroLocation::ClassHead); - HandlePreprocessedEntities(RC, bodyRange, CppSharp::MacroLocation::ClassBody); + HandlePreprocessedEntities(RC, headRange, CppSharp::AST::MacroLocation::ClassHead); + HandlePreprocessedEntities(RC, bodyRange, CppSharp::AST::MacroLocation::ClassBody); RC->IsPOD = Record->isPOD(); RC->IsUnion = Record->isUnion(); @@ -417,7 +417,7 @@ CppSharp::Class^ Parser::WalkRecordCXX(clang::CXXRecordDecl* Record) 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) { @@ -453,14 +453,14 @@ CppSharp::Class^ Parser::WalkRecordCXX(clang::CXXRecordDecl* Record) { AccessSpecDecl* AS = cast(D); - AccessDecl = gcnew CppSharp::AccessSpecifierDecl(); + AccessDecl = gcnew CppSharp::AST::AccessSpecifierDecl(); AccessDecl->Access = ConvertToAccess(AS->getAccess()); AccessDecl->Namespace = RC; auto startLoc = GetDeclStartLocation(C.get(), AS); auto range = SourceRange(startLoc, AS->getColonLoc()); HandlePreprocessedEntities(AccessDecl, range, - CppSharp::MacroLocation::Unknown); + CppSharp::AST::MacroLocation::Unknown); RC->Specifiers->Add(AccessDecl); break; @@ -478,7 +478,7 @@ CppSharp::Class^ Parser::WalkRecordCXX(clang::CXXRecordDecl* Record) { clang::CXXBaseSpecifier &BS = *it; - CppSharp::BaseClassSpecifier^ Base = gcnew CppSharp::BaseClassSpecifier(); + CppSharp::AST::BaseClassSpecifier^ Base = gcnew CppSharp::AST::BaseClassSpecifier(); Base->Access = ConvertToAccess(BS.getAccessSpecifier()); Base->IsVirtual = BS.isVirtual(); 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 clix; auto Class = WalkRecordCXX(TD->getTemplatedDecl()); - CppSharp::ClassTemplate^ CT = gcnew CppSharp::ClassTemplate(Class); + CppSharp::AST::ClassTemplate^ CT = gcnew CppSharp::AST::ClassTemplate(Class); return CT; } //-----------------------------------// -CppSharp::FunctionTemplate^ Parser::WalkFunctionTemplate(clang::FunctionTemplateDecl* TD) +CppSharp::AST::FunctionTemplate^ Parser::WalkFunctionTemplate(clang::FunctionTemplateDecl* TD) { using namespace clang; using namespace clix; auto Function = WalkFunction(TD->getTemplatedDecl(), /*IsDependent=*/true, /*AddToNamespace=*/false); - CppSharp::FunctionTemplate^ FT = gcnew CppSharp::FunctionTemplate(Function); + CppSharp::AST::FunctionTemplate^ FT = gcnew CppSharp::AST::FunctionTemplate(Function); auto TPL = TD->getTemplateParameters(); for(auto it = TPL->begin(); it != TPL->end(); ++it) { auto ND = *it; - auto TP = CppSharp::TemplateParameter(); + auto TP = CppSharp::AST::TemplateParameter(); TP.Name = clix::marshalString(ND->getNameAsString()); 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; @@ -539,46 +539,46 @@ static CppSharp::CXXMethodKind GetMethodKindFromDecl(clang::DeclarationName Name case DeclarationName::ObjCZeroArgSelector: case DeclarationName::ObjCOneArgSelector: case DeclarationName::ObjCMultiArgSelector: - return CppSharp::CXXMethodKind::Normal; + return CppSharp::AST::CXXMethodKind::Normal; case DeclarationName::CXXConstructorName: - return CppSharp::CXXMethodKind::Constructor; + return CppSharp::AST::CXXMethodKind::Constructor; case DeclarationName::CXXDestructorName: - return CppSharp::CXXMethodKind::Destructor; + return CppSharp::AST::CXXMethodKind::Destructor; case DeclarationName::CXXConversionFunctionName: - return CppSharp::CXXMethodKind::Conversion; + return CppSharp::AST::CXXMethodKind::Conversion; case DeclarationName::CXXOperatorName: case DeclarationName::CXXLiteralOperatorName: - return CppSharp::CXXMethodKind::Operator; + return CppSharp::AST::CXXMethodKind::Operator; 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; if (Name.getNameKind() != DeclarationName::CXXOperatorName) - return CppSharp::CXXOperatorKind::None; + return CppSharp::AST::CXXOperatorKind::None; switch(Name.getCXXOverloadedOperator()) { #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" } - 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; DeclarationName Name = MD->getDeclName(); - CppSharp::Method^ Method = gcnew CppSharp::Method(); + CppSharp::AST::Method^ Method = gcnew CppSharp::AST::Method(); Method->Access = ConvertToAccess(MD->getAccess()); Method->Kind = GetMethodKindFromDecl(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 clix; - CppSharp::Field^ F = gcnew CppSharp::Field(); + CppSharp::AST::Field^ F = gcnew CppSharp::AST::Field(); F->Namespace = Class; F->Name = marshalString(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) { 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(); SourceLocationKind Kind; - CppSharp::TranslationUnit^ Unit = GetTranslationUnit(Loc, &Kind); + CppSharp::AST::TranslationUnit^ Unit = GetTranslationUnit(Loc, &Kind); return Unit; } -CppSharp::DeclarationContext^ Parser::GetNamespace(clang::Decl* D, +CppSharp::AST::DeclarationContext^ Parser::GetNamespace(clang::Decl* D, clang::DeclContext *Ctx) { using namespace clang; @@ -686,7 +686,7 @@ CppSharp::DeclarationContext^ Parser::GetNamespace(clang::Decl* D, if (Ctx->isTranslationUnit()) return GetTranslationUnit(D); - CppSharp::TranslationUnit^ Unit = GetTranslationUnit(cast(Ctx)); + CppSharp::AST::TranslationUnit^ Unit = GetTranslationUnit(cast(Ctx)); // 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. @@ -699,7 +699,7 @@ CppSharp::DeclarationContext^ Parser::GetNamespace(clang::Decl* D, assert(Contexts.back()->isTranslationUnit()); Contexts.pop_back(); - CppSharp::DeclarationContext^ DC = Unit; + CppSharp::AST::DeclarationContext^ DC = Unit; for (auto I = Contexts.rbegin(), E = Contexts.rend(); I != E; ++I) { @@ -744,14 +744,14 @@ CppSharp::DeclarationContext^ Parser::GetNamespace(clang::Decl* D, return DC; } -CppSharp::DeclarationContext^ Parser::GetNamespace(clang::Decl *D) +CppSharp::AST::DeclarationContext^ Parser::GetNamespace(clang::Decl *D) { 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"); @@ -825,7 +825,7 @@ clang::TypeLoc ResolveTypeLoc(clang::TypeLoc TL, clang::TypeLoc::TypeLocClass Cl 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) { using namespace clang; @@ -851,7 +851,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, auto Builtin = Type->getAs(); assert(Builtin && "Expected a builtin type"); - auto BT = gcnew CppSharp::BuiltinType(); + auto BT = gcnew CppSharp::AST::BuiltinType(); BT->Type = WalkBuiltinType(Builtin); return BT; @@ -863,7 +863,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, //auto Name = marshalString(GetTagDeclName(ED)); - auto TT = gcnew CppSharp::TagType(); + auto TT = gcnew CppSharp::AST::TagType(); TT->Declaration = WalkDeclaration(ED, 0, /*IgnoreSystemDecls=*/false); return TT; @@ -872,8 +872,8 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, { auto Pointer = Type->getAs(); - auto P = gcnew CppSharp::PointerType(); - P->Modifier = CppSharp::PointerType::TypeModifier::Pointer; + auto P = gcnew CppSharp::AST::PointerType(); + P->Modifier = CppSharp::AST::PointerType::TypeModifier::Pointer; auto Next = TL->getNextTypeLoc(); @@ -888,10 +888,10 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, TypedefNameDecl* TD = TT->getDecl(); auto TTL = TD->getTypeSourceInfo()->getTypeLoc(); - auto TDD = safe_cast(WalkDeclaration(TD, + auto TDD = safe_cast(WalkDeclaration(TD, /*IgnoreSystemDecls=*/false)); - auto Type = gcnew CppSharp::TypedefType(); + auto Type = gcnew CppSharp::AST::TypedefType(); Type->Declaration = TDD; return Type; @@ -901,7 +901,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, auto DT = Type->getAs(); 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->Original = GetQualifiedType(DT->getOriginalType(), WalkType(DT->getOriginalType(), &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(); RecordDecl* RD = RT->getDecl(); - auto TT = gcnew CppSharp::TagType(); + auto TT = gcnew CppSharp::AST::TagType(); TT->Declaration = WalkDeclaration(RD, /*IgnoreSystemDecls=*/false); return TT; @@ -934,10 +934,10 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, { auto AT = AST->getAsConstantArrayType(QualType); - auto A = gcnew CppSharp::ArrayType(); + auto A = gcnew CppSharp::AST::ArrayType(); auto Next = TL->getNextTypeLoc(); A->Type = WalkType(AT->getElementType(), &Next); - A->SizeType = CppSharp::ArrayType::ArraySize::Constant; + A->SizeType = CppSharp::AST::ArrayType::ArraySize::Constant; A->Size = AST->getConstantArrayElementCount(AT); return A; @@ -946,10 +946,10 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, { auto AT = AST->getAsIncompleteArrayType(QualType); - auto A = gcnew CppSharp::ArrayType(); + auto A = gcnew CppSharp::AST::ArrayType(); auto Next = TL->getNextTypeLoc(); A->Type = WalkType(AT->getElementType(), &Next); - A->SizeType = CppSharp::ArrayType::ArraySize::Incomplete; + A->SizeType = CppSharp::AST::ArrayType::ArraySize::Incomplete; return A; } @@ -957,10 +957,10 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, { auto AT = AST->getAsDependentSizedArrayType(QualType); - auto A = gcnew CppSharp::ArrayType(); + auto A = gcnew CppSharp::AST::ArrayType(); auto Next = TL->getNextTypeLoc(); A->Type = WalkType(AT->getElementType(), &Next); - A->SizeType = CppSharp::ArrayType::ArraySize::Dependent; + A->SizeType = CppSharp::AST::ArrayType::ArraySize::Dependent; //A->Size = AT->getSizeExpr(); return A; @@ -972,13 +972,13 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, auto FTL = TL->getAs(); auto RL = FTL.getResultLoc(); - auto F = gcnew CppSharp::FunctionType(); + auto F = gcnew CppSharp::AST::FunctionType(); F->ReturnType = GetQualifiedType(FP->getResultType(), WalkType(FP->getResultType(), &RL)); 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 PTL = PVD->getTypeSourceInfo()->getTypeLoc(); @@ -1006,7 +1006,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, auto MP = Type->getAs(); auto Next = TL->getNextTypeLoc(); - auto MPT = gcnew CppSharp::MemberPointerType(); + auto MPT = gcnew CppSharp::AST::MemberPointerType(); MPT->Pointee = WalkType(MP->getPointeeType(), &Next); return MPT; @@ -1014,10 +1014,10 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, case Type::TemplateSpecialization: { auto TS = Type->getAs(); - auto TST = gcnew CppSharp::TemplateSpecializationType(); + auto TST = gcnew CppSharp::AST::TemplateSpecializationType(); TemplateName Name = TS->getTemplateName(); - TST->Template = safe_cast(WalkDeclaration( + TST->Template = safe_cast(WalkDeclaration( Name.getAsTemplateDecl(), 0, /*IgnoreSystemDecls=*/false)); if (TS->isSugared()) 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) { const TemplateArgument& TA = TS->getArg(I); - auto Arg = CppSharp::TemplateArgument(); + auto Arg = CppSharp::AST::TemplateArgument(); TemplateArgumentLoc ArgLoc; ArgLoc = TSTL.getArgLoc(I); @@ -1051,35 +1051,35 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, { case TemplateArgument::Type: { - Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::Type; + Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::Type; TypeLoc ArgTL; ArgTL = ArgLoc.getTypeSourceInfo()->getTypeLoc(); Arg.Type = GetQualifiedType(TA.getAsType(), WalkType(TA.getAsType(), &ArgTL)); break; } case TemplateArgument::Declaration: - Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::Declaration; + Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::Declaration; Arg.Declaration = WalkDeclaration(TA.getAsDecl(), 0); break; case TemplateArgument::NullPtr: - Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::NullPtr; + Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::NullPtr; break; case TemplateArgument::Integral: - Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::Integral; + Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::Integral; //Arg.Type = WalkType(TA.getIntegralType(), 0); Arg.Integral = TA.getAsIntegral().getLimitedValue(); break; case TemplateArgument::Template: - Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::Template; + Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::Template; break; case TemplateArgument::TemplateExpansion: - Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::TemplateExpansion; + Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::TemplateExpansion; break; case TemplateArgument::Expression: - Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::Expression; + Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::Expression; break; case TemplateArgument::Pack: - Arg.Kind = CppSharp::TemplateArgument::ArgumentKind::Pack; + Arg.Kind = CppSharp::AST::TemplateArgument::ArgumentKind::Pack; break; } @@ -1092,7 +1092,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, { auto TP = Type->getAs(); - auto TPT = gcnew CppSharp::TemplateParameterType(); + auto TPT = gcnew CppSharp::AST::TemplateParameterType(); if (auto Ident = TP->getIdentifier()) TPT->Parameter.Name = marshalString(Ident->getName()); @@ -1103,7 +1103,7 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, { auto TP = Type->getAs(); auto Ty = TP->getReplacementType(); - auto TPT = gcnew CppSharp::TemplateParameterSubstitutionType(); + auto TPT = gcnew CppSharp::AST::TemplateParameterSubstitutionType(); auto Next = TL->getNextTypeLoc(); TPT->Replacement = GetQualifiedType(Ty, WalkType(Ty, &Next)); @@ -1113,23 +1113,23 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, case Type::InjectedClassName: { auto ICN = Type->getAs(); - auto ICNT = gcnew CppSharp::InjectedClassNameType(); - ICNT->Class = safe_cast(WalkDeclaration( + auto ICNT = gcnew CppSharp::AST::InjectedClassNameType(); + ICNT->Class = safe_cast(WalkDeclaration( ICN->getDecl(), 0, /*IgnoreSystemDecls=*/false)); return ICNT; } case Type::DependentName: { auto DN = Type->getAs(); - auto DNT = gcnew CppSharp::DependentNameType(); + auto DNT = gcnew CppSharp::AST::DependentNameType(); return DNT; } case Type::LValueReference: { auto LR = Type->getAs(); - auto P = gcnew CppSharp::PointerType(); - P->Modifier = CppSharp::PointerType::TypeModifier::LVReference; + auto P = gcnew CppSharp::AST::PointerType(); + P->Modifier = CppSharp::AST::PointerType::TypeModifier::LVReference; TypeLoc Next; if (!TL->isNull()) @@ -1144,8 +1144,8 @@ CppSharp::Type^ Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, { auto LR = Type->getAs(); - auto P = gcnew CppSharp::PointerType(); - P->Modifier = CppSharp::PointerType::TypeModifier::RVReference; + auto P = gcnew CppSharp::AST::PointerType(); + P->Modifier = CppSharp::AST::PointerType::TypeModifier::RVReference; TypeLoc Next; 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 clix; @@ -1193,12 +1193,12 @@ CppSharp::Enumeration^ Parser::WalkEnum(clang::EnumDecl* ED) E = NS->FindEnum(Name, /*Create=*/true); if (ED->isScoped()) - E->Modifiers |= CppSharp::Enumeration::EnumModifiers::Scoped; + E->Modifiers |= CppSharp::AST::Enumeration::EnumModifiers::Scoped; // Get the underlying integer backing the enum. QualType IntType = ED->getIntegerType(); E->Type = WalkType(IntType, 0); - E->BuiltinType = safe_cast(WalkType(IntType, 0, + E->BuiltinType = safe_cast(WalkType(IntType, 0, /*DesugarType=*/true)); if (!ED->isThisDeclarationADefinition()) @@ -1216,7 +1216,7 @@ CppSharp::Enumeration^ Parser::WalkEnum(clang::EnumDecl* ED) if (const RawComment* Comment = AST->getRawCommentForAnyRedecl(ECD)) BriefText = Comment->getBriefText(*AST); - auto EnumItem = gcnew CppSharp::Enumeration::Item(); + auto EnumItem = gcnew CppSharp::AST::Enumeration::Item(); EnumItem->Name = marshalString(ECD->getNameAsString()); EnumItem->Value = (int) ECD->getInitVal().getLimitedValue(); EnumItem->Comment = marshalString(BriefText); @@ -1249,7 +1249,7 @@ clang::CallingConv Parser::GetAbiCallConv(clang::CallingConv CC, return CC; } -static CppSharp::CallingConvention ConvertCallConv(clang::CallingConv CC) +static CppSharp::AST::CallingConvention ConvertCallConv(clang::CallingConv CC) { using namespace clang; @@ -1257,23 +1257,23 @@ static CppSharp::CallingConvention ConvertCallConv(clang::CallingConv CC) { case CC_Default: case CC_C: - return CppSharp::CallingConvention::C; + return CppSharp::AST::CallingConvention::C; case CC_X86StdCall: - return CppSharp::CallingConvention::StdCall; + return CppSharp::AST::CallingConvention::StdCall; case CC_X86FastCall: - return CppSharp::CallingConvention::FastCall; + return CppSharp::AST::CallingConvention::FastCall; case CC_X86ThisCall: - return CppSharp::CallingConvention::ThisCall; + return CppSharp::AST::CallingConvention::ThisCall; case CC_X86Pascal: case CC_AAPCS: 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) { using namespace clang; @@ -1308,10 +1308,10 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, CppSharp::Function^ F, auto headEndLoc = SM.getExpansionLoc(FTL.getLParenLoc()); auto headRange = clang::SourceRange(headStartLoc, headEndLoc); - HandlePreprocessedEntities(F, headRange, CppSharp::MacroLocation::FunctionHead); - HandlePreprocessedEntities(F, FTL.getParensRange(), CppSharp::MacroLocation::FunctionParameters); + HandlePreprocessedEntities(F, headRange, CppSharp::AST::MacroLocation::FunctionHead); + HandlePreprocessedEntities(F, FTL.getParensRange(), CppSharp::AST::MacroLocation::FunctionParameters); //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(), @@ -1324,7 +1324,7 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, CppSharp::Function^ F, { ParmVarDecl* VD = (*it); - auto P = gcnew CppSharp::Parameter(); + auto P = gcnew CppSharp::AST::Parameter(); P->Name = marshalString(VD->getNameAsString()); 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) { using namespace clang; @@ -1350,12 +1350,12 @@ CppSharp::Function^ Parser::WalkFunction(clang::FunctionDecl* FD, bool IsDepende assert(NS && "Expected a valid namespace"); auto Name = marshalString(FD->getNameAsString()); - CppSharp::Function^ F = NS->FindFunction(Name, /*Create=*/ false); + CppSharp::AST::Function^ F = NS->FindFunction(Name, /*Create=*/ false); if (F != nullptr) return F; - F = gcnew CppSharp::Function(); + F = gcnew CppSharp::AST::Function(); WalkFunction(FD, F, IsDependent); if (AddToNamespace) @@ -1475,7 +1475,7 @@ void Parser::WalkMacros(clang::PreprocessingRecord* PR) if (Invalid || Expression.empty()) break; - auto macro = gcnew CppSharp::MacroDefinition(); + auto macro = gcnew CppSharp::AST::MacroDefinition(); macro->Name = marshalString(II->getName())->Trim(); macro->Expression = marshalString(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 clix; - auto Var = gcnew CppSharp::Variable(); + auto Var = gcnew CppSharp::AST::Variable(); Var->Name = marshalString(VD->getName()); 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 clix; @@ -1553,9 +1553,9 @@ bool Parser::GetPreprocessedEntityText(clang::PreprocessedEntity* PE, std::strin return !Invalid && !Text.empty(); } -void Parser::HandlePreprocessedEntities(CppSharp::Declaration^ Decl, +void Parser::HandlePreprocessedEntities(CppSharp::AST::Declaration^ Decl, clang::SourceRange sourceRange, - CppSharp::MacroLocation macroLocation) + CppSharp::AST::MacroLocation macroLocation) { using namespace clang; auto PPRecord = C->getPreprocessor().getPreprocessingRecord(); @@ -1566,26 +1566,26 @@ void Parser::HandlePreprocessedEntities(CppSharp::Declaration^ Decl, { PreprocessedEntity* PPEntity = (*it); - CppSharp::PreprocessedEntity^ Entity; + CppSharp::AST::PreprocessedEntity^ Entity; switch(PPEntity->getKind()) { case PreprocessedEntity::MacroExpansionKind: { const MacroExpansion* MD = cast(PPEntity); - Entity = gcnew CppSharp::MacroExpansion(); + Entity = gcnew CppSharp::AST::MacroExpansion(); std::string Text; if (!GetPreprocessedEntityText(PPEntity, Text)) continue; - static_cast(Entity)->Text = + static_cast(Entity)->Text = clix::marshalString(Text); break; } case PreprocessedEntity::MacroDefinitionKind: { const MacroDefinition* MD = cast(PPEntity); - Entity = gcnew CppSharp::MacroDefinition(); + Entity = gcnew CppSharp::AST::MacroDefinition(); break; } 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, /*CanBeDefinition=*/true); } -CppSharp::Declaration^ Parser::WalkDeclaration(clang::Decl* D, +CppSharp::AST::Declaration^ Parser::WalkDeclaration(clang::Decl* D, bool IgnoreSystemDecls, bool CanBeDefinition) { @@ -1631,7 +1631,7 @@ CppSharp::Declaration^ Parser::WalkDeclaration(clang::Decl* D, StringRef AnnotationText = Annotation->getAnnotation(); } - CppSharp::Declaration^ Decl = nullptr; + CppSharp::AST::Declaration^ Decl = nullptr; auto Kind = D->getKind(); switch(D->getKind()) @@ -1671,7 +1671,7 @@ CppSharp::Declaration^ Parser::WalkDeclaration(clang::Decl* D, case Decl::ClassTemplateSpecialization: { auto TS = cast(D); - auto CT = gcnew CppSharp::ClassTemplateSpecialization(); + auto CT = gcnew CppSharp::AST::ClassTemplateSpecialization(); Decl = CT; break; @@ -1679,7 +1679,7 @@ CppSharp::Declaration^ Parser::WalkDeclaration(clang::Decl* D, case Decl::ClassTemplatePartialSpecialization: { auto TS = cast(D); - auto CT = gcnew CppSharp::ClassTemplatePartialSpecialization(); + auto CT = gcnew CppSharp::AST::ClassTemplatePartialSpecialization(); Decl = CT; break; @@ -1764,7 +1764,7 @@ CppSharp::Declaration^ Parser::WalkDeclaration(clang::Decl* D, auto NS = GetNamespace(VD); Decl->Namespace = NS; - NS->Variables->Add(static_cast(Decl)); + NS->Variables->Add(static_cast(Decl)); break; } // Ignore these declarations since they must have been declared in diff --git a/src/Parser/Parser.h b/src/Parser/Parser.h index 5aed4837..8de359c1 100644 --- a/src/Parser/Parser.h +++ b/src/Parser/Parser.h @@ -55,7 +55,7 @@ public ref struct ParserOptions // C/C++ header file name. System::String^ FileName; - CppSharp::Library^ Library; + CppSharp::AST::Library^ Library; // Toolset version - 2005 - 8, 2008 - 9, 2010 - 10, 0 - autoprobe for any. int ToolSetToUse; @@ -101,7 +101,7 @@ public ref struct ParserResult } ParserResultKind Kind; - CppSharp::Library^ Library; + CppSharp::AST::Library^ Library; List^ Diagnostics; }; @@ -131,20 +131,20 @@ protected: // AST traversers void WalkAST(); void WalkMacros(clang::PreprocessingRecord* PR); - CppSharp::Declaration^ WalkDeclaration(clang::Decl* D, + CppSharp::AST::Declaration^ WalkDeclaration(clang::Decl* D, bool IgnoreSystemDecls = true, bool CanBeDefinition = false); - CppSharp::Declaration^ WalkDeclarationDef(clang::Decl* D); - CppSharp::Enumeration^ WalkEnum(clang::EnumDecl*); - CppSharp::Function^ WalkFunction(clang::FunctionDecl*, bool IsDependent = false, + CppSharp::AST::Declaration^ WalkDeclarationDef(clang::Decl* D); + CppSharp::AST::Enumeration^ WalkEnum(clang::EnumDecl*); + CppSharp::AST::Function^ WalkFunction(clang::FunctionDecl*, bool IsDependent = false, bool AddToNamespace = true); - CppSharp::Class^ WalkRecordCXX(clang::CXXRecordDecl*); - CppSharp::Method^ WalkMethodCXX(clang::CXXMethodDecl*); - CppSharp::Field^ WalkFieldCXX(clang::FieldDecl*, CppSharp::Class^); - CppSharp::ClassTemplate^ Parser::WalkClassTemplate(clang::ClassTemplateDecl*); - CppSharp::FunctionTemplate^ Parser::WalkFunctionTemplate( + CppSharp::AST::Class^ WalkRecordCXX(clang::CXXRecordDecl*); + CppSharp::AST::Method^ WalkMethodCXX(clang::CXXMethodDecl*); + CppSharp::AST::Field^ WalkFieldCXX(clang::FieldDecl*, CppSharp::AST::Class^); + CppSharp::AST::ClassTemplate^ Parser::WalkClassTemplate(clang::ClassTemplateDecl*); + CppSharp::AST::FunctionTemplate^ Parser::WalkFunctionTemplate( clang::FunctionTemplateDecl*); - CppSharp::Variable^ WalkVariable(clang::VarDecl*); - CppSharp::Type^ WalkType(clang::QualType, clang::TypeLoc* = 0, + CppSharp::AST::Variable^ WalkVariable(clang::VarDecl*); + CppSharp::AST::Type^ WalkType(clang::QualType, clang::TypeLoc* = 0, bool DesugarType = false); // Clang helpers @@ -153,25 +153,25 @@ protected: std::string GetDeclMangledName(clang::Decl*, clang::TargetCXXABI, bool IsDependent = false); std::string GetTypeName(const clang::Type*); - void HandleComments(clang::Decl* D, CppSharp::Declaration^); - void WalkFunction(clang::FunctionDecl* FD, CppSharp::Function^ F, + void HandleComments(clang::Decl* D, CppSharp::AST::Declaration^); + void WalkFunction(clang::FunctionDecl* FD, CppSharp::AST::Function^ F, bool IsDependent = false); - void HandlePreprocessedEntities(CppSharp::Declaration^ Decl, clang::SourceRange sourceRange, - CppSharp::MacroLocation macroLocation = CppSharp::MacroLocation::Unknown); + void HandlePreprocessedEntities(CppSharp::AST::Declaration^ Decl, clang::SourceRange sourceRange, + CppSharp::AST::MacroLocation macroLocation = CppSharp::AST::MacroLocation::Unknown); bool GetPreprocessedEntityText(clang::PreprocessedEntity*, std::string& Text); - CppSharp::TranslationUnit^ GetTranslationUnit(clang::SourceLocation Loc, + CppSharp::AST::TranslationUnit^ GetTranslationUnit(clang::SourceLocation Loc, SourceLocationKind *Kind = 0); - CppSharp::TranslationUnit^ GetTranslationUnit(const clang::Decl*); + CppSharp::AST::TranslationUnit^ GetTranslationUnit(const clang::Decl*); - CppSharp::DeclarationContext^ GetNamespace(clang::Decl*, clang::DeclContext*); - CppSharp::DeclarationContext^ GetNamespace(clang::Decl*); + CppSharp::AST::DeclarationContext^ GetNamespace(clang::Decl*, clang::DeclContext*); + CppSharp::AST::DeclarationContext^ GetNamespace(clang::Decl*); clang::CallingConv GetAbiCallConv(clang::CallingConv CC, bool IsInstMethod, bool IsVariadic); int Index; - gcroot Lib; + gcroot Lib; gcroot Opts; llvm::OwningPtr C; clang::ASTContext* AST; diff --git a/tests/Hello/Hello.cs b/tests/Hello/Hello.cs index d8e73934..93190f14 100644 --- a/tests/Hello/Hello.cs +++ b/tests/Hello/Hello.cs @@ -1,3 +1,4 @@ +using CppSharp.AST; using CppSharp.Generators; using CppSharp.Utils;