Browse Source

Extended the AST with the GCC vector type ("__attribute__").

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/696/head
Dimitar Dobrev 9 years ago
parent
commit
5d8ecf32d7
  1. 5
      src/AST/ASTVisitor.cs
  2. 6
      src/AST/CppTypePrinter.cs
  3. 28
      src/AST/Type.cs
  4. 2
      src/CppParser/AST.cpp
  5. 13
      src/CppParser/AST.h
  6. 51
      src/CppParser/Bindings/CLI/AST.cpp
  7. 29
      src/CppParser/Bindings/CLI/AST.h
  8. 112
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs
  9. 112
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs
  10. 112
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs
  11. 112
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs
  12. 112
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs
  13. 112
      src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs
  14. 10
      src/CppParser/Parser.cpp
  15. 5
      src/Generator/Generators/CLI/CLITypePrinter.cs
  16. 5
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs
  17. 5
      src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs
  18. 16
      src/Parser/ASTConverter.cs

5
src/AST/ASTVisitor.cs

@ -261,6 +261,11 @@ namespace CppSharp.AST
return true; return true;
} }
public bool VisitVectorType(VectorType vectorType, TypeQualifiers quals)
{
return true;
}
public virtual bool VisitPrimitiveType(PrimitiveType type, TypeQualifiers quals) public virtual bool VisitPrimitiveType(PrimitiveType type, TypeQualifiers quals)
{ {
return true; return true;

6
src/AST/CppTypePrinter.cs

@ -214,6 +214,12 @@ namespace CppSharp.AST
return unaryTransformType.BaseType.Visit(this); 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) public string VisitCILType(CILType type, TypeQualifiers quals)
{ {
if (type.Type == typeof(string)) if (type.Type == typeof(string))

28
src/AST/Type.cs

@ -1011,6 +1011,8 @@ namespace CppSharp.AST
public UnaryTransformType(UnaryTransformType type) public UnaryTransformType(UnaryTransformType type)
: base(type) : base(type)
{ {
Desugared = type.Desugared;
BaseType = type.BaseType;
} }
public QualifiedType Desugared { get; set; } 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<T>(ITypeVisitor<T> visitor, TypeQualifiers quals = new TypeQualifiers())
{
return visitor.VisitVectorType(this, quals);
}
public override object Clone()
{
return new VectorType(this);
}
}
#region Primitives #region Primitives
/// <summary> /// <summary>
@ -1156,6 +1183,7 @@ namespace CppSharp.AST
TypeQualifiers quals); TypeQualifiers quals);
T VisitPackExpansionType(PackExpansionType packExpansionType, TypeQualifiers quals); T VisitPackExpansionType(PackExpansionType packExpansionType, TypeQualifiers quals);
T VisitUnaryTransformType(UnaryTransformType unaryTransformType, TypeQualifiers quals); T VisitUnaryTransformType(UnaryTransformType unaryTransformType, TypeQualifiers quals);
T VisitVectorType(VectorType vectorType, TypeQualifiers quals);
T VisitCILType(CILType type, TypeQualifiers quals); T VisitCILType(CILType type, TypeQualifiers quals);
} }
} }

2
src/CppParser/AST.cpp

@ -184,6 +184,8 @@ PackExpansionType::PackExpansionType() : Type(TypeKind::PackExpansion) {}
UnaryTransformType::UnaryTransformType() : Type(TypeKind::UnaryTransform) {} UnaryTransformType::UnaryTransformType() : Type(TypeKind::UnaryTransform) {}
VectorType::VectorType() : Type(TypeKind::Vector), NumElements(0) {}
BuiltinType::BuiltinType() : CppSharp::CppParser::AST::Type(TypeKind::Builtin) {} BuiltinType::BuiltinType() : CppSharp::CppParser::AST::Type(TypeKind::Builtin) {}
VTableComponent::VTableComponent() : Offset(0), Declaration(0) {} VTableComponent::VTableComponent() : Offset(0), Declaration(0) {}

13
src/CppParser/AST.h

@ -33,7 +33,8 @@ enum class TypeKind
DependentName, DependentName,
PackExpansion, PackExpansion,
Builtin, Builtin,
UnaryTransform UnaryTransform,
Vector
}; };
#define DECLARE_TYPE_KIND(kind) \ #define DECLARE_TYPE_KIND(kind) \
@ -233,7 +234,7 @@ class Class;
class CS_API InjectedClassNameType : public Type class CS_API InjectedClassNameType : public Type
{ {
public: public:
InjectedClassNameType(); DECLARE_TYPE_KIND(InjectedClassName)
QualifiedType InjectedSpecializationType; QualifiedType InjectedSpecializationType;
CppSharp::CppParser::AST::Class* Class; CppSharp::CppParser::AST::Class* Class;
}; };
@ -259,6 +260,14 @@ public:
QualifiedType BaseType; QualifiedType BaseType;
}; };
class CS_API VectorType : public Type
{
public:
DECLARE_TYPE_KIND(Vector)
QualifiedType ElementType;
unsigned NumElements;
};
enum class PrimitiveType enum class PrimitiveType
{ {
Null, Null,

51
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::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::BuiltinType::BuiltinType(::CppSharp::CppParser::AST::BuiltinType* native)
: CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)native) : CppSharp::Parser::AST::Type((::CppSharp::CppParser::AST::Type*)native)
{ {

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

@ -107,6 +107,7 @@ namespace CppSharp
ref class VarTemplatePartialSpecialization; ref class VarTemplatePartialSpecialization;
ref class VarTemplateSpecialization; ref class VarTemplateSpecialization;
ref class Variable; ref class Variable;
ref class VectorType;
ref class VerbatimBlockComment; ref class VerbatimBlockComment;
ref class VerbatimBlockLineComment; ref class VerbatimBlockLineComment;
ref class VerbatimLineComment; ref class VerbatimLineComment;
@ -138,7 +139,8 @@ namespace CppSharp
DependentName = 13, DependentName = 13,
PackExpansion = 14, PackExpansion = 14,
Builtin = 15, Builtin = 15,
UnaryTransform = 16 UnaryTransform = 16,
Vector = 17
}; };
public enum struct DeclarationKind 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 ref class BuiltinType : CppSharp::Parser::AST::Type
{ {
public: public:

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

@ -32,7 +32,8 @@ namespace CppSharp
DependentName = 13, DependentName = 13,
PackExpansion = 14, PackExpansion = 14,
Builtin = 15, Builtin = 15,
UnaryTransform = 16 UnaryTransform = 16,
Vector = 17
} }
public enum DeclarationKind 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 public unsafe partial class BuiltinType : global::CppSharp.Parser.AST.Type, IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 12)] [StructLayout(LayoutKind.Explicit, Size = 12)]

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

@ -32,7 +32,8 @@ namespace CppSharp
DependentName = 13, DependentName = 13,
PackExpansion = 14, PackExpansion = 14,
Builtin = 15, Builtin = 15,
UnaryTransform = 16 UnaryTransform = 16,
Vector = 17
} }
public enum DeclarationKind 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 public unsafe partial class BuiltinType : global::CppSharp.Parser.AST.Type, IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 12)] [StructLayout(LayoutKind.Explicit, Size = 12)]

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

@ -32,7 +32,8 @@ namespace CppSharp
DependentName = 13, DependentName = 13,
PackExpansion = 14, PackExpansion = 14,
Builtin = 15, Builtin = 15,
UnaryTransform = 16 UnaryTransform = 16,
Vector = 17
} }
public enum DeclarationKind 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 public unsafe partial class BuiltinType : global::CppSharp.Parser.AST.Type, IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 12)] [StructLayout(LayoutKind.Explicit, Size = 12)]

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

@ -32,7 +32,8 @@ namespace CppSharp
DependentName = 13, DependentName = 13,
PackExpansion = 14, PackExpansion = 14,
Builtin = 15, Builtin = 15,
UnaryTransform = 16 UnaryTransform = 16,
Vector = 17
} }
public enum DeclarationKind 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 public unsafe partial class BuiltinType : global::CppSharp.Parser.AST.Type, IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 12)] [StructLayout(LayoutKind.Explicit, Size = 12)]

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

@ -32,7 +32,8 @@ namespace CppSharp
DependentName = 13, DependentName = 13,
PackExpansion = 14, PackExpansion = 14,
Builtin = 15, Builtin = 15,
UnaryTransform = 16 UnaryTransform = 16,
Vector = 17
} }
public enum DeclarationKind 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 public unsafe partial class BuiltinType : global::CppSharp.Parser.AST.Type, IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 12)] [StructLayout(LayoutKind.Explicit, Size = 12)]

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

@ -32,7 +32,8 @@ namespace CppSharp
DependentName = 13, DependentName = 13,
PackExpansion = 14, PackExpansion = 14,
Builtin = 15, Builtin = 15,
UnaryTransform = 16 UnaryTransform = 16,
Vector = 17
} }
public enum DeclarationKind 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 public unsafe partial class BuiltinType : global::CppSharp.Parser.AST.Type, IDisposable
{ {
[StructLayout(LayoutKind.Explicit, Size = 12)] [StructLayout(LayoutKind.Explicit, Size = 12)]

10
src/CppParser/Parser.cpp

@ -2546,8 +2546,14 @@ Type* Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
} }
case clang::Type::Vector: case clang::Type::Vector:
{ {
// GCC-specific / __attribute__((vector_size(n)) auto V = Type->getAs<clang::VectorType>();
return nullptr;
auto VT = new VectorType();
VT->ElementType = GetQualifiedType(V->getElementType());
VT->NumElements = V->getNumElements();
Ty = VT;
break;
} }
case clang::Type::PackExpansion: case clang::Type::PackExpansion:
{ {

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

@ -322,6 +322,11 @@ namespace CppSharp.Generators.CLI
return unaryTransformType.BaseType.Visit(this); return unaryTransformType.BaseType.Visit(this);
} }
public string VisitVectorType(VectorType vectorType, TypeQualifiers quals)
{
throw new NotImplementedException();
}
public string VisitCILType(CILType type, TypeQualifiers quals) public string VisitCILType(CILType type, TypeQualifiers quals)
{ {
var result = type.Type.FullName.Replace(".", "::"); var result = type.Type.FullName.Replace(".", "::");

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

@ -823,6 +823,11 @@ namespace CppSharp.Generators.CSharp
return unaryTransformType.BaseType.Visit(this); return unaryTransformType.BaseType.Visit(this);
} }
public CSharpTypePrinterResult VisitVectorType(VectorType vectorType, TypeQualifiers quals)
{
throw new NotImplementedException();
}
public CSharpTypePrinterResult VisitFunctionTemplateSpecializationDecl(FunctionTemplateSpecialization specialization) public CSharpTypePrinterResult VisitFunctionTemplateSpecializationDecl(FunctionTemplateSpecialization specialization)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

5
src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs

@ -173,6 +173,11 @@ namespace CppSharp.Passes
return false; return false;
} }
public bool VisitVectorType(VectorType vectorType, TypeQualifiers quals)
{
return false;
}
public bool VisitCILType(CILType type, TypeQualifiers quals) public bool VisitCILType(CILType type, TypeQualifiers quals)
{ {
return false; return false;

16
src/Parser/ASTConverter.cs

@ -29,6 +29,7 @@ namespace CppSharp
public abstract TRet VisitBuiltin(BuiltinType type); public abstract TRet VisitBuiltin(BuiltinType type);
public abstract TRet VisitPackExpansion(PackExpansionType type); public abstract TRet VisitPackExpansion(PackExpansionType type);
public abstract TRet VisitUnaryTransform(UnaryTransformType type); public abstract TRet VisitUnaryTransform(UnaryTransformType type);
public abstract TRet VisitVector(VectorType type);
public TRet Visit(Parser.AST.Type type) public TRet Visit(Parser.AST.Type type)
{ {
@ -122,6 +123,11 @@ namespace CppSharp
var _type = UnaryTransformType.__CreateInstance(type.__Instance); var _type = UnaryTransformType.__CreateInstance(type.__Instance);
return VisitUnaryTransform(_type); return VisitUnaryTransform(_type);
} }
case TypeKind.Vector:
{
var _type = VectorType.__CreateInstance(type.__Instance);
return VisitVector(_type);
}
} }
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
@ -385,7 +391,7 @@ namespace CppSharp
typeConverter.declConverter = declConverter; typeConverter.declConverter = declConverter;
} }
public CppSharp.AST.ASTContext Convert() public AST.ASTContext Convert()
{ {
var _ctx = new AST.ASTContext(); var _ctx = new AST.ASTContext();
@ -750,6 +756,14 @@ namespace CppSharp
_type.BaseType = VisitQualified(type.BaseType); _type.BaseType = VisitQualified(type.BaseType);
return _type; 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<AST.Declaration> public unsafe class DeclConverter : DeclVisitor<AST.Declaration>

Loading…
Cancel
Save