Skip to content

Commit d15a3e5

Browse files
committed
chore: cleanup
1 parent 648699d commit d15a3e5

File tree

14 files changed

+80
-179
lines changed

14 files changed

+80
-179
lines changed

include/mrdox/Corpus.hpp

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -139,46 +139,6 @@ class MRDOX_VISIBLE
139139

140140
//------------------------------------------------
141141

142-
/** Invoke a function object with an Info-derived type.
143-
*/
144-
template<class F, class... Args>
145-
auto
146-
visit(
147-
Info const& I, F&& f, Args&&... args)
148-
{
149-
switch(I.Kind)
150-
{
151-
case InfoKind::Namespace:
152-
return f(static_cast<NamespaceInfo const&>(I),
153-
std::forward<Args>(args)...);
154-
case InfoKind::Record:
155-
return f(static_cast<RecordInfo const&>(I),
156-
std::forward<Args>(args)...);
157-
case InfoKind::Function:
158-
return f(static_cast<FunctionInfo const&>(I),
159-
std::forward<Args>(args)...);
160-
case InfoKind::Enum:
161-
return f(static_cast<EnumInfo const&>(I),
162-
std::forward<Args>(args)...);
163-
case InfoKind::Field:
164-
return f(static_cast<FieldInfo const&>(I),
165-
std::forward<Args>(args)...);
166-
case InfoKind::Typedef:
167-
return f(static_cast<TypedefInfo const&>(I),
168-
std::forward<Args>(args)...);
169-
case InfoKind::Variable:
170-
return f(static_cast<VariableInfo const&>(I),
171-
std::forward<Args>(args)...);
172-
case InfoKind::Specialization:
173-
return f(static_cast<SpecializationInfo const&>(I),
174-
std::forward<Args>(args)...);
175-
default:
176-
MRDOX_UNREACHABLE();
177-
}
178-
}
179-
180-
//------------------------------------------------
181-
182142
template<class T>
183143
T const&
184144
Corpus::

include/mrdox/Metadata/Info.hpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <mrdox/Metadata/Javadoc.hpp>
1717
#include <mrdox/Metadata/Specifiers.hpp>
1818
#include <mrdox/Metadata/Symbols.hpp>
19+
#include <mrdox/Support/TypeTraits.hpp>
1920
#include <array>
2021
#include <memory>
2122
#include <string>
@@ -29,6 +30,7 @@ struct NamespaceInfo;
2930
struct RecordInfo;
3031
struct FunctionInfo;
3132
struct EnumInfo;
33+
struct FieldInfo;
3234
struct TypedefInfo;
3335
struct VariableInfo;
3436
struct SpecializationInfo;
@@ -156,6 +158,57 @@ struct IsInfo : Info
156158
}
157159
};
158160

161+
/** Invoke a function object with an Info-derived type.
162+
*/
163+
template<
164+
class F,
165+
class... Args,
166+
class Dependent = void>
167+
auto
168+
visit(
169+
Info const& I,
170+
F&& f,
171+
Args&&... args)
172+
{
173+
switch(I.Kind)
174+
{
175+
case InfoKind::Namespace:
176+
return f(static_cast<make_dependent_t<
177+
NamespaceInfo const&, Dependent>>(I),
178+
std::forward<Args>(args)...);
179+
case InfoKind::Record:
180+
return f(static_cast<make_dependent_t<
181+
RecordInfo const&, Dependent>>(I),
182+
std::forward<Args>(args)...);
183+
case InfoKind::Function:
184+
return f(static_cast<make_dependent_t<
185+
FunctionInfo const&, Dependent>>(I),
186+
std::forward<Args>(args)...);
187+
case InfoKind::Enum:
188+
return f(static_cast<make_dependent_t<
189+
EnumInfo const&, Dependent>>(I),
190+
std::forward<Args>(args)...);
191+
case InfoKind::Field:
192+
return f(static_cast<make_dependent_t<
193+
FieldInfo const&, Dependent>>(I),
194+
std::forward<Args>(args)...);
195+
case InfoKind::Typedef:
196+
return f(static_cast<make_dependent_t<
197+
TypedefInfo const&, Dependent>>(I),
198+
std::forward<Args>(args)...);
199+
case InfoKind::Variable:
200+
return f(static_cast<make_dependent_t<
201+
VariableInfo const&, Dependent>>(I),
202+
std::forward<Args>(args)...);
203+
case InfoKind::Specialization:
204+
return f(static_cast<make_dependent_t<
205+
SpecializationInfo const&, Dependent>>(I),
206+
std::forward<Args>(args)...);
207+
default:
208+
MRDOX_UNREACHABLE();
209+
}
210+
}
211+
159212
} // mrdox
160213
} // clang
161214

include/mrdox/Metadata/Type.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
//
2-
// This is a derivative work. originally part of the LLVM Project.
32
// Licensed under the Apache License v2.0 with LLVM Exceptions.
43
// See https://llvm.org/LICENSE.txt for license information.
54
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65
//
7-
// Copyright (c) 2023 Vinnie Falco ([email protected])
86
// Copyright (c) 2023 Krystian Stasiowski ([email protected])
97
//
108
// Official repository: https://github.com/cppalliance/mrdox

source/Support/TypeTraits.hpp renamed to include/mrdox/Support/TypeTraits.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55
//
66
// Copyright (c) 2023 Vinnie Falco ([email protected])
7+
// Copyright (c) 2023 Krystian Stasiowski ([email protected])
78
//
89
// Official repository: https://github.com/cppalliance/mrdox
910
//
@@ -29,6 +30,15 @@ to_underlying(
2930
std::underlying_type_t<Enum>>(value);
3031
}
3132

33+
template<typename T, typename U>
34+
struct make_dependent
35+
{
36+
using type = T;
37+
};
38+
39+
template<typename T, typename U>
40+
using make_dependent_t = make_dependent<T, U>::type;
41+
3242
} // mrdox
3343
} // clang
3444

source/-XML/XMLTags.hpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,6 @@ struct Attribute
8888
{
8989
}
9090

91-
#if 0
92-
Attribute(
93-
AccessSpecifier access) noexcept
94-
: name("access")
95-
, value(clang::getAccessSpelling(access))
96-
, pred(access != AccessSpecifier::AS_none)
97-
{
98-
}
99-
#endif
100-
10191
Attribute(
10292
SymbolID id)
10393
: name("id")

source/-XML/XMLWriter.cpp

Lines changed: 3 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,6 @@ XMLWriter::
275275
writeEnum(
276276
EnumInfo const& I)
277277
{
278-
#if 0
279-
tags_.open(enumTagName, {
280-
{ "name", I.Name },
281-
{ "class", "scoped", I.Scoped },
282-
{ I.BaseType },
283-
{ I.Access },
284-
{ I.id }
285-
});
286-
#else
287278
tags_.open(enumTagName, {
288279
{ "name", I.Name },
289280
{ "class", "scoped", I.Scoped },
@@ -296,7 +287,6 @@ writeEnum(
296287
writeType(I.BaseType, tags_);
297288
tags_.close(baseTagName);
298289
}
299-
#endif
300290

301291
writeSourceInfo(I);
302292

@@ -377,15 +367,6 @@ writeRecord(
377367

378368
write(I.specs, tags_);
379369

380-
#if 0
381-
for(auto const& B : I.Bases)
382-
tags_.write(baseTagName, "", {
383-
{ "name", B.Type.Name },
384-
{ B.Access },
385-
{ "class", "virtual", B.IsVirtual },
386-
{ B.Type.id }
387-
});
388-
#else
389370
for(auto const& B : I.Bases)
390371
{
391372
tags_.open(baseTagName, {
@@ -395,8 +376,6 @@ writeRecord(
395376
writeType(B.Type, tags_);
396377
tags_.close(baseTagName);
397378
}
398-
#endif
399-
400379

401380
// Friends
402381
for(auto const& id : I.Friends)
@@ -435,11 +414,6 @@ writeTypedef(
435414
writeSourceInfo(I);
436415

437416
writeType(I.Underlying, tags_);
438-
#if 0
439-
tags_.write("type", "", {
440-
{ "name", I.Underlying.Name },
441-
{ I.Underlying.id } });
442-
#endif
443417

444418
writeJavadoc(I.javadoc);
445419

@@ -467,12 +441,6 @@ writeField(
467441
write(I.specs, tags_);
468442

469443
writeType(I.Type, tags_);
470-
#if 0
471-
tags_.write("type", {}, {
472-
{ "name", I.Type.Name },
473-
{ I.Type.id }
474-
});
475-
#endif
476444

477445
writeJavadoc(I.javadoc);
478446

@@ -499,12 +467,6 @@ writeVar(
499467
write(I.specs, tags_);
500468

501469
writeType(I.Type, tags_);
502-
#if 0
503-
tags_.write("type", {}, {
504-
{ "name", I.Type.Name },
505-
{ I.Type.id }
506-
});
507-
#endif
508470

509471
writeJavadoc(I.javadoc);
510472

@@ -549,23 +511,13 @@ openTemplate(
549511
{
550512
if(! I)
551513
return;
552-
const char* spec = nullptr;
553-
switch(I->specializationKind())
554-
{
555-
case TemplateSpecKind::Explicit:
556-
spec = "explicit";
557-
break;
558-
case TemplateSpecKind::Partial:
559-
spec = "partial";
560-
break;
561-
default:
562-
break;
563-
}
514+
564515
const SymbolID& id = I->Primary ?
565516
*I->Primary : SymbolID::zero;
566517

567518
tags_.open(templateTagName, {
568-
{"class", spec, !! spec},
519+
{"class", toString(I->specializationKind()),
520+
I->specializationKind() != TemplateSpecKind::Primary},
569521
{id}
570522
});
571523

@@ -608,26 +560,6 @@ writeSpecialization(
608560

609561
//------------------------------------------------
610562

611-
#if 0
612-
void
613-
XMLWriter::
614-
writeType(
615-
const std::unique_ptr<TypeInfo>& type)
616-
{
617-
if(! type)
618-
return;
619-
#if 0
620-
tags_.write("type", {}, {
621-
{ "name", toString(*type) },
622-
});
623-
#else
624-
625-
#endif
626-
}
627-
#endif
628-
629-
//------------------------------------------------
630-
631563
void
632564
XMLWriter::
633565
writeJavadoc(

source/-adoc/Builder.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,6 @@ Builder(
139139
{
140140
return a && b;
141141
});
142-
143-
Handlebars.registerHelper(
144-
'concat', function()
145-
{
146-
var result = '';
147-
for(var i = 0; i < arguments.length - 1; ++i)
148-
result += arguments[i];
149-
return result;
150-
});
151142
)");
152143
if(err)
153144
throw err;

source/AST/BitcodeReader.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@ getInfos()
120120
continue;
121121
}
122122

123-
// NamedType and Comment blocks should
123+
// Comment blocks should
124124
// not appear at the top level
125-
// case BI_TYPE_BLOCK_ID:
126125
case BI_JAVADOC_BLOCK_ID:
127126
case BI_JAVADOC_LIST_BLOCK_ID:
128127
case BI_JAVADOC_NODE_BLOCK_ID:

0 commit comments

Comments
 (0)