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

xoofx / CppAst.NET / 14764138022

30 Apr 2025 08:52PM UTC coverage: 78.596% (-0.2%) from 78.842%
14764138022

push

github

web-flow
Merge pull request #110 from xoofx/objective-c

Add support for Objective-C

1123 of 1824 branches covered (61.57%)

Branch coverage included in aggregate %.

456 of 566 new or added lines in 13 files covered. (80.57%)

2 existing lines in 1 file now uncovered.

4888 of 5824 relevant lines covered (83.93%)

2189.8 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
        {
NEW
44
            get => 0;
×
45

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

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

NEW
77
            builder.Append(")");
×
NEW
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

© 2026 Coveralls, Inc