Skip to content

Commit e6eab16

Browse files
committed
organizing metadata: removed FunctorId.hpp.
1 parent c2fff8a commit e6eab16

File tree

6 files changed

+23
-79
lines changed

6 files changed

+23
-79
lines changed

ReflectionTemplateLib/rtl/builder/SetupFunction.hpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#include "SetupFunction.h"
1919
#include "RObjectBuilder.hpp"
2020

21-
#include "FunctorId.hpp"
22-
2321
namespace rtl
2422
{
2523
namespace detail
@@ -31,9 +29,9 @@ namespace rtl
3129
{
3230
return [](const FunctorId& pFunctorId, _signature&&... params) -> Return
3331
{
34-
auto fptr = pFunctorId.get_lambda_function<_signature...>()
35-
->template get_hopper<void>()
36-
.f_ptr();
32+
using function_t = dispatch::function_ptr<void, _signature...>;
33+
34+
auto fptr = static_cast<const function_t&>(pFunctorId.get_functor()).f_ptr();
3735

3836
fptr(std::forward<_signature>(params)...);
3937
return { error::None, RObject{} };
@@ -50,9 +48,9 @@ namespace rtl
5048
this is stored in _derivedType's (FunctorContainer) vector holding lambda's.
5149
*/ return [](const FunctorId& pFunctorId, _signature&&...params)-> Return
5250
{
53-
auto fptr = pFunctorId.get_lambda_function<_signature...>()
54-
->template get_hopper<_returnType>()
55-
.f_ptr();
51+
using function_t = dispatch::function_ptr<_returnType, _signature...>;
52+
53+
auto fptr = static_cast<const function_t&>(pFunctorId.get_functor()).f_ptr();
5654

5755
constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>);
5856

@@ -122,7 +120,7 @@ namespace rtl
122120
pRecordId,
123121
_derivedType::getContainerId(),
124122
_derivedType::template getSignatureStr<_returnType>(),
125-
&(typeMeta.get_lambda())
123+
&(typeMeta.get_functor())
126124
}
127125
};
128126
}

ReflectionTemplateLib/rtl/builder/SetupMethod.hpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
#include "type_meta.hpp"
2222

23-
#include "FunctorId.hpp"
24-
2523
namespace rtl::detail
2624
{
2725
template<class _derivedType>
@@ -33,9 +31,9 @@ namespace rtl::detail
3331
this is stored in _derivedType's (MethodContainer<detail::member::NonConst, _signature...>) vector holding lambda's.
3432
*/ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return
3533
{
36-
auto fptr = pFunctorId.get_lambda_method<_recordType, _signature...>()
37-
->template get_hopper<void>()
38-
.f_ptr();
34+
using method_t = dispatch::method_ptr<_recordType, void, _signature...>;
35+
36+
auto fptr = static_cast<const method_t&>(pFunctorId.get_functor()).f_ptr();
3937

4038
if (!pTargetObj.isConstCastSafe()) [[unlikely]] {
4139
return { error::IllegalConstCast, RObject{} };
@@ -57,9 +55,9 @@ namespace rtl::detail
5755
this is stored in _derivedType's (MethodContainer<detail::member::NonConst, _signature...>) vector holding lambda's.
5856
*/ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return
5957
{
60-
auto fptr = pFunctorId.get_lambda_method<_recordType, _signature...>()
61-
->template get_hopper<_returnType>()
62-
.f_ptr();
58+
using method_t = dispatch::method_ptr<_recordType, _returnType, _signature...>;
59+
60+
auto fptr = static_cast<const method_t&>(pFunctorId.get_functor()).f_ptr();
6361

6462
if (!pTargetObj.isConstCastSafe()) [[unlikely]] {
6563
return { error::IllegalConstCast, RObject{} };
@@ -102,9 +100,9 @@ namespace rtl::detail
102100
this is stored in _derivedType's (MethodContainer<detail::member::Const, _signature...>) vector holding lambda's.
103101
*/ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return
104102
{
105-
auto fptr = pFunctorId.get_lambda_method<const _recordType, _signature...>()
106-
->template get_hopper<void>()
107-
.f_ptr();
103+
using method_t = dispatch::method_ptr<const _recordType, void, _signature...>;
104+
105+
auto fptr = static_cast<const method_t&>(pFunctorId.get_functor()).f_ptr();
108106

109107
const _recordType& target = pTargetObj.view<_recordType>()->get();
110108
(target.*fptr)(std::forward<_signature>(params)...);
@@ -122,9 +120,9 @@ namespace rtl::detail
122120
this is stored in _derivedType's (MethodContainer<detail::member::Const, _signature...>) vector holding lambda's.
123121
*/ return [](const FunctorId& pFunctorId, const RObject& pTargetObj, _signature&&...params)-> Return
124122
{
125-
auto fptr = pFunctorId.get_lambda_method<const _recordType, _signature...>()
126-
->template get_hopper<_returnType>()
127-
.f_ptr();
123+
using method_t = dispatch::method_ptr<const _recordType, _returnType, _signature...>;
124+
125+
auto fptr = static_cast<const method_t&>(pFunctorId.get_functor()).f_ptr();
128126

129127
constexpr bool isConstCastSafe = (!traits::is_const_v<_returnType>);
130128
//'target' is const and 'pFunctor' is const-member-function.
@@ -197,7 +195,7 @@ namespace rtl::detail
197195
TypeId<_recordType>::get(),
198196
_derivedType::getContainerId(),
199197
_derivedType::template getSignatureStr<_recordType, _returnType>(),
200-
&(typeMeta.get_lambda())
198+
&(typeMeta.get_functor())
201199
}
202200
};
203201
}
@@ -247,7 +245,7 @@ namespace rtl::detail
247245
TypeId<_recordType>::get(),
248246
_derivedType::getContainerId(),
249247
_derivedType::template getSignatureStr<_recordType, _returnType>(),
250-
&(typeMeta.get_lambda())
248+
&(typeMeta.get_functor())
251249
}
252250
};
253251
}

ReflectionTemplateLib/rtl/detail/inc/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ set(LOCAL_HEADERS
55
"${CMAKE_CURRENT_SOURCE_DIR}/ConversionUtils.h"
66
"${CMAKE_CURRENT_SOURCE_DIR}/CxxReflection.h"
77
"${CMAKE_CURRENT_SOURCE_DIR}/FunctorId.h"
8-
"${CMAKE_CURRENT_SOURCE_DIR}/FunctorId.hpp"
98
"${CMAKE_CURRENT_SOURCE_DIR}/ReflectCast.h"
109
"${CMAKE_CURRENT_SOURCE_DIR}/ReflectCast.hpp"
1110
"${CMAKE_CURRENT_SOURCE_DIR}/ReflectCastUtil.h"

ReflectionTemplateLib/rtl/detail/inc/FunctorId.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ namespace rtl::detail
4040
//signature of functor as string. platform dependent, may not be very much readable format.
4141
std::string m_signature;
4242

43-
const dispatch::lambda_base* m_lambda = nullptr;
43+
const dispatch::functor* m_functor = nullptr;
4444

4545
GETTER(std::size_t, LambdaIndex, m_lambdaIndex)
4646
GETTER(std::size_t, ReturnId, m_returnId);
4747
GETTER(std::size_t, RecordId, m_recordId);
4848
GETTER(std::size_t, SignatureId, m_containerId)
4949
GETTER_CREF(std::string, SignatureStr, m_signature)
50-
GETTER_CREF(dispatch::lambda_base, _lambda, (*m_lambda))
50+
GETTER_CREF(dispatch::functor, _functor, (*m_functor))
5151

5252
/* @method: getHashCode()
5353
@return: std::size_t (a unique hash-code for a functor)
@@ -75,17 +75,5 @@ namespace rtl::detail
7575
m_lambdaIndex == pOther.m_lambdaIndex &&
7676
m_signature == pOther.m_signature);
7777
}
78-
79-
template<class ..._signature>
80-
using lambda_ft = dispatch::lambda_function<_signature...>;
81-
82-
template<class rec_t, class ..._signature>
83-
using lambda_mt = dispatch::lambda_method<rec_t, _signature...>;
84-
85-
template<class ...args_t>
86-
constexpr const lambda_ft<args_t...>* get_lambda_function(std::size_t p_argsId = 0) const;
87-
88-
template<class record_t, class ...args_t>
89-
constexpr const lambda_mt<record_t, args_t...>* get_lambda_method(std::size_t p_recordId = 0, std::size_t p_argsId = 0) const;
9078
};
9179
}

ReflectionTemplateLib/rtl/detail/inc/FunctorId.hpp

Lines changed: 0 additions & 32 deletions
This file was deleted.

ReflectionTemplateLib/rtl/dispatch/lambda_base.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ namespace rtl::dispatch
5757
else return nullptr;
5858
}
5959

60-
GETTER_BOOL(_void, m_functor.m_is_void)
61-
GETTER_BOOL(_any_arg_ncref, m_functor.m_is_any_arg_ncref)
62-
63-
GETTER(traits::uid_t, _strict_sign_id, m_functor.m_strict_args_id)
64-
GETTER(traits::uid_t, _normal_sign_id, m_functor.m_normal_args_id)
65-
GETTER_CREF(detail::RObjectId, _return_id, m_functor.m_robject_id)
66-
6760
lambda_base(const functor& p_functor) noexcept
6861
: m_functor(p_functor)
6962
{ }

0 commit comments

Comments
 (0)