Skip to content

Commit

Permalink
chore: RecordInfo 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 bcf02e8 commit 1b6bb13
Show file tree
Hide file tree
Showing 60 changed files with 949 additions and 1,538 deletions.
7 changes: 0 additions & 7 deletions include/mrdox/Corpus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@ class MRDOX_VISIBLE
MRDOX_DECL virtual bool visit(VarInfo const&);
MRDOX_DECL virtual bool visit(FieldInfo const&);
MRDOX_DECL virtual bool visit(SpecializationInfo const&);

MRDOX_DECL virtual bool visit(MemberEnum const&, Access);
MRDOX_DECL virtual bool visit(MemberFunction const&, Access);
MRDOX_DECL virtual bool visit(MemberRecord const&, Access);
MRDOX_DECL virtual bool visit(MemberType const&, Access);
MRDOX_DECL virtual bool visit(DataMember const&, Access);
MRDOX_DECL virtual bool visit(StaticDataMember const&, Access);
};

/** Traverse the symbol, list, or its children.
Expand Down
11 changes: 11 additions & 0 deletions include/mrdox/Metadata/Info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ struct MRDOX_VISIBLE
*/
InfoKind Kind;

/** Declaration access.
Class members use:
@li `AccessKind::Public`,
@li `AccessKind::Protected`, and
@li `AccessKind::Private`.
Namespace members use `AccessKind::None`.
*/
AccessKind Access = AccessKind::None;

/** The unqualified name.
*/
std::string Name;
Expand Down
36 changes: 36 additions & 0 deletions include/mrdox/Metadata/Interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,42 @@
namespace clang {
namespace mrdox {

struct DataMember
{
FieldInfo const* I;
RecordInfo const* From;
};

struct MemberEnum
{
EnumInfo const* I;
RecordInfo const* From;
};

struct MemberFunction
{
FunctionInfo const* I;
RecordInfo const* From;
};

struct MemberRecord
{
RecordInfo const* I;
RecordInfo const* From;
};

struct MemberType
{
TypedefInfo const* I;
RecordInfo const* From;
};

struct StaticDataMember
{
VarInfo const* I;
RecordInfo const* From;
};

/** The aggregated interface for a given struct, class, or union.
*/
class Interface
Expand Down
98 changes: 7 additions & 91 deletions include/mrdox/Metadata/Record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,6 @@
namespace clang {
namespace mrdox {

/** Access specifier.
Public is set to zero since it is the most
frequently occurring access, and it is
elided by the bitstream encoder because it
has an all-zero bit pattern. This improves
compression in the bitstream.
@note It is by design that there is no
constant to represent "none."
*/
enum class Access
{
Public = 0,
Protected,
Private
};

/** A reference to a symbol, and an access specifier.
This is used in records to refer to nested
elements with access control.
*/
struct MemberRef
{
SymbolID id;
Access access;

constexpr MemberRef() = default;

constexpr MemberRef(
const SymbolID& id_,
Access access_)
: id(id_)
, access(access_)
{
}
};

/** Bit constants used with Record metadata
*/
union RecFlags0
Expand All @@ -85,13 +46,13 @@ struct BaseInfo
{
SymbolID id;
std::string Name;
Access access;
AccessKind access;
bool IsVirtual;

BaseInfo(
SymbolID const& id_ = SymbolID::zero,
std::string_view Name_ = "",
Access access_ = Access::Public,
AccessKind access_ = AccessKind::Public,
bool IsVirtual_ = false)
: id(id_)
, Name(Name_)
Expand All @@ -101,19 +62,6 @@ struct BaseInfo
}
};

/** Members of a class, struct, or union.
*/
struct RecordScope
{
std::vector<MemberRef> Records;
std::vector<MemberRef> Functions;
std::vector<MemberRef> Enums;
std::vector<MemberRef> Types;
std::vector<MemberRef> Fields;
std::vector<MemberRef> Vars;
std::vector<SymbolID> Specializations;
};

enum class RecordKeyKind
{
Struct,
Expand Down Expand Up @@ -155,7 +103,11 @@ struct RecordInfo

/** Record members
*/
RecordScope Members;
std::vector<SymbolID> Members;

/** Record member specializations
*/
std::vector<SymbolID> Specializations;

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

Expand All @@ -175,42 +127,6 @@ struct RecordInfo
}
};

struct DataMember
{
FieldInfo const* I;
RecordInfo const* From;
};

struct MemberEnum
{
EnumInfo const* I;
RecordInfo const* From;
};

struct MemberFunction
{
FunctionInfo const* I;
RecordInfo const* From;
};

struct MemberRecord
{
RecordInfo const* I;
RecordInfo const* From;
};

struct MemberType
{
TypedefInfo const* I;
RecordInfo const* From;
};

struct StaticDataMember
{
VarInfo const* I;
RecordInfo const* From;
};

} // mrdox
} // clang

Expand Down
21 changes: 20 additions & 1 deletion include/mrdox/Metadata/Symbols.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ using OptionalSymbolID = Optional<SymbolID>;
*/
enum class InfoKind
{
Namespace,
Namespace = 0,
Record,
Function,
Enum,
Expand All @@ -119,6 +119,25 @@ enum class InfoKind
Specialization
};

/** Access specifier.
Public is set to zero since it is the most
frequently occurring access, and it is
elided by the bitstream encoder because it
has an all-zero bit pattern. This improves
compression in the bitstream.
None is used for namespace members and friend;
such declarations have no access.
*/
enum class AccessKind
{
Public = 0,
Protected,
Private,
None
};

/** Return the result of comparing s0 to s1.
This function returns true if the string
Expand Down
4 changes: 1 addition & 3 deletions include/mrdox/MetadataFwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Corpus;

class Interface;

enum class Access;
enum class AccessKind;
enum class FunctionKind;

struct BaseInfo;
Expand All @@ -36,10 +36,8 @@ struct FunctionInfo;
struct Info;
struct Javadoc;
struct Location;
struct MemberRef;
struct NamespaceInfo;
struct RecordInfo;
struct RecordScope;
struct Param;
struct SpecializationInfo;
struct SpecializedMember;
Expand Down
24 changes: 14 additions & 10 deletions source/-XML/XMLTags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,29 @@ struct Attribute
}

Attribute(
Access access)
AccessKind access)
: name("access")
, value(
[access]
{
switch(access)
{
case Access::Public: return std::string("public");
case Access::Protected: return std::string("protected");
case Access::Private: return std::string("private");
case AccessKind::None:
return std::string();
case AccessKind::Public: return std::string("public");
case AccessKind::Protected: return std::string("protected");
case AccessKind::Private: return std::string("private");
default:
llvm_unreachable("unknown Access");
}
}())
, pred(true)
, pred(access == AccessKind::Private || access == AccessKind::Protected)
{
}

#if 0
Attribute(
Access const* access)
AccessKind const* access)
: name("access")
, value(
[access]
Expand All @@ -134,16 +137,17 @@ struct Attribute
return std::string();
switch(*access)
{
case Access::Public: return std::string("public");
case Access::Protected: return std::string("protected");
case Access::Private: return std::string("private");
case AccessKind::Public: return std::string("public");
case AccessKind::Protected: return std::string("protected");
case AccessKind::Private: return std::string("private");
default:
llvm_unreachable("unknown Access");
}
}())
, pred(access != nullptr && *access != Access::Public)
, pred(access != nullptr && *access != AccessKind::Public)
{
}
#endif

Attribute(
std::optional<TypeInfo> const& opt)
Expand Down
Loading

0 comments on commit 1b6bb13

Please sign in to comment.