Skip to content

Commit f11eb29

Browse files
committed
[FOLD] xmlwriter supports attributes
1 parent 4840abe commit f11eb29

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

src/lib/Gen/xml/XMLWriter.cpp

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ writeEnum(
244244
}
245245

246246
writeSourceInfo(I);
247-
248247
writeJavadoc(I.javadoc);
248+
writeAttributes(I.Attributes);
249249

250250
corpus_.traverse(I, *this);
251251

@@ -269,8 +269,8 @@ writeEnumConstant(
269269
});
270270

271271
writeSourceInfo(I);
272-
273272
writeJavadoc(I.javadoc);
273+
writeAttributes(I.Attributes);
274274

275275
tags_.close(enumConstantTagName);
276276
}
@@ -286,8 +286,8 @@ writeFriend(
286286
});
287287

288288
writeSourceInfo(I);
289-
290289
writeJavadoc(I.javadoc);
290+
writeAttributes(I.Attributes);
291291

292292
Attributes attrs = {};
293293
if(I.FriendSymbol)
@@ -325,6 +325,8 @@ writeFunction(
325325
});
326326

327327
writeSourceInfo(I);
328+
writeJavadoc(I.javadoc);
329+
writeAttributes(I.Attributes);
328330

329331
writeAttr(I.IsVariadic, "is-variadic", tags_);
330332
writeAttr(I.IsVirtualAsWritten, "is-virtual-as-written", tags_);
@@ -348,7 +350,6 @@ writeFunction(
348350
for(auto const& J : I.Params)
349351
writeParam(J, tags_);
350352

351-
writeJavadoc(I.javadoc);
352353

353354
tags_.close(functionTagName);
354355

@@ -381,6 +382,8 @@ writeGuide(
381382
});
382383

383384
writeSourceInfo(I);
385+
writeJavadoc(I.javadoc);
386+
writeAttributes(I.Attributes);
384387

385388
tags_.open(deducedTagName);
386389
writeType(I.Deduced, tags_);
@@ -389,8 +392,6 @@ writeGuide(
389392
for(auto const& J : I.Params)
390393
writeParam(J, tags_);
391394

392-
writeJavadoc(I.javadoc);
393-
394395
tags_.close(guideTagName);
395396

396397
closeTemplate(I.Template);
@@ -411,8 +412,8 @@ writeConcept(
411412
});
412413

413414
writeSourceInfo(I);
414-
415415
writeJavadoc(I.javadoc);
416+
writeAttributes(I.Attributes);
416417

417418
tags_.close(conceptTagName);
418419

@@ -431,8 +432,8 @@ writeNamespaceAlias(
431432
});
432433

433434
writeSourceInfo(I);
434-
435435
writeJavadoc(I.javadoc);
436+
writeAttributes(I.Attributes);
436437

437438
tags_.write("aliased", {}, {
438439
{"name", toString(*I.AliasedSymbol)},
@@ -475,8 +476,8 @@ XMLWriter::
475476
});
476477

477478
writeSourceInfo(I);
478-
479479
writeJavadoc(I.javadoc);
480+
writeAttributes(I.Attributes);
480481

481482
for (auto const& id : I.UsingSymbols)
482483
tags_.write("named", {}, { id });
@@ -500,6 +501,8 @@ writeRecord(
500501
});
501502

502503
writeSourceInfo(I);
504+
writeJavadoc(I.javadoc);
505+
writeAttributes(I.Attributes);
503506

504507
writeAttr(I.IsFinal, "is-final", tags_);
505508
writeAttr(I.IsFinalDestructor, "is-final-dtor", tags_);
@@ -514,7 +517,6 @@ writeRecord(
514517
tags_.close(baseTagName);
515518
}
516519

517-
writeJavadoc(I.javadoc);
518520

519521
corpus_.traverse(I, *this);
520522

@@ -542,11 +544,11 @@ writeTypedef(
542544
});
543545

544546
writeSourceInfo(I);
547+
writeJavadoc(I.javadoc);
548+
writeAttributes(I.Attributes);
545549

546550
writeType(I.Type, tags_);
547551

548-
writeJavadoc(I.javadoc);
549-
550552
tags_.close(tag);
551553

552554
closeTemplate(I.Template);
@@ -576,6 +578,8 @@ writeField(
576578
});
577579

578580
writeSourceInfo(I);
581+
writeJavadoc(I.javadoc);
582+
writeAttributes(I.Attributes);
579583

580584
if(I.IsMutable)
581585
tags_.write(attributeTagName, {}, {
@@ -586,7 +590,6 @@ writeField(
586590

587591
writeType(I.Type, tags_);
588592

589-
writeJavadoc(I.javadoc);
590593

591594
tags_.close(tag_name);
592595
}
@@ -605,6 +608,8 @@ writeVariable(
605608
});
606609

607610
writeSourceInfo(I);
611+
writeJavadoc(I.javadoc);
612+
writeAttributes(I.Attributes);
608613

609614
writeAttr(I.StorageClass, "storage-class", tags_);
610615
writeAttr(I.IsInline, "is-inline", tags_);
@@ -614,7 +619,6 @@ writeVariable(
614619

615620
writeType(I.Type, tags_);
616621

617-
writeJavadoc(I.javadoc);
618622

619623
tags_.close(varTagName);
620624

@@ -623,6 +627,15 @@ writeVariable(
623627

624628
//------------------------------------------------
625629

630+
void
631+
XMLWriter::
632+
writeAttributes(
633+
std::span<const AttributeKind> attributes)
634+
{
635+
for(auto attr : attributes)
636+
tags.write(attributeTagName, {}, { { "id", toString(attr) } });
637+
}
638+
626639
void
627640
XMLWriter::
628641
writeSourceInfo(

src/lib/Gen/xml/XMLWriter.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class XMLWriter
6868
void writeSourceInfo(SourceInfo const& I);
6969
void writeLocation(Location const& loc, bool def = false);
7070
void writeJavadoc(std::optional<Javadoc> const& javadoc);
71+
void writeAttributes(std::span<const AttributeKind> attributes);
7172
void openTemplate(const std::optional<TemplateInfo>& I);
7273
void closeTemplate(const std::optional<TemplateInfo>& I);
7374

0 commit comments

Comments
 (0)