Skip to content

Commit 4d3d0d8

Browse files
sdkrystianalandefreitas
authored andcommitted
feat: recursive TypeInfo structure
closes cppalliance#209, closes cppalliance#343
1 parent df530ad commit 4d3d0d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1735
-435
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{#if (eq kind "lvalue-reference")~}}
2+
{{#if (or (eq pointee-type.kind "array") (eq pointee-type.kind "function"))~}}){{~/if~}}
3+
{{~>declarator-after pointee-type~}}
4+
{{~else if (eq kind "rvalue-reference")~}}
5+
{{#if (or (eq pointee-type.kind "array") (eq pointee-type.kind "function"))~}}){{~/if~}}
6+
{{~>declarator-after pointee-type~}}
7+
{{~else if (eq kind "pointer")~}}
8+
{{#if (or (eq pointee-type.kind "array") (eq pointee-type.kind "function"))~}}){{~/if~}}
9+
{{~>declarator-after pointee-type~}}
10+
{{~else if (eq kind "member-pointer")~}}
11+
{{#if (or (eq pointee-type.kind "array") (eq pointee-type.kind "function"))~}}){{~/if~}}
12+
{{~>declarator-after pointee-type~}}
13+
{{~else if (eq kind "pack")~}}
14+
{{~>declarator-after pattern-type~}}
15+
{{~else if (eq kind "array")~}}
16+
[{{bounds-value}}]
17+
{{~>declarator-after element-type~}}
18+
{{~else if (eq kind "function")~}}
19+
({{~#each param-types~}}
20+
{{~>declarator decl-name="" decl-name-targs=""~}}{{~#unless @last}}, {{/unless~}}
21+
{{~/each~}})
22+
{{~#if cv-qualifiers}} {{cv-qualifiers}}{{/if~}}
23+
{{~#if (eq ref-qualifier "lvalue")}} &{{else if (eq ref-qualifier "rvalue")}} &&{{/if~}}
24+
{{~#if exception-spec}} {{exception-spec}}{{~/if~}}
25+
{{~>declarator-after return-type~}}
26+
{{/if}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{#if (eq kind "builtin")~}}
2+
{{#if cv-qualifiers}}{{cv-qualifiers}} {{/if~}}
3+
{{name~}}
4+
{{~else if (eq kind "tag")~}}
5+
{{#if cv-qualifiers}}{{cv-qualifiers}} {{/if~}}
6+
{{#if parent-type~}}{{>declarator parent-type decl-name="" decl-name-targs=""}}::{{/if~}}
7+
{{#if id}}xref:{{id}}[{{name~}}]{{else}}{{name~}}{{/if}}
8+
{{~else if (eq kind "specialization")~}}
9+
{{#if cv-qualifiers}}{{cv-qualifiers}} {{/if~}}
10+
{{#if parent-type~}}{{>declarator parent-type decl-name="" decl-name-targs=""}}::{{/if~}}
11+
{{#if id}}xref:{{id}}[{{name~}}]{{else}}{{name~}}{{/if}}
12+
{{~>template-args args=template-args~}}
13+
{{~else if (eq kind "lvalue-reference")~}}
14+
{{~>declarator-before pointee-type~}}
15+
{{#if (or (eq pointee-type.kind "array") (eq pointee-type.kind "function"))~}}({{~/if~}}&
16+
{{~else if (eq kind "rvalue-reference")~}}
17+
{{~>declarator-before pointee-type~}}
18+
{{#if (or (eq pointee-type.kind "array") (eq pointee-type.kind "function"))~}}({{~/if~}}&&
19+
{{~else if (eq kind "pointer")~}}
20+
{{~>declarator-before pointee-type~}}
21+
{{#if (or (eq pointee-type.kind "array") (eq pointee-type.kind "function"))~}}({{~/if~}}*
22+
{{~#if cv-qualifiers}} {{cv-qualifiers}}{{/if~}}
23+
{{~else if (eq kind "member-pointer")~}}
24+
{{~>declarator-before pointee-type~}}
25+
{{#if (or (eq pointee-type.kind "array") (eq pointee-type.kind "function"))~}}({{~/if~}}
26+
{{#if parent-type~}}{{>declarator parent-type decl-name="" decl-name-targs=""}}::*{{/if~}}
27+
{{#if cv-qualifiers}} {{cv-qualifiers}}{{/if~}}
28+
{{~else if (eq kind "pack")~}}
29+
{{~>declarator-before pattern-type~}}...
30+
{{~else if (eq kind "array")~}}
31+
{{~>declarator-before element-type~}}
32+
{{~else if (eq kind "function")~}}
33+
{{~>declarator-before return-type~}}
34+
{{/if}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{>declarator-before~}}
2+
{{~#if decl-name}} {{decl-name~}}
3+
{{~#if decl-name-targs~}}{{>template-args args=decl-name-targs}}{{~/if~}}
4+
{{~/if~}}
5+
{{~>declarator-after~}}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
[source,cpp,subs=+macros]
22
----
3-
{{#if (eq storageClass "static")}}
4-
static
5-
{{/if}}
6-
{{>type-name return}}
3+
{{#if template}}{{>template-head template}}{{/if~}}
4+
{{#if (eq storageClass "static")}}static
5+
{{/if~}}
6+
{{>declarator-before return}}
77
8-
{{#if params}}
9-
{{name}}(
8+
{{name~}}
9+
{{#if (eq template.kind "explicit")~}}
10+
{{~>template-args args=template.args~}}
11+
{{~/if~}}
12+
13+
{{~#if params}}
14+
(
1015
{{#each params}}
11-
{{>type-name type~}}
12-
{{#if name}} {{name}}{{/if}}
16+
{{>declarator type decl-name=name~}}
1317
{{~#if @last}}){{else}},
1418
{{/if}}
1519
{{~/each}}
1620
{{~else~}}
17-
{{name}}()
21+
()
1822
{{~/if~}}
1923
{{#if (eq exceptionSpec "noexcept")}} noexcept{{/if~}}
24+
{{~>declarator-after return~}}
2025
{{#if isDeleted}} = delete{{/if~}}
2126
;
2227
----

addons/generator/asciidoc/partials/record-member.adoc.hbs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{{#if (eq kind "function")}}
22
{{#if (eq storageClass "static")}}static {{/if~}}
3-
{{>type-name return}} {{name}}(
3+
{{>declarator return decl-name=""}} {{name}}(
44
{{~#each params}}
5-
{{>type-name type}}
5+
{{>declarator type decl-name=""}}
66
{{#if name}} {{name}}{{/if}}
77
{{~#unless @last}}, {{/unless}}
88
{{~/each}})

addons/generator/asciidoc/partials/record.adoc.hbs

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
{{#if symbol.template}}
1212
{{>template-head symbol.template}}
1313
{{symbol.tag}} {{symbol.name~}}
14-
{{>template-args symbol.template}}
14+
{{#if (neq symbol.template.kind "primary")~}}
15+
{{>template-args args=symbol.template.args}}
16+
{{/if}}
1517
{{else}}
1618
{{symbol.tag}} {{symbol.name~}}
1719
{{/if}}
@@ -22,7 +24,7 @@
2224
{{#if @first}}:{{else}},{{/if}}
2325
{{~#unless (eq access ../symbol.defaultAccess)}} {{access}}{{/unless}}
2426
{{~#if isVirtual}} virtual{{/if}}
25-
{{~null}} {{type.name}}
27+
{{~null}} {{>declarator type decl-name=""}}
2628
{{~#if @last}};{{/if}}
2729
{{/each}}
2830
{{/unless}}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
{{#if (neq kind "primary")~}}<
2-
{{~#each args~}}
1+
<{{~#each args~}}
32
{{value}}
43
{{~#if (not @last)}}, {{/if}}
5-
{{~/each~}}
6-
>{{/if}}
4+
{{~/each~}}>
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
{{#if params~}}
12
template<
23
{{#each params}}
34
{{#if (eq kind "type")}}
4-
{{>type-tparam~}}
5+
{{>tparam-type~}}
56
{{else if (eq kind "non-type")}}
6-
{{>nontype-tparam~}}
7+
{{>tparam-nontype~}}
78
{{else if (eq kind "template")}}
8-
{{>template-tparam~}}
9+
{{>tparam-template~}}
910
{{/if}}
1011
{{~#unless @last}},
1112
{{else}}
1213
{{/unless}}
1314
{{/each}}>
15+
{{else~}}
16+
template<>
17+
{{/if}}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{>type-name type}}
1+
{{>declarator type decl-name=""}}
22
{{~#if is-pack}}...{{/if}}
33
{{~#if name}} {{name}}{{/if}}
44
{{~#if default}} = {{default}}{{/if~}}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
typename
22
{{~#if is-pack}}...{{/if}}
33
{{~#if name}} {{name}}{{/if}}
4-
{{~#if default}} = {{>type-name default}}{{~/if~}}
4+
{{~#if default}} = {{>declarator default decl-name=""}}{{~/if~}}

addons/generator/asciidoc/partials/type-name.adoc.hbs

-4
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1 +1,27 @@
11
{{!-- typedef --}}
2+
[#{{symbol.id}}]
3+
== {{symbol.name}}
4+
5+
{{symbol.doc.brief}}
6+
7+
=== Synopsis
8+
9+
[source,cpp,subs=+macros]
10+
----
11+
{{#if symbol.isUsing~}}
12+
{{~#if symbol.template}}{{>template-head symbol.template}}{{/if~}}
13+
using {{symbol.name}} = {{>declarator symbol.type}}
14+
{{~else~}}
15+
typedef {{>declarator symbol.type decl-name=symbol.name}}
16+
{{~/if}}
17+
;
18+
----
19+
20+
{{>source symbol.loc}}
21+
22+
{{#if symbol.doc.description}}
23+
=== Description
24+
25+
{{symbol.doc.description}}
26+
27+
{{/if}}

addons/generator/asciidoc/partials/variable.adoc.hbs

+6-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88

99
[source,cpp,subs=+macros]
1010
----
11-
{{#if symbol.template}}
12-
{{>template-head symbol.template}}
13-
{{symbol.type.name}} {{symbol.name~}}
14-
{{>template-args symbol.template}}
15-
{{else}}
16-
{{symbol.type.name}} {{symbol.name~}}
17-
{{/if}}
11+
{{#if symbol.template}}{{>template-head symbol.template}}{{/if~}}
12+
{{#if (or (eq symbol.template.kind "explicit") (eq symbol.template.kind "partial"))~}}
13+
{{~>declarator symbol.type decl-name=symbol.name decl-name-targs=symbol.template.args~}}
14+
{{~else~}}
15+
{{~>declarator symbol.type decl-name=symbol.name decl-name-targs=""~}}
16+
{{~/if}}
1817
;
1918
----
2019

include/mrdox/Metadata/Enum.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct EnumInfo
7070
// Set to nonempty to the type when this is an explicitly typed enum. For
7171
// enum Foo : short { ... };
7272
// this will be "short".
73-
std::optional<TypeInfo> BaseType;
73+
std::unique_ptr<TypeInfo> BaseType;
7474

7575
// Enumeration members.
7676
std::vector<EnumValueInfo> Members;

include/mrdox/Metadata/Field.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct FieldInfo
4343
, SourceInfo
4444
{
4545
/** Type of the field */
46-
TypeInfo Type;
46+
std::unique_ptr<TypeInfo> Type;
4747

4848
/** The default member initializer, if any.
4949
*/

include/mrdox/Metadata/Function.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ union FnFlags1
9393
struct Param
9494
{
9595
/** The type of this parameter */
96-
TypeInfo Type;
96+
std::unique_ptr<TypeInfo> Type;
9797

9898
/** The parameter name.
9999
@@ -107,7 +107,7 @@ struct Param
107107
Param() = default;
108108

109109
Param(
110-
TypeInfo&& type,
110+
std::unique_ptr<TypeInfo>&& type,
111111
std::string&& name,
112112
std::string&& def_arg)
113113
: Type(std::move(type))
@@ -125,7 +125,7 @@ struct FunctionInfo
125125
{
126126
friend class ASTVisitor;
127127

128-
TypeInfo ReturnType; // Info about the return type of this function.
128+
std::unique_ptr<TypeInfo> ReturnType; // Info about the return type of this function.
129129
std::vector<Param> Params; // List of parameters.
130130

131131
// When present, this function is a template or specialization.

include/mrdox/Metadata/Info.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct MRDOX_VISIBLE
9090
//--------------------------------------------
9191

9292
virtual ~Info() = default;
93-
Info(Info const &Other) = delete;
93+
Info(Info const& Other) = delete;
9494
Info(Info&& Other) = default;
9595

9696
explicit

include/mrdox/Metadata/Record.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ union RecFlags0
4444
*/
4545
struct BaseInfo
4646
{
47-
TypeInfo Type;
47+
std::unique_ptr<TypeInfo> Type;
4848
AccessKind Access = AccessKind::Public;
4949
bool IsVirtual = false;
5050

5151
BaseInfo() = default;
5252

5353
BaseInfo(
54-
TypeInfo&& type,
54+
std::unique_ptr<TypeInfo>&& type,
5555
AccessKind access,
5656
bool is_virtual)
5757
: Type(std::move(type))

include/mrdox/Metadata/Template.hpp

+2-18
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ struct TParam;
4444
struct TypeTParam
4545
{
4646
/** Default type for the type template parameter */
47-
std::optional<TypeInfo> Default;
47+
std::unique_ptr<TypeInfo> Default;
4848
};
4949

5050
struct NonTypeTParam
5151
{
5252
/** Type of the non-type template parameter */
53-
TypeInfo Type;
53+
std::unique_ptr<TypeInfo> Type;
5454
// Non-type template parameter default value (if any)
5555
Optional<std::string> Default;
5656
};
@@ -118,22 +118,13 @@ struct TParam
118118
TParam(
119119
TParam&& other) noexcept;
120120

121-
MRDOX_DECL
122-
TParam(
123-
const TParam& other);
124-
125121
MRDOX_DECL
126122
TParam(
127123
std::string&& name,
128124
bool is_pack);
129125

130126
MRDOX_DECL ~TParam();
131127

132-
MRDOX_DECL
133-
TParam&
134-
operator=(
135-
const TParam& other);
136-
137128
MRDOX_DECL
138129
TParam&
139130
operator=(
@@ -234,13 +225,6 @@ struct TemplateInfo
234225
*/
235226
OptionalSymbolID Primary;
236227

237-
#if 0
238-
/** Stores information for explicit specializations of members
239-
of implicitly instantiated class template specializations
240-
*/
241-
std::vector<SpecializationInfo> Specializations;
242-
#endif
243-
244228
// KRYSTIAN NOTE: using the presence of args/params
245229
// to determine the specialization kind *should* work.
246230
// emphasis on should.

0 commit comments

Comments
 (0)