Skip to content

Commit

Permalink
more cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
apolukhin committed Dec 18, 2024
1 parent 654dd46 commit 4ca9b3b
Showing 1 changed file with 21 additions and 39 deletions.
60 changes: 21 additions & 39 deletions include/boost/dll/detail/demangling/msvc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ namespace parser {
}
return result;
}

inline bool ignore_prefix(boost::core::string_view& s, boost::core::string_view prefix) {
parser::try_consume_prefix(s, prefix);
return true;
}

inline void consume_ptrs(boost::core::string_view& s) {
do {
Expand All @@ -117,8 +122,8 @@ namespace parser {
return parser::try_consume_prefix(s, "void");
}

parser::try_consume_prefix(s, "class ");
parser::try_consume_prefix(s, "struct ");
parser::ignore_prefix(s, "class ");
parser::ignore_prefix(s, "struct ");

const auto& mangled_name = ms.get_name<T>();
if (!parser::try_consume_prefix(s, mangled_name)) {
Expand Down Expand Up @@ -184,12 +189,9 @@ namespace parser {
: dtor_name_(dtor_name) {}

inline bool operator()(boost::core::string_view s) const {
if (!parser::try_consume_visibility(s)) {
return false;
}
parser::try_consume_prefix(s, " virtual");

return parser::try_consume_thiscall(s)
return parser::try_consume_visibility(s)
&& parser::ignore_prefix(s, " virtual")
&& parser::try_consume_thiscall(s)
&& parser::try_consume_prefix(s, dtor_name_)
&& parser::ignore_ptrs(s)
&& s.empty();
Expand Down Expand Up @@ -265,14 +267,11 @@ namespace parser {
if (parser::try_consume_visibility(s) && !parser::try_consume_prefix(s, " static ")) {
return false;
}
if (!parser::try_consume_type<Result>(s, ms_)) {
return false;
}

parser::try_consume_prefix(s, " ");

using Signature = Result(*)(Args...);
return parser::try_consume_prefix(s, "__cdecl ")
return parser::try_consume_type<Result>(s, ms_)
&& parser::ignore_prefix(s, " ")
&& parser::try_consume_prefix(s, "__cdecl ")
&& parser::try_consume_prefix(s, function_name_)
&& parser::try_consume_prefix(s, "(")
&& parser::try_consume_arg_list(s, ms_, Signature())
Expand All @@ -299,39 +298,22 @@ namespace parser {
: function_name_(function_name), ms_(ms) {}

inline bool operator()(boost::core::string_view s) const {
if (!parser::try_consume_visibility(s)) {
return false;
}
parser::try_consume_prefix(s, " virtual");

using Signature = Result(*)(Args...);
const bool is_name_and_args_ok = parser::try_consume_prefix(s, " ")
return parser::try_consume_visibility(s)
&& parser::ignore_prefix(s, " virtual")
&& parser::try_consume_prefix(s, " ")
&& parser::try_consume_type<Result>(s, ms_)
&& parser::try_consume_thiscall(s)
&& parser::try_consume_type<typename std::remove_cv<Class>::type>(s, ms_)
&& parser::try_consume_prefix(s, "::")
&& parser::try_consume_prefix(s, function_name_)
&& parser::try_consume_prefix(s, "(")
&& parser::try_consume_arg_list(s, ms_, Signature())
&& parser::try_consume_prefix(s, ")");
if (!is_name_and_args_ok) {
return false;
}

if (std::is_const<Class>::value) {
if (!parser::try_consume_prefix(s, "const ")) {
return false;
}
}

if (std::is_volatile<Class>::value) {
if (!parser::try_consume_prefix(s, "volatile ")) {
return false;
}
}

parser::ignore_ptrs(s);
return s.empty();
&& parser::try_consume_prefix(s, ")")
&& (!std::is_const<Class>::value || parser::try_consume_prefix(s, "const "))
&& (!std::is_volatile<Class>::value || parser::try_consume_prefix(s, "volatile "))
&& parser::ignore_ptrs(s)
&& s.empty();
}

inline bool operator()(const mangled_storage_base::entry& e) const {
Expand Down

0 comments on commit 4ca9b3b

Please sign in to comment.