• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

xoofx / CppAst.NET / 14789351421

02 May 2025 05:31AM CUT coverage: 79.202%. Remained the same
14789351421

push

github

xoofx
Fix CppClass.ToString() for ObjC generics

1173 of 1868 branches covered (62.79%)

Branch coverage included in aggregate %.

11 of 11 new or added lines in 2 files covered. (100.0%)

5004 of 5931 relevant lines covered (84.37%)

2221.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.43
/src/CppAst/CppFunctionTypeBase.cs
1
// Copyright (c) Alexandre Mutel. All rights reserved.
2
// Licensed under the BSD-Clause 2 license.
3
// See license.txt file in the project root for full license information.
4

5
using System;
6
using System.Collections.Generic;
7
using System.Text;
8

9
namespace CppAst
10
{
11
    /// <summary>
12
    /// An Objective-C block function (e.g `void (^)(int arg1, int arg2)`) or C++ function type (e.g `void (*)(int arg1, int arg2)`)
13
    /// </summary>
14
    public abstract class CppFunctionTypeBase : CppTypeDeclaration
15
    {
16
        /// <summary>
17
        /// Constructor of a function type.
18
        /// </summary>
19
        /// <param name="returnType">Return type of this function type.</param>
20
        protected CppFunctionTypeBase(CppTypeKind kind, CppType returnType) : base(kind)
22✔
21
        {
22
            ReturnType = returnType ?? throw new ArgumentNullException(nameof(returnType));
22!
23
            Parameters = new CppContainerList<CppParameter>(this);
22✔
24
        }
22✔
25

26
        /// <summary>
27
        /// Gets or sets the calling convention of this function type.
28
        /// </summary>
29
        public CppCallingConvention CallingConvention { get; set; }
30

31
        /// <summary>
32
        /// Gets or sets the return type of this function type.
33
        /// </summary>
34
        public CppType ReturnType { get; set; }
35

36
        /// <summary>
37
        /// Gets a list of the parameters.
38
        /// </summary>
39
        public CppContainerList<CppParameter> Parameters { get; }
40

41
        /// <inheritdoc />
42
        public override int SizeOf
43
        {
44
            get => 0;
×
45

46
            set => throw new InvalidOperationException("This type does not support SizeOf");
×
47
        }
48

49
        /// <inheritdoc />
50
        public override IEnumerable<ICppDeclaration> Children() => Parameters;
×
51

52
        /// <inheritdoc />
53
        public override CppType GetCanonicalType() => this;
2✔
54

55
        /// <inheritdoc />
56
        public override string ToString()
57
        {
58
            var builder = new StringBuilder();
×
59
            builder.Append(ReturnType.GetDisplayName());
×
60
            builder.Append(" ");
×
61
            // Don't complicate with a virtual methods, hardcode derived cases here
62
            if (TypeKind == CppTypeKind.ObjCBlockFunction)
×
63
            {
64
                builder.Append("(^)(");
×
65
            }
66
            else
67
            {
68
                builder.Append("(*)(");
×
69
            }
70
            for (var i = 0; i < Parameters.Count; i++)
×
71
            {
72
                var param = Parameters[i];
×
73
                if (i > 0) builder.Append(", ");
×
74
                builder.Append(param);
×
75
            }
76

77
            builder.Append(")");
×
78
            return builder.ToString();
×
79
        }
80
    }
81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc