Skip to content

Commit

Permalink
unify traverse functions
Browse files Browse the repository at this point in the history
#refactor
  • Loading branch information
alandefreitas committed Dec 17, 2024
1 parent 1579517 commit 938b673
Show file tree
Hide file tree
Showing 12 changed files with 459 additions and 469 deletions.
2 changes: 1 addition & 1 deletion include/mrdocs/Metadata/Concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct ConceptInfo
{
/** The concepts template parameters
*/
std::unique_ptr<TemplateInfo> Template;
std::optional<TemplateInfo> Template;

/** The concepts constraint-expression
*/
Expand Down
13 changes: 8 additions & 5 deletions include/mrdocs/Metadata/Function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,16 @@ struct FunctionInfo
: InfoCommonBase<InfoKind::Function>
, SourceInfo
{
std::unique_ptr<TypeInfo> ReturnType; // Info about the return type of this function.
std::vector<Param> Params; // List of parameters.
/// Info about the return type of this function.
std::unique_ptr<TypeInfo> ReturnType;

// When present, this function is a template or specialization.
std::unique_ptr<TemplateInfo> Template;
/// List of parameters.
std::vector<Param> Params;

// the class of function this is
/// When present, this function is a template or specialization.
std::optional<TemplateInfo> Template;

/// The class of function this is
FunctionClass Class = FunctionClass::Normal;

NoexceptInfo Noexcept;
Expand Down
2 changes: 1 addition & 1 deletion include/mrdocs/Metadata/Guide.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct GuideInfo

/** Template head, if any.
*/
std::unique_ptr<TemplateInfo> Template;
std::optional<TemplateInfo> Template;

/** The parameters of the deduction guide.
*/
Expand Down
8 changes: 4 additions & 4 deletions include/mrdocs/Metadata/Record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ struct RecordInfo
*/
RecordKeyKind KeyKind = RecordKeyKind::Struct;

// When present, this record is a template or specialization.
std::unique_ptr<TemplateInfo> Template;
/// When present, this record is a template or specialization.
std::optional<TemplateInfo> Template;

// Indicates if the record was declared using a typedef. Things like anonymous
// structs in a typedef:
// Indicates if the record was declared using a typedef.
// Things like anonymous structs in a typedef:
// typedef struct { ... } foo_t;
// are converted into records with the typedef as the Name + this flag set.
// KRYSTIAN FIXME: this does not account for alias-declarations
Expand Down
11 changes: 8 additions & 3 deletions include/mrdocs/Metadata/Template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,14 @@ struct TemplateInfo
TemplateSpecKind specializationKind() const noexcept
{
if(Params.empty())
{
return TemplateSpecKind::Explicit;
return Args.empty() ? TemplateSpecKind::Primary :
TemplateSpecKind::Partial;
}
if (Args.empty())
{
return TemplateSpecKind::Primary;
}
return TemplateSpecKind::Partial;
}
};

Expand All @@ -388,7 +393,7 @@ void
tag_invoke(
dom::ValueFromTag,
dom::Value& v,
std::unique_ptr<TemplateInfo> const& I,
std::optional<TemplateInfo> const& I,
DomCorpus const* domCorpus)
{
if (!I)
Expand Down
2 changes: 1 addition & 1 deletion include/mrdocs/Metadata/Typedef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct TypedefInfo
// typedef std::vector<int> MyVector;
bool IsUsing = false;

std::unique_ptr<TemplateInfo> Template;
std::optional<TemplateInfo> Template;

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

Expand Down
2 changes: 1 addition & 1 deletion include/mrdocs/Metadata/Variable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct VariableInfo
/** The type of the variable */
std::unique_ptr<TypeInfo> Type;

std::unique_ptr<TemplateInfo> Template;
std::optional<TemplateInfo> Template;

ExprInfo Initializer;

Expand Down
Loading

0 comments on commit 938b673

Please sign in to comment.