Exemplo n.º 1
0
        /// <summary>
        /// Constructor of a pointer type.
        /// </summary>
        /// <param name="elementType">The element type pointed to.</param>
        public CppPointerType(CppType elementType) : base(CppTypeKind.Pointer, elementType)
        {
            SizeOf = IntPtr.Size;
            // Check if it is a function ptr
            Regex regex = new Regex(@"\(\*\w*\d*_*\)");

            IsFunctionPtr = regex.IsMatch(elementType.GetDisplayName());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Gets the display name of the specified type. If the type is <see cref="ICppMember"/> it will
 /// only use the name provided by <see cref="ICppMember.Name"/>
 /// </summary>
 /// <param name="type">The type</param>
 /// <returns>The display name</returns>
 public static string GetDisplayName(this CppType type)
 {
     if (type is ICppMember member)
     {
         return(member.Name);
     }
     return(type.ToString());
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor of a pointer type.
 /// </summary>
 /// <param name="elementType">The element type pointed to.</param>
 public CppPointerType(CppType elementType) : base(CppTypeKind.Pointer, elementType)
 {
 }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor for a C++ qualified type.
 /// </summary>
 /// <param name="qualifier">The C++ qualified (e.g `const`)</param>
 /// <param name="elementType">The element type (e.g `int`)</param>
 public CppQualifiedType(CppTypeQualifier qualifier, CppType elementType) : base(CppTypeKind.Qualified)
 {
     Qualifier   = qualifier;
     ElementType = elementType ?? throw new ArgumentNullException(nameof(elementType));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructor of a function type.
 /// </summary>
 /// <param name="returnType">Return type of this function type.</param>
 public CppFunctionType(CppType returnType) : base(CppTypeKind.Function)
 {
     ReturnType     = returnType ?? throw new ArgumentNullException(nameof(returnType));
     ParameterTypes = new List <CppType>();
 }
Exemplo n.º 6
0
 /// <summary>
 /// Constructor of a reference type.
 /// </summary>
 /// <param name="elementType">The element type referenced to.</param>
 public CppReferenceType(CppType elementType) : base(CppTypeKind.Reference, elementType)
 {
 }
Exemplo n.º 7
0
 /// <summary>
 /// Constructor for a C++ qualified type.
 /// </summary>
 /// <param name="qualifier">The C++ qualified (e.g `const`)</param>
 /// <param name="elementType">The element type (e.g `int`)</param>
 public CppQualifiedType(CppTypeQualifier qualifier, CppType elementType) : base(CppTypeKind.Qualified, elementType)
 {
     Qualifier = qualifier;
     SizeOf    = elementType.SizeOf;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Constructor of a reference type.
 /// </summary>
 /// <param name="elementType">The element type referenced to.</param>
 public CppReferenceType(CppType elementType) : base(CppTypeKind.Reference)
 {
     ElementType = elementType ?? throw new ArgumentNullException(nameof(elementType));
 }
Exemplo n.º 9
0
 public override bool IsEquivalent(CppType other)
 {
     // Special case for typedef, as they are aliasing, we don't care about the name
     return(Type.IsEquivalent(other));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Constructor of a pointer type.
 /// </summary>
 /// <param name="elementType">The element type pointed to.</param>
 public CppPointerType(CppType elementType) : base(CppTypeKind.Pointer, elementType)
 {
     SizeOf = IntPtr.Size;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Constructor of a C++ array.
 /// </summary>
 /// <param name="elementType">The element type (e.g `int`)</param>
 /// <param name="size">The size of the array. 0 means an unbound array</param>
 public CppArrayType(CppType elementType, int size) : base(CppTypeKind.Array, elementType)
 {
     Size = size;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Constructor of a pointer type.
 /// </summary>
 /// <param name="elementType">The element type pointed to.</param>
 public CppPointerType(CppType elementType) : base(CppTypeKind.Pointer)
 {
     ElementType = elementType ?? throw new ArgumentNullException(nameof(elementType));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Creates a base type.
 /// </summary>
 /// <param name="baseType">Type of the base</param>
 public CppBaseType(CppType baseType)
 {
     Type = baseType ?? throw new ArgumentNullException(nameof(baseType));
 }
Exemplo n.º 14
0
 protected CppTypeWithElementType(CppTypeKind typeKind, CppType elementType) : base(typeKind)
 {
     ElementType = elementType ?? throw new ArgumentNullException(nameof(elementType));
 }
Exemplo n.º 15
0
 /// <summary>
 /// Creates a new instance of a C++ function parameter.
 /// </summary>
 /// <param name="type">Type of the parameter.</param>
 /// <param name="name">Name of the parameter</param>
 public CppParameter(CppType type, string name)
 {
     Type = type ?? throw new ArgumentNullException(nameof(type));
     Name = name ?? throw new ArgumentNullException(nameof(name));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Creates a new instance of a typedef.
 /// </summary>
 /// <param name="name">Name of the typedef (e.g `XXX`)</param>
 /// <param name="type">Underlying type.</param>
 public CppTypedef(string name, CppType type) : base(CppTypeKind.Typedef)
 {
     Name = name ?? throw new ArgumentNullException(nameof(name));
     Type = type ?? throw new ArgumentNullException(nameof(type));
 }
Exemplo n.º 17
0
 public CppField(CppType type, string name)
 {
     Type = type ?? throw new ArgumentNullException(nameof(type));
     Name = name;
 }
Exemplo n.º 18
0
 /// <summary>
 /// Constructor of a function type.
 /// </summary>
 /// <param name="returnType">Return type of this function type.</param>
 public CppFunctionType(CppType returnType) : base(CppTypeKind.Function)
 {
     ReturnType = returnType ?? throw new ArgumentNullException(nameof(returnType));
     Parameters = new CppContainerList <CppParameter>(this);
 }
Exemplo n.º 19
0
 /// <summary>
 /// Constructor of a C++ array.
 /// </summary>
 /// <param name="elementType">The element type (e.g `int`)</param>
 /// <param name="size">The size of the array. 0 means an unbound array</param>
 public CppArrayType(CppType elementType, int size) : base(CppTypeKind.Array)
 {
     ElementType = elementType ?? throw new ArgumentNullException(nameof(elementType));
     Size        = size;
 }