From 79867473732550802a9c206d68e931403fdec69b Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Mon, 18 Jul 2016 00:54:07 +0300 Subject: [PATCH] Added dependent template specialization types to the AST. Signed-off-by: Dimitar Dobrev --- src/AST/ASTVisitor.cs | 30 +++ src/AST/Type.cs | 56 ++++++ src/Core/Parser/ASTConverter.cs | 27 ++- src/CppParser/AST.cpp | 12 ++ src/CppParser/AST.h | 12 ++ src/CppParser/Bindings/CLI/AST.cpp | 73 ++++++++ src/CppParser/Bindings/CLI/AST.h | 44 ++++- .../CppSharp.CppParser.cs | 174 +++++++++++++++++- .../i686-pc-win32-msvc/CppSharp.CppParser.cs | 174 +++++++++++++++++- .../CppSharp.CppParser.cs | 174 +++++++++++++++++- .../CppSharp.CppParser.cs | 174 +++++++++++++++++- .../x86_64-linux-gnu/CppSharp.CppParser.cs | 174 +++++++++++++++++- .../CppSharp.CppParser.cs | 174 +++++++++++++++++- src/CppParser/Parser.cpp | 43 +++++ .../Generators/CLI/CLITypePrinter.cs | 8 + .../Generators/CSharp/CSharpTypePrinter.cs | 8 + .../CheckVirtualOverrideReturnCovariance.cs | 5 + src/Generator/Types/CppTypePrinter.cs | 8 + 18 files changed, 1327 insertions(+), 43 deletions(-) diff --git a/src/AST/ASTVisitor.cs b/src/AST/ASTVisitor.cs index abe39066..e0a6c2ee 100644 --- a/src/AST/ASTVisitor.cs +++ b/src/AST/ASTVisitor.cs @@ -188,6 +188,36 @@ namespace CppSharp.AST return specialization != null && specialization.Visit(this); } + public bool VisitDependentTemplateSpecializationType( + DependentTemplateSpecializationType template, TypeQualifiers quals) + { + if (!VisitType(template, quals)) + return false; + + if (Options.VisitTemplateArguments) + { + foreach (var arg in template.Arguments) + { + switch (arg.Kind) + { + case TemplateArgument.ArgumentKind.Type: + var type = arg.Type.Type; + if (type != null) + type.Visit(this, arg.Type.Qualifiers); + break; + case TemplateArgument.ArgumentKind.Declaration: + arg.Declaration.Visit(this); + break; + } + } + } + + if (template.Desugared != null) + return template.Desugared.Visit(this); + + return false; + } + public virtual bool VisitTemplateParameterType(TemplateParameterType param, TypeQualifiers quals) { diff --git a/src/AST/Type.cs b/src/AST/Type.cs index 01e72b39..384c8f94 100644 --- a/src/AST/Type.cs +++ b/src/AST/Type.cs @@ -681,6 +681,60 @@ namespace CppSharp.AST } } + /// + /// Represents a C++ dependent template specialization type. + /// + public class DependentTemplateSpecializationType : Type + { + public DependentTemplateSpecializationType() + { + Arguments = new List(); + } + + public DependentTemplateSpecializationType(DependentTemplateSpecializationType type) + : base(type) + { + Arguments = type.Arguments.Select( + t => new TemplateArgument + { + Declaration = t.Declaration, + Integral = t.Integral, + Kind = t.Kind, + Type = new QualifiedType((Type) t.Type.Type.Clone(), t.Type.Qualifiers) + }).ToList(); + Desugared = (Type) type.Desugared.Clone(); + } + + public List Arguments; + + public Type Desugared; + + public override T Visit(ITypeVisitor visitor, + TypeQualifiers quals = new TypeQualifiers()) + { + return visitor.VisitDependentTemplateSpecializationType(this, quals); + } + + public override object Clone() + { + return new DependentTemplateSpecializationType(this); + } + + public override bool Equals(object obj) + { + var type = obj as TemplateSpecializationType; + if (type == null) return false; + + return Arguments.SequenceEqual(type.Arguments) && + Desugared == type.Desugared; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + /// /// Represents a C++ template parameter type. /// @@ -1033,6 +1087,8 @@ namespace CppSharp.AST T VisitDecayedType(DecayedType decayed, TypeQualifiers quals); T VisitTemplateSpecializationType(TemplateSpecializationType template, TypeQualifiers quals); + T VisitDependentTemplateSpecializationType( + DependentTemplateSpecializationType template, TypeQualifiers quals); T VisitPrimitiveType(PrimitiveType type, TypeQualifiers quals); T VisitDeclaration(Declaration decl, TypeQualifiers quals); T VisitTemplateParameterType(TemplateParameterType param, diff --git a/src/Core/Parser/ASTConverter.cs b/src/Core/Parser/ASTConverter.cs index 8824ccd0..22185842 100644 --- a/src/Core/Parser/ASTConverter.cs +++ b/src/Core/Parser/ASTConverter.cs @@ -20,6 +20,7 @@ namespace CppSharp public abstract TRet VisitAttributed(AttributedType type); public abstract TRet VisitDecayed(DecayedType type); public abstract TRet VisitTemplateSpecialization(TemplateSpecializationType type); + public abstract TRet VisitDependentTemplateSpecialization(DependentTemplateSpecializationType type); public abstract TRet VisitTemplateParameter(TemplateParameterType type); public abstract TRet VisitTemplateParameterSubstitution(TemplateParameterSubstitutionType type); public abstract TRet VisitInjectedClassName(InjectedClassNameType type); @@ -79,6 +80,11 @@ namespace CppSharp var _type = TemplateSpecializationType.__CreateInstance(type.__Instance); return VisitTemplateSpecialization(_type); } + case TypeKind.DependentTemplateSpecialization: + { + var _type = DependentTemplateSpecializationType.__CreateInstance(type.__Instance); + return VisitDependentTemplateSpecialization(_type); + } case TypeKind.TemplateParameter: { var _type = TemplateParameterType.__CreateInstance(type.__Instance); @@ -564,7 +570,7 @@ namespace CppSharp public override AST.Type VisitTemplateSpecialization(TemplateSpecializationType type) { - var _type = new CppSharp.AST.TemplateSpecializationType(); + var _type = new AST.TemplateSpecializationType(); for (uint i = 0; i < type.ArgumentsCount; ++i) { @@ -581,6 +587,25 @@ namespace CppSharp return _type; } + public override AST.Type VisitDependentTemplateSpecialization( + DependentTemplateSpecializationType type) + { + var _type = new AST.DependentTemplateSpecializationType(); + + for (uint i = 0; i < type.ArgumentsCount; ++i) + { + var arg = type.getArguments(i); + var _arg = VisitTemplateArgument(arg); + _type.Arguments.Add(_arg); + } + + _type.Desugared = Visit(type.Desugared); + + VisitType(type, _type); + + return _type; + } + public override AST.Type VisitTemplateParameter(TemplateParameterType type) { var _type = new AST.TemplateParameterType(); diff --git a/src/CppParser/AST.cpp b/src/CppParser/AST.cpp index 9c2d2227..e15054d4 100644 --- a/src/CppParser/AST.cpp +++ b/src/CppParser/AST.cpp @@ -146,6 +146,7 @@ TemplateArgument::TemplateArgument() : Declaration(0), Integral(0) {} TemplateSpecializationType::TemplateSpecializationType() : Type(TypeKind::TemplateSpecialization), Template(0), Desugared(0) {} + TemplateSpecializationType::TemplateSpecializationType( const TemplateSpecializationType& rhs) : Type(rhs), Arguments(rhs.Arguments), Template(rhs.Template), Desugared(rhs.Desugared) {} @@ -154,6 +155,17 @@ TemplateSpecializationType::~TemplateSpecializationType() {} DEF_VECTOR(TemplateSpecializationType, TemplateArgument, Arguments) +DependentTemplateSpecializationType::DependentTemplateSpecializationType() + : Type(TypeKind::DependentTemplateSpecialization), Desugared(0) {} + +DependentTemplateSpecializationType::DependentTemplateSpecializationType( + const DependentTemplateSpecializationType& rhs) : Type(rhs), + Arguments(rhs.Arguments), Desugared(rhs.Desugared) {} + +DependentTemplateSpecializationType::~DependentTemplateSpecializationType() {} + +DEF_VECTOR(DependentTemplateSpecializationType, TemplateArgument, Arguments) + TemplateParameterType::TemplateParameterType() : Type(TypeKind::TemplateParameter), Parameter(0) {} TemplateParameterType::~TemplateParameterType() {} diff --git a/src/CppParser/AST.h b/src/CppParser/AST.h index c9888861..412d8e9b 100644 --- a/src/CppParser/AST.h +++ b/src/CppParser/AST.h @@ -25,6 +25,7 @@ enum class TypeKind Attributed, Decayed, TemplateSpecialization, + DependentTemplateSpecialization, TemplateParameter, TemplateParameterSubstitution, InjectedClassName, @@ -194,6 +195,17 @@ public: Type* Desugared; }; +class CS_API DependentTemplateSpecializationType : public Type +{ +public: + DependentTemplateSpecializationType(); + DependentTemplateSpecializationType(const DependentTemplateSpecializationType&); + ~DependentTemplateSpecializationType(); + + VECTOR(TemplateArgument, Arguments) + Type* Desugared; +}; + class TypeTemplateParameter; class CS_API TemplateParameterType : public Type diff --git a/src/CppParser/Bindings/CLI/AST.cpp b/src/CppParser/Bindings/CLI/AST.cpp index 85b513b8..50f8d0a0 100644 --- a/src/CppParser/Bindings/CLI/AST.cpp +++ b/src/CppParser/Bindings/CLI/AST.cpp @@ -801,6 +801,79 @@ void CppSharp::Parser::AST::TemplateSpecializationType::Desugared::set(CppSharp: ((::CppSharp::CppParser::AST::TemplateSpecializationType*)NativePtr)->Desugared = (::CppSharp::CppParser::AST::Type*)value->NativePtr; } +CppSharp::Parser::AST::DependentTemplateSpecializationType::DependentTemplateSpecializationType(::CppSharp::CppParser::AST::DependentTemplateSpecializationType* native) + : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)native) +{ +} + +CppSharp::Parser::AST::DependentTemplateSpecializationType^ CppSharp::Parser::AST::DependentTemplateSpecializationType::__CreateInstance(::System::IntPtr native) +{ + return gcnew ::CppSharp::Parser::AST::DependentTemplateSpecializationType((::CppSharp::CppParser::AST::DependentTemplateSpecializationType*) native.ToPointer()); +} + +CppSharp::Parser::AST::DependentTemplateSpecializationType::~DependentTemplateSpecializationType() +{ + if (NativePtr) + { + auto __nativePtr = NativePtr; + NativePtr = 0; + delete (::CppSharp::CppParser::AST::DependentTemplateSpecializationType*) __nativePtr; + } +} + +CppSharp::Parser::AST::DependentTemplateSpecializationType::DependentTemplateSpecializationType() + : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr) +{ + __ownsNativeInstance = true; + NativePtr = new ::CppSharp::CppParser::AST::DependentTemplateSpecializationType(); +} + +CppSharp::Parser::AST::DependentTemplateSpecializationType::DependentTemplateSpecializationType(CppSharp::Parser::AST::DependentTemplateSpecializationType^ _0) + : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr) +{ + __ownsNativeInstance = true; + if (ReferenceEquals(_0, nullptr)) + throw gcnew ::System::ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); + auto &__arg0 = *(::CppSharp::CppParser::AST::DependentTemplateSpecializationType*)_0->NativePtr; + NativePtr = new ::CppSharp::CppParser::AST::DependentTemplateSpecializationType(__arg0); +} + +CppSharp::Parser::AST::TemplateArgument^ CppSharp::Parser::AST::DependentTemplateSpecializationType::getArguments(unsigned int i) +{ + auto __ret = ((::CppSharp::CppParser::AST::DependentTemplateSpecializationType*)NativePtr)->getArguments(i); + auto ____ret = new ::CppSharp::CppParser::AST::TemplateArgument(__ret); + return (____ret == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::TemplateArgument((::CppSharp::CppParser::AST::TemplateArgument*)____ret); +} + +void CppSharp::Parser::AST::DependentTemplateSpecializationType::addArguments(CppSharp::Parser::AST::TemplateArgument^ s) +{ + if (ReferenceEquals(s, nullptr)) + throw gcnew ::System::ArgumentNullException("s", "Cannot be null because it is a C++ reference (&)."); + auto &__arg0 = *(::CppSharp::CppParser::AST::TemplateArgument*)s->NativePtr; + ((::CppSharp::CppParser::AST::DependentTemplateSpecializationType*)NativePtr)->addArguments(__arg0); +} + +void CppSharp::Parser::AST::DependentTemplateSpecializationType::clearArguments() +{ + ((::CppSharp::CppParser::AST::DependentTemplateSpecializationType*)NativePtr)->clearArguments(); +} + +unsigned int CppSharp::Parser::AST::DependentTemplateSpecializationType::ArgumentsCount::get() +{ + auto __ret = ((::CppSharp::CppParser::AST::DependentTemplateSpecializationType*)NativePtr)->getArgumentsCount(); + return __ret; +} + +CppSharp::Parser::AST::Type^ CppSharp::Parser::AST::DependentTemplateSpecializationType::Desugared::get() +{ + return (((::CppSharp::CppParser::AST::DependentTemplateSpecializationType*)NativePtr)->Desugared == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)((::CppSharp::CppParser::AST::DependentTemplateSpecializationType*)NativePtr)->Desugared); +} + +void CppSharp::Parser::AST::DependentTemplateSpecializationType::Desugared::set(CppSharp::Parser::AST::Type^ value) +{ + ((::CppSharp::CppParser::AST::DependentTemplateSpecializationType*)NativePtr)->Desugared = (::CppSharp::CppParser::AST::Type*)value->NativePtr; +} + CppSharp::Parser::AST::TemplateParameterType::TemplateParameterType(::CppSharp::CppParser::AST::TemplateParameterType* native) : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)native) { diff --git a/src/CppParser/Bindings/CLI/AST.h b/src/CppParser/Bindings/CLI/AST.h index a74b21d2..f6a7a0a5 100644 --- a/src/CppParser/Bindings/CLI/AST.h +++ b/src/CppParser/Bindings/CLI/AST.h @@ -46,6 +46,7 @@ namespace CppSharp ref class Declaration; ref class DeclarationContext; ref class DependentNameType; + ref class DependentTemplateSpecializationType; ref class Enumeration; ref class Expression; ref class Field; @@ -126,12 +127,13 @@ namespace CppSharp Attributed = 6, Decayed = 7, TemplateSpecialization = 8, - TemplateParameter = 9, - TemplateParameterSubstitution = 10, - InjectedClassName = 11, - DependentName = 12, - PackExpansion = 13, - Builtin = 14 + DependentTemplateSpecialization = 9, + TemplateParameter = 10, + TemplateParameterSubstitution = 11, + InjectedClassName = 12, + DependentName = 13, + PackExpansion = 14, + Builtin = 15 }; public enum struct DeclarationKind @@ -786,6 +788,36 @@ namespace CppSharp void clearArguments(); }; + public ref class DependentTemplateSpecializationType : CppSharp::Parser::AST::Type + { + public: + + DependentTemplateSpecializationType(::CppSharp::CppParser::AST::DependentTemplateSpecializationType* native); + static DependentTemplateSpecializationType^ __CreateInstance(::System::IntPtr native); + DependentTemplateSpecializationType(); + + DependentTemplateSpecializationType(CppSharp::Parser::AST::DependentTemplateSpecializationType^ _0); + + ~DependentTemplateSpecializationType(); + + property unsigned int ArgumentsCount + { + unsigned int get(); + } + + property CppSharp::Parser::AST::Type^ Desugared + { + CppSharp::Parser::AST::Type^ get(); + void set(CppSharp::Parser::AST::Type^); + } + + CppSharp::Parser::AST::TemplateArgument^ getArguments(unsigned int i); + + void addArguments(CppSharp::Parser::AST::TemplateArgument^ s); + + void clearArguments(); + }; + public ref class TemplateParameterType : CppSharp::Parser::AST::Type { public: diff --git a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs index 82e8c6d2..d2d5107f 100644 --- a/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs @@ -25,12 +25,13 @@ namespace CppSharp Attributed = 6, Decayed = 7, TemplateSpecialization = 8, - TemplateParameter = 9, - TemplateParameterSubstitution = 10, - InjectedClassName = 11, - DependentName = 12, - PackExpansion = 13, - Builtin = 14 + DependentTemplateSpecialization = 9, + TemplateParameter = 10, + TemplateParameterSubstitution = 11, + InjectedClassName = 12, + DependentName = 13, + PackExpansion = 14, + Builtin = 15 } public enum DeclarationKind @@ -1935,6 +1936,167 @@ namespace CppSharp } } + public unsafe partial class DependentTemplateSpecializationType : global::CppSharp.Parser.AST.Type, IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 24)] + public new partial struct Internal + { + [FieldOffset(0)] + public global::CppSharp.Parser.AST.TypeKind Kind; + + [FieldOffset(4)] + public byte IsDependent; + + [FieldOffset(20)] + public global::System.IntPtr Desugared; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationTypeC2Ev")] + internal static extern void ctor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationTypeC2ERKS2_")] + internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr _0); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationTypeD2Ev")] + internal static extern void dtor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType12getArgumentsEj")] + internal static extern void getArguments_0(global::System.IntPtr @return, global::System.IntPtr instance, uint i); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType12addArgumentsERNS1_16TemplateArgumentE")] + internal static extern void addArguments_0(global::System.IntPtr instance, global::System.IntPtr s); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType14clearArgumentsEv")] + internal static extern void clearArguments_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType17getArgumentsCountEv")] + internal static extern uint getArgumentsCount_0(global::System.IntPtr instance); + } + + public static new DependentTemplateSpecializationType __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new DependentTemplateSpecializationType(native.ToPointer(), skipVTables); + } + + public static DependentTemplateSpecializationType __CreateInstance(DependentTemplateSpecializationType.Internal native, bool skipVTables = false) + { + return new DependentTemplateSpecializationType(native, skipVTables); + } + + private static void* __CopyValue(DependentTemplateSpecializationType.Internal native) + { + var ret = Marshal.AllocHGlobal(24); + global::CppSharp.Parser.AST.DependentTemplateSpecializationType.Internal.cctor_1(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private DependentTemplateSpecializationType(DependentTemplateSpecializationType.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected DependentTemplateSpecializationType(void* native, bool skipVTables = false) + : base((void*) null) + { + __PointerAdjustment = 0; + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public DependentTemplateSpecializationType() + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(24); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public DependentTemplateSpecializationType(global::CppSharp.Parser.AST.DependentTemplateSpecializationType _0) + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(24); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + if (ReferenceEquals(_0, null)) + throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = _0.__Instance; + Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); + } + + protected override void Dispose(bool disposing) + { + global::CppSharp.Parser.AST.Type __dummy; + NativeToManagedMap.TryRemove(__Instance, out __dummy); + Internal.dtor_0((__Instance + __PointerAdjustment)); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + } + + public global::CppSharp.Parser.AST.TemplateArgument getArguments(uint i) + { + var __ret = new global::CppSharp.Parser.AST.TemplateArgument.Internal(); + Internal.getArguments_0(new IntPtr(&__ret), (__Instance + __PointerAdjustment), i); + return global::CppSharp.Parser.AST.TemplateArgument.__CreateInstance(__ret); + } + + public void addArguments(global::CppSharp.Parser.AST.TemplateArgument s) + { + if (ReferenceEquals(s, null)) + throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = s.__Instance; + Internal.addArguments_0((__Instance + __PointerAdjustment), __arg0); + } + + public void clearArguments() + { + Internal.clearArguments_0((__Instance + __PointerAdjustment)); + } + + public uint ArgumentsCount + { + get + { + var __ret = Internal.getArgumentsCount_0((__Instance + __PointerAdjustment)); + return __ret; + } + } + + public global::CppSharp.Parser.AST.Type Desugared + { + get + { + global::CppSharp.Parser.AST.Type __result0; + if (((Internal*) __Instance)->Desugared == IntPtr.Zero) __result0 = null; + else if (global::CppSharp.Parser.AST.Type.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Desugared)) + __result0 = (global::CppSharp.Parser.AST.Type) global::CppSharp.Parser.AST.Type.NativeToManagedMap[((Internal*) __Instance)->Desugared]; + else __result0 = global::CppSharp.Parser.AST.Type.__CreateInstance(((Internal*) __Instance)->Desugared); + return __result0; + } + + set + { + ((Internal*) __Instance)->Desugared = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; + } + } + } + public unsafe partial class TemplateParameterType : global::CppSharp.Parser.AST.Type, IDisposable { [StructLayout(LayoutKind.Explicit, Size = 24)] diff --git a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs index ef488071..6b1c4132 100644 --- a/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs @@ -25,12 +25,13 @@ namespace CppSharp Attributed = 6, Decayed = 7, TemplateSpecialization = 8, - TemplateParameter = 9, - TemplateParameterSubstitution = 10, - InjectedClassName = 11, - DependentName = 12, - PackExpansion = 13, - Builtin = 14 + DependentTemplateSpecialization = 9, + TemplateParameter = 10, + TemplateParameterSubstitution = 11, + InjectedClassName = 12, + DependentName = 13, + PackExpansion = 14, + Builtin = 15 } public enum DeclarationKind @@ -1935,6 +1936,167 @@ namespace CppSharp } } + public unsafe partial class DependentTemplateSpecializationType : global::CppSharp.Parser.AST.Type, IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 24)] + public new partial struct Internal + { + [FieldOffset(0)] + public global::CppSharp.Parser.AST.TypeKind Kind; + + [FieldOffset(4)] + public byte IsDependent; + + [FieldOffset(20)] + public global::System.IntPtr Desugared; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="??0DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QAE@XZ")] + internal static extern global::System.IntPtr ctor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="??0DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QAE@ABV0123@@Z")] + internal static extern global::System.IntPtr cctor_1(global::System.IntPtr instance, global::System.IntPtr _0); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="??1DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QAE@XZ")] + internal static extern void dtor_0(global::System.IntPtr instance, int delete); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="?getArguments@DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QAE?AUTemplateArgument@234@I@Z")] + internal static extern void getArguments_0(global::System.IntPtr instance, global::System.IntPtr @return, uint i); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="?addArguments@DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QAEXAAUTemplateArgument@234@@Z")] + internal static extern void addArguments_0(global::System.IntPtr instance, global::System.IntPtr s); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="?clearArguments@DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QAEXXZ")] + internal static extern void clearArguments_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="?getArgumentsCount@DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QAEIXZ")] + internal static extern uint getArgumentsCount_0(global::System.IntPtr instance); + } + + public static new DependentTemplateSpecializationType __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new DependentTemplateSpecializationType(native.ToPointer(), skipVTables); + } + + public static DependentTemplateSpecializationType __CreateInstance(DependentTemplateSpecializationType.Internal native, bool skipVTables = false) + { + return new DependentTemplateSpecializationType(native, skipVTables); + } + + private static void* __CopyValue(DependentTemplateSpecializationType.Internal native) + { + var ret = Marshal.AllocHGlobal(24); + global::CppSharp.Parser.AST.DependentTemplateSpecializationType.Internal.cctor_1(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private DependentTemplateSpecializationType(DependentTemplateSpecializationType.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected DependentTemplateSpecializationType(void* native, bool skipVTables = false) + : base((void*) null) + { + __PointerAdjustment = 0; + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public DependentTemplateSpecializationType() + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(24); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public DependentTemplateSpecializationType(global::CppSharp.Parser.AST.DependentTemplateSpecializationType _0) + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(24); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + if (ReferenceEquals(_0, null)) + throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = _0.__Instance; + Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); + } + + protected override void Dispose(bool disposing) + { + global::CppSharp.Parser.AST.Type __dummy; + NativeToManagedMap.TryRemove(__Instance, out __dummy); + Internal.dtor_0((__Instance + __PointerAdjustment), 0); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + } + + public global::CppSharp.Parser.AST.TemplateArgument getArguments(uint i) + { + var __ret = new global::CppSharp.Parser.AST.TemplateArgument.Internal(); + Internal.getArguments_0((__Instance + __PointerAdjustment), new IntPtr(&__ret), i); + return global::CppSharp.Parser.AST.TemplateArgument.__CreateInstance(__ret); + } + + public void addArguments(global::CppSharp.Parser.AST.TemplateArgument s) + { + if (ReferenceEquals(s, null)) + throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = s.__Instance; + Internal.addArguments_0((__Instance + __PointerAdjustment), __arg0); + } + + public void clearArguments() + { + Internal.clearArguments_0((__Instance + __PointerAdjustment)); + } + + public uint ArgumentsCount + { + get + { + var __ret = Internal.getArgumentsCount_0((__Instance + __PointerAdjustment)); + return __ret; + } + } + + public global::CppSharp.Parser.AST.Type Desugared + { + get + { + global::CppSharp.Parser.AST.Type __result0; + if (((Internal*) __Instance)->Desugared == IntPtr.Zero) __result0 = null; + else if (global::CppSharp.Parser.AST.Type.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Desugared)) + __result0 = (global::CppSharp.Parser.AST.Type) global::CppSharp.Parser.AST.Type.NativeToManagedMap[((Internal*) __Instance)->Desugared]; + else __result0 = global::CppSharp.Parser.AST.Type.__CreateInstance(((Internal*) __Instance)->Desugared); + return __result0; + } + + set + { + ((Internal*) __Instance)->Desugared = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; + } + } + } + public unsafe partial class TemplateParameterType : global::CppSharp.Parser.AST.Type, IDisposable { [StructLayout(LayoutKind.Explicit, Size = 24)] diff --git a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs index b4cabc11..1da768b3 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs @@ -25,12 +25,13 @@ namespace CppSharp Attributed = 6, Decayed = 7, TemplateSpecialization = 8, - TemplateParameter = 9, - TemplateParameterSubstitution = 10, - InjectedClassName = 11, - DependentName = 12, - PackExpansion = 13, - Builtin = 14 + DependentTemplateSpecialization = 9, + TemplateParameter = 10, + TemplateParameterSubstitution = 11, + InjectedClassName = 12, + DependentName = 13, + PackExpansion = 14, + Builtin = 15 } public enum DeclarationKind @@ -1935,6 +1936,167 @@ namespace CppSharp } } + public unsafe partial class DependentTemplateSpecializationType : global::CppSharp.Parser.AST.Type, IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 40)] + public new partial struct Internal + { + [FieldOffset(0)] + public global::CppSharp.Parser.AST.TypeKind Kind; + + [FieldOffset(4)] + public byte IsDependent; + + [FieldOffset(32)] + public global::System.IntPtr Desugared; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationTypeC2Ev")] + internal static extern void ctor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationTypeC2ERKS2_")] + internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr _0); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationTypeD2Ev")] + internal static extern void dtor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType12getArgumentsEj")] + internal static extern void getArguments_0(global::System.IntPtr @return, global::System.IntPtr instance, uint i); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType12addArgumentsERNS1_16TemplateArgumentE")] + internal static extern void addArguments_0(global::System.IntPtr instance, global::System.IntPtr s); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType14clearArgumentsEv")] + internal static extern void clearArguments_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType17getArgumentsCountEv")] + internal static extern uint getArgumentsCount_0(global::System.IntPtr instance); + } + + public static new DependentTemplateSpecializationType __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new DependentTemplateSpecializationType(native.ToPointer(), skipVTables); + } + + public static DependentTemplateSpecializationType __CreateInstance(DependentTemplateSpecializationType.Internal native, bool skipVTables = false) + { + return new DependentTemplateSpecializationType(native, skipVTables); + } + + private static void* __CopyValue(DependentTemplateSpecializationType.Internal native) + { + var ret = Marshal.AllocHGlobal(40); + global::CppSharp.Parser.AST.DependentTemplateSpecializationType.Internal.cctor_1(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private DependentTemplateSpecializationType(DependentTemplateSpecializationType.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected DependentTemplateSpecializationType(void* native, bool skipVTables = false) + : base((void*) null) + { + __PointerAdjustment = 0; + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public DependentTemplateSpecializationType() + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(40); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public DependentTemplateSpecializationType(global::CppSharp.Parser.AST.DependentTemplateSpecializationType _0) + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(40); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + if (ReferenceEquals(_0, null)) + throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = _0.__Instance; + Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); + } + + protected override void Dispose(bool disposing) + { + global::CppSharp.Parser.AST.Type __dummy; + NativeToManagedMap.TryRemove(__Instance, out __dummy); + Internal.dtor_0((__Instance + __PointerAdjustment)); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + } + + public global::CppSharp.Parser.AST.TemplateArgument getArguments(uint i) + { + var __ret = new global::CppSharp.Parser.AST.TemplateArgument.Internal(); + Internal.getArguments_0(new IntPtr(&__ret), (__Instance + __PointerAdjustment), i); + return global::CppSharp.Parser.AST.TemplateArgument.__CreateInstance(__ret); + } + + public void addArguments(global::CppSharp.Parser.AST.TemplateArgument s) + { + if (ReferenceEquals(s, null)) + throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = s.__Instance; + Internal.addArguments_0((__Instance + __PointerAdjustment), __arg0); + } + + public void clearArguments() + { + Internal.clearArguments_0((__Instance + __PointerAdjustment)); + } + + public uint ArgumentsCount + { + get + { + var __ret = Internal.getArgumentsCount_0((__Instance + __PointerAdjustment)); + return __ret; + } + } + + public global::CppSharp.Parser.AST.Type Desugared + { + get + { + global::CppSharp.Parser.AST.Type __result0; + if (((Internal*) __Instance)->Desugared == IntPtr.Zero) __result0 = null; + else if (global::CppSharp.Parser.AST.Type.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Desugared)) + __result0 = (global::CppSharp.Parser.AST.Type) global::CppSharp.Parser.AST.Type.NativeToManagedMap[((Internal*) __Instance)->Desugared]; + else __result0 = global::CppSharp.Parser.AST.Type.__CreateInstance(((Internal*) __Instance)->Desugared); + return __result0; + } + + set + { + ((Internal*) __Instance)->Desugared = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; + } + } + } + public unsafe partial class TemplateParameterType : global::CppSharp.Parser.AST.Type, IDisposable { [StructLayout(LayoutKind.Explicit, Size = 32)] diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs index 46dfb1ab..b3a4a36b 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs @@ -25,12 +25,13 @@ namespace CppSharp Attributed = 6, Decayed = 7, TemplateSpecialization = 8, - TemplateParameter = 9, - TemplateParameterSubstitution = 10, - InjectedClassName = 11, - DependentName = 12, - PackExpansion = 13, - Builtin = 14 + DependentTemplateSpecialization = 9, + TemplateParameter = 10, + TemplateParameterSubstitution = 11, + InjectedClassName = 12, + DependentName = 13, + PackExpansion = 14, + Builtin = 15 } public enum DeclarationKind @@ -1935,6 +1936,167 @@ namespace CppSharp } } + public unsafe partial class DependentTemplateSpecializationType : global::CppSharp.Parser.AST.Type, IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 40)] + public new partial struct Internal + { + [FieldOffset(0)] + public global::CppSharp.Parser.AST.TypeKind Kind; + + [FieldOffset(4)] + public byte IsDependent; + + [FieldOffset(32)] + public global::System.IntPtr Desugared; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationTypeC2Ev")] + internal static extern void ctor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationTypeC2ERKS2_")] + internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr _0); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationTypeD2Ev")] + internal static extern void dtor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType12getArgumentsEj")] + internal static extern void getArguments_0(global::System.IntPtr @return, global::System.IntPtr instance, uint i); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType12addArgumentsERNS1_16TemplateArgumentE")] + internal static extern void addArguments_0(global::System.IntPtr instance, global::System.IntPtr s); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType14clearArgumentsEv")] + internal static extern void clearArguments_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType17getArgumentsCountEv")] + internal static extern uint getArgumentsCount_0(global::System.IntPtr instance); + } + + public static new DependentTemplateSpecializationType __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new DependentTemplateSpecializationType(native.ToPointer(), skipVTables); + } + + public static DependentTemplateSpecializationType __CreateInstance(DependentTemplateSpecializationType.Internal native, bool skipVTables = false) + { + return new DependentTemplateSpecializationType(native, skipVTables); + } + + private static void* __CopyValue(DependentTemplateSpecializationType.Internal native) + { + var ret = Marshal.AllocHGlobal(40); + global::CppSharp.Parser.AST.DependentTemplateSpecializationType.Internal.cctor_1(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private DependentTemplateSpecializationType(DependentTemplateSpecializationType.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected DependentTemplateSpecializationType(void* native, bool skipVTables = false) + : base((void*) null) + { + __PointerAdjustment = 0; + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public DependentTemplateSpecializationType() + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(40); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public DependentTemplateSpecializationType(global::CppSharp.Parser.AST.DependentTemplateSpecializationType _0) + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(40); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + if (ReferenceEquals(_0, null)) + throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = _0.__Instance; + Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); + } + + protected override void Dispose(bool disposing) + { + global::CppSharp.Parser.AST.Type __dummy; + NativeToManagedMap.TryRemove(__Instance, out __dummy); + Internal.dtor_0((__Instance + __PointerAdjustment)); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + } + + public global::CppSharp.Parser.AST.TemplateArgument getArguments(uint i) + { + var __ret = new global::CppSharp.Parser.AST.TemplateArgument.Internal(); + Internal.getArguments_0(new IntPtr(&__ret), (__Instance + __PointerAdjustment), i); + return global::CppSharp.Parser.AST.TemplateArgument.__CreateInstance(__ret); + } + + public void addArguments(global::CppSharp.Parser.AST.TemplateArgument s) + { + if (ReferenceEquals(s, null)) + throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = s.__Instance; + Internal.addArguments_0((__Instance + __PointerAdjustment), __arg0); + } + + public void clearArguments() + { + Internal.clearArguments_0((__Instance + __PointerAdjustment)); + } + + public uint ArgumentsCount + { + get + { + var __ret = Internal.getArgumentsCount_0((__Instance + __PointerAdjustment)); + return __ret; + } + } + + public global::CppSharp.Parser.AST.Type Desugared + { + get + { + global::CppSharp.Parser.AST.Type __result0; + if (((Internal*) __Instance)->Desugared == IntPtr.Zero) __result0 = null; + else if (global::CppSharp.Parser.AST.Type.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Desugared)) + __result0 = (global::CppSharp.Parser.AST.Type) global::CppSharp.Parser.AST.Type.NativeToManagedMap[((Internal*) __Instance)->Desugared]; + else __result0 = global::CppSharp.Parser.AST.Type.__CreateInstance(((Internal*) __Instance)->Desugared); + return __result0; + } + + set + { + ((Internal*) __Instance)->Desugared = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; + } + } + } + public unsafe partial class TemplateParameterType : global::CppSharp.Parser.AST.Type, IDisposable { [StructLayout(LayoutKind.Explicit, Size = 32)] diff --git a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs index 46dfb1ab..b3a4a36b 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs @@ -25,12 +25,13 @@ namespace CppSharp Attributed = 6, Decayed = 7, TemplateSpecialization = 8, - TemplateParameter = 9, - TemplateParameterSubstitution = 10, - InjectedClassName = 11, - DependentName = 12, - PackExpansion = 13, - Builtin = 14 + DependentTemplateSpecialization = 9, + TemplateParameter = 10, + TemplateParameterSubstitution = 11, + InjectedClassName = 12, + DependentName = 13, + PackExpansion = 14, + Builtin = 15 } public enum DeclarationKind @@ -1935,6 +1936,167 @@ namespace CppSharp } } + public unsafe partial class DependentTemplateSpecializationType : global::CppSharp.Parser.AST.Type, IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 40)] + public new partial struct Internal + { + [FieldOffset(0)] + public global::CppSharp.Parser.AST.TypeKind Kind; + + [FieldOffset(4)] + public byte IsDependent; + + [FieldOffset(32)] + public global::System.IntPtr Desugared; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationTypeC2Ev")] + internal static extern void ctor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationTypeC2ERKS2_")] + internal static extern void cctor_1(global::System.IntPtr instance, global::System.IntPtr _0); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationTypeD2Ev")] + internal static extern void dtor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType12getArgumentsEj")] + internal static extern void getArguments_0(global::System.IntPtr @return, global::System.IntPtr instance, uint i); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType12addArgumentsERNS1_16TemplateArgumentE")] + internal static extern void addArguments_0(global::System.IntPtr instance, global::System.IntPtr s); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType14clearArgumentsEv")] + internal static extern void clearArguments_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST35DependentTemplateSpecializationType17getArgumentsCountEv")] + internal static extern uint getArgumentsCount_0(global::System.IntPtr instance); + } + + public static new DependentTemplateSpecializationType __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new DependentTemplateSpecializationType(native.ToPointer(), skipVTables); + } + + public static DependentTemplateSpecializationType __CreateInstance(DependentTemplateSpecializationType.Internal native, bool skipVTables = false) + { + return new DependentTemplateSpecializationType(native, skipVTables); + } + + private static void* __CopyValue(DependentTemplateSpecializationType.Internal native) + { + var ret = Marshal.AllocHGlobal(40); + global::CppSharp.Parser.AST.DependentTemplateSpecializationType.Internal.cctor_1(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private DependentTemplateSpecializationType(DependentTemplateSpecializationType.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected DependentTemplateSpecializationType(void* native, bool skipVTables = false) + : base((void*) null) + { + __PointerAdjustment = 0; + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public DependentTemplateSpecializationType() + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(40); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public DependentTemplateSpecializationType(global::CppSharp.Parser.AST.DependentTemplateSpecializationType _0) + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(40); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + if (ReferenceEquals(_0, null)) + throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = _0.__Instance; + Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); + } + + protected override void Dispose(bool disposing) + { + global::CppSharp.Parser.AST.Type __dummy; + NativeToManagedMap.TryRemove(__Instance, out __dummy); + Internal.dtor_0((__Instance + __PointerAdjustment)); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + } + + public global::CppSharp.Parser.AST.TemplateArgument getArguments(uint i) + { + var __ret = new global::CppSharp.Parser.AST.TemplateArgument.Internal(); + Internal.getArguments_0(new IntPtr(&__ret), (__Instance + __PointerAdjustment), i); + return global::CppSharp.Parser.AST.TemplateArgument.__CreateInstance(__ret); + } + + public void addArguments(global::CppSharp.Parser.AST.TemplateArgument s) + { + if (ReferenceEquals(s, null)) + throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = s.__Instance; + Internal.addArguments_0((__Instance + __PointerAdjustment), __arg0); + } + + public void clearArguments() + { + Internal.clearArguments_0((__Instance + __PointerAdjustment)); + } + + public uint ArgumentsCount + { + get + { + var __ret = Internal.getArgumentsCount_0((__Instance + __PointerAdjustment)); + return __ret; + } + } + + public global::CppSharp.Parser.AST.Type Desugared + { + get + { + global::CppSharp.Parser.AST.Type __result0; + if (((Internal*) __Instance)->Desugared == IntPtr.Zero) __result0 = null; + else if (global::CppSharp.Parser.AST.Type.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Desugared)) + __result0 = (global::CppSharp.Parser.AST.Type) global::CppSharp.Parser.AST.Type.NativeToManagedMap[((Internal*) __Instance)->Desugared]; + else __result0 = global::CppSharp.Parser.AST.Type.__CreateInstance(((Internal*) __Instance)->Desugared); + return __result0; + } + + set + { + ((Internal*) __Instance)->Desugared = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; + } + } + } + public unsafe partial class TemplateParameterType : global::CppSharp.Parser.AST.Type, IDisposable { [StructLayout(LayoutKind.Explicit, Size = 32)] diff --git a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs index 0ac7fd28..05aa8420 100644 --- a/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs +++ b/src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs @@ -25,12 +25,13 @@ namespace CppSharp Attributed = 6, Decayed = 7, TemplateSpecialization = 8, - TemplateParameter = 9, - TemplateParameterSubstitution = 10, - InjectedClassName = 11, - DependentName = 12, - PackExpansion = 13, - Builtin = 14 + DependentTemplateSpecialization = 9, + TemplateParameter = 10, + TemplateParameterSubstitution = 11, + InjectedClassName = 12, + DependentName = 13, + PackExpansion = 14, + Builtin = 15 } public enum DeclarationKind @@ -1935,6 +1936,167 @@ namespace CppSharp } } + public unsafe partial class DependentTemplateSpecializationType : global::CppSharp.Parser.AST.Type, IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 40)] + public new partial struct Internal + { + [FieldOffset(0)] + public global::CppSharp.Parser.AST.TypeKind Kind; + + [FieldOffset(4)] + public byte IsDependent; + + [FieldOffset(32)] + public global::System.IntPtr Desugared; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="??0DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QEAA@XZ")] + internal static extern global::System.IntPtr ctor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="??0DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QEAA@AEBV0123@@Z")] + internal static extern global::System.IntPtr cctor_1(global::System.IntPtr instance, global::System.IntPtr _0); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="??1DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QEAA@XZ")] + internal static extern void dtor_0(global::System.IntPtr instance, int delete); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="?getArguments@DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QEAA?AUTemplateArgument@234@I@Z")] + internal static extern void getArguments_0(global::System.IntPtr instance, global::System.IntPtr @return, uint i); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="?addArguments@DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QEAAXAEAUTemplateArgument@234@@Z")] + internal static extern void addArguments_0(global::System.IntPtr instance, global::System.IntPtr s); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="?clearArguments@DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QEAAXXZ")] + internal static extern void clearArguments_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="?getArgumentsCount@DependentTemplateSpecializationType@AST@CppParser@CppSharp@@QEAAIXZ")] + internal static extern uint getArgumentsCount_0(global::System.IntPtr instance); + } + + public static new DependentTemplateSpecializationType __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new DependentTemplateSpecializationType(native.ToPointer(), skipVTables); + } + + public static DependentTemplateSpecializationType __CreateInstance(DependentTemplateSpecializationType.Internal native, bool skipVTables = false) + { + return new DependentTemplateSpecializationType(native, skipVTables); + } + + private static void* __CopyValue(DependentTemplateSpecializationType.Internal native) + { + var ret = Marshal.AllocHGlobal(40); + global::CppSharp.Parser.AST.DependentTemplateSpecializationType.Internal.cctor_1(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private DependentTemplateSpecializationType(DependentTemplateSpecializationType.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected DependentTemplateSpecializationType(void* native, bool skipVTables = false) + : base((void*) null) + { + __PointerAdjustment = 0; + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public DependentTemplateSpecializationType() + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(40); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public DependentTemplateSpecializationType(global::CppSharp.Parser.AST.DependentTemplateSpecializationType _0) + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(40); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + if (ReferenceEquals(_0, null)) + throw new global::System.ArgumentNullException("_0", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = _0.__Instance; + Internal.cctor_1((__Instance + __PointerAdjustment), __arg0); + } + + protected override void Dispose(bool disposing) + { + global::CppSharp.Parser.AST.Type __dummy; + NativeToManagedMap.TryRemove(__Instance, out __dummy); + Internal.dtor_0((__Instance + __PointerAdjustment), 0); + if (__ownsNativeInstance) + Marshal.FreeHGlobal(__Instance); + } + + public global::CppSharp.Parser.AST.TemplateArgument getArguments(uint i) + { + var __ret = new global::CppSharp.Parser.AST.TemplateArgument.Internal(); + Internal.getArguments_0((__Instance + __PointerAdjustment), new IntPtr(&__ret), i); + return global::CppSharp.Parser.AST.TemplateArgument.__CreateInstance(__ret); + } + + public void addArguments(global::CppSharp.Parser.AST.TemplateArgument s) + { + if (ReferenceEquals(s, null)) + throw new global::System.ArgumentNullException("s", "Cannot be null because it is a C++ reference (&)."); + var __arg0 = s.__Instance; + Internal.addArguments_0((__Instance + __PointerAdjustment), __arg0); + } + + public void clearArguments() + { + Internal.clearArguments_0((__Instance + __PointerAdjustment)); + } + + public uint ArgumentsCount + { + get + { + var __ret = Internal.getArgumentsCount_0((__Instance + __PointerAdjustment)); + return __ret; + } + } + + public global::CppSharp.Parser.AST.Type Desugared + { + get + { + global::CppSharp.Parser.AST.Type __result0; + if (((Internal*) __Instance)->Desugared == IntPtr.Zero) __result0 = null; + else if (global::CppSharp.Parser.AST.Type.NativeToManagedMap.ContainsKey(((Internal*) __Instance)->Desugared)) + __result0 = (global::CppSharp.Parser.AST.Type) global::CppSharp.Parser.AST.Type.NativeToManagedMap[((Internal*) __Instance)->Desugared]; + else __result0 = global::CppSharp.Parser.AST.Type.__CreateInstance(((Internal*) __Instance)->Desugared); + return __result0; + } + + set + { + ((Internal*) __Instance)->Desugared = ReferenceEquals(value, null) ? global::System.IntPtr.Zero : value.__Instance; + } + } + } + public unsafe partial class TemplateParameterType : global::CppSharp.Parser.AST.Type, IDisposable { [StructLayout(LayoutKind.Explicit, Size = 32)] diff --git a/src/CppParser/Parser.cpp b/src/CppParser/Parser.cpp index b738c32a..8a2f6b99 100644 --- a/src/CppParser/Parser.cpp +++ b/src/CppParser/Parser.cpp @@ -2240,6 +2240,49 @@ Type* Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, Ty = TST; break; } + case clang::Type::DependentTemplateSpecialization: + { + auto TS = Type->getAs(); + auto TST = new DependentTemplateSpecializationType(); + + if (TS->isSugared()) + TST->Desugared = WalkType(TS->desugar(), TL); + + TypeLoc UTL, ETL, ITL; + + if (LocValid) + { + auto TypeLocClass = TL->getTypeLocClass(); + if (TypeLocClass == TypeLoc::Qualified) + { + UTL = TL->getUnqualifiedLoc(); + TL = &UTL; + } + else if (TypeLocClass == TypeLoc::Elaborated) + { + ETL = TL->getAs(); + ITL = ETL.getNextTypeLoc(); + TL = &ITL; + } + + assert(TL->getTypeLocClass() == TypeLoc::DependentTemplateSpecialization); + } + + TemplateSpecializationTypeLoc TSpecTL; + TemplateSpecializationTypeLoc *TSTL = 0; + if (LocValid) + { + TSpecTL = TL->getAs(); + TSTL = &TSpecTL; + } + + TemplateArgumentList TArgs(TemplateArgumentList::OnStack, TS->getArgs(), + TS->getNumArgs()); + TST->Arguments = WalkTemplateArgumentList(&TArgs, TSTL); + + Ty = TST; + break; + } case clang::Type::TemplateTypeParm: { auto TP = Type->getAs(); diff --git a/src/Generator/Generators/CLI/CLITypePrinter.cs b/src/Generator/Generators/CLI/CLITypePrinter.cs index 23842805..1a7956bc 100644 --- a/src/Generator/Generators/CLI/CLITypePrinter.cs +++ b/src/Generator/Generators/CLI/CLITypePrinter.cs @@ -277,6 +277,14 @@ namespace CppSharp.Generators.CLI return decl.Name; } + public string VisitDependentTemplateSpecializationType( + DependentTemplateSpecializationType template, TypeQualifiers quals) + { + if (template.Desugared != null) + return template.Desugared.Visit(this); + return string.Empty; + } + public string VisitTemplateParameterType(TemplateParameterType param, TypeQualifiers quals) { diff --git a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs index 026070bf..592289ea 100644 --- a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs +++ b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs @@ -424,6 +424,14 @@ namespace CppSharp.Generators.CSharp ".Internal" : string.Empty); } + public CSharpTypePrinterResult VisitDependentTemplateSpecializationType( + DependentTemplateSpecializationType template, TypeQualifiers quals) + { + if (template.Desugared != null) + return template.Desugared.Visit(this); + return string.Empty; + } + private string GetCSharpSignature(TypeMap typeMap) { Context.CSharpKind = ContextKind; diff --git a/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs b/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs index 74cd3a70..23fa80ca 100644 --- a/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs +++ b/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs @@ -128,6 +128,11 @@ namespace CppSharp.Passes return false; } + public bool VisitDependentTemplateSpecializationType(DependentTemplateSpecializationType template, TypeQualifiers quals) + { + return false; + } + public bool VisitPrimitiveType(PrimitiveType type, TypeQualifiers quals) { return false; diff --git a/src/Generator/Types/CppTypePrinter.cs b/src/Generator/Types/CppTypePrinter.cs index 6c28b61b..630aabb9 100644 --- a/src/Generator/Types/CppTypePrinter.cs +++ b/src/Generator/Types/CppTypePrinter.cs @@ -158,6 +158,14 @@ namespace CppSharp.Types return VisitClassTemplateSpecializationDecl(specialization); } + public string VisitDependentTemplateSpecializationType( + DependentTemplateSpecializationType template, TypeQualifiers quals) + { + if (template.Desugared != null) + return template.Desugared.Visit(this); + return string.Empty; + } + public string VisitTemplateParameterType(TemplateParameterType param, TypeQualifiers quals) { if (param.Parameter.Name == null)