Added support for C++20 coroutines in class diagrams (#221)

This commit is contained in:
Bartek Kryza
2023-12-15 20:00:56 +01:00
parent 7be848b8a1
commit f2fe1ca2cf
16 changed files with 218 additions and 1 deletions

View File

@@ -63,6 +63,7 @@ void to_json(nlohmann::json &j, const class_method &c)
j["is_noexcept"] = c.is_noexcept();
j["is_constexpr"] = c.is_constexpr();
j["is_consteval"] = c.is_consteval();
j["is_coroutine"] = c.is_coroutine();
j["is_constructor"] = c.is_constructor();
j["is_move_assignment"] = c.is_move_assignment();
j["is_copy_assignment"] = c.is_copy_assignment();

View File

@@ -251,6 +251,9 @@ void generator::generate_method(
if (m.is_consteval()) {
method_mods.emplace_back("consteval");
}
if (m.is_coroutine()) {
method_mods.emplace_back("coroutine");
}
if (!method_mods.empty()) {
ostr << fmt::format("[{}] ", fmt::join(method_mods, ","));

View File

@@ -338,6 +338,9 @@ void generator::generate_method(
else if (m.is_deleted())
ostr << " = deleted";
if (m.is_coroutine())
ostr << " [coroutine]";
ostr << " : " << type;
if (config().generate_links) {

View File

@@ -70,6 +70,13 @@ void class_method::is_consteval(bool is_consteval)
is_consteval_ = is_consteval;
}
bool class_method::is_coroutine() const { return is_coroutine_; }
void class_method::is_coroutine(bool is_coroutine)
{
is_coroutine_ = is_coroutine;
}
bool class_method::is_noexcept() const { return is_noexcept_; }
void class_method::is_noexcept(bool is_noexcept) { is_noexcept_ = is_noexcept; }

View File

@@ -152,6 +152,20 @@ public:
*/
void is_consteval(bool is_consteval);
/**
* @brief Whether the method is a C++20 coroutine.
*
* @return True, if the method is a coroutine
*/
bool is_coroutine() const;
/**
* @brief Set whether the method is a C++20 coroutine.
*
* @param is_coroutine True, if the method is a coroutine
*/
void is_coroutine(bool is_coroutine);
/**
* @brief Whether the method is noexcept.
*
@@ -262,6 +276,7 @@ private:
bool is_noexcept_{false};
bool is_constexpr_{false};
bool is_consteval_{false};
bool is_coroutine_{false};
bool is_constructor_{false};
bool is_destructor_{false};
bool is_move_assignment_{false};

View File

@@ -1369,6 +1369,7 @@ void translation_unit_visitor::process_method_properties(
method.is_move_assignment(mf.isMoveAssignmentOperator());
method.is_copy_assignment(mf.isCopyAssignmentOperator());
method.is_noexcept(isNoexceptExceptionSpec(mf.getExceptionSpecType()));
method.is_coroutine(common::is_coroutine(mf));
}
void translation_unit_visitor::