Skip to content

Commit

Permalink
chore: NamespaceInfo member refs are just symbol IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
sdkrystian committed Jun 12, 2023
1 parent 993bfa1 commit 3205784
Show file tree
Hide file tree
Showing 36 changed files with 243 additions and 882 deletions.
1 change: 0 additions & 1 deletion include/mrdox/Corpus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ class MRDOX_VISIBLE
MRDOX_DECL bool traverse(Visitor&, RecordInfo const& I) const;
MRDOX_DECL bool traverse(Visitor&, SpecializationInfo const& I) const;
MRDOX_DECL bool traverse(Visitor&, SymbolID id) const;
MRDOX_DECL bool traverse(Visitor&, std::vector<Reference> const& R) const;
MRDOX_DECL bool traverse(Visitor&, std::vector<SymbolID> const& R) const;
/** @} */

Expand Down
2 changes: 0 additions & 2 deletions include/mrdox/Metadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include <mrdox/Metadata/Namespace.hpp>
#include <mrdox/Metadata/Overloads.hpp>
#include <mrdox/Metadata/Record.hpp>
#include <mrdox/Metadata/Reference.hpp>
#include <mrdox/Metadata/Scope.hpp>
#include <mrdox/Metadata/Specialization.hpp>
#include <mrdox/Metadata/Symbol.hpp>
#include <mrdox/Metadata/Symbols.hpp>
Expand Down
37 changes: 18 additions & 19 deletions include/mrdox/Metadata/Info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include <mrdox/Platform.hpp>
#include <mrdox/Metadata/Javadoc.hpp>
#include <mrdox/Metadata/Reference.hpp>
#include <mrdox/Metadata/Symbols.hpp>
#include <array>
#include <memory>
Expand Down Expand Up @@ -81,15 +80,15 @@ struct MRDOX_VISIBLE
std::string_view
symbolType() const noexcept;

constexpr bool isDefault() { return Kind == InfoKind::Default; }
constexpr bool isNamespace() { return Kind == InfoKind::Namespace; }
constexpr bool isRecord() { return Kind == InfoKind::Record; }
constexpr bool isFunction() { return Kind == InfoKind::Function; }
constexpr bool isEnum() { return Kind == InfoKind::Enum; }
constexpr bool isTypedef() { return Kind == InfoKind::Typedef; }
constexpr bool isVariable() { return Kind == InfoKind::Variable; }
constexpr bool isField() { return Kind == InfoKind::Field; }
constexpr bool isSpecialization() { return Kind == InfoKind::Specialization; }
constexpr bool isDefault() const noexcept { return Kind == InfoKind::Default; }
constexpr bool isNamespace() const noexcept { return Kind == InfoKind::Namespace; }
constexpr bool isRecord() const noexcept { return Kind == InfoKind::Record; }
constexpr bool isFunction() const noexcept { return Kind == InfoKind::Function; }
constexpr bool isEnum() const noexcept { return Kind == InfoKind::Enum; }
constexpr bool isTypedef() const noexcept { return Kind == InfoKind::Typedef; }
constexpr bool isVariable() const noexcept { return Kind == InfoKind::Variable; }
constexpr bool isField() const noexcept { return Kind == InfoKind::Field; }
constexpr bool isSpecialization() const noexcept { return Kind == InfoKind::Specialization; }
};

//------------------------------------------------
Expand All @@ -107,15 +106,15 @@ struct IsInfo : Info
*/
static constexpr InfoKind kind_id = K;

static constexpr bool isDefault() { return K== InfoKind::Default; }
static constexpr bool isNamespace() { return K == InfoKind::Namespace; }
static constexpr bool isRecord() { return K == InfoKind::Record; }
static constexpr bool isFunction() { return K == InfoKind::Function; }
static constexpr bool isEnum() { return K == InfoKind::Enum; }
static constexpr bool isTypedef() { return K == InfoKind::Typedef; }
static constexpr bool isVariable() { return K == InfoKind::Variable; }
static constexpr bool isField() { return K == InfoKind::Field; }
static constexpr bool isSpecialization() { return K == InfoKind::Specialization; }
static constexpr bool isDefault() noexcept { return K== InfoKind::Default; }
static constexpr bool isNamespace() noexcept { return K == InfoKind::Namespace; }
static constexpr bool isRecord() noexcept { return K == InfoKind::Record; }
static constexpr bool isFunction() noexcept { return K == InfoKind::Function; }
static constexpr bool isEnum() noexcept { return K == InfoKind::Enum; }
static constexpr bool isTypedef() noexcept { return K == InfoKind::Typedef; }
static constexpr bool isVariable() noexcept { return K == InfoKind::Variable; }
static constexpr bool isField() noexcept { return K == InfoKind::Field; }
static constexpr bool isSpecialization() noexcept { return K == InfoKind::Specialization; }

protected:
constexpr IsInfo()
Expand Down
5 changes: 3 additions & 2 deletions include/mrdox/Metadata/Namespace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <mrdox/Platform.hpp>
#include <mrdox/Metadata/Info.hpp>
#include <mrdox/Metadata/Scope.hpp>
#include <vector>

namespace clang {
namespace mrdox {
Expand All @@ -24,7 +24,8 @@ namespace mrdox {
struct NamespaceInfo
: IsInfo<InfoKind::Namespace>
{
Scope Children;
std::vector<SymbolID> Members;
std::vector<SymbolID> Specializations;

//--------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions include/mrdox/Metadata/Record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

#include <mrdox/Platform.hpp>
#include <mrdox/ADT/BitField.hpp>
#include <mrdox/Metadata/Enum.hpp>
#include <mrdox/Metadata/Field.hpp>
#include <mrdox/Metadata/Function.hpp>
#include <mrdox/Metadata/Reference.hpp>
#include <mrdox/Metadata/Scope.hpp>
#include <mrdox/Metadata/Symbol.hpp>
#include <mrdox/Metadata/Symbols.hpp>
#include <mrdox/Metadata/Template.hpp>
#include <mrdox/Metadata/Typedef.hpp>
#include <mrdox/Metadata/Var.hpp>
#include <memory>
#include <string>
Expand Down
74 changes: 0 additions & 74 deletions include/mrdox/Metadata/Reference.hpp

This file was deleted.

47 changes: 0 additions & 47 deletions include/mrdox/Metadata/Scope.hpp

This file was deleted.

24 changes: 9 additions & 15 deletions include/mrdox/Metadata/Type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#define MRDOX_API_METADATA_TYPE_HPP

#include <mrdox/Platform.hpp>
#include <mrdox/Metadata/Reference.hpp>
#include <mrdox/Metadata/Symbols.hpp>
#include <string>
#include <string_view>

namespace clang {
namespace mrdox {
Expand All @@ -34,24 +36,16 @@ namespace mrdox {
@li unsigned long, unsigned long long
*/
struct TypeInfo
: Reference
{
TypeInfo() = default;
SymbolID id;
std::string Name;

explicit
TypeInfo(
Reference const& R) noexcept
: Reference(R)
{
}

// Convenience constructor for when there is no symbol ID or info type
// (normally used for built-in types in tests).
explicit
TypeInfo(
std::string_view Name)
: Reference(
SymbolID::zero, Name, InfoKind::Default)
SymbolID ID = SymbolID::zero,
std::string_view name = {}) noexcept
: id(ID)
, Name(name)
{
}

Expand Down
2 changes: 0 additions & 2 deletions include/mrdox/MetadataFwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ struct NamespaceInfo;
struct RecordInfo;
struct RecordScope;
struct Param;
struct Reference;
struct Scope;
struct SpecializationInfo;
struct SpecializedMember;
struct SymbolInfo;
Expand Down
34 changes: 22 additions & 12 deletions source/-adoc/AdocSinglePageWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,24 @@ build()

//------------------------------------------------

// FIXME: we really should sort the members into
// vectors of their respective types in one pass
template<class Type>
std::vector<Type const*>
AdocSinglePageWriter::
buildSortedList(
std::vector<Reference> const& from) const
std::vector<SymbolID> const& from) const
{
std::vector<Type const*> result;
result.reserve(from.size());
for(auto const& ref : from)
result.push_back(&corpus_.get<Type>(ref.id));
for(auto const& id : from)
{
const Info* info = corpus_.find(id);
Assert(info);
if(Type::kind_id == info->Kind)
result.push_back(
static_cast<const Type*>(info));
}
llvm::sort(result,
[&](Info const* I0, Info const* I1)
{
Expand All @@ -76,20 +84,22 @@ visit(
{
// build sorted list of namespaces,
// this is for visitation not display.
auto namespaceList = buildSortedList<NamespaceInfo>(I.Children.Namespaces);
auto recordList = buildSortedList<RecordInfo>(I.Children.Records);

// FIXME: sort members in one pass
auto namespaceList = buildSortedList<NamespaceInfo>(I.Members);
auto recordList = buildSortedList<RecordInfo>(I.Members);
auto functionOverloads = makeNamespaceOverloads(I, corpus_);
auto typedefList = buildSortedList<TypedefInfo>(I.Children.Typedefs);
auto enumList = buildSortedList<EnumInfo>(I.Children.Enums);
auto variableList = buildSortedList<VarInfo>(I.Children.Vars);
auto typedefList = buildSortedList<TypedefInfo>(I.Members);
auto enumList = buildSortedList<EnumInfo>(I.Members);
auto variableList = buildSortedList<VarInfo>(I.Members);

// don't emit empty namespaces,
// but still visit child namespaces.
if( ! I.Children.Records.empty() ||
if( ! namespaceList.empty() ||
! functionOverloads.list.empty() ||
! I.Children.Typedefs.empty() ||
! I.Children.Enums.empty() ||
! I.Children.Vars.empty())
! typedefList.empty() ||
! enumList.empty() ||
! variableList.empty())
{
std::string s;
if(I.id == SymbolID::zero)
Expand Down
2 changes: 1 addition & 1 deletion source/-adoc/AdocSinglePageWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AdocSinglePageWriter
template<class Type>
std::vector<Type const*>
buildSortedList(
std::vector<Reference> const& from) const;
std::vector<SymbolID> const& from) const;

bool visit(NamespaceInfo const&) override;
bool visit(RecordInfo const&) override;
Expand Down
6 changes: 3 additions & 3 deletions source/-adoc/AdocWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ void
AdocWriter::
writeNestedTypes(
llvm::StringRef sectionName,
std::vector<Reference> const& list,
std::vector<SymbolID> const& list,
AccessSpecifier access)
{
if(list.empty())
Expand All @@ -504,9 +504,9 @@ writeNestedTypes(
"|===\n" <<
"|Name |Description\n" <<
"\n";
for(auto const& ref : list)
for(auto const& id : list)
{
auto& I = corpus_.get<TypedefInfo>(ref.id);
auto& I = corpus_.get<TypedefInfo>(id);
#if 0
if(it->Access != access)
continue;
Expand Down
2 changes: 1 addition & 1 deletion source/-adoc/AdocWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class AdocWriter
void writeBase(BaseInfo const& I);
void writeNestedTypes(
llvm::StringRef sectionName,
std::vector<Reference> const& list,
std::vector<SymbolID> const& list,
AccessSpecifier access);

void writeFunctionDeclaration(
Expand Down
Loading

0 comments on commit 3205784

Please sign in to comment.