Skip to content

Commit

Permalink
get rid of method.name
Browse files Browse the repository at this point in the history
  • Loading branch information
jll63 committed Sep 15, 2024
1 parent 6c2110b commit 5c1b555
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
7 changes: 4 additions & 3 deletions docs.in/reference/policy-throw_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ BOOST_AUTO_TEST_CASE(ref_throw_error) {
} catch (yomm2::resolution_error& error) {
BOOST_TEST(error.status == yomm2::resolution_error::no_definition);
BOOST_TEST(
error.method_name ==
typeid(method_class(void, kick, (virtual_<Animal&>), throw_policy))
.name());
error.method ==
yomm2::type_id(
&typeid(method_class(
void, kick, (virtual_<Animal&>), throw_policy))));
BOOST_TEST(error.arity == 1);
BOOST_TEST(error.types[0] == throw_policy::static_type<Dog>());
threw = true;
Expand Down
10 changes: 2 additions & 8 deletions include/yorel/yomm2/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,12 +817,6 @@ template<
method<Name, Return(Parameters...), Options...>::method() {
this->slots_strides_ptr = slots_strides;

#ifndef BOOST_NO_RTTI
this->name = typeid(method).name();
#else
this->name = "method";
#endif

using virtual_type_ids = detail::type_id_list<
Policy,
boost::mp11::mp_transform_q<
Expand Down Expand Up @@ -1057,7 +1051,7 @@ method<Name, Return(Parameters...), Options...>::not_implemented_handler(
if constexpr (Policy::template has_facet<policies::error_handler>) {
resolution_error error;
error.status = resolution_error::no_definition;
error.method_name = fn.name;
error.method = Policy::template static_type<method>();
error.arity = arity;
type_id types[sizeof...(args)];
auto ti_iter = types;
Expand All @@ -1079,7 +1073,7 @@ method<Name, Return(Parameters...), Options...>::ambiguous_handler(
if constexpr (Policy::template has_facet<policies::error_handler>) {
resolution_error error;
error.status = resolution_error::ambiguous;
error.method_name = fn.name;
error.method = Policy::template static_type<method>();
error.arity = arity;
type_id types[sizeof...(args)];
auto ti_iter = types;
Expand Down
2 changes: 1 addition & 1 deletion include/yorel/yomm2/decode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void decode_dispatch_data(Data& init) {
auto method_index = 0;

for (auto& method : Policy::methods) {
++trace << "method " << method.name << "\n";
++trace << "method " << type_name(method.method_type) << "\n";
indent _(trace);

*methods_iter++ = &method;
Expand Down
2 changes: 1 addition & 1 deletion include/yorel/yomm2/detail/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ void compiler<Policy>::augment_methods() {
auto meth_iter = methods.begin();

for (auto& meth_info : Policy::methods) {
++trace << meth_info.name << " "
++trace << type_name(meth_info.method_type) << " "
<< range{meth_info.vp_begin, meth_info.vp_end} << "\n";

indent _(trace);
Expand Down
2 changes: 2 additions & 0 deletions include/yorel/yomm2/detail/trace.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef YOREL_YOMM2_DETAIL_TRACE_HPP
#define YOREL_YOMM2_DETAIL_TRACE_HPP

#include <yorel/yomm2/detail/types.hpp>

#include <boost/dynamic_bitset.hpp>

namespace yorel {
Expand Down
1 change: 0 additions & 1 deletion include/yorel/yomm2/detail/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ struct class_info : static_list<class_info>::static_link {
struct definition_info;

struct yOMM2_API method_info : static_list<method_info>::static_link {
std::string_view name;
type_id *vp_begin, *vp_end;
static_list<definition_info> specs;
void* ambiguous;
Expand Down
10 changes: 6 additions & 4 deletions include/yorel/yomm2/generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,9 @@ void generator::encode_dispatch_data(
os << indent << "// slots and strides\n";

for (auto& method : methods) {
os << indent << "// "
<< boost::core::demangle(method->info->name.data()) << "\n";
os << indent << "// ";
Compiler::policy_type::type_name(method->info->method_type, os);
os << "\n";
os << indent;
auto strides_iter = std::transform(
method->slots.begin(), method->slots.end(),
Expand Down Expand Up @@ -452,8 +453,9 @@ void generator::encode_dispatch_data(
continue;
}

os << indent << "// " << boost::core::demangle(method.info->name.data())
<< "\n";
os << indent << "// ";
Compiler::policy_type::type_name(method.info->method_type, os);
os << "\n";
os << indent;
auto dt_iter = std::transform(
method.dispatch_table.begin(), method.dispatch_table.end() - 1,
Expand Down
2 changes: 1 addition & 1 deletion include/yorel/yomm2/policies/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct error {};

struct resolution_error : error {
enum status_type { no_definition = 1, ambiguous } status;
std::string_view method_name;
type_id method;
std::size_t arity;
static constexpr std::size_t max_types = 16;
type_id types[max_types];
Expand Down
4 changes: 3 additions & 1 deletion include/yorel/yomm2/policies/vectored_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ struct yOMM2_API_gcc vectored_error : virtual error_handler {
Policy::error_stream
<< explanation
[error->status - resolution_error::no_definition]
<< " for " << error->method_name << "(";
<< " for ";
Policy::type_name(error->method, Policy::error_stream);
Policy::error_stream << "(";
auto comma = "";

for (auto ti :
Expand Down

0 comments on commit 5c1b555

Please sign in to comment.