/// <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()); }
/// <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()); }
/// <summary> /// Constructor of a pointer type. /// </summary> /// <param name="elementType">The element type pointed to.</param> public CppPointerType(CppType elementType) : base(CppTypeKind.Pointer, elementType) { }
/// <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)); }
/// <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>(); }
/// <summary> /// Constructor of a reference type. /// </summary> /// <param name="elementType">The element type referenced to.</param> public CppReferenceType(CppType elementType) : base(CppTypeKind.Reference, elementType) { }
/// <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; }
/// <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)); }
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)); }
/// <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; }
/// <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; }
/// <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)); }
/// <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)); }
protected CppTypeWithElementType(CppTypeKind typeKind, CppType elementType) : base(typeKind) { ElementType = elementType ?? throw new ArgumentNullException(nameof(elementType)); }
/// <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)); }
/// <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)); }
public CppField(CppType type, string name) { Type = type ?? throw new ArgumentNullException(nameof(type)); Name = name; }
/// <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); }
/// <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; }