Added aliased template handling
This commit is contained in:
@@ -168,8 +168,7 @@ public:
|
||||
|
||||
void add_type_alias(type_alias &&ta)
|
||||
{
|
||||
spdlog::debug(
|
||||
"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);
|
||||
}
|
||||
|
||||
@@ -210,7 +209,7 @@ public:
|
||||
|
||||
return fmt::format("{}", fmt::join(res, " "));
|
||||
});
|
||||
ostr << fmt::format("<{}>", fmt::join(tnames, ", "));
|
||||
ostr << fmt::format("<{}>", fmt::join(tnames, ","));
|
||||
}
|
||||
|
||||
return ostr.str();
|
||||
@@ -249,29 +248,28 @@ struct diagram {
|
||||
|
||||
void add_type_alias(type_alias &&ta)
|
||||
{
|
||||
spdlog::debug(
|
||||
"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);
|
||||
}
|
||||
|
||||
void add_class(class_ &&c)
|
||||
{
|
||||
spdlog::debug("Adding class: {}, {}", c.name, c.usr);
|
||||
LOG_DBG("Adding class: {}, {}", c.name, c.usr);
|
||||
if (!has_class(c.usr))
|
||||
classes.emplace_back(std::move(c));
|
||||
else
|
||||
spdlog::debug("Class {} already in the model", c.name);
|
||||
LOG_DBG("Class {} already in the model", c.name);
|
||||
}
|
||||
|
||||
void add_enum(enum_ &&e)
|
||||
{
|
||||
spdlog::debug("Adding enum: {}", e.name);
|
||||
LOG_DBG("Adding enum: {}", e.name);
|
||||
auto it = std::find(enums.begin(), enums.end(), e);
|
||||
if (it == enums.end())
|
||||
enums.emplace_back(std::move(e));
|
||||
else
|
||||
spdlog::debug("Enum {} already in the model", e.name);
|
||||
LOG_DBG("Enum {} already in the model", e.name);
|
||||
}
|
||||
|
||||
std::string to_alias(const std::vector<std::string> &using_namespaces,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -30,8 +30,10 @@
|
||||
#include <cppast/cpp_template_parameter.hpp>
|
||||
#include <cppast/cpp_type.hpp>
|
||||
#include <cppast/visitor.hpp>
|
||||
#include <type_safe/reference.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -49,10 +51,78 @@ struct tu_context {
|
||||
{
|
||||
}
|
||||
|
||||
bool has_type_alias(const std::string &full_name) const
|
||||
{
|
||||
bool res = alias_index.find(full_name) != alias_index.end();
|
||||
LOG_DBG("Alias {} {} found in index", full_name, res ? "" : "not");
|
||||
return res;
|
||||
}
|
||||
|
||||
void add_type_alias(const std::string &full_name,
|
||||
type_safe::object_ref<const cppast::cpp_type> &&ref)
|
||||
{
|
||||
if (!has_type_alias(full_name)) {
|
||||
LOG_DBG("Stored type alias: {} -> {} ", full_name,
|
||||
cppast::to_string(ref.get()));
|
||||
alias_index.emplace(full_name, std::move(ref));
|
||||
}
|
||||
}
|
||||
|
||||
type_safe::object_ref<const cppast::cpp_type> get_type_alias(
|
||||
const std::string &full_name) const
|
||||
{
|
||||
assert(has_type_alias(full_name));
|
||||
|
||||
return alias_index.at(full_name);
|
||||
}
|
||||
|
||||
type_safe::object_ref<const cppast::cpp_type> get_type_alias_final(
|
||||
const cppast::cpp_type &t) const
|
||||
{
|
||||
const auto fn =
|
||||
cx::util::full_name(cppast::remove_cv(t), entity_index, false);
|
||||
|
||||
if (has_type_alias(fn)) {
|
||||
return get_type_alias_final(alias_index.at(fn).get());
|
||||
}
|
||||
|
||||
return type_safe::ref(t);
|
||||
}
|
||||
|
||||
bool has_type_alias_template(const std::string &full_name) const
|
||||
{
|
||||
bool res =
|
||||
alias_template_index.find(full_name) != alias_template_index.end();
|
||||
LOG_DBG(
|
||||
"Alias template {} {} found in index", full_name, res ? "" : "not");
|
||||
return res;
|
||||
}
|
||||
|
||||
void add_type_alias_template(const std::string &full_name,
|
||||
type_safe::object_ref<const cppast::cpp_type> &&ref)
|
||||
{
|
||||
if (!has_type_alias_template(full_name)) {
|
||||
LOG_DBG("Stored type alias template for: {} ", full_name);
|
||||
alias_template_index.emplace(full_name, std::move(ref));
|
||||
}
|
||||
}
|
||||
|
||||
type_safe::object_ref<const cppast::cpp_type> get_type_alias_template(
|
||||
const std::string &full_name) const
|
||||
{
|
||||
assert(has_type_alias_template(full_name));
|
||||
|
||||
return alias_template_index.at(full_name);
|
||||
}
|
||||
|
||||
std::vector<std::string> namespace_;
|
||||
cppast::cpp_entity_index &entity_index;
|
||||
clanguml::model::class_diagram::diagram &d;
|
||||
const clanguml::config::class_diagram &config;
|
||||
std::map<std::string, type_safe::object_ref<const cppast::cpp_type>>
|
||||
alias_index;
|
||||
std::map<std::string, type_safe::object_ref<const cppast::cpp_type>>
|
||||
alias_template_index;
|
||||
};
|
||||
|
||||
template <typename T> struct element_visitor_context {
|
||||
@@ -87,6 +157,10 @@ public:
|
||||
clanguml::model::class_diagram::class_ &c,
|
||||
cppast::cpp_access_specifier_kind as);
|
||||
|
||||
void process_field_with_template_instantiation(
|
||||
const cppast::cpp_member_variable &mv, const cppast::cpp_type &tr,
|
||||
clanguml::model::class_diagram::class_ &c);
|
||||
|
||||
void process_static_field(const cppast::cpp_variable &mv,
|
||||
clanguml::model::class_diagram::class_ &c,
|
||||
cppast::cpp_access_specifier_kind as);
|
||||
@@ -138,9 +212,10 @@ public:
|
||||
|
||||
private:
|
||||
clanguml::model::class_diagram::class_ build_template_instantiation(
|
||||
const cppast::cpp_entity &e,
|
||||
const cppast::cpp_template_instantiation_type &t);
|
||||
|
||||
const cppast::cpp_type &resolve_alias(const cppast::cpp_type &t);
|
||||
|
||||
tu_context ctx;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user