Skip to content

Commit f446d15

Browse files
committed
child types are refs
1 parent 2a1bbde commit f446d15

File tree

11 files changed

+40
-51
lines changed

11 files changed

+40
-51
lines changed

include/mrdox/Metadata/Scope.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct Scope
3737
std::vector<Reference> Namespaces;
3838
std::vector<Reference> Records;
3939
std::vector<Reference> Functions;
40-
std::vector<TypedefInfo> Typedefs;
40+
std::vector<Reference> Typedefs;
4141
std::vector<EnumInfo> Enums;
4242
std::vector<Reference> Variables;
4343

source/api/AST/AnyBlock.hpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,17 @@ class TopLevelBlock
784784
}
785785
break;
786786
}
787+
case FieldId::F_child_typedef:
788+
{
789+
if constexpr(
790+
std::derived_from<T, NamespaceInfo> ||
791+
std::derived_from<T, RecordInfo>)
792+
{
793+
I->Children.Typedefs.emplace_back(std::move(R));
794+
return llvm::Error::success();
795+
}
796+
break;
797+
}
787798
default:
788799
return makeWrongFieldError(Id);
789800
}
@@ -1202,20 +1213,6 @@ readSubBlock(
12021213
}
12031214
break;
12041215
}
1205-
case BI_TYPEDEF_BLOCK_ID:
1206-
{
1207-
if constexpr(
1208-
std::derived_from<T, NamespaceInfo> ||
1209-
std::derived_from<T, RecordInfo>)
1210-
{
1211-
TypedefBlock B(br_);
1212-
if(auto Err = br_.readBlock(B, ID))
1213-
return Err;
1214-
I->Children.Typedefs.emplace_back(std::move(*B.I));
1215-
return llvm::Error::success();
1216-
}
1217-
break;
1218-
}
12191216
case BI_ENUM_BLOCK_ID:
12201217
{
12211218
if constexpr(

source/api/AST/BitcodeIDs.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ enum class FieldId
133133
F_type,
134134
F_child_namespace,
135135
F_child_record,
136-
F_child_function
136+
F_child_function,
137+
F_child_typedef
137138
};
138139

139140
} // mrdox

source/api/AST/BitcodeWriter.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -892,16 +892,16 @@ emitBlock(
892892
{
893893
StreamSubBlockGuard Block(Stream, BI_NAMESPACE_BLOCK_ID);
894894
emitInfoPart(I);
895-
for (const auto& C : I.Children.Namespaces)
896-
emitBlock(C, FieldId::F_child_namespace);
897-
for (const auto& C : I.Children.Records)
898-
emitBlock(C, FieldId::F_child_record);
899-
for (auto const& C : I.Children.Functions)
900-
emitBlock(C, FieldId::F_child_function);
895+
for (const auto& ref : I.Children.Namespaces)
896+
emitBlock(ref, FieldId::F_child_namespace);
897+
for (const auto& ref : I.Children.Records)
898+
emitBlock(ref, FieldId::F_child_record);
899+
for (auto const& ref : I.Children.Functions)
900+
emitBlock(ref, FieldId::F_child_function);
901+
for (const auto& ref : I.Children.Typedefs)
902+
emitBlock(ref, FieldId::F_child_typedef);
901903
for (const auto& C : I.Children.Enums)
902904
emitBlock(C);
903-
for (const auto& C : I.Children.Typedefs)
904-
emitBlock(C);
905905
}
906906

907907
void
@@ -927,10 +927,10 @@ emitBlock(
927927
emitBlock(C, FieldId::F_child_record);
928928
for (auto const& C : I.Children.Functions)
929929
emitBlock(C, FieldId::F_child_function);
930+
for (const auto& ref : I.Children.Typedefs)
931+
emitBlock(ref, FieldId::F_child_typedef);
930932
for (const auto& C : I.Children.Enums)
931933
emitBlock(C);
932-
for (const auto& C : I.Children.Typedefs)
933-
emitBlock(C);
934934
if (I.Template)
935935
emitBlock(*I.Template);
936936
emitRecord(I.Friends, RECORD_FRIENDS);

source/api/AST/DecodeRecord.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ decodeRecord(
218218
case FieldId::F_child_namespace:
219219
case FieldId::F_child_record:
220220
case FieldId::F_child_function:
221+
case FieldId::F_child_typedef:
221222
case FieldId::F_default:
222223
Field = F;
223224
return llvm::Error::success();

source/api/AST/Serializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ insertChild(Parent& parent, Child&& I)
469469
}
470470
else if constexpr(std::is_same_v<Child, TypedefInfo>)
471471
{
472-
parent.Children.Typedefs.emplace_back(std::move(I));
472+
parent.Children.Typedefs.emplace_back(I.id, I.Name, Child::type_id);
473473
}
474474
else if constexpr(std::is_same_v<Child, EnumInfo>)
475475
{

source/api/Corpus.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ visit(Scope const& I, Visitor& f) const
174174
for(auto const& ref : I.Functions)
175175
if(! visit(get<FunctionInfo>(ref.id), f))
176176
return false;
177-
for(auto const& J : I.Typedefs)
178-
if(! visit(J, f))
177+
for(auto const& ref : I.Typedefs)
178+
if(! visit(get<TypedefInfo>(ref.id), f))
179179
return false;
180180
for(auto const& J : I.Enums)
181181
if(! visit(J, f))
@@ -227,8 +227,8 @@ visitWithOverloads(
227227
return false;
228228
}
229229
}
230-
for(auto const& J : I.Typedefs)
231-
if(! visit(J, f))
230+
for(auto const& ref : I.Typedefs)
231+
if(! visit(get<TypedefInfo>(ref.id), f))
232232
return false;
233233
for(auto const& J : I.Enums)
234234
if(! visit(J, f))

source/api/CorpusImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ visit(Scope& I, MutableVisitor& f)
7878
visit(get<RecordInfo>(ref.id), f);
7979
for(auto& ref : I.Functions)
8080
visit(get<FunctionInfo>(ref.id), f);
81-
for(auto& J : I.Typedefs)
82-
visit(J, f);
81+
for(auto& ref : I.Typedefs)
82+
visit(get<TypedefInfo>(ref.id), f);
8383
for(auto& J : I.Enums)
8484
visit(J, f);
8585
}

source/api/_adoc/AdocWriter.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -378,39 +378,29 @@ void
378378
AdocWriter::
379379
writeNestedTypes(
380380
llvm::StringRef sectionName,
381-
std::vector<TypedefInfo> const& list,
381+
std::vector<Reference> const& list,
382382
AccessSpecifier access)
383383
{
384384
if(list.empty())
385385
return;
386-
auto it = list.begin();
387-
#if 0
388-
for(;;)
389-
{
390-
if(it == list.end())
391-
return;
392-
if(it->Access == access)
393-
break;
394-
++it;
395-
}
396-
#endif
397386
beginSection(sectionName);
398387
os_ <<
399388
"\n"
400389
"[,cols=2]\n" <<
401390
"|===\n" <<
402391
"|Name |Description\n" <<
403392
"\n";
404-
for(;it != list.end(); ++it)
393+
for(auto const& ref : list)
405394
{
395+
auto& I = corpus_.get<TypedefInfo>(ref.id);
406396
#if 0
407397
if(it->Access != access)
408398
continue;
409399
#endif
410400
os_ <<
411-
"|`" << it->Name << "`\n" <<
401+
"|`" << I.Name << "`\n" <<
412402
"|";
413-
writeBrief(it->javadoc, false);
403+
writeBrief(I.javadoc, false);
414404
os_ << '\n';
415405
}
416406
os_ <<

source/api/_adoc/AdocWriter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class AdocWriter
7272
OverloadsSet const& set);
7373
void writeNestedTypes(
7474
llvm::StringRef sectionName,
75-
std::vector<TypedefInfo> const& list,
75+
std::vector<Reference> const& list,
7676
AccessSpecifier access);
7777
void writeDataMembers(
7878
llvm::StringRef sectionName,

0 commit comments

Comments
 (0)