@@ -42,7 +42,7 @@ namespace rtl {
4242 !insertMethodsToRecordIdMap (function) )
4343 {
4444 // Finally, register the 'function' as a non-member function under the given or global namespace.
45- insertFunctionToNamespaceMap (function);
45+ addFunction (function);
4646 }
4747 }
4848 }
@@ -51,12 +51,12 @@ namespace rtl {
5151 /* @method: addFunction
5252 @params: FunctionMap, Function
5353 * adds the 'Function' object as non-member function mapped to the given namespace name.
54- */ void CxxReflection::addFunction (FunctionMap& pFunctionMap, const Function& pFunction)
54+ */ void CxxReflection::addFunction (const Function& pFunction)
5555 {
5656 const auto & fname = pFunction.getFunctionName ();
57- const auto & itr = pFunctionMap .find (fname);
58- if (itr == pFunctionMap .end ()) {
59- pFunctionMap .emplace (fname, pFunction);
57+ const auto & itr = m_functionsMap .find (fname);
58+ if (itr == m_functionsMap .end ()) {
59+ m_functionsMap .emplace (fname, pFunction);
6060 }
6161 else {
6262 const auto & function = itr->second ;
@@ -90,48 +90,6 @@ namespace rtl {
9090 }
9191
9292
93- /* @method: organizeFunctorsMetaData
94- @params: Function
95- * seggregates all the 'Function' objects and builds 'Record' & 'Method' objects.
96- */ void CxxReflection::insertFunctionToNamespaceMap (const Function& pFunction)
97- {
98- const std::string& nameSpace = detail::NAMESPACE_GLOBAL; // pFunction.getNamespace();
99- const std::string& recordName = pFunction.getRecordName ();
100- const traits::uid_t recordId = pFunction.getRecordTypeId ();
101- // if the recordId(class/struct's type-id) is TypeId<>::None, 'Function' object is considered as non-member function.
102- if (recordId == traits::uid<>::none)
103- {
104- const auto & itr = m_functionNamespaceMap.find (nameSpace);
105- if (itr == m_functionNamespaceMap.end ()) {
106- const auto & funcMapItr = m_functionNamespaceMap.emplace (nameSpace, FunctionMap ());
107- addFunction (funcMapItr.first ->second , pFunction);
108- }
109- else {
110- addFunction (itr->second , pFunction);
111- }
112- }
113- }
114-
115-
116- void CxxReflection::addInNamespaceMap (Record& pRecord)
117- {
118- const auto & itr = m_recordNamespaceMap.find (pRecord.m_namespaceStr );
119- if (itr == m_recordNamespaceMap.end ())
120- {
121- RecordMap& recordStrMap = m_recordNamespaceMap.emplace (pRecord.m_namespaceStr , RecordMap ()).first ->second ;
122- recordStrMap.emplace (pRecord.m_recordName , std::ref (pRecord));
123- }
124- else
125- {
126- RecordMap& recordStrMap = itr->second ;
127- const auto & itr0 = recordStrMap.find (pRecord.m_recordName );
128- if (itr0 == recordStrMap.end ()) {
129- recordStrMap.emplace (pRecord.m_recordName , std::ref (pRecord));
130- }
131- }
132- }
133-
134-
13593 void CxxReflection::buildRecordIdMap (const std::vector<Function>& pFunctions)
13694 {
13795 for (auto & function : pFunctions) {
@@ -145,8 +103,17 @@ namespace rtl {
145103 auto & record = [&]()->const Record& {
146104 const auto & itr = m_recordIdMap.find (recordId);
147105 if (itr == m_recordIdMap.end ()) {
106+
148107 auto & record = m_recordIdMap.emplace (recordId, Record (recordName, recordId, function.m_namespaceStr )).first ->second ;
149- addInNamespaceMap (record);
108+ const auto & itr0 = m_recordMap.find (recordName);
109+ if (itr0 == m_recordMap.end ()) {
110+ m_recordMap.emplace (recordName, std::ref (record));
111+ }
112+ else {
113+ std::cout << " \n [WARNING] Multiple registrations of different type with same name detected."
114+ << " \n Attempted re-registration as \" " << recordName << " \" "
115+ << " \n This registration is ignored.\n " ;
116+ }
150117 return record;
151118 }
152119 else {
0 commit comments