Skip to content

Commit 0a0c3fa

Browse files
committed
RObjectId- pure pod now.
1 parent 605642e commit 0a0c3fa

File tree

15 files changed

+82
-135
lines changed

15 files changed

+82
-135
lines changed

CxxTestDesignPatternsUsingRTL/CxxTestProxyDesignPattern/inc/Proxy.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ namespace proxy_test
1919
{
2020
const auto orgMethod = OriginalReflection::getClass()->getMethod(pFunctionName);
2121
if (!orgMethod.has_value()) {
22-
return { rtl::error::FunctionNotRegisterd, rtl::RObject() };
22+
return { rtl::error::FunctionNotRegisterd, rtl::RObject{ } };
2323
}
2424
if (orgMethod->hasSignature<_args...>()) {
2525
return orgMethod->bind(m_originalObj).call(std::forward<_args>(params)...);
2626
}
27-
return { rtl::error::SignatureMismatch, rtl::RObject() };
27+
return { rtl::error::SignatureMismatch, rtl::RObject{ } };
2828
}
2929

3030

@@ -44,11 +44,11 @@ namespace proxy_test
4444
{
4545
const auto orgMethod = OriginalReflection::getClass()->getMethod(pFunctionName);
4646
if (!orgMethod.has_value()) {
47-
return { rtl::error::FunctionNotRegisterd, rtl::RObject() };
47+
return { rtl::error::FunctionNotRegisterd, rtl::RObject{ } };
4848
}
4949
if (orgMethod->hasSignature<_args...>()) {
5050
return orgMethod->bind().call(std::forward<_args>(params)...);
5151
}
52-
return { rtl::error::SignatureMismatch, rtl::RObject() };
52+
return { rtl::error::SignatureMismatch, rtl::RObject{ } };
5353
}
5454
}

CxxTestDesignPatternsUsingRTL/CxxTestProxyDesignPattern/src/Proxy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace proxy_test
1515
Proxy::Proxy()
1616
: m_originalObj([&]() {
1717
auto [err, robj] = OriginalReflection::getClass()->create<rtl::alloc::Heap>();
18-
return (err == rtl::error::None ? std::move(robj) : rtl::RObject());
18+
return (err == rtl::error::None ? std::move(robj) : rtl::RObject{ });
1919
}())
2020
{
2121
assert(!m_originalObj.isEmpty() && "Reflected instance creation failed.");

RTLBenchmarkApp/src/BenchMark.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace rtl_bench
7676

7777
void BenchMark::lambdaCall_noReturn(benchmark::State& state)
7878
{
79-
std::function sendMsg = [](const char* pMsg) {
79+
static std::function sendMsg = [](const char* pMsg) {
8080
sendMessage(pMsg);
8181
};
8282

@@ -90,24 +90,25 @@ namespace rtl_bench
9090

9191
void BenchMark::reflectedCall_noReturn(benchmark::State& state)
9292
{
93-
rtl::Function sendMsg = cxx_mirror().getFunction("sendMessage").value();
93+
static rtl::Function sendMsg = cxx_mirror().getFunction("sendMessage").value();
94+
static auto sendMsgCall = sendMsg.bind<const char*>();
9495
for (auto _ : state)
9596
{
96-
benchmark::DoNotOptimize(sendMsg.bind<const char*>().call("reflected"));
97+
benchmark::DoNotOptimize(sendMsgCall.call("reflected"));//*/.call("reflected"));
9798
}
9899
}
99100

100101

101102
void BenchMark::reflectedMethodCall_noReturn(benchmark::State& state)
102103
{
103-
rtl::Record rNode = cxx_mirror().getRecord("node").value();
104-
rtl::Method sendMsg = rNode.getMethod("sendMessage").value();
105-
rtl::RObject robj = rNode.create<rtl::alloc::Stack>().second;
106-
107-
for (auto _ : state)
108-
{
109-
benchmark::DoNotOptimize(sendMsg.bind<const char*>(robj).call("reflected"));
110-
}
104+
//rtl::Record rNode = cxx_mirror().getRecord("node").value();
105+
//rtl::Method sendMsg = rNode.getMethod("sendMessage").value();
106+
//rtl::RObject robj = rNode.create<rtl::alloc::Stack>().second;
107+
108+
//for (auto _ : state)
109+
//{
110+
// benchmark::DoNotOptimize(sendMsg.bind<const char*>(robj).call("reflected"));
111+
//}
111112
}
112113

113114

@@ -145,13 +146,13 @@ namespace rtl_bench
145146

146147
void BenchMark::reflectedMethodCall_withReturn(benchmark::State& state)
147148
{
148-
rtl::Record rNode = cxx_mirror().getRecord("node").value();
149-
rtl::Method getMsg = rNode.getMethod("getMessage").value();
150-
rtl::RObject robj = rNode.create<rtl::alloc::Stack>().second;
151-
152-
for (auto _ : state)
153-
{
154-
benchmark::DoNotOptimize(getMsg.bind<const char*>(robj).call("reflected"));
155-
}
149+
//rtl::Record rNode = cxx_mirror().getRecord("node").value();
150+
//rtl::Method getMsg = rNode.getMethod("getMessage").value();
151+
//rtl::RObject robj = rNode.create<rtl::alloc::Stack>().second;
152+
153+
//for (auto _ : state)
154+
//{
155+
// benchmark::DoNotOptimize(getMsg.bind<const char*>(robj).call("reflected"));
156+
//}
156157
}
157158
}

RTLBenchmarkApp/src/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
BENCHMARK(rtl_bench::BenchMark::directCall_noReturn);
1212
BENCHMARK(rtl_bench::BenchMark::lambdaCall_noReturn);
1313
BENCHMARK(rtl_bench::BenchMark::reflectedCall_noReturn);
14-
BENCHMARK(rtl_bench::BenchMark::reflectedMethodCall_noReturn);
15-
BENCHMARK(rtl_bench::BenchMark::directCall_withReturn);
16-
BENCHMARK(rtl_bench::BenchMark::lambdaCall_withReturn);
17-
BENCHMARK(rtl_bench::BenchMark::reflectedCall_withReturn);
18-
BENCHMARK(rtl_bench::BenchMark::reflectedMethodCall_withReturn);
14+
//BENCHMARK(rtl_bench::BenchMark::reflectedMethodCall_noReturn);
15+
//BENCHMARK(rtl_bench::BenchMark::directCall_withReturn);
16+
//BENCHMARK(rtl_bench::BenchMark::lambdaCall_withReturn);
17+
//BENCHMARK(rtl_bench::BenchMark::reflectedCall_withReturn);
18+
//BENCHMARK(rtl_bench::BenchMark::reflectedMethodCall_withReturn);
1919
BENCHMARK_MAIN();

RTLTestRunApp/src/FunctionalityTests/ConstMethodOverloadTests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ namespace rtl_tests
7676

7777
string lastName = person::LAST_NAME;
7878
{
79-
auto [err, ret] = updateLastName->bind(constCast(RObject())).call(lastName);
79+
auto [err, ret] = updateLastName->bind(constCast(RObject{ })).call(lastName);
8080

8181
EXPECT_TRUE(err == error::EmptyRObject);
8282
ASSERT_TRUE(ret.isEmpty());
8383
} {
84-
auto [err, ret] = updateLastName->bind(constCast(RObject())).call(lastName);
84+
auto [err, ret] = updateLastName->bind(constCast(RObject{ })).call(lastName);
8585

8686
EXPECT_TRUE(err == error::EmptyRObject);
8787
ASSERT_TRUE(ret.isEmpty());

ReflectionTemplateLib/access/inc/RObject.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ namespace rtl
4444
mutable Cloner m_getClone;
4545
mutable std::any m_object;
4646
mutable detail::RObjectId m_objectId;
47-
4847
mutable const std::vector<traits::ConverterPair>* m_converters;
4948

5049
RObject(const RObject&) = default;

ReflectionTemplateLib/access/inc/RObject.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace rtl
4040
{
4141
// Explicitly clear moved-from source
4242
pOther.m_object.reset();
43-
pOther.m_objectId.reset();
43+
pOther.m_objectId = { };
4444
pOther.m_getClone = nullptr;
4545
pOther.m_converters = nullptr;
4646
}
@@ -179,19 +179,19 @@ namespace rtl
179179
template<>
180180
inline std::pair<error, RObject> RObject::createCopy<alloc::Heap, detail::EntityKind::Wrapper>() const
181181
{
182-
return { error::StlWrapperHeapAllocForbidden, RObject() };
182+
return { error::StlWrapperHeapAllocForbidden, RObject{ } };
183183
}
184184

185185

186186
template<>
187187
inline std::pair<error, RObject> RObject::createCopy<alloc::Stack, detail::EntityKind::Wrapper>() const
188188
{
189189
if (m_objectId.m_wrapperType == detail::Wrapper::None) {
190-
return { error::NotWrapperType, RObject() };
190+
return { error::NotWrapperType, RObject{ } };
191191
}
192192
else if (m_objectId.m_wrapperType == detail::Wrapper::Unique)
193193
{
194-
return { error::TypeNotCopyConstructible, RObject() };
194+
return { error::TypeNotCopyConstructible, RObject{ } };
195195
}
196196
else {
197197
return { error::None, RObject(*this) };
@@ -203,7 +203,7 @@ namespace rtl
203203
inline std::pair<error, RObject> RObject::clone() const
204204
{
205205
if (isEmpty()) {
206-
return { error::EmptyRObject, RObject() };
206+
return { error::EmptyRObject, RObject{ } };
207207
}
208208
if constexpr (_copyTarget == copy::Value) {
209209
return createCopy<_allocOn, detail::EntityKind::Value>();

ReflectionTemplateLib/common/Constants.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace rtl {
2222
// cleanup is always automatic.
2323
enum class alloc
2424
{
25-
None, /*
25+
None = 0,/*
2626
* Assigned to empty or moved-from RObjects.
2727
* - Represents an invalid / non-owning state.
2828
* - Any attempt to call or clone results in rtl::error::EmptyRObject.
@@ -104,15 +104,15 @@ namespace rtl::detail
104104
{
105105
enum class EntityKind
106106
{
107-
None,
107+
None = 0,
108108
Ref,
109109
Value,
110110
Wrapper
111111
};
112112

113113
enum class Wrapper
114114
{
115-
None,
115+
None = 0,
116116
Any,
117117
Weak,
118118
Unique,
@@ -126,7 +126,7 @@ namespace rtl::detail
126126
// MethodQ: Method qualifier + static marker.
127127
enum class methodQ
128128
{
129-
None, // Static method (no const/non-const qualifier)
129+
None = 0, // Static method (no const/non-const qualifier)
130130
Const, // Const-qualified instance method
131131
NonConst // Non-const instance method
132132
};

ReflectionTemplateLib/detail/inc/FunctionCaller.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ namespace rtl::detail
3939
return { err, Container::template forwardCall<_args...>(err, index, std::forward<_args>(params)...) };
4040
}
4141

42-
return { error::SignatureMismatch, RObject() };
42+
return { error::SignatureMismatch, RObject{ } };
4343
}
4444
}

ReflectionTemplateLib/detail/inc/MethodInvoker.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ namespace rtl::detail
4040
}
4141
if (m_target.isEmpty()) {
4242
//if the target is empty.
43-
return { error::EmptyRObject, RObject() };
43+
return { error::EmptyRObject, RObject{ } };
4444
}
4545
if (m_target.getTypeId() != m_method.getRecordTypeId()) {
4646
//if the m_target's type-id & type-id of the 'class/struct' owner of the associated functor(m_method's) do not match.
47-
return { error::TargetMismatch, RObject() };
47+
return { error::TargetMismatch, RObject{ } };
4848
}
4949
if constexpr (sizeof...(_signature) == 0) {
5050
// executes when bind doesn't have any explicit signature types specified. (e.g. perfect-forwaring)
@@ -84,15 +84,15 @@ namespace rtl::detail
8484
{
8585
if (!pTarget.isConstCastSafe()) {
8686
pError = error::ConstOverloadMissing;
87-
return RObject();
87+
return RObject{ };
8888
}
8989
return containerNonConst::template forwardCall<_args...>(pError, pTarget, nonConstMethodIndex, std::forward<_args>(params)...);
9090
}
9191
else {
9292
pError = error::SignatureMismatch;
9393
}
9494
}
95-
return RObject();
95+
return RObject{ };
9696
}
9797
}
9898

@@ -120,11 +120,11 @@ namespace rtl::detail
120120
}
121121
if (m_target.isEmpty()) {
122122
//if the target is empty.
123-
return { error::EmptyRObject, RObject() };
123+
return { error::EmptyRObject, RObject{ } };
124124
}
125125
if (m_target.getTypeId() != m_method.getRecordTypeId()) {
126126
//if the m_target's type-id & type-id of the 'class/struct' owner of the associated functor(m_method's) do not match.
127-
return { error::TargetMismatch, RObject() };
127+
return { error::TargetMismatch, RObject{ } };
128128
}
129129
if constexpr (sizeof...(_signature) == 0) {
130130
error err = error::None;
@@ -160,11 +160,11 @@ namespace rtl::detail
160160
if (index != rtl::index_none) {
161161
// So, const-overload is present and non-const overload is not registered or doesn't exists.
162162
pError = error::NonConstOverloadMissing;
163-
return RObject();
163+
return RObject{ };
164164
}
165165
// else the signature might be wrong.
166166
pError = error::SignatureMismatch;
167-
return RObject();
167+
return RObject{ };
168168
}
169169
}
170170
}

0 commit comments

Comments
 (0)