Skip to content

Commit

Permalink
fix: omit single void arg only if function is processed
Browse files Browse the repository at this point in the history
  • Loading branch information
DNKpp committed Mar 3, 2025
1 parent 375e492 commit c59909b
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions include/mimic++/printing/type/PostProcessing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,11 @@ namespace mimicpp::printing::type::detail
| std::views::drop(matches[0].length());
auto const iter = util::find_closing_token(reversedName, ')', '(');
assert(iter != reversedName.end() && "No function begin found.");

StringViewT const argList{iter.base(), name.end() - matches[0].length()};
std::tuple info{
"(",
StringT{ iter.base(), name.end() - matches[0].length()},
StringT{argList == "void" ? "" : argList},
StringT{matches[0].first, matches[0].second}
};
name.erase(iter.base() - 1, name.cend());
Expand Down Expand Up @@ -519,26 +521,23 @@ namespace mimicpp::printing::type::detail
auto const& [scopeBegin, argList, scopeEnd] = *specialTypeInfo;
out = std::ranges::copy(scopeBegin, std::move(out)).out;

if (argList != "void")
bool isFirst{true};
StringViewT pendingArgList{argList};
while (!pendingArgList.empty())
{
bool isFirst{true};
StringViewT pendingArgList{argList};
while (!pendingArgList.empty())
if (!std::exchange(isFirst, false))
{
if (!std::exchange(isFirst, false))
{
out = std::ranges::copy(StringViewT{", "}, std::move(out)).out;
}

auto const tokenDelimiter = util::find_next_unwrapped_token(
pendingArgList,
argumentDelimiter,
openingBrackets,
closingBrackets);
StringViewT const arg = trimmed(StringViewT{pendingArgList.begin(), tokenDelimiter.begin()});
out = prettify_identifier(std::move(out), StringT{arg});
pendingArgList = StringViewT{tokenDelimiter.end(), pendingArgList.end()};
out = std::ranges::copy(StringViewT{", "}, std::move(out)).out;
}

auto const tokenDelimiter = util::find_next_unwrapped_token(
pendingArgList,
argumentDelimiter,
openingBrackets,
closingBrackets);
StringViewT const arg = trimmed(StringViewT{pendingArgList.begin(), tokenDelimiter.begin()});
out = prettify_identifier(std::move(out), StringT{arg});
pendingArgList = StringViewT{tokenDelimiter.end(), pendingArgList.end()};
}

out = std::ranges::copy(scopeEnd, std::move(out)).out;
Expand Down

0 comments on commit c59909b

Please sign in to comment.