Fixed building on MSVC
This commit is contained in:
@@ -43,7 +43,7 @@ using nested_trait_ns =
|
||||
clanguml::common::model::nested_trait<clanguml::common::model::element,
|
||||
clanguml::common::model::namespace_>;
|
||||
|
||||
class diagram : public common::model::diagram::diagram,
|
||||
class diagram : public common::model::diagram,
|
||||
public element_view<class_>,
|
||||
public element_view<enum_>,
|
||||
public element_view<concept_>,
|
||||
|
||||
@@ -1090,7 +1090,7 @@ std::optional<template_parameter> template_builder::try_as_template_parm_type(
|
||||
|
||||
argument.is_variadic(is_variadic);
|
||||
|
||||
ensure_lambda_type_is_relative(type_parameter_name);
|
||||
visitor_.ensure_lambda_type_is_relative(type_parameter_name);
|
||||
|
||||
return argument;
|
||||
}
|
||||
@@ -1109,7 +1109,7 @@ std::optional<template_parameter> template_builder::try_as_lambda(
|
||||
auto argument = template_parameter::make_argument("");
|
||||
type = consume_context(type, argument);
|
||||
|
||||
ensure_lambda_type_is_relative(type_name);
|
||||
visitor_.ensure_lambda_type_is_relative(type_name);
|
||||
argument.set_type(type_name);
|
||||
|
||||
return argument;
|
||||
@@ -1257,40 +1257,4 @@ bool template_builder::add_base_classes(class_ &tinst,
|
||||
return variadic_params;
|
||||
}
|
||||
|
||||
void template_builder::ensure_lambda_type_is_relative(
|
||||
std::string ¶meter_type) const
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
auto root_name = fmt::format(
|
||||
"{}\\", std::filesystem::current_path().root_name().string());
|
||||
if (root_name.back() == '\\') {
|
||||
root_name.pop_back();
|
||||
root_name.push_back('/');
|
||||
}
|
||||
#else
|
||||
auto root_name = std::string{"/"};
|
||||
#endif
|
||||
|
||||
std::string lambda_prefix{fmt::format("(lambda at {}", root_name)};
|
||||
|
||||
while (parameter_type.find(lambda_prefix) != std::string::npos) {
|
||||
auto lambda_begin = parameter_type.find(lambda_prefix);
|
||||
|
||||
auto absolute_lambda_path_end =
|
||||
parameter_type.find(':', lambda_begin + lambda_prefix.size());
|
||||
auto absolute_lambda_path =
|
||||
parameter_type.substr(lambda_begin + lambda_prefix.size() - 1,
|
||||
absolute_lambda_path_end -
|
||||
(lambda_begin + lambda_prefix.size() - 1));
|
||||
|
||||
auto relative_lambda_path = util::path_to_url(std::filesystem::relative(
|
||||
absolute_lambda_path, config().relative_to())
|
||||
.string());
|
||||
|
||||
parameter_type = fmt::format("{}(lambda at {}{}",
|
||||
parameter_type.substr(0, lambda_begin), relative_lambda_path,
|
||||
parameter_type.substr(absolute_lambda_path_end));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace clanguml::class_diagram::visitor
|
||||
|
||||
@@ -181,8 +181,6 @@ public:
|
||||
clang::SourceManager &source_manager() const;
|
||||
|
||||
private:
|
||||
void ensure_lambda_type_is_relative(std::string ¶meter_type) const;
|
||||
|
||||
// Reference to the output diagram model
|
||||
clanguml::class_diagram::model::diagram &diagram_;
|
||||
|
||||
|
||||
@@ -1690,11 +1690,7 @@ void translation_unit_visitor::ensure_lambda_type_is_relative(
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
auto root_name = fmt::format(
|
||||
"{}\\", std::filesystem::current_path().root_name().string());
|
||||
if (root_name.back() == '\\') {
|
||||
root_name.pop_back();
|
||||
root_name.push_back('/');
|
||||
}
|
||||
"{}", std::filesystem::current_path().root_name().string());
|
||||
#else
|
||||
auto root_name = std::string{"/"};
|
||||
#endif
|
||||
@@ -1703,13 +1699,17 @@ void translation_unit_visitor::ensure_lambda_type_is_relative(
|
||||
|
||||
while (parameter_type.find(lambda_prefix) != std::string::npos) {
|
||||
auto lambda_begin = parameter_type.find(lambda_prefix);
|
||||
|
||||
auto lambda_prefix_size = lambda_prefix.size();
|
||||
#ifdef _MSC_VER
|
||||
// Skip the `\` or `/` after drive letter and semicolon
|
||||
lambda_prefix_size++;
|
||||
#endif
|
||||
auto absolute_lambda_path_end =
|
||||
parameter_type.find(':', lambda_begin + lambda_prefix.size());
|
||||
parameter_type.find(':', lambda_begin + lambda_prefix_size);
|
||||
auto absolute_lambda_path =
|
||||
parameter_type.substr(lambda_begin + lambda_prefix.size() - 1,
|
||||
parameter_type.substr(lambda_begin + lambda_prefix_size - 1,
|
||||
absolute_lambda_path_end -
|
||||
(lambda_begin + lambda_prefix.size() - 1));
|
||||
(lambda_begin + lambda_prefix_size - 1));
|
||||
|
||||
auto relative_lambda_path = util::path_to_url(
|
||||
config().make_path_relative(absolute_lambda_path).string());
|
||||
@@ -2102,7 +2102,7 @@ void translation_unit_visitor::add_class(std::unique_ptr<class_> &&c)
|
||||
|
||||
const auto file = config().make_path_relative(c->file());
|
||||
|
||||
common::model::path p{file, common::model::path_type::kFilesystem};
|
||||
common::model::path p{file.string(), common::model::path_type::kFilesystem};
|
||||
p.pop_back();
|
||||
|
||||
diagram().add(p, std::move(c));
|
||||
@@ -2120,7 +2120,7 @@ void translation_unit_visitor::add_enum(std::unique_ptr<enum_> &&e)
|
||||
|
||||
const auto file = config().make_path_relative(e->file());
|
||||
|
||||
common::model::path p{file, common::model::path_type::kFilesystem};
|
||||
common::model::path p{file.string(), common::model::path_type::kFilesystem};
|
||||
p.pop_back();
|
||||
|
||||
diagram().add(p, std::move(e));
|
||||
@@ -2138,7 +2138,7 @@ void translation_unit_visitor::add_concept(std::unique_ptr<concept_> &&c)
|
||||
|
||||
const auto file = config().make_path_relative(c->file());
|
||||
|
||||
common::model::path p{file, common::model::path_type::kFilesystem};
|
||||
common::model::path p{file.string(), common::model::path_type::kFilesystem};
|
||||
p.pop_back();
|
||||
|
||||
diagram().add(p, std::move(c));
|
||||
|
||||
@@ -125,6 +125,8 @@ public:
|
||||
void add_enum(std::unique_ptr<enum_> &&e);
|
||||
void add_concept(std::unique_ptr<concept_> &&c);
|
||||
|
||||
void ensure_lambda_type_is_relative(std::string ¶meter_type) const;
|
||||
|
||||
private:
|
||||
bool should_include(const clang::NamedDecl *decl);
|
||||
|
||||
@@ -189,8 +191,6 @@ private:
|
||||
const found_relationships_t &relationships,
|
||||
bool break_on_first_aggregation = false);
|
||||
|
||||
void ensure_lambda_type_is_relative(std::string ¶meter_type) const;
|
||||
|
||||
void process_record_parent(
|
||||
clang::RecordDecl *cls, class_ &c, const namespace_ &ns);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user