diff --git a/src/AST/ASTVisitor.cs b/src/AST/ASTVisitor.cs index 0b65474e..5ff6fd24 100644 --- a/src/AST/ASTVisitor.cs +++ b/src/AST/ASTVisitor.cs @@ -261,6 +261,11 @@ namespace CppSharp.AST return true; } + public bool VisitVectorType(VectorType vectorType, TypeQualifiers quals) + { + return true; + } + public virtual bool VisitPrimitiveType(PrimitiveType type, TypeQualifiers quals) { return true; diff --git a/src/AST/CppTypePrinter.cs b/src/AST/CppTypePrinter.cs index 572d902b..40dab134 100644 --- a/src/AST/CppTypePrinter.cs +++ b/src/AST/CppTypePrinter.cs @@ -214,6 +214,12 @@ namespace CppSharp.AST return unaryTransformType.BaseType.Visit(this); } + public string VisitVectorType(VectorType vectorType, TypeQualifiers quals) + { + // an incomplete implementation but we'd hardly need anything better + return "__attribute__()"; + } + public string VisitCILType(CILType type, TypeQualifiers quals) { if (type.Type == typeof(string)) diff --git a/src/AST/Type.cs b/src/AST/Type.cs index f8b76f96..2a57313d 100644 --- a/src/AST/Type.cs +++ b/src/AST/Type.cs @@ -1011,6 +1011,8 @@ namespace CppSharp.AST public UnaryTransformType(UnaryTransformType type) : base(type) { + Desugared = type.Desugared; + BaseType = type.BaseType; } public QualifiedType Desugared { get; set; } @@ -1027,6 +1029,31 @@ namespace CppSharp.AST } } + public class VectorType : Type + { + public VectorType() + { + } + + public VectorType(VectorType type) + : base(type) + { + } + + public QualifiedType ElementType { get; set; } + public uint NumElements { get; set; } + + public override T Visit(ITypeVisitor visitor, TypeQualifiers quals = new TypeQualifiers()) + { + return visitor.VisitVectorType(this, quals); + } + + public override object Clone() + { + return new VectorType(this); + } + } + #region Primitives /// @@ -1156,6 +1183,7 @@ namespace CppSharp.AST TypeQualifiers quals); T VisitPackExpansionType(PackExpansionType packExpansionType, TypeQualifiers quals); T VisitUnaryTransformType(UnaryTransformType unaryTransformType, TypeQualifiers quals); + T VisitVectorType(VectorType vectorType, TypeQualifiers quals); T VisitCILType(CILType type, TypeQualifiers quals); } } diff --git a/src/CppParser/AST.cpp b/src/CppParser/AST.cpp index 95a62e1f..73f05111 100644 --- a/src/CppParser/AST.cpp +++ b/src/CppParser/AST.cpp @@ -184,6 +184,8 @@ PackExpansionType::PackExpansionType() : Type(TypeKind::PackExpansion) {} UnaryTransformType::UnaryTransformType() : Type(TypeKind::UnaryTransform) {} +VectorType::VectorType() : Type(TypeKind::Vector), NumElements(0) {} + BuiltinType::BuiltinType() : CppSharp::CppParser::AST::Type(TypeKind::Builtin) {} VTableComponent::VTableComponent() : Offset(0), Declaration(0) {} diff --git a/src/CppParser/AST.h b/src/CppParser/AST.h index 66a36601..57be4bf6 100644 --- a/src/CppParser/AST.h +++ b/src/CppParser/AST.h @@ -33,7 +33,8 @@ enum class TypeKind DependentName, PackExpansion, Builtin, - UnaryTransform + UnaryTransform, + Vector }; #define DECLARE_TYPE_KIND(kind) \ @@ -233,7 +234,7 @@ class Class; class CS_API InjectedClassNameType : public Type { public: - InjectedClassNameType(); + DECLARE_TYPE_KIND(InjectedClassName) QualifiedType InjectedSpecializationType; CppSharp::CppParser::AST::Class* Class; }; @@ -259,6 +260,14 @@ public: QualifiedType BaseType; }; +class CS_API VectorType : public Type +{ +public: + DECLARE_TYPE_KIND(Vector) + QualifiedType ElementType; + unsigned NumElements; +}; + enum class PrimitiveType { Null, diff --git a/src/CppParser/Bindings/CLI/AST.cpp b/src/CppParser/Bindings/CLI/AST.cpp index a4a2f08c..04ee30a7 100644 --- a/src/CppParser/Bindings/CLI/AST.cpp +++ b/src/CppParser/Bindings/CLI/AST.cpp @@ -1166,6 +1166,57 @@ void CppSharp::Parser::AST::UnaryTransformType::BaseType::set(CppSharp::Parser:: ((::CppSharp::CppParser::AST::UnaryTransformType*)NativePtr)->BaseType = *(::CppSharp::CppParser::AST::QualifiedType*)value->NativePtr; } +CppSharp::Parser::AST::VectorType::VectorType(::CppSharp::CppParser::AST::VectorType* native) + : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)native) +{ +} + +CppSharp::Parser::AST::VectorType^ CppSharp::Parser::AST::VectorType::__CreateInstance(::System::IntPtr native) +{ + return gcnew ::CppSharp::Parser::AST::VectorType((::CppSharp::CppParser::AST::VectorType*) native.ToPointer()); +} + +CppSharp::Parser::AST::VectorType::~VectorType() +{ +} + +CppSharp::Parser::AST::VectorType::VectorType() + : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)nullptr) +{ + __ownsNativeInstance = true; + NativePtr = new ::CppSharp::CppParser::AST::VectorType(); +} + +CppSharp::Parser::AST::VectorType::VectorType(CppSharp::Parser::AST::VectorType^ _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::VectorType*)_0->NativePtr; + NativePtr = new ::CppSharp::CppParser::AST::VectorType(__arg0); +} + +CppSharp::Parser::AST::QualifiedType^ CppSharp::Parser::AST::VectorType::ElementType::get() +{ + return (&((::CppSharp::CppParser::AST::VectorType*)NativePtr)->ElementType == nullptr) ? nullptr : gcnew CppSharp::Parser::AST::QualifiedType((::CppSharp::CppParser::AST::QualifiedType*)&((::CppSharp::CppParser::AST::VectorType*)NativePtr)->ElementType); +} + +void CppSharp::Parser::AST::VectorType::ElementType::set(CppSharp::Parser::AST::QualifiedType^ value) +{ + ((::CppSharp::CppParser::AST::VectorType*)NativePtr)->ElementType = *(::CppSharp::CppParser::AST::QualifiedType*)value->NativePtr; +} + +unsigned int CppSharp::Parser::AST::VectorType::NumElements::get() +{ + return ((::CppSharp::CppParser::AST::VectorType*)NativePtr)->NumElements; +} + +void CppSharp::Parser::AST::VectorType::NumElements::set(unsigned int value) +{ + ((::CppSharp::CppParser::AST::VectorType*)NativePtr)->NumElements = value; +} + CppSharp::Parser::AST::BuiltinType::BuiltinType(::CppSharp::CppParser::AST::BuiltinType* 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 73b1002b..6aa5a970 100644 --- a/src/CppParser/Bindings/CLI/AST.h +++ b/src/CppParser/Bindings/CLI/AST.h @@ -107,6 +107,7 @@ namespace CppSharp ref class VarTemplatePartialSpecialization; ref class VarTemplateSpecialization; ref class Variable; + ref class VectorType; ref class VerbatimBlockComment; ref class VerbatimBlockLineComment; ref class VerbatimLineComment; @@ -138,7 +139,8 @@ namespace CppSharp DependentName = 13, PackExpansion = 14, Builtin = 15, - UnaryTransform = 16 + UnaryTransform = 16, + Vector = 17 }; public enum struct DeclarationKind @@ -970,6 +972,31 @@ namespace CppSharp } }; + public ref class VectorType : CppSharp::Parser::AST::Type + { + public: + + VectorType(::CppSharp::CppParser::AST::VectorType* native); + static VectorType^ __CreateInstance(::System::IntPtr native); + VectorType(); + + VectorType(CppSharp::Parser::AST::VectorType^ _0); + + ~VectorType(); + + property CppSharp::Parser::AST::QualifiedType^ ElementType + { + CppSharp::Parser::AST::QualifiedType^ get(); + void set(CppSharp::Parser::AST::QualifiedType^); + } + + property unsigned int NumElements + { + unsigned int get(); + void set(unsigned int); + } + }; + public ref class BuiltinType : 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 4c07b2fd..0e272ba6 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 @@ -32,7 +32,8 @@ namespace CppSharp DependentName = 13, PackExpansion = 14, Builtin = 15, - UnaryTransform = 16 + UnaryTransform = 16, + Vector = 17 } public enum DeclarationKind @@ -2756,6 +2757,115 @@ namespace CppSharp } } + public unsafe partial class VectorType : global::CppSharp.Parser.AST.Type, IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 20)] + public new partial struct Internal + { + [FieldOffset(0)] + public global::CppSharp.Parser.AST.TypeKind Kind; + + [FieldOffset(4)] + public byte IsDependent; + + [FieldOffset(8)] + public global::CppSharp.Parser.AST.QualifiedType.Internal ElementType; + + [FieldOffset(16)] + public uint NumElements; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10VectorTypeC2Ev")] + internal static extern void ctor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10VectorTypeC2ERKS2_")] + internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0); + } + + public static new VectorType __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new VectorType(native.ToPointer(), skipVTables); + } + + public static VectorType __CreateInstance(VectorType.Internal native, bool skipVTables = false) + { + return new VectorType(native, skipVTables); + } + + private static void* __CopyValue(VectorType.Internal native) + { + var ret = Marshal.AllocHGlobal(20); + global::CppSharp.Parser.AST.VectorType.Internal.cctor_2(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private VectorType(VectorType.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected VectorType(void* native, bool skipVTables = false) + : base((void*) null) + { + __PointerAdjustment = 0; + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public VectorType() + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(20); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public VectorType(global::CppSharp.Parser.AST.VectorType _0) + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(20); + __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_2((__Instance + __PointerAdjustment), __arg0); + } + + public global::CppSharp.Parser.AST.QualifiedType ElementType + { + get + { + return global::CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->ElementType); + } + + set + { + ((Internal*) __Instance)->ElementType = ReferenceEquals(value, null) ? new global::CppSharp.Parser.AST.QualifiedType.Internal() : *(global::CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); + } + } + + public uint NumElements + { + get + { + return ((Internal*) __Instance)->NumElements; + } + + set + { + ((Internal*) __Instance)->NumElements = value; + } + } + } + public unsafe partial class BuiltinType : global::CppSharp.Parser.AST.Type, IDisposable { [StructLayout(LayoutKind.Explicit, Size = 12)] 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 47c4d2b8..15b87285 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 @@ -32,7 +32,8 @@ namespace CppSharp DependentName = 13, PackExpansion = 14, Builtin = 15, - UnaryTransform = 16 + UnaryTransform = 16, + Vector = 17 } public enum DeclarationKind @@ -2756,6 +2757,115 @@ namespace CppSharp } } + public unsafe partial class VectorType : global::CppSharp.Parser.AST.Type, IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 20)] + public new partial struct Internal + { + [FieldOffset(0)] + public global::CppSharp.Parser.AST.TypeKind Kind; + + [FieldOffset(4)] + public byte IsDependent; + + [FieldOffset(8)] + public global::CppSharp.Parser.AST.QualifiedType.Internal ElementType; + + [FieldOffset(16)] + public uint NumElements; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.ThisCall, + EntryPoint="??0VectorType@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="??0VectorType@AST@CppParser@CppSharp@@QAE@ABV0123@@Z")] + internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0); + } + + public static new VectorType __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new VectorType(native.ToPointer(), skipVTables); + } + + public static VectorType __CreateInstance(VectorType.Internal native, bool skipVTables = false) + { + return new VectorType(native, skipVTables); + } + + private static void* __CopyValue(VectorType.Internal native) + { + var ret = Marshal.AllocHGlobal(20); + global::CppSharp.Parser.AST.VectorType.Internal.cctor_2(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private VectorType(VectorType.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected VectorType(void* native, bool skipVTables = false) + : base((void*) null) + { + __PointerAdjustment = 0; + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public VectorType() + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(20); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public VectorType(global::CppSharp.Parser.AST.VectorType _0) + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(20); + __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_2((__Instance + __PointerAdjustment), __arg0); + } + + public global::CppSharp.Parser.AST.QualifiedType ElementType + { + get + { + return global::CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->ElementType); + } + + set + { + ((Internal*) __Instance)->ElementType = ReferenceEquals(value, null) ? new global::CppSharp.Parser.AST.QualifiedType.Internal() : *(global::CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); + } + } + + public uint NumElements + { + get + { + return ((Internal*) __Instance)->NumElements; + } + + set + { + ((Internal*) __Instance)->NumElements = value; + } + } + } + public unsafe partial class BuiltinType : global::CppSharp.Parser.AST.Type, IDisposable { [StructLayout(LayoutKind.Explicit, Size = 12)] 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 51e97437..ff78579b 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 @@ -32,7 +32,8 @@ namespace CppSharp DependentName = 13, PackExpansion = 14, Builtin = 15, - UnaryTransform = 16 + UnaryTransform = 16, + Vector = 17 } public enum DeclarationKind @@ -2756,6 +2757,115 @@ namespace CppSharp } } + public unsafe partial class VectorType : global::CppSharp.Parser.AST.Type, IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 32)] + public new partial struct Internal + { + [FieldOffset(0)] + public global::CppSharp.Parser.AST.TypeKind Kind; + + [FieldOffset(4)] + public byte IsDependent; + + [FieldOffset(8)] + public global::CppSharp.Parser.AST.QualifiedType.Internal ElementType; + + [FieldOffset(24)] + public uint NumElements; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10VectorTypeC2Ev")] + internal static extern void ctor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10VectorTypeC2ERKS2_")] + internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0); + } + + public static new VectorType __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new VectorType(native.ToPointer(), skipVTables); + } + + public static VectorType __CreateInstance(VectorType.Internal native, bool skipVTables = false) + { + return new VectorType(native, skipVTables); + } + + private static void* __CopyValue(VectorType.Internal native) + { + var ret = Marshal.AllocHGlobal(32); + global::CppSharp.Parser.AST.VectorType.Internal.cctor_2(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private VectorType(VectorType.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected VectorType(void* native, bool skipVTables = false) + : base((void*) null) + { + __PointerAdjustment = 0; + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public VectorType() + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(32); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public VectorType(global::CppSharp.Parser.AST.VectorType _0) + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(32); + __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_2((__Instance + __PointerAdjustment), __arg0); + } + + public global::CppSharp.Parser.AST.QualifiedType ElementType + { + get + { + return global::CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->ElementType); + } + + set + { + ((Internal*) __Instance)->ElementType = ReferenceEquals(value, null) ? new global::CppSharp.Parser.AST.QualifiedType.Internal() : *(global::CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); + } + } + + public uint NumElements + { + get + { + return ((Internal*) __Instance)->NumElements; + } + + set + { + ((Internal*) __Instance)->NumElements = value; + } + } + } + public unsafe partial class BuiltinType : global::CppSharp.Parser.AST.Type, IDisposable { [StructLayout(LayoutKind.Explicit, Size = 12)] 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 68f63402..91bf535f 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 @@ -32,7 +32,8 @@ namespace CppSharp DependentName = 13, PackExpansion = 14, Builtin = 15, - UnaryTransform = 16 + UnaryTransform = 16, + Vector = 17 } public enum DeclarationKind @@ -2756,6 +2757,115 @@ namespace CppSharp } } + public unsafe partial class VectorType : global::CppSharp.Parser.AST.Type, IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 32)] + public new partial struct Internal + { + [FieldOffset(0)] + public global::CppSharp.Parser.AST.TypeKind Kind; + + [FieldOffset(4)] + public byte IsDependent; + + [FieldOffset(8)] + public global::CppSharp.Parser.AST.QualifiedType.Internal ElementType; + + [FieldOffset(24)] + public uint NumElements; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10VectorTypeC2Ev")] + internal static extern void ctor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10VectorTypeC2ERKS2_")] + internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0); + } + + public static new VectorType __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new VectorType(native.ToPointer(), skipVTables); + } + + public static VectorType __CreateInstance(VectorType.Internal native, bool skipVTables = false) + { + return new VectorType(native, skipVTables); + } + + private static void* __CopyValue(VectorType.Internal native) + { + var ret = Marshal.AllocHGlobal(32); + global::CppSharp.Parser.AST.VectorType.Internal.cctor_2(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private VectorType(VectorType.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected VectorType(void* native, bool skipVTables = false) + : base((void*) null) + { + __PointerAdjustment = 0; + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public VectorType() + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(32); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public VectorType(global::CppSharp.Parser.AST.VectorType _0) + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(32); + __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_2((__Instance + __PointerAdjustment), __arg0); + } + + public global::CppSharp.Parser.AST.QualifiedType ElementType + { + get + { + return global::CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->ElementType); + } + + set + { + ((Internal*) __Instance)->ElementType = ReferenceEquals(value, null) ? new global::CppSharp.Parser.AST.QualifiedType.Internal() : *(global::CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); + } + } + + public uint NumElements + { + get + { + return ((Internal*) __Instance)->NumElements; + } + + set + { + ((Internal*) __Instance)->NumElements = value; + } + } + } + public unsafe partial class BuiltinType : global::CppSharp.Parser.AST.Type, IDisposable { [StructLayout(LayoutKind.Explicit, Size = 12)] 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 e6b900a3..80d3d281 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 @@ -32,7 +32,8 @@ namespace CppSharp DependentName = 13, PackExpansion = 14, Builtin = 15, - UnaryTransform = 16 + UnaryTransform = 16, + Vector = 17 } public enum DeclarationKind @@ -2756,6 +2757,115 @@ namespace CppSharp } } + public unsafe partial class VectorType : global::CppSharp.Parser.AST.Type, IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 32)] + public new partial struct Internal + { + [FieldOffset(0)] + public global::CppSharp.Parser.AST.TypeKind Kind; + + [FieldOffset(4)] + public byte IsDependent; + + [FieldOffset(8)] + public global::CppSharp.Parser.AST.QualifiedType.Internal ElementType; + + [FieldOffset(24)] + public uint NumElements; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10VectorTypeC2Ev")] + internal static extern void ctor_0(global::System.IntPtr instance); + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="_ZN8CppSharp9CppParser3AST10VectorTypeC2ERKS2_")] + internal static extern void cctor_2(global::System.IntPtr instance, global::System.IntPtr _0); + } + + public static new VectorType __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new VectorType(native.ToPointer(), skipVTables); + } + + public static VectorType __CreateInstance(VectorType.Internal native, bool skipVTables = false) + { + return new VectorType(native, skipVTables); + } + + private static void* __CopyValue(VectorType.Internal native) + { + var ret = Marshal.AllocHGlobal(32); + global::CppSharp.Parser.AST.VectorType.Internal.cctor_2(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private VectorType(VectorType.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected VectorType(void* native, bool skipVTables = false) + : base((void*) null) + { + __PointerAdjustment = 0; + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public VectorType() + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(32); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public VectorType(global::CppSharp.Parser.AST.VectorType _0) + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(32); + __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_2((__Instance + __PointerAdjustment), __arg0); + } + + public global::CppSharp.Parser.AST.QualifiedType ElementType + { + get + { + return global::CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->ElementType); + } + + set + { + ((Internal*) __Instance)->ElementType = ReferenceEquals(value, null) ? new global::CppSharp.Parser.AST.QualifiedType.Internal() : *(global::CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); + } + } + + public uint NumElements + { + get + { + return ((Internal*) __Instance)->NumElements; + } + + set + { + ((Internal*) __Instance)->NumElements = value; + } + } + } + public unsafe partial class BuiltinType : global::CppSharp.Parser.AST.Type, IDisposable { [StructLayout(LayoutKind.Explicit, Size = 12)] 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 859813ef..9013a668 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 @@ -32,7 +32,8 @@ namespace CppSharp DependentName = 13, PackExpansion = 14, Builtin = 15, - UnaryTransform = 16 + UnaryTransform = 16, + Vector = 17 } public enum DeclarationKind @@ -2756,6 +2757,115 @@ namespace CppSharp } } + public unsafe partial class VectorType : global::CppSharp.Parser.AST.Type, IDisposable + { + [StructLayout(LayoutKind.Explicit, Size = 32)] + public new partial struct Internal + { + [FieldOffset(0)] + public global::CppSharp.Parser.AST.TypeKind Kind; + + [FieldOffset(4)] + public byte IsDependent; + + [FieldOffset(8)] + public global::CppSharp.Parser.AST.QualifiedType.Internal ElementType; + + [FieldOffset(24)] + public uint NumElements; + + [SuppressUnmanagedCodeSecurity] + [DllImport("CppSharp.CppParser.dll", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, + EntryPoint="??0VectorType@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="??0VectorType@AST@CppParser@CppSharp@@QEAA@AEBV0123@@Z")] + internal static extern global::System.IntPtr cctor_2(global::System.IntPtr instance, global::System.IntPtr _0); + } + + public static new VectorType __CreateInstance(global::System.IntPtr native, bool skipVTables = false) + { + return new VectorType(native.ToPointer(), skipVTables); + } + + public static VectorType __CreateInstance(VectorType.Internal native, bool skipVTables = false) + { + return new VectorType(native, skipVTables); + } + + private static void* __CopyValue(VectorType.Internal native) + { + var ret = Marshal.AllocHGlobal(32); + global::CppSharp.Parser.AST.VectorType.Internal.cctor_2(ret, new global::System.IntPtr(&native)); + return ret.ToPointer(); + } + + private VectorType(VectorType.Internal native, bool skipVTables = false) + : this(__CopyValue(native), skipVTables) + { + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + } + + protected VectorType(void* native, bool skipVTables = false) + : base((void*) null) + { + __PointerAdjustment = 0; + if (native == null) + return; + __Instance = new global::System.IntPtr(native); + } + + public VectorType() + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(32); + __ownsNativeInstance = true; + NativeToManagedMap[__Instance] = this; + Internal.ctor_0((__Instance + __PointerAdjustment)); + } + + public VectorType(global::CppSharp.Parser.AST.VectorType _0) + : this((void*) null) + { + __Instance = Marshal.AllocHGlobal(32); + __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_2((__Instance + __PointerAdjustment), __arg0); + } + + public global::CppSharp.Parser.AST.QualifiedType ElementType + { + get + { + return global::CppSharp.Parser.AST.QualifiedType.__CreateInstance(((Internal*) __Instance)->ElementType); + } + + set + { + ((Internal*) __Instance)->ElementType = ReferenceEquals(value, null) ? new global::CppSharp.Parser.AST.QualifiedType.Internal() : *(global::CppSharp.Parser.AST.QualifiedType.Internal*) (value.__Instance); + } + } + + public uint NumElements + { + get + { + return ((Internal*) __Instance)->NumElements; + } + + set + { + ((Internal*) __Instance)->NumElements = value; + } + } + } + public unsafe partial class BuiltinType : global::CppSharp.Parser.AST.Type, IDisposable { [StructLayout(LayoutKind.Explicit, Size = 12)] diff --git a/src/CppParser/Parser.cpp b/src/CppParser/Parser.cpp index 7fcaa848..f4cea0cc 100644 --- a/src/CppParser/Parser.cpp +++ b/src/CppParser/Parser.cpp @@ -2546,8 +2546,14 @@ Type* Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, } case clang::Type::Vector: { - // GCC-specific / __attribute__((vector_size(n)) - return nullptr; + auto V = Type->getAs(); + + auto VT = new VectorType(); + VT->ElementType = GetQualifiedType(V->getElementType()); + VT->NumElements = V->getNumElements(); + + Ty = VT; + break; } case clang::Type::PackExpansion: { diff --git a/src/Generator/Generators/CLI/CLITypePrinter.cs b/src/Generator/Generators/CLI/CLITypePrinter.cs index e803a9f6..c89316bd 100644 --- a/src/Generator/Generators/CLI/CLITypePrinter.cs +++ b/src/Generator/Generators/CLI/CLITypePrinter.cs @@ -322,6 +322,11 @@ namespace CppSharp.Generators.CLI return unaryTransformType.BaseType.Visit(this); } + public string VisitVectorType(VectorType vectorType, TypeQualifiers quals) + { + throw new NotImplementedException(); + } + public string VisitCILType(CILType type, TypeQualifiers quals) { var result = type.Type.FullName.Replace(".", "::"); diff --git a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs index 89f16698..b59de6e0 100644 --- a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs +++ b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs @@ -823,6 +823,11 @@ namespace CppSharp.Generators.CSharp return unaryTransformType.BaseType.Visit(this); } + public CSharpTypePrinterResult VisitVectorType(VectorType vectorType, TypeQualifiers quals) + { + throw new NotImplementedException(); + } + public CSharpTypePrinterResult VisitFunctionTemplateSpecializationDecl(FunctionTemplateSpecialization specialization) { throw new NotImplementedException(); diff --git a/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs b/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs index 30bfacf8..65eafa71 100644 --- a/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs +++ b/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs @@ -173,6 +173,11 @@ namespace CppSharp.Passes return false; } + public bool VisitVectorType(VectorType vectorType, TypeQualifiers quals) + { + return false; + } + public bool VisitCILType(CILType type, TypeQualifiers quals) { return false; diff --git a/src/Parser/ASTConverter.cs b/src/Parser/ASTConverter.cs index 07b5ea4a..d4d3c318 100644 --- a/src/Parser/ASTConverter.cs +++ b/src/Parser/ASTConverter.cs @@ -29,6 +29,7 @@ namespace CppSharp public abstract TRet VisitBuiltin(BuiltinType type); public abstract TRet VisitPackExpansion(PackExpansionType type); public abstract TRet VisitUnaryTransform(UnaryTransformType type); + public abstract TRet VisitVector(VectorType type); public TRet Visit(Parser.AST.Type type) { @@ -122,6 +123,11 @@ namespace CppSharp var _type = UnaryTransformType.__CreateInstance(type.__Instance); return VisitUnaryTransform(_type); } + case TypeKind.Vector: + { + var _type = VectorType.__CreateInstance(type.__Instance); + return VisitVector(_type); + } } throw new ArgumentOutOfRangeException(); @@ -385,7 +391,7 @@ namespace CppSharp typeConverter.declConverter = declConverter; } - public CppSharp.AST.ASTContext Convert() + public AST.ASTContext Convert() { var _ctx = new AST.ASTContext(); @@ -750,6 +756,14 @@ namespace CppSharp _type.BaseType = VisitQualified(type.BaseType); return _type; } + + public override AST.Type VisitVector(VectorType type) + { + var _type = new AST.VectorType(); + _type.NumElements = type.NumElements; + _type.ElementType = VisitQualified(type.ElementType); + return _type; + } } public unsafe class DeclConverter : DeclVisitor