Skip to content

Commit 8e531ab

Browse files
committed
refactored
1 parent 6a5c0cd commit 8e531ab

File tree

9 files changed

+30
-39
lines changed

9 files changed

+30
-39
lines changed

ReflectionTemplateLib/access/inc/Record.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "RStatus.h"
44
#include "Method.h"
55
#include "Constants.h"
6-
#include "Constants.hpp"
76
#include "Instance.h"
87

98
namespace rtl {
@@ -13,12 +12,12 @@ namespace rtl {
1312
template<class ..._ctorArgs>
1413
inline const std::pair<RStatus, Instance> Record::instance(_ctorArgs ...params) const
1514
{
16-
const std::string& ctor = getCtorName(m_recordName);
15+
const std::string& ctor = CtorName::ctor(m_recordName);
1716
const auto& itr = m_methods.find(ctor);
1817
if (itr != m_methods.end()) {
1918
const RStatus& status = itr->second.invokeCtor(params...);
2019
if (status) {
21-
const std::string& dctor = getDctorName(m_recordName);
20+
const std::string& dctor = CtorName::dctor(m_recordName);
2221
return std::make_pair(status, Instance(status.getReturn(), status, *getMethod(dctor)));
2322
}
2423
return std::make_pair(status, Instance());

ReflectionTemplateLib/access/src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ set(LOCAL_SOURCES
1111

1212
SET(COMMON_HEADERS
1313
"${PROJECT_SOURCE_DIR}/common/Constants.h"
14-
"${PROJECT_SOURCE_DIR}/common/Constants.hpp"
1514
"${PROJECT_SOURCE_DIR}/common/RTLibInterface.h"
1615
)
1716

ReflectionTemplateLib/access/src/Method.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
#include "Method.h"
3-
#include "Constants.hpp"
43

54
namespace rtl {
65

@@ -18,7 +17,7 @@ namespace rtl {
1817

1918
Method Method::getDestructorMethod(const Function& pFunction, const detail::FunctorId& pFunctorId)
2019
{
21-
const std::string dctorStr = getDctorName(pFunction.getRecordName());
20+
const std::string dctorStr = CtorName::dctor(pFunction.getRecordName());
2221
return Method(pFunction, pFunctorId, dctorStr);
2322
}
2423
}

ReflectionTemplateLib/access/src/Record.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "RStatus.h"
55
#include "Instance.h"
66
#include "Constants.h"
7-
#include "Constants.hpp"
87
#include "Function.hpp"
98

109
namespace rtl {
@@ -45,9 +44,9 @@ namespace rtl {
4544
return std::make_pair(RStatus(Error::EmptyInstance), Instance());
4645
}
4746

48-
const std::string& dctor = getDctorName(m_recordName);
49-
const std::string& copyStr = getCopyCtorName(m_recordName);
50-
const std::string& constCopyStr = getConstCopyCtorName(m_recordName);
47+
const std::string& dctor = CtorName::dctor(m_recordName);
48+
const std::string& copyStr = CtorName::copy(m_recordName);
49+
const std::string& constCopyStr = CtorName::constCopy(m_recordName);
5150

5251
std::optional<Function> destructor = getMethod(dctor);
5352
std::optional<Function> constCopyCtor = getMethod(constCopyStr);

ReflectionTemplateLib/builder/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
SET(COMMON_HEADERS
44
"${PROJECT_SOURCE_DIR}/common/Constants.h"
5-
"${PROJECT_SOURCE_DIR}/common/Constants.hpp"
65
)
76

87
SET(LOCAL_HEADERS

ReflectionTemplateLib/builder/inc/ConstructorBuilder.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include "Function.h"
44
#include "Builder.hpp"
5-
#include "Constants.hpp"
65
#include "ConstructorBuilder.h"
76

87
namespace rtl {
@@ -26,15 +25,15 @@ namespace rtl {
2625
{
2726
default:
2827
case FunctorType::Ctor: {
29-
const auto& ctorName = getCtorName(m_record);
28+
const auto& ctorName = CtorName::ctor(m_record);
3029
return Builder<TypeQ::Mute>(m_namespace, m_record, ctorName).build<_recordType, _ctorSignature...>();
3130
}
3231
case FunctorType::CopyCtor: {
33-
const auto& ctorName = getCopyCtorName(m_record);
32+
const auto& ctorName = CtorName::copy(m_record);
3433
return Builder<TypeQ::Mute>(m_namespace, m_record, ctorName).build<_recordType, _ctorSignature...>();
3534
}
3635
case FunctorType::CopyCtorConst: {
37-
const auto& ctorName = getConstCopyCtorName(m_record);
36+
const auto& ctorName = CtorName::constCopy(m_record);
3837
return Builder<TypeQ::Mute>(m_namespace, m_record, ctorName).build<_recordType, _ctorSignature...>();
3938
}
4039
}

ReflectionTemplateLib/common/Constants.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <string>
34
#include <type_traits>
45

56
namespace rtl {
@@ -61,4 +62,23 @@ namespace rtl {
6162

6263
template<class _type, class _typeB>
6364
using enable_if_not_same = typename std::enable_if< !std::is_same<_type, _typeB>::value >::type;
65+
66+
struct CtorName
67+
{
68+
static const std::string ctor(const std::string& pRecordName) {
69+
return (pRecordName + "::" + pRecordName + "()");
70+
}
71+
72+
static const std::string dctor(const std::string& pRecordName) {
73+
return (pRecordName + "::~" + pRecordName + "()");
74+
}
75+
76+
static const std::string copy(const std::string& pRecordName) {
77+
return (pRecordName + "::" + pRecordName + "(" + pRecordName + "&)");
78+
}
79+
80+
static const std::string constCopy(const std::string& pRecordName) {
81+
return (pRecordName + "::" + pRecordName + "(const " + pRecordName + "&)");
82+
}
83+
};
6484
}

ReflectionTemplateLib/common/Constants.hpp

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

ReflectionTemplateLib/detail/src/CxxReflection.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "TypeId.h"
33
#include "Record.h"
44
#include "Method.h"
5-
#include "Constants.hpp"
65
#include "CxxReflection.h"
76

87
namespace rtl {
@@ -54,7 +53,7 @@ namespace rtl {
5453
auto& functorIds = pFunction.getFunctorIds();
5554
if (functorIds.size() > 1)
5655
{
57-
const auto& dctorName = getDctorName(pFunction.getRecordName());
56+
const auto& dctorName = CtorName::dctor(pFunction.getRecordName());
5857
if (pMethodMap.find(dctorName) == pMethodMap.end()) {
5958
access::Method method = access::Method::getDestructorMethod(pFunction, functorIds[1]);
6059
pMethodMap.insert(std::make_pair(method.getFunctionName(), method));

0 commit comments

Comments
 (0)