Skip to content

Commit 7bc73ef

Browse files
committed
bug: unintended rtl::Record::create code flow path fixed.
1 parent 3989a4e commit 7bc73ef

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

RTLBenchmarkApp/src/ReflectedCall.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ namespace
2121
static rtl::RObject nodeObj = []()
2222
{
2323
auto Node = cxx::mirror().getRecord("Node").value();
24-
25-
rtl::RObject robj = Node.create<rtl::alloc::Stack>().rObject;
26-
24+
auto [err, robj] = Node.create<rtl::alloc::Stack>();
25+
if (nodeObj.isEmpty()) {
26+
std::cout << "[0] nodeObj empty! \n";
27+
}
2728
return std::move(robj);
2829
}();
2930
}
@@ -36,17 +37,17 @@ namespace
3637
auto err = SendMessage(bm::g_longStr).err;
3738

3839
if (err != rtl::error::None) {
39-
std::cout << "[0] error: "<< rtl::to_string(err)<<"\n";
40+
std::cout << "[1] error: "<< rtl::to_string(err)<<"\n";
4041
}
4142
return 0;
4243
};
4344

4445
static auto _test1 = []()
4546
{
46-
auto err = NodeSendMessage(nodeObj)(bm::g_longStr).err;
47+
auto err = NodeSendMessage.bind(nodeObj).call(bm::g_longStr).err;
4748

4849
if (err != rtl::error::None) {
49-
std::cout << "[1] error: " << rtl::to_string(err) << "\n";
50+
std::cout << "[2] error: " << rtl::to_string(err) << "\n";
5051
}
5152
return 0;
5253
};
@@ -56,7 +57,7 @@ namespace
5657
auto err = GetMessage(bm::g_longStr).err;
5758

5859
if (err != rtl::error::None) {
59-
std::cout << "[2] error: " << rtl::to_string(err) << "\n";
60+
std::cout << "[3] error: " << rtl::to_string(err) << "\n";
6061
}
6162
return 0;
6263
};
@@ -66,7 +67,7 @@ namespace
6667
auto err = NodeGetMessage(nodeObj)(bm::g_longStr).err;
6768

6869
if (err != rtl::error::None) {
69-
std::cout << "[3] error: " << rtl::to_string(err) << "\n";
70+
std::cout << "[4] error: " << rtl::to_string(err) << "\n";
7071
}
7172
return 0;
7273
};

ReflectionTemplateLib/access/inc/Method.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace rtl {
4141

4242
//invokes the constructor associated with this 'Method'
4343
template<class ..._args>
44-
Return invokeCtor(alloc&& pAllocType, std::size_t&& pClonerIndex, _args&&...params) const;
44+
Return invokeCtor(alloc pAllocType, std::size_t pClonerIndex, _args&&...params) const;
4545

4646
public:
4747

ReflectionTemplateLib/access/inc/Method.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@ namespace rtl
3434
@return: RStatus
3535
* calls the constructor with given arguments.
3636
*/ template<class ..._args>
37-
inline Return Method::invokeCtor(alloc&& pAllocType, std::size_t&& pClonerIndex, _args&& ...params) const
37+
inline Return Method::invokeCtor(alloc pAllocType, std::size_t pClonerIndex, _args&& ...params) const
3838
{
39-
return Function::bind().call<alloc, std::size_t, _args...>( std::forward<alloc>(pAllocType),
40-
std::forward<std::size_t>(pClonerIndex),
41-
std::forward<_args>(params)...);
39+
using Container = detail::FunctorContainer<alloc, std::size_t, std::remove_reference_t<_args>...>;
40+
41+
std::size_t index = hasSignatureId(Container::getContainerId());
42+
if (index != rtl::index_none) [[likely]] {
43+
return Container::template forwardCall<_args...>(index, pAllocType, pClonerIndex, std::forward<_args>(params)...);
44+
}
45+
return { error::SignatureMismatch, RObject{} };
4246
}
4347

4448

ReflectionTemplateLib/access/inc/Record.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ namespace rtl {
9595
static_assert(_alloc != rtl::alloc::None, "Instance cannot be created with 'rtl::alloc::None' option.");
9696
const auto& method = m_methods.at(detail::ctor_name(m_recordName));
9797
std::size_t copyCtorIndex = method.getFunctorIds()[detail::Index::CopyCtor].getIndex();
98-
return method.invokeCtor( _alloc,
99-
std::move(copyCtorIndex),
100-
std::forward<_ctorArgs>(params)...);
98+
return method.invokeCtor(_alloc, copyCtorIndex, std::forward<_ctorArgs>(params)...);
10199
}
102100

103101
//only class which can create objects of this class & manipulates 'm_methods'.

0 commit comments

Comments
 (0)