Skip to content
Snippets Groups Projects
Commit 8aa6bccf authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Sort functions and types alphabetically when using getModuleInfo

parent 33c095c4
No related branches found
No related tags found
1 merge request!145git subrepo clone git@gitlab.com:OlMon/org-themes.git packages/org-themes
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <utils/PugsAssert.hpp> #include <utils/PugsAssert.hpp>
#include <algorithm> #include <algorithm>
#include <set>
void void
ModuleRepository::_subscribe(std::unique_ptr<IModule> m) ModuleRepository::_subscribe(std::unique_ptr<IModule> m)
...@@ -219,20 +220,31 @@ ModuleRepository::getModuleInfo(const std::string& module_name) const ...@@ -219,20 +220,31 @@ ModuleRepository::getModuleInfo(const std::string& module_name) const
os << rang::fgB::yellow << "Module '" << rang::fgB::blue << module_name << rang::fgB::yellow << "' provides" os << rang::fgB::yellow << "Module '" << rang::fgB::blue << module_name << rang::fgB::yellow << "' provides"
<< rang::style::reset << '\n'; << rang::style::reset << '\n';
const auto& builtin_function_map = i_module->second->getNameBuiltinFunctionMap(); const auto& builtin_function_map = i_module->second->getNameBuiltinFunctionMap();
if (builtin_function_map.size() > 0) { std::map<std::string, std::pair<std::string, std::string>> sorted_builtin_function_map;
os << " functions\n";
for (auto& [mangled_name, function] : builtin_function_map) { for (auto& [mangled_name, function] : builtin_function_map) {
sorted_builtin_function_map[mangled_name] =
std::make_pair(dataTypeName(function->getParameterDataTypes()), dataTypeName(function->getReturnDataType()));
}
Assert(sorted_builtin_function_map.size() == builtin_function_map.size());
if (sorted_builtin_function_map.size() > 0) {
os << " functions\n";
for (auto& [mangled_name, domain_to_codomain] : sorted_builtin_function_map) {
os << " " << rang::fgB::green << demangleBuiltinFunction(mangled_name) << rang::style::reset << ": "; os << " " << rang::fgB::green << demangleBuiltinFunction(mangled_name) << rang::style::reset << ": ";
os << dataTypeName(function->getParameterDataTypes()); os << domain_to_codomain.first;
os << rang::fgB::yellow << " -> " << rang::style::reset; os << rang::fgB::yellow << " -> " << rang::style::reset;
os << dataTypeName(function->getReturnDataType()) << '\n'; os << domain_to_codomain.second << '\n';
} }
} }
const auto& builtin_type_map = i_module->second->getNameTypeMap(); const auto& builtin_type_map = i_module->second->getNameTypeMap();
if (builtin_type_map.size() > 0) { std::set<std::string> sorted_builtin_type_map;
os << " types\n";
for (auto& [name, descriptor] : builtin_type_map) { for (auto& [name, descriptor] : builtin_type_map) {
sorted_builtin_type_map.insert(name);
}
Assert(sorted_builtin_type_map.size() == builtin_type_map.size());
if (sorted_builtin_type_map.size() > 0) {
os << " types\n";
for (auto& name : sorted_builtin_type_map) {
os << " " << rang::fgB::green << name << rang::style::reset << '\n'; os << " " << rang::fgB::green << name << rang::style::reset << '\n';
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment