Skip to content

Commit acbfb3e

Browse files
committed
rtl::constructor- implementation done.
1 parent 3c8e96a commit acbfb3e

File tree

7 files changed

+25
-25
lines changed

7 files changed

+25
-25
lines changed

ReflectionTemplateLib/rtl/detail/inc/FunctionCaller.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ namespace rtl::detail
186186
auto fn = fn_cast(ty_meta.get_functor()).template to_function<dispatch::erase::t_return>();
187187
pHopper.get_rhop().push_back(fn.f_ptr());
188188
}
189-
190189
pHopper.get_overloads().push_back(&ty_meta.get_functor());
191190
pHopper.set_init_error(error::None);
192191
}

ReflectionTemplateLib/rtl/inc/Record.h

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,11 @@ namespace rtl
111111
template<class ...args_t>
112112
inline constructor<args_t...> Record::ctor() const
113113
{
114-
constructor<args_t...> fnCtor;
115-
const auto& method = m_methods.at(detail::ctor_name(m_recordName));
116-
const auto& functorsMeta = method.getFunctorsMeta();
117-
118114
std::vector<rtl::type_meta> fnTyMetas(detail::call_by::ncref);
119-
120115
auto normalId = traits::uid<traits::normal_sign_id_t<args_t...>>::value;
121-
for (auto& ty_meta : functorsMeta)
116+
const auto& method = m_methods.at(detail::ctor_name(m_recordName));
117+
118+
for (auto& ty_meta : method.getFunctorsMeta())
122119
{
123120
if (normalId == ty_meta.get_normal_args_id())
124121
{
@@ -132,17 +129,26 @@ namespace rtl
132129
}
133130
}
134131

135-
std::size_t index = rtl::index_none;
136-
auto strictId = traits::uid<traits::strict_sign_id_t<args_t...>>::value;
137-
for (int i = 0; i < fnTyMetas.size(); i++)
132+
constructor<args_t...> fnCtor;
133+
for (auto& ty_meta : fnTyMetas)
138134
{
139-
auto& ty_meta = fnTyMetas[i];
140-
if (!ty_meta.is_empty() && ty_meta.get_strict_args_id() == strictId) {
141-
index = i;
142-
break;
135+
if (ty_meta.is_empty()) {
136+
fnCtor.get_hop().push_back(nullptr);
137+
fnCtor.get_overloads().push_back(nullptr);
138+
continue;
143139
}
140+
141+
using fn_cast = dispatch::functor_cast<dispatch::fn_void::no, traits::normal_sign_t<args_t>...>;
142+
auto fn = fn_cast(ty_meta.get_functor()).template to_function<dispatch::erase::t_ctor>();
143+
144+
fnCtor.get_hop().push_back(fn.f_ptr());
145+
fnCtor.get_overloads().push_back(&ty_meta.get_functor());
146+
fnCtor.set_init_error(error::None);
144147
}
145148

149+
if (fnCtor.get_init_error() != error::None) {
150+
fnCtor.set_init_error(error::SignatureMismatch);
151+
}
146152
return fnCtor;
147153
}
148154
}

ReflectionTemplateLib/rtl/rtl_function_erased_return.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ namespace rtl
2323
template<class ...signature_t>
2424
inline constexpr function<Return(signature_t...)>::operator bool() const noexcept {
2525
return !(m_init_err != error::None || m_functors.empty() ||
26-
(m_functors.size() == 1 && m_functors[0] == nullptr));
26+
(m_functors.size() == 1 && m_functors[0] == nullptr));
2727
}
2828

2929

3030
template<class ...signature_t>
3131
inline constexpr bool function<Return(signature_t...)>::must_bind_refs() const noexcept {
32-
return (m_functors[detail::call_by::value] == nullptr &&
33-
(m_functors.size() > detail::call_by::ncref || m_functors[detail::call_by::cref]->is_any_arg_ncref()));
32+
return (m_functors[detail::call_by::value] == nullptr && m_functors.size() > detail::call_by::ncref);
3433
}
3534

3635

ReflectionTemplateLib/rtl/rtl_method_erased.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ namespace rtl
124124
}
125125

126126
constexpr bool must_bind_refs() const noexcept {
127-
return (m_functors[detail::call_by::value] == nullptr &&
128-
(m_functors.size() > detail::call_by::ncref || m_functors[detail::call_by::cref]->is_any_arg_ncref()));
127+
return (m_functors[detail::call_by::value] == nullptr && m_functors.size() > detail::call_by::ncref);
129128
}
130129

131130
GETTER(rtl::error, _init_error, m_init_err)

ReflectionTemplateLib/rtl/rtl_method_erased_return.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ namespace rtl
121121
}
122122

123123
constexpr bool must_bind_refs() const noexcept {
124-
return (m_functors[detail::call_by::value] == nullptr &&
125-
(m_functors.size() > detail::call_by::ncref || m_functors[detail::call_by::cref]->is_any_arg_ncref()));
124+
return (m_functors[detail::call_by::value] == nullptr && m_functors.size() > detail::call_by::ncref);
126125
}
127126

128127
GETTER(rtl::error, _init_error, m_init_err)

ReflectionTemplateLib/rtl/rtl_method_erased_return_const.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ namespace rtl
111111
}
112112

113113
constexpr bool must_bind_refs() const noexcept {
114-
return (m_functors[detail::call_by::value] == nullptr &&
115-
(m_functors.size() > detail::call_by::ncref || m_functors[detail::call_by::cref]->is_any_arg_ncref()));
114+
return (m_functors[detail::call_by::value] == nullptr && m_functors.size() > detail::call_by::ncref);
116115
}
117116

118117
GETTER(rtl::error, _init_error, m_init_err)

ReflectionTemplateLib/rtl/rtl_method_erased_target.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ namespace rtl
109109
}
110110

111111
constexpr bool must_bind_refs() const noexcept {
112-
return (m_functors[detail::call_by::value] == nullptr &&
113-
(m_functors.size() > detail::call_by::ncref || m_functors[detail::call_by::cref]->is_any_arg_ncref()));
112+
return (m_functors[detail::call_by::value] == nullptr && m_functors.size() > detail::call_by::ncref);
114113
}
115114

116115
GETTER(rtl::error, _init_error, m_init_err)

0 commit comments

Comments
 (0)