File tree 7 files changed +51
-48
lines changed
addons/generator/asciidoc/partials
7 files changed +51
-48
lines changed Original file line number Diff line number Diff line change 2
2
{{> namespace }}
3
3
{{ else if (eq symbol.kind "function")}}
4
4
{{> function }}
5
- {{ else if (eq symbol.kind "class")}}
6
- {{> record }}
7
- {{ else if (eq symbol.kind "struct")}}
8
- {{> record }}
9
- {{ else if (eq symbol.kind "union")}}
5
+ {{ else if (eq symbol.kind "record")}}
10
6
{{> record }}
11
7
{{ /if }}
Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ enum class InfoKind
47
47
Specialization
48
48
};
49
49
50
+ MRDOX_DECL
51
+ std::string_view
52
+ toString (InfoKind kind) noexcept ;
53
+
50
54
/* * Common properties of all symbols
51
55
*/
52
56
struct MRDOX_VISIBLE
@@ -106,14 +110,6 @@ struct MRDOX_VISIBLE
106
110
std::string
107
111
extractName () const ;
108
112
109
- /* * Return a string representing the symbol type.
110
-
111
- For example, "namespace", "class", et. al.
112
- */
113
- MRDOX_DECL
114
- std::string_view
115
- symbolType () const noexcept ;
116
-
117
113
constexpr bool isNamespace () const noexcept { return Kind == InfoKind::Namespace; }
118
114
constexpr bool isRecord () const noexcept { return Kind == InfoKind::Record; }
119
115
constexpr bool isFunction () const noexcept { return Kind == InfoKind::Function; }
Original file line number Diff line number Diff line change @@ -68,6 +68,10 @@ enum class RecordKeyKind
68
68
Union
69
69
};
70
70
71
+ MRDOX_DECL
72
+ std::string_view
73
+ toString (RecordKeyKind kind) noexcept ;
74
+
71
75
/* * Metadata for struct, class, or union.
72
76
*/
73
77
struct RecordInfo
Original file line number Diff line number Diff line change @@ -335,15 +335,9 @@ writeRecord(
335
335
{
336
336
openTemplate (I.Template );
337
337
338
- llvm::StringRef tagName;
339
- switch (I.KeyKind )
340
- {
341
- case RecordKeyKind::Class: tagName = classTagName; break ;
342
- case RecordKeyKind::Struct: tagName = structTagName; break ;
343
- case RecordKeyKind::Union: tagName = unionTagName; break ;
344
- default :
345
- MRDOX_ASSERT (false );
346
- }
338
+ llvm::StringRef tagName =
339
+ toString (I.KeyKind );
340
+
347
341
tags_.open (tagName, {
348
342
{ " name" , I.Name },
349
343
{ I.Access },
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ get(std::string_view key) const
41
41
if (key == " id" )
42
42
return toBase16 (I_->id );
43
43
if (key == " kind" )
44
- return I_->symbolType ( );
44
+ return toString ( I_->Kind );
45
45
if (key == " access" )
46
46
return toString (I_->Access );
47
47
if (key == " name" )
@@ -72,16 +72,7 @@ get(std::string_view key) const
72
72
if constexpr (T::isRecord ())
73
73
{
74
74
if (key == " tag" )
75
- {
76
- switch (I_->KeyKind )
77
- {
78
- case RecordKeyKind::Class: return " class" ;
79
- case RecordKeyKind::Struct: return " struct" ;
80
- case RecordKeyKind::Union: return " union" ;
81
- default :
82
- MRDOX_UNREACHABLE ();
83
- }
84
- }
75
+ return toString (I_->KeyKind );
85
76
if (key == " is-typedef" )
86
77
return I_->IsTypeDef ;
87
78
if (key == " bases" )
Original file line number Diff line number Diff line change @@ -85,26 +85,14 @@ getFullyQualifiedName(
85
85
#endif
86
86
87
87
std::string_view
88
- Info::
89
- symbolType () const noexcept
88
+ toString (InfoKind kind) noexcept
90
89
{
91
- switch (this -> Kind )
90
+ switch (kind )
92
91
{
93
92
case InfoKind::Namespace:
94
93
return " namespace" ;
95
94
case InfoKind::Record:
96
- switch (static_cast <RecordInfo const *>(this )->KeyKind )
97
- {
98
- case RecordKeyKind::Struct:
99
- return " struct" ;
100
- case RecordKeyKind::Class:
101
- return " class" ;
102
- case RecordKeyKind::Union:
103
- return " union" ;
104
- default :
105
- // unknown RecordKeyKind
106
- MRDOX_UNREACHABLE ();
107
- }
95
+ return " record" ;
108
96
case InfoKind::Field:
109
97
return " data" ;
110
98
case InfoKind::Function:
Original file line number Diff line number Diff line change
1
+ //
2
+ // Licensed under the Apache License v2.0 with LLVM Exceptions.
3
+ // See https://llvm.org/LICENSE.txt for license information.
4
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5
+ //
6
+ // Copyright (c) 2023 Krystian Stasiowski (sdkrystian@gmail.com)
7
+ //
8
+ // Official repository: https://github.com/cppalliance/mrdox
9
+ //
10
+
11
+ #include < mrdox/Metadata/Record.hpp>
12
+
13
+ namespace clang {
14
+ namespace mrdox {
15
+
16
+ std::string_view
17
+ toString (RecordKeyKind kind) noexcept
18
+ {
19
+ switch (kind)
20
+ {
21
+ case RecordKeyKind::Struct:
22
+ return " struct" ;
23
+ case RecordKeyKind::Class:
24
+ return " class" ;
25
+ case RecordKeyKind::Union:
26
+ return " union" ;
27
+ default :
28
+ // unknown RecordKeyKind
29
+ MRDOX_UNREACHABLE ();
30
+ }
31
+ }
32
+
33
+ } // mrdox
34
+ } // clang
You can’t perform that action at this time.
0 commit comments