Skip to content

Commit 3c9010a

Browse files
committed
Removed logical namespace grouping. Done.
1 parent cf40e44 commit 3c9010a

File tree

10 files changed

+44
-126
lines changed

10 files changed

+44
-126
lines changed

ReflectionTemplateLib/rtl/builder/Builder.h

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ namespace rtl::builder
1818
{
1919
struct CtorBuilder : protected ReflectionBuilder
2020
{
21-
CtorBuilder(std::string_view pNamespace, std::string_view pRecordStr,
22-
std::string_view pFunction, traits::uid_t pRecordUid)
23-
: ReflectionBuilder(pFunction, pRecordUid, pRecordStr, pNamespace)
21+
CtorBuilder(const std::string& pRecordStr, const std::string& pFunction, traits::uid_t pRecordUid)
22+
: ReflectionBuilder(std::string_view(pFunction), pRecordUid, std::string_view(pRecordStr))
2423
{ }
2524

2625
/* @method: build()
@@ -59,8 +58,8 @@ namespace rtl::builder
5958
template<>
6059
struct Builder<detail::member::None, void> : protected ReflectionBuilder
6160
{
62-
Builder(traits::uid_t pRecordUid, std::string_view pFunction, std::string_view pNamespace)
63-
: ReflectionBuilder(pFunction, pRecordUid, detail::RECORD_NONE, pNamespace)
61+
Builder(traits::uid_t pRecordUid, std::string_view pFunction)
62+
: ReflectionBuilder(pFunction, pRecordUid, detail::RECORD_NONE)
6463
{ }
6564

6665
/* @method: build()
@@ -80,8 +79,8 @@ namespace rtl::builder
8079
template<class ...signature_t>
8180
struct Builder<detail::member::None, signature_t...> : protected ReflectionBuilder
8281
{
83-
Builder(traits::uid_t pRecordUid, std::string_view pFunction, std::string_view pNamespace)
84-
: ReflectionBuilder(pFunction, pRecordUid, detail::RECORD_NONE, pNamespace)
82+
Builder(traits::uid_t pRecordUid, std::string_view pFunction)
83+
: ReflectionBuilder(pFunction, pRecordUid, detail::RECORD_NONE)
8584
{ }
8685

8786
/* @method: build()
@@ -101,8 +100,8 @@ namespace rtl::builder
101100
template<>
102101
struct Builder<detail::member::None> : protected ReflectionBuilder
103102
{
104-
Builder(traits::uid_t pRecordUid, std::string_view pFunction, std::string_view pNamespace)
105-
: ReflectionBuilder(pFunction, pRecordUid, detail::RECORD_NONE, pNamespace)
103+
Builder(traits::uid_t pRecordUid, std::string_view pFunction)
104+
: ReflectionBuilder(pFunction, pRecordUid, detail::RECORD_NONE)
106105
{ }
107106

108107
/* @method: build()
@@ -126,8 +125,8 @@ namespace rtl::builder
126125
struct Builder<detail::member::Static, void> : protected ReflectionBuilder
127126
{
128127
Builder(traits::uid_t pRecordUid, std::string_view pFunction,
129-
std::string_view pRecordStr, std::string_view pNamespace)
130-
: ReflectionBuilder(pFunction, pRecordUid, pRecordStr, pNamespace)
128+
std::string_view pRecordStr)
129+
: ReflectionBuilder(pFunction, pRecordUid, pRecordStr)
131130
{ }
132131

133132
/* @method: build()
@@ -148,8 +147,8 @@ namespace rtl::builder
148147
struct Builder<detail::member::Static, signature_t...> : protected ReflectionBuilder
149148
{
150149
Builder(traits::uid_t pRecordUid, std::string_view pFunction,
151-
std::string_view pRecordStr, std::string_view pNamespace)
152-
: ReflectionBuilder(pFunction, pRecordUid, pRecordStr, pNamespace)
150+
std::string_view pRecordStr)
151+
: ReflectionBuilder(pFunction, pRecordUid, pRecordStr)
153152
{ }
154153

155154
/* @method: build()
@@ -170,8 +169,8 @@ namespace rtl::builder
170169
struct Builder<detail::member::Static> : protected ReflectionBuilder
171170
{
172171
Builder(traits::uid_t pRecordUid, std::string_view pFunction,
173-
std::string_view pRecordStr, std::string_view pNamespace)
174-
: ReflectionBuilder(pFunction, pRecordUid, pRecordStr, pNamespace)
172+
std::string_view pRecordStr)
173+
: ReflectionBuilder(pFunction, pRecordUid, pRecordStr)
175174
{ }
176175

177176
/* @method: build()
@@ -195,7 +194,7 @@ namespace rtl::builder
195194
struct Builder<detail::member::Const, void> : protected ReflectionBuilder
196195
{
197196
Builder(std::string_view pFunction, traits::uid_t pRecordUid)
198-
: ReflectionBuilder(pFunction, pRecordUid, detail::INIT_LATER, detail::INIT_LATER)
197+
: ReflectionBuilder(pFunction, pRecordUid, detail::INIT_LATER)
199198
{ }
200199

201200
/* @method: build()
@@ -216,7 +215,7 @@ namespace rtl::builder
216215
struct Builder<detail::member::Const, signature_t...> : protected ReflectionBuilder
217216
{
218217
Builder(std::string_view pFunction, traits::uid_t pRecordUid)
219-
: ReflectionBuilder(pFunction, pRecordUid, detail::INIT_LATER, detail::INIT_LATER)
218+
: ReflectionBuilder(pFunction, pRecordUid, detail::INIT_LATER)
220219
{ }
221220

222221
/* @method: build()
@@ -237,7 +236,7 @@ namespace rtl::builder
237236
struct Builder<detail::member::Const> : protected ReflectionBuilder
238237
{
239238
Builder(std::string_view pFunction, traits::uid_t pRecordUid)
240-
: ReflectionBuilder(pFunction, pRecordUid, detail::INIT_LATER, detail::INIT_LATER)
239+
: ReflectionBuilder(pFunction, pRecordUid, detail::INIT_LATER)
241240
{ }
242241

243242
/* @method: build()
@@ -261,7 +260,7 @@ namespace rtl::builder
261260
struct Builder<detail::member::NonConst, void> : protected ReflectionBuilder
262261
{
263262
Builder(std::string_view pFunction, traits::uid_t pRecordUid)
264-
: ReflectionBuilder(pFunction, pRecordUid, detail::INIT_LATER, detail::INIT_LATER)
263+
: ReflectionBuilder(pFunction, pRecordUid, detail::INIT_LATER)
265264
{ }
266265

267266
/* @method: build()
@@ -282,7 +281,7 @@ namespace rtl::builder
282281
struct Builder<detail::member::NonConst, signature_t...> : protected ReflectionBuilder
283282
{
284283
Builder(std::string_view pFunction, traits::uid_t pRecordUid)
285-
: ReflectionBuilder(pFunction, pRecordUid, detail::INIT_LATER, detail::INIT_LATER)
284+
: ReflectionBuilder(pFunction, pRecordUid, detail::INIT_LATER)
286285
{ }
287286

288287
/* @method: build()
@@ -303,7 +302,7 @@ namespace rtl::builder
303302
struct Builder<detail::member::NonConst> : protected ReflectionBuilder
304303
{
305304
Builder(std::string_view pFunction, traits::uid_t pRecordUid)
306-
: ReflectionBuilder(pFunction, pRecordUid, detail::INIT_LATER, detail::INIT_LATER)
305+
: ReflectionBuilder(pFunction, pRecordUid, detail::INIT_LATER)
307306
{ }
308307

309308

ReflectionTemplateLib/rtl/builder/ConstructorBuilder.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,14 @@ namespace rtl::builder
2929
//given name of the class/struct.
3030
const std::string m_recordStr;
3131

32-
//given name of the namespace.
33-
const std::string m_namespaceStr;
34-
3532
public:
3633

3734
ConstructorBuilder()
3835
: m_recordStr("")
39-
, m_namespaceStr("")
4036
{ }
4137

42-
ConstructorBuilder(const std::string& pNamespace, const std::string& pRecord)
38+
ConstructorBuilder(std::string_view pRecord)
4339
: m_recordStr(pRecord)
44-
, m_namespaceStr(pNamespace)
4540
{ }
4641

4742
/* @method: build()
@@ -55,8 +50,7 @@ namespace rtl::builder
5550
const bool isAccessible = (sizeof...(signature_t) == 0 || std::is_constructible_v<record_t, signature_t...>);
5651
static_assert(isAccessible, "The specified constructor is either deleted or not publicly accessible.");
5752

58-
return CtorBuilder( m_namespaceStr, m_recordStr,
59-
std::string(detail::ctor_name(m_recordStr)),
53+
return CtorBuilder( m_recordStr, std::string(detail::ctor_name(m_recordStr)),
6054
traits::uid<record_t>::value ).build<record_t, signature_t...>();
6155
}
6256
};

ReflectionTemplateLib/rtl/builder/RecordBuilder.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,18 @@ namespace rtl::builder
2424
class RecordBuilder
2525
{
2626
const std::string m_recordStr;
27-
const std::string m_namespaceStr;
2827
const traits::uid_t m_recordId;
2928

3029
public:
3130

32-
RecordBuilder(std::string_view pNamespace, const std::string& pRecord, traits::uid_t pRecordId)
31+
RecordBuilder(const std::string& pRecord, traits::uid_t pRecordId)
3332
: m_recordStr(pRecord)
34-
, m_namespaceStr(pNamespace)
3533
, m_recordId(pRecordId)
3634
{ }
3735

3836
constexpr const Function build() const
3937
{
40-
return ConstructorBuilder<record_t>(m_namespaceStr, m_recordStr).build();
38+
return ConstructorBuilder<record_t>(m_recordStr).build();
4139
}
4240
};
4341

@@ -76,7 +74,7 @@ namespace rtl::builder
7674
* compiler error on 'build(..)' if non-static member or non-member function pointer is passed.
7775
*/ const Builder<detail::member::Static> methodStatic(std::string_view pFunction) const
7876
{
79-
return Builder<detail::member::Static>(traits::uid<record_t>::value, pFunction, detail::INIT_LATER, detail::INIT_LATER);
77+
return Builder<detail::member::Static>(traits::uid<record_t>::value, pFunction, detail::INIT_LATER);
8078
}
8179

8280
/* @method: methodStatic<...>()
@@ -90,7 +88,7 @@ namespace rtl::builder
9088
*/ template<class ...signature_t>
9189
const Builder<detail::member::Static, signature_t...> methodStatic(std::string_view pFunction) const
9290
{
93-
return Builder<detail::member::Static, signature_t...>(traits::uid<record_t>::value, pFunction, detail::INIT_LATER, detail::INIT_LATER);
91+
return Builder<detail::member::Static, signature_t...>(traits::uid<record_t>::value, pFunction, detail::INIT_LATER);
9492
}
9593

9694

ReflectionTemplateLib/rtl/builder/Reflect.h

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -15,69 +15,6 @@
1515

1616
namespace rtl
1717
{
18-
/* @class: Reflect
19-
* provides interface to register all kinds of functions (member/non-member).
20-
*/ struct type_ns
21-
{
22-
type_ns() = delete;
23-
type_ns(type_ns&&) = delete;
24-
type_ns(const type_ns&) = delete;
25-
type_ns& operator=(type_ns&&) = delete;
26-
type_ns& operator=(const type_ns&) = delete;
27-
28-
type_ns(const std::string& pNamespace)
29-
: m_recordStr("")
30-
, m_namespaceStr(pNamespace)
31-
{ }
32-
33-
/* @function: record()
34-
@param: std::string (name of class/struct)
35-
@return: RecordBuilder<record_t>
36-
* provides object of 'RecordBuilder', which provides interface to registers member functions of class/struct of 'record_t'.
37-
* the 'build(..)' called on return object accepts non-member function pointer only.
38-
* compiler error on 'build(..)' if function pointer passed is not a member of class/struct- 'record_t'.
39-
*/ template<class record_t>
40-
constexpr const builder::RecordBuilder<record_t> record(std::string_view pClass)
41-
{
42-
return builder::RecordBuilder<record_t>(m_namespaceStr, std::string(pClass), traits::uid<record_t>::value);
43-
}
44-
45-
/* @method: function<...>()
46-
@param: std::string (name of function)
47-
@return: Builder<detail::member::None, signature_t...>
48-
* registers only non-member functions.
49-
* used for registering overloads, if unique member function, use non-templated version 'function()'.
50-
* template parameters must be explicitly specified, should be exactly same as the function being registered.
51-
* the 'build(..)' called on return object accepts non-member function pointer only.
52-
* compiler error on 'build(..)' if any member function pointer is passed.
53-
*/ template<class ...signature_t>
54-
constexpr const builder::Builder<detail::member::None, signature_t...> function(std::string_view pFunction)
55-
{
56-
return builder::Builder<detail::member::None, signature_t...>(traits::uid<>::none, std::string(pFunction), m_namespaceStr);
57-
}
58-
59-
/* @function: function()
60-
@param: std::string (name of the function).
61-
@return: Builder<detail::member::None>
62-
* registers only non-member functions.
63-
* the 'build(..)' called on return object accepts non-member function pointer only.
64-
* compiler error on 'build(..)' if member function pointer is passed.
65-
*/ const builder::Builder<detail::member::None> function(std::string_view pFunction)
66-
{
67-
return builder::Builder<detail::member::None>(traits::uid<>::none, std::string(pFunction), m_namespaceStr);
68-
}
69-
70-
private:
71-
72-
//name of the class, struct being registered.
73-
std::string m_recordStr;
74-
75-
//name of the namespace being registered.
76-
std::string m_namespaceStr;
77-
};
78-
79-
80-
8118
/* @class: Reflect
8219
* provides interface to register all kinds of functions (member/non-member).
8320
*/ struct type
@@ -97,7 +34,7 @@ namespace rtl
9734
template<class record_t>
9835
constexpr const builder::RecordBuilder<record_t> record(std::string_view pClass)
9936
{
100-
return type_ns(detail::NAMESPACE_GLOBAL).record<record_t>(pClass);
37+
return builder::RecordBuilder<record_t>(std::string(pClass), traits::uid<record_t>::value);
10138
}
10239

10340
template<class ...signature_t>
@@ -106,7 +43,7 @@ namespace rtl
10643
constexpr bool hasConstRValueRef = ((std::is_const_v<std::remove_reference_t<signature_t>> && std::is_rvalue_reference_v<signature_t>) || ...);
10744
static_assert(!hasConstRValueRef, "Registration of functions with 'const T&&' parameters is not allowed.");
10845

109-
return type_ns(detail::NAMESPACE_GLOBAL).function<signature_t...>(pFunction);
46+
return builder::Builder<detail::member::None, signature_t...>(traits::uid<>::none, std::string(pFunction));
11047
}
11148
};
11249
}

ReflectionTemplateLib/rtl/builder/ReflectionBuilder.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,44 +29,42 @@ namespace rtl::builder {
2929
const traits::uid_t m_recordId;
3030
const std::string m_recordStr;
3131
const std::string m_function;
32-
const std::string m_namespaceStr;
3332

3433
ReflectionBuilder(std::string_view pFunction, std::size_t pRecordId,
35-
std::string_view pRecordStr, std::string_view pNamespace)
34+
std::string_view pRecordStr)
3635
: m_recordId(pRecordId)
3736
, m_recordStr(pRecordStr)
3837
, m_function(pFunction)
39-
, m_namespaceStr(pNamespace)
4038
{ }
4139

4240
template<class record_t, class ...signature_t>
4341
constexpr const Function buildConstructor() const
4442
{
4543
type_meta fnMeta = RegisterCtor::template addConstructor<record_t, signature_t...>();
46-
return Function(m_namespaceStr, m_recordStr, m_function, fnMeta, m_recordId, fnMeta.get_member_kind());
44+
return Function(m_recordStr, m_function, fnMeta, m_recordId, fnMeta.get_member_kind());
4745
}
4846

4947
template<class return_t, class ...signature_t>
5048
constexpr const Function buildFunctor(return_t(*pFunctor)(signature_t...), detail::member pMemberType) const
5149
{
5250
type_meta fnMeta = RegisterFunction::template addFunctor<return_t, signature_t...>(pFunctor, m_recordId, pMemberType);
53-
return Function(m_namespaceStr, m_recordStr, m_function, fnMeta, m_recordId, pMemberType);
51+
return Function(m_recordStr, m_function, fnMeta, m_recordId, pMemberType);
5452
}
5553

5654
//adds 'pFunctor' to the 'MethodContainer'.
5755
template<class record_t, class return_t, class ...signature_t>
5856
constexpr const Function buildMethodFunctor(return_t(record_t::* pFunctor)(signature_t...)) const
5957
{
6058
type_meta fnMeta = RegisterMethod::template addMethodFunctor<record_t, return_t, signature_t...>(pFunctor);
61-
return Function(m_namespaceStr, m_recordStr, m_function, fnMeta, m_recordId, detail::member::NonConst);
59+
return Function(m_recordStr, m_function, fnMeta, m_recordId, detail::member::NonConst);
6260
}
6361

6462
//adds 'pFunctor' to the 'MethodContainer'.
6563
template<class record_t, class return_t, class ...signature_t>
6664
constexpr const Function buildMethodFunctor(return_t(record_t::* pFunctor)(signature_t...) const) const
6765
{
6866
type_meta fnMeta = RegisterMethod::template addMethodFunctor<record_t, return_t, signature_t...>(pFunctor);
69-
return Function(m_namespaceStr, m_recordStr, m_function, fnMeta, m_recordId, detail::member::Const);
67+
return Function(m_recordStr, m_function, fnMeta, m_recordId, detail::member::Const);
7068
}
7169
};
7270
}

ReflectionTemplateLib/rtl/detail/src/CxxReflection.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ namespace rtl {
104104
const auto& itr = m_recordIdMap.find(recordId);
105105
if (itr == m_recordIdMap.end()) {
106106

107-
auto& record = m_recordIdMap.emplace(recordId, Record(recordName, recordId, function.m_namespaceStr)).first->second;
107+
auto& record = m_recordIdMap.emplace(recordId, Record(recordName, recordId)).first->second;
108108
const auto& itr0 = m_recordMap.find(recordName);
109109
if (itr0 == m_recordMap.end()) {
110110
m_recordMap.emplace(recordName, std::ref(record));
@@ -113,6 +113,7 @@ namespace rtl {
113113
std::cout << "\n[WARNING] Multiple registrations of different type with same name detected."
114114
<< "\n Attempted re-registration as \"" << recordName << "\""
115115
<< "\n This registration is ignored.\n";
116+
std::abort(); //TODO : remove with proper message.
116117
}
117118
return record;
118119
}
@@ -132,7 +133,6 @@ namespace rtl {
132133
if (!isRegistrationIgnored) {
133134
Function constructor = function;
134135
constructor.m_recordStr = record.m_recordName;
135-
constructor.m_namespaceStr = record.m_namespaceStr;
136136
constructor.m_function = ctor_name(record.m_recordName);
137137
addMethod(record.getFunctionsMap(), constructor);
138138
}
@@ -180,7 +180,6 @@ namespace rtl {
180180
Function memberFunc = pFunction;
181181

182182
memberFunc.m_recordStr = record.m_recordName;
183-
memberFunc.m_namespaceStr = record.m_namespaceStr;
184183
addMethod(record.getFunctionsMap(), memberFunc);
185184
}
186185
else {

ReflectionTemplateLib/rtl/inc/Function.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,13 @@ namespace rtl
3434
//name of the function as supplied by the user.
3535
std::string m_function;
3636

37-
//name of the namespace as supplied by the user.
38-
std::string m_namespaceStr;
39-
4037
mutable std::vector<type_meta> m_functorsMeta;
4138

4239
private:
4340

44-
Function(const std::string& pNamespace, const std::string& pClassName,
45-
const std::string& pFuncName, const type_meta& pFunctorsMeta,
46-
const traits::uid_t pRecordTypeId, const detail::member pQualifier);
41+
Function(const std::string& pRecord, const std::string& pFunction,
42+
const type_meta& pFunctorsMeta, const traits::uid_t pRecordTypeId,
43+
const detail::member pQualifier);
4744

4845
void addOverload(const Function& pOtherFunc) const;
4946

0 commit comments

Comments
 (0)