Skip to content

Commit 30b632d

Browse files
committed
better xml typedefs
1 parent 69efdb9 commit 30b632d

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

include/mrdox/Metadata/Type.hpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ namespace mrdox {
2121
// A base struct for TypeInfos
2222
struct TypeInfo
2323
{
24+
/** The type being referenced.
25+
*/
26+
Reference Type;
27+
28+
//--------------------------------------------
29+
2430
TypeInfo() = default;
2531

2632
explicit
@@ -44,8 +50,6 @@ struct TypeInfo
4450
{
4551
return Type == Other.Type;
4652
}
47-
48-
Reference Type; // Referenced type in this info.
4953
};
5054

5155
} // mrdox

include/mrdox/Metadata/Typedef.hpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ namespace mrdox {
2222
// Info for typedef and using statements.
2323
struct TypedefInfo : SymbolInfo
2424
{
25+
TypeInfo Underlying;
26+
27+
// Indicates if this is a new C++ "using"-style typedef:
28+
// using MyVector = std::vector<int>
29+
// False means it's a C-style typedef:
30+
// typedef std::vector<int> MyVector;
31+
bool IsUsing = false;
32+
33+
//--------------------------------------------
34+
2535
static constexpr InfoType type_id = InfoType::IT_typedef;
2636

2737
TypedefInfo(
@@ -31,14 +41,6 @@ struct TypedefInfo : SymbolInfo
3141
}
3242

3343
void merge(TypedefInfo&& I);
34-
35-
TypeInfo Underlying;
36-
37-
// Inidicates if this is a new C++ "using"-style typedef:
38-
// using MyVector = std::vector<int>
39-
// False means it's a C-style typedef:
40-
// typedef std::vector<int> MyVector;
41-
bool IsUsing = false;
4244
};
4345

4446
} // mrdox

source/api/_XML/XMLWriter.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -342,18 +342,24 @@ visit(
342342
if(fd_os_ && fd_os_->error())
343343
return false;
344344

345-
tags_.open("typedef", {
345+
llvm::StringRef tag;
346+
if(I.IsUsing)
347+
tag = "using";
348+
else
349+
tag = "typedef";
350+
tags_.open(tag, {
346351
{ "name", I.Name },
347352
{ I.id }
348353
});
349354

350355
writeInfo(I);
351356
writeSymbol(I);
352-
if(I.Underlying.Type.id != EmptySID)
353-
tags_.write("qualusr", toBase64(I.Underlying.Type.id));
357+
tags_.write("type", "", {
358+
{ "name", I.Underlying.Type.Name },
359+
{ I.Underlying.Type.id } });
354360
writeJavadoc(I.javadoc);
355361

356-
tags_.close("typedef");
362+
tags_.close(tag);
357363

358364
return true;
359365
}

test-files/old-tests/record-1.xml

+4-2
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@
6161
</para>
6262
</doc>
6363
</function>
64-
<typedef name="U1" id="6UtddyCJy89K/bZpTmDb5jVXwAY=">
64+
<using name="U1" id="6UtddyCJy89K/bZpTmDb5jVXwAY=">
6565
<file path="record-1.cpp" line="3" class="def"/>
66-
</typedef>
66+
<type name="int"/>
67+
</using>
6768
<typedef name="U2" id="wwp4SQjMPktMmsnvq1thxjxFHFs=">
6869
<file path="record-1.cpp" line="4" class="def"/>
70+
<type name="char"/>
6971
</typedef>
7072
</struct>
7173
</namespace>

0 commit comments

Comments
 (0)