Refactored type_alias
This commit is contained in:
@@ -316,6 +316,20 @@ bool operator==(const class_template &l, const class_template &r)
|
|||||||
return (l.name == r.name) && (l.type == r.type);
|
return (l.name == r.name) && (l.type == r.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// type_alias
|
||||||
|
//
|
||||||
|
void type_alias::set_alias(const std::string &alias) { alias_ = alias; }
|
||||||
|
|
||||||
|
std::string type_alias::alias() const { return alias_; }
|
||||||
|
|
||||||
|
void type_alias::set_underlying_type(const std::string &type)
|
||||||
|
{
|
||||||
|
underlying_type_ = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string type_alias::underlying_type() const { return underlying_type_; }
|
||||||
|
|
||||||
//
|
//
|
||||||
// class_
|
// class_
|
||||||
//
|
//
|
||||||
@@ -387,8 +401,8 @@ bool operator==(const class_ &l, const class_ &r)
|
|||||||
|
|
||||||
void class_::add_type_alias(type_alias &&ta)
|
void class_::add_type_alias(type_alias &&ta)
|
||||||
{
|
{
|
||||||
LOG_DBG("Adding class alias: {} -> {}", ta.alias, ta.underlying_type);
|
LOG_DBG("Adding class alias: {} -> {}", ta.alias(), ta.underlying_type());
|
||||||
type_aliases_[ta.alias] = std::move(ta);
|
type_aliases_[ta.alias()] = std::move(ta);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string class_::full_name(bool relative) const
|
std::string class_::full_name(bool relative) const
|
||||||
@@ -480,9 +494,9 @@ bool diagram::has_class(const class_ &c) const
|
|||||||
|
|
||||||
void diagram::add_type_alias(type_alias &&ta)
|
void diagram::add_type_alias(type_alias &&ta)
|
||||||
{
|
{
|
||||||
LOG_DBG("Adding global alias: {} -> {}", ta.alias, ta.underlying_type);
|
LOG_DBG("Adding global alias: {} -> {}", ta.alias(), ta.underlying_type());
|
||||||
|
|
||||||
type_aliases_[ta.alias] = std::move(ta);
|
type_aliases_[ta.alias()] = std::move(ta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void diagram::add_class(class_ &&c)
|
void diagram::add_class(class_ &&c)
|
||||||
|
|||||||
@@ -244,9 +244,17 @@ private:
|
|||||||
static std::atomic_uint64_t m_nextId;
|
static std::atomic_uint64_t m_nextId;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct type_alias {
|
class type_alias {
|
||||||
std::string alias;
|
public:
|
||||||
std::string underlying_type;
|
void set_alias(const std::string &alias);
|
||||||
|
std::string alias() const;
|
||||||
|
|
||||||
|
void set_underlying_type(const std::string &type);
|
||||||
|
std::string underlying_type() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string alias_;
|
||||||
|
std::string underlying_type_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class class_ : public element, public stylable_element {
|
class class_ : public element, public stylable_element {
|
||||||
|
|||||||
@@ -246,9 +246,9 @@ void tu_visitor::operator()(const cppast::cpp_entity &file)
|
|||||||
|
|
||||||
auto &ta = static_cast<const cppast::cpp_type_alias &>(e);
|
auto &ta = static_cast<const cppast::cpp_type_alias &>(e);
|
||||||
type_alias t;
|
type_alias t;
|
||||||
t.alias = cx::util::full_name(ctx.namespace_, ta);
|
t.set_alias(cx::util::full_name(ctx.namespace_, ta));
|
||||||
t.underlying_type = cx::util::full_name(ta.underlying_type(),
|
t.set_underlying_type(cx::util::full_name(ta.underlying_type(),
|
||||||
ctx.entity_index, cx::util::is_inside_class(e));
|
ctx.entity_index, cx::util::is_inside_class(e)));
|
||||||
|
|
||||||
ctx.add_type_alias(cx::util::full_name(ctx.namespace_, ta),
|
ctx.add_type_alias(cx::util::full_name(ctx.namespace_, ta),
|
||||||
type_safe::ref(ta.underlying_type()));
|
type_safe::ref(ta.underlying_type()));
|
||||||
|
|||||||
Reference in New Issue
Block a user