Skip to content

Commit b46e8df

Browse files
committed
refactor record members, include access specifier
1 parent 51fdd68 commit b46e8df

34 files changed

+918
-873
lines changed

include/mrdox/Corpus.hpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,24 @@ class MRDOX_VISIBLE
107107
MRDOX_DECL virtual bool visit(TypedefInfo const&);
108108
MRDOX_DECL virtual bool visit(EnumInfo const&);
109109
MRDOX_DECL virtual bool visit(VarInfo const&);
110+
111+
MRDOX_DECL virtual bool visit(DataMember const&);
112+
MRDOX_DECL virtual bool visit(MemberEnum const&);
113+
MRDOX_DECL virtual bool visit(MemberFunction const&);
114+
MRDOX_DECL virtual bool visit(MemberRecord const&);
115+
MRDOX_DECL virtual bool visit(MemberType const&);
116+
MRDOX_DECL virtual bool visit(StaticDataMember const&);
110117
};
111118

112-
/** Visit the specified symbol ID or node.
119+
/** Traverse the symbol, list, or its children.
113120
*/
114121
/** @{ */
115-
MRDOX_DECL bool visit(Visitor& f, SymbolID id) const;
116-
MRDOX_DECL bool visit(Visitor& f, std::vector<Reference> const& R) const;
117-
MRDOX_DECL bool visit(Visitor& f, std::vector<SymbolID> const& R) const;
118-
MRDOX_DECL bool visit(Visitor& f, Scope const& I) const;
119-
MRDOX_DECL bool visit(Visitor& f, Info const& I) const;
122+
MRDOX_DECL bool traverse(Visitor&, Info const& I) const;
123+
MRDOX_DECL bool traverse(Visitor&, NamespaceInfo const& I) const;
124+
MRDOX_DECL bool traverse(Visitor&, RecordInfo const& I) const;
125+
MRDOX_DECL bool traverse(Visitor&, SymbolID id) const;
126+
MRDOX_DECL bool traverse(Visitor&, std::vector<Reference> const& R) const;
127+
MRDOX_DECL bool traverse(Visitor&, std::vector<SymbolID> const& R) const;
120128
/** @} */
121129

122130
//--------------------------------------------

include/mrdox/Metadata/Function.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,6 @@ struct FunctionInfo : SymbolInfo
7979
TypeInfo ReturnType; // Info about the return type of this function.
8080
llvm::SmallVector<FieldTypeInfo, 4> Params; // List of parameters.
8181

82-
// Access level for this method (public, private, protected, none).
83-
// AS_public is set as default because the bitcode writer requires the enum
84-
// with value 0 to be used as the default.
85-
// (AS_public = 0, AS_protected = 1, AS_private = 2, AS_none = 3)
86-
AccessSpecifier Access = AccessSpecifier::AS_public;
87-
8882
// Full qualified name of this function, including namespaces and template
8983
// specializations.
9084
SmallString<16> FullName;

include/mrdox/Metadata/Interface.hpp

Lines changed: 13 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -14,56 +14,14 @@
1414

1515
#include <mrdox/Platform.hpp>
1616
#include <mrdox/MetadataFwd.hpp>
17-
#include <mrdox/Metadata/Access.hpp>
17+
#include <mrdox/Metadata/Members.hpp>
1818
#include <span>
1919
#include <utility>
2020
#include <vector>
2121

2222
namespace clang {
2323
namespace mrdox {
2424

25-
struct RecordWithAccess
26-
{
27-
RecordInfo const* I;
28-
RecordInfo const* From;
29-
Access access;
30-
};
31-
32-
struct FunctionWithAccess
33-
{
34-
FunctionInfo const* I;
35-
RecordInfo const* From;
36-
Access access;
37-
};
38-
39-
struct EnumWithAccess
40-
{
41-
EnumInfo const* I;
42-
RecordInfo const* From;
43-
Access access;
44-
};
45-
46-
struct TypeWithAccess
47-
{
48-
TypedefInfo const* I;
49-
RecordInfo const* From;
50-
Access access;
51-
};
52-
53-
struct VarWithAccess
54-
{
55-
VarInfo const* I;
56-
RecordInfo const* From;
57-
Access access;
58-
};
59-
60-
struct DataWithAccess
61-
{
62-
MemberTypeInfo const* I;
63-
RecordInfo const* From;
64-
Access access;
65-
};
66-
6725
/** The aggregated interface for a given struct, class, or union.
6826
*/
6927
class Interface
@@ -73,12 +31,12 @@ class Interface
7331
*/
7432
struct Tranche
7533
{
76-
std::span<RecordWithAccess const> Records;
77-
std::span<FunctionWithAccess const> Functions;
78-
std::span<EnumWithAccess const> Enums;
79-
std::span<TypeWithAccess const> Types;
80-
std::span<DataWithAccess const> Data;
81-
std::span<VarWithAccess const> Vars;
34+
std::span<MemberRecord const> Records;
35+
std::span<MemberFunction const> Functions;
36+
std::span<MemberEnum const> Enums;
37+
std::span<MemberType const> Types;
38+
std::span<DataMember const> Data;
39+
std::span<StaticDataMember const> Vars;
8240
};
8341

8442
/** The aggregated public interfaces.
@@ -104,12 +62,12 @@ class Interface
10462
private:
10563
class Build;
10664

107-
std::vector<RecordWithAccess> records_;
108-
std::vector<FunctionWithAccess> functions_;
109-
std::vector<EnumWithAccess> enums_;
110-
std::vector<TypeWithAccess> types_;
111-
std::vector<DataWithAccess> data_;
112-
std::vector<VarWithAccess> vars_;
65+
std::vector<MemberRecord> records_;
66+
std::vector<MemberFunction> functions_;
67+
std::vector<MemberEnum> enums_;
68+
std::vector<MemberType> types_;
69+
std::vector<DataMember> data_;
70+
std::vector<StaticDataMember> vars_;
11371
};
11472

11573
//------------------------------------------------

include/mrdox/Metadata/Members.hpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//
2+
// This is a derivative work. originally part of the LLVM Project.
3+
// Licensed under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
// Copyright (c) 2023 Vinnie Falco ([email protected])
8+
//
9+
// Official repository: https://github.com/cppalliance/mrdox
10+
//
11+
12+
#ifndef MRDOX_METADATA_MEMBERS_HPP
13+
#define MRDOX_METADATA_MEMBERS_HPP
14+
15+
#include <mrdox/Platform.hpp>
16+
#include <mrdox/Metadata/Access.hpp>
17+
#include <mrdox/Metadata/Enum.hpp>
18+
#include <mrdox/Metadata/Function.hpp>
19+
#include <mrdox/Metadata/MemberType.hpp>
20+
#include <mrdox/Metadata/Record.hpp>
21+
#include <mrdox/Metadata/Typedef.hpp>
22+
#include <mrdox/Metadata/Var.hpp>
23+
24+
namespace clang {
25+
namespace mrdox {
26+
27+
struct DataMember
28+
{
29+
MemberTypeInfo const* I;
30+
RecordInfo const* From;
31+
Access access;
32+
};
33+
34+
struct MemberEnum
35+
{
36+
EnumInfo const* I;
37+
RecordInfo const* From;
38+
Access access;
39+
};
40+
41+
struct MemberFunction
42+
{
43+
FunctionInfo const* I;
44+
RecordInfo const* From;
45+
Access access;
46+
};
47+
48+
struct MemberRecord
49+
{
50+
RecordInfo const* I;
51+
RecordInfo const* From;
52+
Access access;
53+
};
54+
55+
struct MemberType
56+
{
57+
TypedefInfo const* I;
58+
RecordInfo const* From;
59+
Access access;
60+
};
61+
62+
struct StaticDataMember
63+
{
64+
VarInfo const* I;
65+
RecordInfo const* From;
66+
Access access;
67+
};
68+
69+
} // mrdox
70+
} // clang
71+
72+
#endif

include/mrdox/Metadata/Overloads.hpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,47 +24,6 @@ namespace clang {
2424
namespace mrdox {
2525

2626
class Corpus;
27-
struct Scope;
28-
29-
/** A list of overloads for one function name.
30-
*/
31-
struct Overloads
32-
{
33-
llvm::StringRef name;
34-
std::vector<FunctionInfo const*> list;
35-
};
36-
37-
/** A set of unique function names in a scope
38-
*/
39-
struct OverloadsSet
40-
{
41-
/** The access control of this scope.
42-
*/
43-
AccessSpecifier access;
44-
45-
/** The list of function overloads in the scope.
46-
*/
47-
std::vector<Overloads> list;
48-
};
49-
50-
/** Create an overload set for all functions in a scope.
51-
*/
52-
MRDOX_DECL
53-
OverloadsSet
54-
makeOverloadsSet(
55-
Corpus const& corpus,
56-
Scope const& scope);
57-
58-
/** Create an overload set for all functions in a scope.
59-
*/
60-
MRDOX_DECL
61-
OverloadsSet
62-
makeOverloadsSet(
63-
Corpus const& corpus,
64-
Scope const& scope,
65-
AccessSpecifier access);
66-
67-
//------------------------------------------------
6827

6928
struct OverloadInfo
7029
{

include/mrdox/Metadata/Record.hpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ struct BaseInfo
6363
}
6464
};
6565

66+
/** Children of a class, struct, or union.
67+
*/
68+
struct RecordScope
69+
{
70+
std::vector<RefWithAccess> Records;
71+
std::vector<RefWithAccess> Functions;
72+
std::vector<RefWithAccess> Enums;
73+
std::vector<RefWithAccess> Types;
74+
std::vector<RefWithAccess> Vars;
75+
};
76+
6677
/** Metadata for struct, class, or union.
6778
*/
6879
struct RecordInfo : SymbolInfo
@@ -96,18 +107,7 @@ struct RecordInfo : SymbolInfo
96107
*/
97108
llvm::SmallVector<SymbolID, 4> Friends;
98109

99-
mrdox::Scope Children;
100-
101-
struct Scope
102-
{
103-
std::vector<RefWithAccess> Records;
104-
std::vector<RefWithAccess> Functions;
105-
std::vector<RefWithAccess> Enums;
106-
std::vector<RefWithAccess> Types;
107-
std::vector<RefWithAccess> Vars;
108-
};
109-
110-
Scope Children_;
110+
RecordScope Children_;
111111

112112
//--------------------------------------------
113113

@@ -118,7 +118,6 @@ struct RecordInfo : SymbolInfo
118118
SymbolID id = SymbolID(),
119119
llvm::StringRef Name = llvm::StringRef())
120120
: SymbolInfo(InfoType::IT_record, id, Name)
121-
, Children(false)
122121
{
123122
}
124123
};

include/mrdox/MetadataFwd.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ struct EnumValueInfo;
3030
struct EnumInfo;
3131
struct FieldTypeInfo;
3232
struct FunctionInfo;
33-
struct Overloads;
34-
struct OverloadsSet;
3533
struct Info;
3634
struct Javadoc;
3735
struct Location;
3836
struct MemberTypeInfo;
3937
struct NamespaceInfo;
4038
struct RecordInfo;
39+
struct RecordScope;
4140
struct RefWithAccess;
4241
struct Reference;
4342
struct Scope;
@@ -50,6 +49,12 @@ struct TypedefInfo;
5049
struct VarInfo;
5150
struct VerbatimBlock;
5251

52+
struct DataMember;
53+
struct MemberEnum;
54+
struct MemberFunction;
55+
struct MemberRecord;
56+
struct MemberType;
57+
struct StaticDataMember;
5358

5459
template<unsigned char Offset,
5560
unsigned char Size,

0 commit comments

Comments
 (0)