36 struct ShuttingDownSignaler :
public T {
39 ~ShuttingDownSignaler()
41 if (gInterpreterHelper)
54 if (
name.compare(0,5,
"std::")==0) {
59 if (gInterpreterHelper) {
60 for(
size_t i = 5; i <
name.length(); ++i) {
61 if (
name[i] ==
'<')
break;
64 std::string scope(
name.data(),i);
65 std::string scoperesult;
68 static ShuttingDownSignaler<std::set<std::string>> gInlined;
70 if (gInlined.find(scope) != gInlined.end()) {
72 if (i+1<
name.length() &&
name[i+1]==
':') {
79 gInlined.insert(scope);
81 if (i+1<
name.length() &&
name[i+1]==
':') {
114 name.remove_prefix(len);
122 if (0 == strncmp(clName,
"complex<", 8)) {
123 const char *clNamePlus8 = clName + 8;
124 if (0 == strcmp(
"float>", clNamePlus8)) {
125 return EComplexType::kFloat;
127 if (0 == strcmp(
"double>", clNamePlus8)) {
128 return EComplexType::kDouble;
130 if (0 == strcmp(
"int>", clNamePlus8)) {
131 return EComplexType::kInt;
133 if (0 == strcmp(
"long>", clNamePlus8)) {
134 return EComplexType::kLong;
148 if (
this == gInterpreterHelper)
149 gInterpreterHelper =
nullptr;
156 gInterpreterHelper = helper;
192 if (fElements[0].empty())
return 0;
193 int numb = fElements.size();
194 if (!fElements[numb-1].empty() && fElements[numb-1][0]==
'*') --numb;
196 if ( fNestedLocation ) {
202 int kind =
STLKind(fElements[0]);
207 if (testAlloc && (numb-1 > nargs) && !
IsDefAlloc(fElements[numb-1].c_str(),fElements[1].c_str())) {
219 if (k<0) kind = -kind;
225 if(kind>2) kind = - kind;
245 int narg = fElements.size();
256 if (fElements[narg-1].empty() ==
false &&
257 (fElements[narg-1][0]==
'*'
258 || fElements[narg-1][0]==
'&'
259 || fElements[narg-1][0]==
'['
260 || 0 == fElements[narg-1].compare(0,6,
"const*")
261 || 0 == fElements[narg-1].compare(0,6,
"const&")
262 || 0 == fElements[narg-1].compare(0,6,
"const[")
263 || 0 == fElements[narg-1].compare(
"const")
266 if ((mode&1)==0) tailLoc = narg-1;
268 else { assert(fElements[narg-1].empty()); };
272 if (fNestedLocation) narg--;
277 const int kind =
STLKind(fElements[0]);
278 const int iall =
STLArgs(kind);
282 while(narg-1>iall) { fElements.pop_back(); narg--;}
283 if (!fElements[0].empty() && tailLoc) {
286 fElements[0].clear();
294 bool allocRemoved =
false;
300 if (narg-1 == iall+1) {
302 bool dropAlloc =
false;
317 dropAlloc =
IsDefAlloc(fElements[iall+1].c_str(),fElements[1].c_str());
323 dropAlloc =
IsDefAlloc(fElements[iall+1].c_str(),fElements[1].c_str(),fElements[2].c_str());
341 if (
IsDefComp( fElements[iall].c_str(), fElements[1].c_str() ) ) {
356 if (!allocRemoved && narg-1 == iall+1) {
360 if (narg-1 == iall) narg--;
383 bool predRemoved =
false;
386 if (
IsDefPred( fElements[iall].c_str(), fElements[1].c_str() ) ) {
393 if (
IsDefHash( fElements[iall-1].c_str(), fElements[1].c_str() ) ) {
401 unsigned int offset = (0==strncmp(
"const ",fElements[0].c_str(),6)) ? 6 : 0;
402 offset += (0==strncmp(
"std::",fElements[0].c_str()+offset,5)) ? 5 : 0;
403 if (0 == strcmp(fElements[0].c_str()+offset,
"__shared_ptr"))
406 static const std::string sharedPtrDef = std::to_string(__gnu_cxx::__default_lock_policy);
408 static const std::string sharedPtrDef = std::to_string(2);
410 if (fElements[2] == sharedPtrDef) {
418 for (
int i=1;i<narg; i++) {
419 if (strchr(fElements[i].c_str(),
'<')==0) {
421 unsigned int offset = (0==strncmp(
"const ",fElements[i].c_str(),6)) ? 6 : 0;
435 if (gInterpreterHelper &&
438 if (!typeresult.empty()) fElements[i] = typeresult;
443 unsigned int tailOffset = 0;
444 if (tailLoc && fElements[tailLoc].compare(0,5,
"const") == 0) {
448 if (!fElements[0].empty()) {answ += fElements[0]; answ +=
"<";}
457 int nargNonDefault = 0;
458 std::string nonDefName = answ;
460 std::string nameSuperLong = fName;
461 if (gInterpreterHelper)
463 while (++nargNonDefault < narg) {
466 const char* closeTemplate =
" >";
467 if (nonDefName[nonDefName.length() - 1] !=
'>')
469 string nondef = nonDefName + closeTemplate;
470 if (gInterpreterHelper &&
473 if (nargNonDefault>1) nonDefName +=
",";
474 nonDefName += fElements[nargNonDefault];
476 if (nargNonDefault < narg)
477 narg = nargNonDefault;
481 {
for (
int i=1;i<narg-1; i++) { answ += fElements[i]; answ+=
",";} }
482 if (narg>1) { answ += fElements[narg-1]; }
484 if (!fElements[0].empty()) {
485 if ( answ.at(answ.size()-1) ==
'>') {
491 if (fNestedLocation) {
494 answ += fElements[fNestedLocation];
497 if (tailLoc) answ += fElements[tailLoc].c_str()+tailOffset;
504 return !fElements[0].empty();
514 if (
type.compare(0,6,
"const ")==0) { offset += 6; }
518 static const char *stls[] =
519 {
"any",
"vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset",
520 "forward_list",
"unordered_set",
"unordered_multiset",
"unordered_map",
"unordered_multimap", 0};
521 static const size_t stllen[] =
522 { 3, 6, 4, 5, 3, 8, 3, 8, 6,
523 12, 13, 18, 13, 18, 0};
538 auto len =
type.length();
541 for(
int k=1;stls[k];k++) {
542 if (len == stllen[k]) {
543 if (
type.compare(offset,len,stls[k])==0)
return values[k];
547 for(
int k=1;stls[k];k++) {
if (
type.compare(offset,len,stls[k])==0)
return values[k];}
557 static const char stln[] =
559 { 1, 1, 1, 1, 3, 3, 2, 2, 1,
571 for(
size_t i = 0; i < full.length(); ++i) {
573 case '<': { ++level;
break; }
575 if (level == 0)
return i;
580 if (level == 0)
return i;
586 return full.length();
593 return pos +
findNameEnd( {full.data()+pos,full.length()-pos} );
605 if (
a==
"alloc")
return true;
606 if (
a==
"__default_alloc_template<true,0>")
return true;
607 if (
a==
"__malloc_alloc_template<0>")
return true;
609 const static int alloclen = strlen(
"allocator<");
610 if (
a.compare(0,alloclen,
"allocator<") != 0) {
613 a.remove_prefix(alloclen);
620 if (
a.compare(0,k.length(),k) != 0) {
624 std::string valuepart;
627 std::string norm_value;
630 if (valuepart != norm_value) {
633 a.remove_prefix(end);
635 a.remove_prefix(k.length());
638 if (
a.compare(0,1,
">")!=0 &&
a.compare(0,2,
" >")!=0) {
650 const char *keyclassname,
651 const char *valueclassname)
653 if (
IsDefAlloc(allocname,keyclassname))
return true;
658 const static int alloclen = strlen(
"allocator<");
659 if (
a.compare(0,alloclen,
"allocator<") != 0) {
662 a.remove_prefix(alloclen);
666 const static int pairlen = strlen(
"pair<");
667 if (
a.compare(0,pairlen,
"pair<") != 0) {
670 a.remove_prefix(pairlen);
672 const static int constlen = strlen(
"const");
673 if (
a.compare(0,constlen+1,
"const ") == 0) {
674 a.remove_prefix(constlen+1);
681 if (k.compare(0,constlen+1,
"const ") == 0) {
682 k.remove_prefix(constlen+1);
685 if (
a.compare(0,k.length(),k) != 0) {
689 std::string alloc_keypart;
692 std::string norm_key;
695 if (alloc_keypart != norm_key) {
696 if ( norm_key[norm_key.length()-1] ==
'*' ) {
700 norm_key +=
" const";
702 if (alloc_keypart != norm_key) {
706 a.remove_prefix(end);
708 size_t end = k.length();
709 if ( (
a[end-1] ==
'*') ||
a[end]==
' ' ) {
710 size_t skipSpace = (
a[end] ==
' ');
711 if (
a.compare(end+skipSpace,constlen,
"const") == 0) {
712 end += constlen+skipSpace;
715 a.remove_prefix(end);
727 if (
a.compare(0,
v.length(),
v) != 0) {
731 std::string valuepart;
734 std::string norm_value;
737 if (valuepart != norm_value) {
740 a.remove_prefix(end);
742 a.remove_prefix(
v.length());
745 if (
a.compare(0,1,
">")!=0 &&
a.compare(0,2,
" >")!=0) {
756static bool IsDefElement(
const char *elementName,
const char* defaultElementName,
const char *classname)
758 string c = elementName;
762 const int elementlen = strlen(defaultElementName);
763 if (
c.compare(pos,elementlen,defaultElementName) != 0) {
768 string k = classname;
769 if (
c.compare(pos,k.length(),k) != 0) {
778 std::string norm_key;
781 if (keypart != norm_key) {
789 if (
c.compare(pos,1,
">")!=0 &&
c.compare(pos,2,
" >")!=0) {
840 norm_name = std::string(
name);
869 if (norm_name.length()>2 && norm_name[0]==
':' && norm_name[1]==
':') {
870 norm_name.erase(0,2);
873 if (gInterpreterHelper) {
875 std::string typeresult;
879 if (!typeresult.empty()) norm_name = typeresult;
900 static const char* longlong_s =
"long long";
901 static const char* ulonglong_s =
"unsigned long long";
902 static const unsigned int longlong_len = strlen(longlong_s);
903 static const unsigned int ulonglong_len = strlen(ulonglong_s);
905 string result = original;
908 while( (pos = result.find(ulonglong_s,pos) ) >=0 ) {
909 result.replace(pos, ulonglong_len,
"ULong64_t");
912 while( (pos = result.find(longlong_s,pos) ) >=0 ) {
913 result.replace(pos, longlong_len,
"Long64_t");
923 const char *lastPos = original;
926 for(
auto cursor = original; *cursor !=
'\0'; ++cursor) {
927 if ( *cursor ==
'<' || *cursor ==
'(') ++depth;
928 else if ( *cursor ==
'>' || *cursor ==
')' ) --depth;
929 else if ( *cursor ==
':' ) {
930 if (depth==0 && *(cursor+1) ==
':' && *(cursor+2) !=
'\0') {
945 const char *t = full.c_str();
946 const unsigned int tlen( full.size() );
948 const char *starloc = t + tlen - 1;
949 bool hasconst =
false;
951 && (starloc-t) > 4 && 0 == strncmp((starloc-4),
"const",5)
952 && ( (*(starloc-5)) ==
' ' || (*(starloc-5)) ==
'*' || (*(starloc-5)) ==
'&'
953 || (*(starloc-5)) ==
'>' || (*(starloc-5)) ==
']') ) {
956 if ((*starloc-1)==
' ') {
962 if ( hasconst || (*starloc)==
'*' || (*starloc)==
'&' || (*starloc)==
']' ) {
963 bool isArray = ( (*starloc)==
']' );
964 while( t<=(starloc-1) && ((*(starloc-1))==
'*' || (*(starloc-1))==
'&' || (*(starloc-1))==
't' || isArray)) {
967 isArray = ! ( (*starloc)==
'[' );
968 }
else if ( (*(starloc-1))==
't' ) {
969 if ( (starloc-1-t) > 5 && 0 == strncmp((starloc-5),
"const",5)
970 && ( (*(starloc-6)) ==
' ' || (*(starloc-6)) ==
'*' || (*(starloc-6)) ==
'&'
971 || (*(starloc-6)) ==
'>' || (*(starloc-6)) ==
']')) {
982 if ((*(starloc-1))==
' ') {
987 const unsigned int starlen = strlen(starloc);
988 full.erase(tlen-starlen,starlen);
989 }
else if (hasconst) {
991 const unsigned int starlen = strlen(starloc);
992 full.erase(tlen-starlen,starlen);
1012 if (strlen(
type)==0)
return 0;
1014 int cleantypeMode = 1 ;
1023 unsigned int const_offset = (0==strncmp(
"const ",full.c_str(),6)) ? 6 : 0;
1024 bool isString =
false;
1025 bool isStdString =
false;
1026 size_t std_offset = const_offset;
1027 static const char* basic_string_std =
"std::basic_string<char";
1028 static const unsigned int basic_string_std_len = strlen(basic_string_std);
1030 if (full.compare(const_offset,basic_string_std_len,basic_string_std) == 0
1031 && full.size() > basic_string_std_len) {
1035 }
else if (full.compare(const_offset,basic_string_std_len-5,basic_string_std+5) == 0
1036 && full.size() > (basic_string_std_len-5)) {
1039 }
else if (full.find(
"basic_string") != std::string::npos) {
1040 size_t len =
StdLen(full.c_str() + const_offset);
1041 if (len && len != 5 && full.compare(const_offset + len, basic_string_std_len-5, basic_string_std+5) == 0) {
1048 size_t offset = basic_string_std_len - 5;
1049 offset += std_offset;
1050 if ( full[offset] ==
'>' ) {
1052 }
else if (full[offset] ==
',') {
1054 if (full.compare(offset, 5,
"std::") == 0) {
1057 static const char* char_traits_s =
"char_traits<char>";
1058 static const unsigned int char_traits_len = strlen(char_traits_s);
1059 if (full.compare(offset, char_traits_len, char_traits_s) == 0) {
1060 offset += char_traits_len;
1061 if ( full[offset] ==
'>') {
1063 }
else if (full[offset] ==
' ' && full[offset+1] ==
'>') {
1066 }
else if (full[offset] ==
',') {
1068 if (full.compare(offset, 5,
"std::") == 0) {
1071 static const char* allocator_s =
"allocator<char>";
1072 static const unsigned int allocator_len = strlen(allocator_s);
1073 if (full.compare(offset, allocator_len, allocator_s) == 0) {
1074 offset += allocator_len;
1075 if ( full[offset] ==
'>') {
1077 }
else if (full[offset] ==
' ' && full[offset+1] ==
'>') {
1098 output.push_back(
string());
1100 if (isStdString && !(mode &
kDropStd)) {
1101 output.push_back(
"const std::string");
1103 output.push_back(
"const string");
1106 if (isStdString && !(mode &
kDropStd)) {
1107 output.push_back(
"std::string");
1109 output.push_back(
"string");
1112 if (offset < full.length()) {
1115 string right( full.substr(offset) );
1118 output.back().append(right.c_str()+1);
1129 unsigned int offset = (0==strncmp(
"const ",full.c_str(),6)) ? 6 : 0;
1134 if ( !full.empty() ) {
1138 const char *
c = strchr(full.c_str(),
'<');
1141 output.push_back(
string(full,0,
c - full.c_str()));
1145 int parenthesis = 0;
1146 for(cursor =
c + 1; *cursor !=
'\0' && !(level==0 && *cursor ==
'>'); ++cursor) {
1147 if (*cursor ==
'(') {
1150 }
else if (*cursor ==
')') {
1157 case '<': ++level;
break;
1158 case '>': --level;
break;
1161 output.push_back(std::string(
c+1,cursor));
1168 if (*(cursor-1) ==
' ') {
1169 output.push_back(std::string(
c+1,cursor-1));
1171 output.push_back(std::string(
c+1,cursor));
1174 if (*(cursor+1)==
':') {
1177 nestedLoc =
output.size();
1178 output.push_back((cursor+1));
1180 }
else if (level >= 0) {
1182 output.push_back(std::string(
c+1,cursor));
1186 output.push_back(
string());
1213 static const char* remove[] = {
"class",
"const",
"volatile",0};
1214 static bool isinit =
false;
1215 static std::vector<size_t> lengths;
1217 for (
int k=0; remove[k]; ++k) {
1218 lengths.push_back(strlen(remove[k]));
1224 result.reserve(strlen(typeDesc)*2);
1228 for(
c=typeDesc;*
c;
c++) {
1231 if (!isalnum(
c[ 1]) &&
c[ 1] !=
'_')
continue;
1233 if (kbl && (mode>=2 || lev==0)) {
1235 int n = (mode) ? 999 : 1;
1238 for (
int k=0; k<
n && remove[k]; k++) {
1239 int rlen = lengths[k];
1242 if (strncmp(remove[k],
c,rlen))
continue;
1245 if (isalnum(
c[rlen]) ||
c[rlen]==
'_' ||
c[rlen]==
'$')
continue;
1247 c+=rlen-1; done = 1;
break;
1252 kbl = (!isalnum(
c[ 0]) &&
c[ 0]!=
'_' &&
c[ 0]!=
'$' &&
c[0]!=
'[' &&
c[0]!=
']' &&
c[0]!=
'-' &&
c[0]!=
'@');
1256 if (*
c ==
'<' || *
c ==
'(') lev++;
1257 if (lev==0 && !isalnum(*
c)) {
1258 if (!strchr(
"*&:._$ []-@",*
c))
break;
1262 if (
c[0]==
'>' && result.size() && result[result.size()-1]==
'>') result+=
" ";
1266 if (*
c ==
'>' || *
c ==
')') lev--;
1303 size_t len = strlen(
type);
1304 if (len < 2 || strncmp(
type+len-2,
"_t",2) != 0)
return false;
1306 unsigned char offset = 0;
1307 if (strncmp(
type,
"const ",6)==0) { offset += 6; }
1308 static const char *names[] = {
"CallFunc_t",
"ClassInfo_t",
"BaseClassInfo_t",
1309 "DataMemberInfo_t",
"FuncTempInfo_t",
"MethodInfo_t",
"MethodArgInfo_t",
1310 "TypeInfo_t",
"TypedefInfo_t",0};
1312 for(
int k=1;names[k];k++) {
if (strcmp(
type+offset,names[k])==0)
return true;}
1321 size_t offset =
StdLen(classname);
1322 if ( strncmp(classname+offset,
"bitset<",strlen(
"bitset<"))==0)
return true;
1340 if (
type.compare(0,6,
"const ",6) == 0)
1341 type.remove_prefix(6);
1343 while(
type[
type.length()-1]==
'*' ||
1346 type.remove_suffix(1);
1359 auto pos =
type.find(
'<');
1363 for (
decltype(
type.length()) level = 1;
c <
type.length(); ++
c) {
1364 if (
type[
c] ==
'<') ++level;
1365 if (
type[
c] ==
'>') --level;
1366 if (level == 0)
break;
1368 if (
c != (
type.length()-1) ) {
1388 if (strchr(
type,
'<')==0)
return 0;
1399 classname +=
StdLen( classname );
1400 if ( strcmp(classname,
"string")==0 )
return true;
1401 if ( strncmp(classname,
"bitset<",strlen(
"bitset<"))==0)
return true;
1402 if (
IsStdPair(classname) )
return true;
1403 if ( strcmp(classname,
"allocator")==0)
return true;
1404 if ( strncmp(classname,
"allocator<",strlen(
"allocator<"))==0)
return true;
1405 if ( strncmp(classname,
"greater<",strlen(
"greater<"))==0)
return true;
1406 if ( strncmp(classname,
"less<",strlen(
"less<"))==0)
return true;
1407 if ( strncmp(classname,
"equal_to<",strlen(
"equal_to<"))==0)
return true;
1408 if ( strncmp(classname,
"hash<",strlen(
"hash<"))==0)
return true;
1409 if ( strncmp(classname,
"auto_ptr<",strlen(
"auto_ptr<"))==0)
return true;
1411 if ( strncmp(classname,
"vector<",strlen(
"vector<"))==0)
return true;
1412 if ( strncmp(classname,
"list<",strlen(
"list<"))==0)
return true;
1413 if ( strncmp(classname,
"forward_list<",strlen(
"forward_list<"))==0)
return true;
1414 if ( strncmp(classname,
"deque<",strlen(
"deque<"))==0)
return true;
1415 if ( strncmp(classname,
"map<",strlen(
"map<"))==0)
return true;
1416 if ( strncmp(classname,
"multimap<",strlen(
"multimap<"))==0)
return true;
1417 if ( strncmp(classname,
"set<",strlen(
"set<"))==0)
return true;
1418 if ( strncmp(classname,
"multiset<",strlen(
"multiset<"))==0)
return true;
1419 if ( strncmp(classname,
"unordered_set<",strlen(
"unordered_set<"))==0)
return true;
1420 if ( strncmp(classname,
"unordered_multiset<",strlen(
"unordered_multiset<"))==0)
return true;
1421 if ( strncmp(classname,
"unordered_map<",strlen(
"unordered_map<"))==0)
return true;
1422 if ( strncmp(classname,
"unordered_multimap<",strlen(
"unordered_multimap<"))==0)
return true;
1423 if ( strncmp(classname,
"bitset<",strlen(
"bitset<"))==0)
return true;
1442 unsigned int cursor,
1444 unsigned int start_of_type,
1445 unsigned int end_of_type,
1446 unsigned int mod_start_of_type,
1448 std::string &result)
1450 std::string
type(modified && (mod_start_of_type < result.length()) ?
1451 result.substr(mod_start_of_type, string::npos)
1452 :
string(tname, start_of_type, end_of_type == 0 ? cursor - start_of_type : end_of_type - start_of_type));
1457 if (!typeresult.empty()) {
1460 result.replace(mod_start_of_type, string::npos,
1465 mod_start_of_type = start_of_type;
1466 result += string(tname,0,start_of_type);
1467 if (constprefix && typeresult.compare(0,6,
"const ",6) == 0) {
1468 result += typeresult.substr(6,string::npos);
1470 result += typeresult;
1473 }
else if (modified) {
1474 result.replace(mod_start_of_type, string::npos,
1478 if (end_of_type != 0 && end_of_type!=cursor) {
1479 result += std::string(tname,end_of_type,cursor-end_of_type);
1486 if (end_of_type != 0 && end_of_type!=cursor) {
1487 result += std::string(tname,end_of_type,cursor-end_of_type);
1497 unsigned int &cursor,
1499 std::string &result)
1506 bool constprefix =
false;
1508 if (tname[cursor]==
' ') {
1511 result += string(tname,0,cursor);
1513 while (tname[cursor]==
' ') ++cursor;
1516 if (tname[cursor]==
'c' && (cursor+6<len)) {
1517 if (strncmp(tname+cursor,
"const ",6) == 0) {
1519 if (modified) result +=
"const ";
1525 if (len > 2 && strncmp(tname+cursor,
"::",2) == 0) {
1529 unsigned int start_of_type = cursor;
1530 unsigned int end_of_type = 0;
1531 unsigned int mod_start_of_type = result.length();
1532 unsigned int prevScope = cursor;
1533 for ( ; cursor<len; ++cursor) {
1534 switch (tname[cursor]) {
1536 if ((cursor+1)>=len || tname[cursor+1]!=
':') {
1538 if (modified) result += (tname+prevScope);
1543 scope = result.substr(mod_start_of_type, string::npos);
1544 scope += std::string(tname+prevScope,cursor-prevScope);
1546 scope = std::string(tname, start_of_type, cursor - start_of_type);
1548 std::string scoperesult;
1549 bool isInlined =
false;
1553 if (!scoperesult.empty()) {
1556 if (constprefix && scoperesult.compare(0,6,
"const ",6) != 0) mod_start_of_type -= 6;
1557 result.replace(mod_start_of_type, string::npos,
1562 mod_start_of_type = start_of_type;
1563 result += string(tname,0,start_of_type);
1565 result += scoperesult;
1568 }
else if (modified) {
1569 result += std::string(tname+prevScope,cursor+2-prevScope);
1573 if (modified) result += std::string(tname+prevScope,cursor+2-prevScope);
1574 }
else if (isInlined) {
1578 mod_start_of_type = start_of_type;
1579 result += string(tname,0,start_of_type);
1581 result += string(tname,start_of_type,prevScope - start_of_type);
1583 }
else if (modified) {
1584 result += std::string(tname+prevScope,cursor+2-prevScope);
1588 prevScope = cursor+1;
1594 result += std::string(tname+prevScope,cursor+1-prevScope);
1600 }
while( cursor<len && tname[cursor] ==
',' );
1602 while (cursor<len && tname[cursor+1]==
' ') ++cursor;
1607 if (cursor+2<len && tname[cursor+1]==
':' && tname[cursor+2]==
':') {
1608 if (modified) result +=
"::";
1610 prevScope = cursor+1;
1612 if ( (cursor+1)<len && tname[cursor+1] ==
',') {
1614 if (modified) result +=
',';
1617 if ( (cursor+1)<len && tname[cursor+1] ==
'>') {
1619 if (modified) result +=
" >";
1622 if ( (cursor+1) >= len) {
1625 if (tname[cursor] !=
' ')
break;
1626 if (modified) prevScope = cursor+1;
1633 end_of_type = cursor;
1635 while ((cursor+1)<len && tname[cursor+1] ==
' ') ++cursor;
1637 auto next = cursor+1;
1638 if (strncmp(tname+next,
"const",5) == 0 && ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
']'))
1643 result += string(tname,0,start_of_type);
1645 mod_start_of_type = start_of_type + 6;
1646 result += string(tname,start_of_type,end_of_type-start_of_type);
1647 }
else if (mod_start_of_type < result.length()) {
1648 result.insert(mod_start_of_type,
"const ");
1649 mod_start_of_type += 6;
1652 mod_start_of_type += 6;
1653 result += string(tname,start_of_type,end_of_type-start_of_type);
1656 end_of_type = cursor+1;
1657 prevScope = end_of_type;
1658 if ((next+5)==len || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1661 }
else if (next!=len && tname[next] !=
'*' && tname[next] !=
'&') {
1671 if (tname[cursor] !=
' ') end_of_type = cursor;
1673 auto next = cursor+1;
1674 if (strncmp(tname+next,
"const",5) == 0) {
1675 if ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1680 (tname[next] ==
' ' || tname[next] ==
'*' || tname[next] ==
'&')) {
1683 if (strncmp(tname+next,
"const",5) == 0) {
1684 if ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1696 if (modified && prevScope) {
1697 result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1701 if (modified) result +=
',';
1705 if (modified && prevScope) {
1706 result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1710 if (modified) result +=
'>';
1718 if (prevScope && modified) result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1735 if (tname == 0 || tname[0] == 0)
1737 if (!gInterpreterHelper)
1746 if (result.empty())
return tname;
1750 unsigned int len = strlen(tname);
1752 unsigned int cursor = 0;
1753 bool modified =
false;
1756 if (!modified)
return tname;
1770 static const char* sSTLtypes[] = {
1783 "basic_istringstream",
1786 "basic_ostringstream",
1790 "basic_stringstream",
1819 "istreambuf_iterator",
1828 "localedef utility",
1845 "moneypunct_byname",
1857 "ostreambuf_iterator",
1863 "pointer_to_binary_function",
1864 "pointer_to_unary_function",
1868 "raw_storage_iterator",
1887 "unordered_multimap",
1888 "unordered_multiset",
1894 static ShuttingDownSignaler<set<string>> sSetSTLtypes;
1896 if (tname==0 || tname[0]==0)
return "";
1898 if (sSetSTLtypes.empty()) {
1900 const size_t nSTLtypes =
sizeof(sSTLtypes) /
sizeof(
const char*);
1901 for (
size_t i = 0; i < nSTLtypes; ++i)
1902 sSetSTLtypes.insert(sSTLtypes[i]);
1906 size_t len = strlen(tname);
1908 ret.reserve(len + 20);
1912 bool precScope =
false;
1913 while (!(isalnum(tname[
b]) || tname[
b] ==
'_') &&
b < len) {
1914 precScope = (
b < len - 2) && (tname[
b] ==
':') && (tname[
b + 1] ==
':');
1926 while (
e < len && (isalnum(tname[
e]) || tname[
e] ==
'_'))
1930 set<string>::const_iterator iSTLtype = sSetSTLtypes.find(
id);
1931 if (iSTLtype != sSetSTLtypes.end())
1946class NameCleanerForIO {
1948 std::vector<std::unique_ptr<NameCleanerForIO>> fArgumentNodes = {};
1949 NameCleanerForIO* fMother;
1950 bool fHasChanged =
false;
1951 bool AreAncestorsSTLContOrArray()
1953 NameCleanerForIO* mother = fMother;
1954 if (!mother)
return false;
1955 bool isSTLContOrArray =
true;
1956 while (
nullptr != mother){
1959 mother = mother->fMother;
1962 return isSTLContOrArray;
1966 NameCleanerForIO(
const std::string& clName =
"",
1968 NameCleanerForIO* mother =
nullptr):fMother(mother)
1970 if (clName.back() !=
'>') {
1975 std::vector<std::string>
v;
1980 auto argsEnd =
v.end();
1981 auto argsBeginPlusOne = ++
v.begin();
1982 auto argPos = std::find_if(argsBeginPlusOne, argsEnd,
1983 [](std::string& arg){
return (!arg.empty() && arg.front() ==
':');});
1984 if (argPos != argsEnd) {
1985 const int lenght = clName.size();
1986 int wedgeBalance = 0;
1987 int lastOpenWedge = 0;
1988 for (
int i=lenght-1;i>-1;i--) {
1989 auto&
c = clName.at(i);
1993 }
else if (
c ==
'>') {
1995 }
else if (
c ==
':' && 0 == wedgeBalance) {
1997 auto nameToClean = clName.substr(0,i-1);
1998 NameCleanerForIO node(nameToClean, mode);
1999 auto cleanName = node.ToString();
2000 fHasChanged = node.HasChanged();
2006 cleanName += clName.substr(i+1,lastOpenWedge-i-1);
2009 auto lastTemplate = &clName.data()[i+1];
2021 unsigned int nargs =
v.size() - 2;
2022 for (
unsigned int i=0;i<nargs;++i) {
2023 fArgumentNodes.emplace_back(
new NameCleanerForIO(
v[i+1],mode,
this));
2027 bool HasChanged()
const {
return fHasChanged;}
2031 std::string
name(fName);
2033 if (fArgumentNodes.empty())
return name;
2038 name = fArgumentNodes.front()->ToString();
2041 tst.ShortType(
name, 1);
2047 auto stlContType = AreAncestorsSTLContOrArray();
2049 name = fArgumentNodes.front()->ToString();
2056 for (
auto& node : fArgumentNodes) {
2057 name += node->ToString() +
",";
2058 fHasChanged |= node->HasChanged();
2061 name +=
name.back() ==
'>' ?
" >" :
">";
2065 const std::string& GetName() {
return fName;}
2066 const std::vector<std::unique_ptr<NameCleanerForIO>>* GetChildNodes()
const {
return &fArgumentNodes;}
2082 NameCleanerForIO node(templateInstanceName, mode);
2083 auto nameForIO = node.ToString();
2085 *hasChanged = node.HasChanged();
2094 std::string& typeNameBuf,
2095 std::array<int, 5>& maxIndices,
2101 NameCleanerForIO node(typeName);
2104 auto childNodes = node.GetChildNodes();
2105 for (ndim = 1;ndim <=5 ; ndim++) {
2106 maxIndices[ndim-1] = std::atoi(childNodes->back()->GetName().c_str());
2107 auto& frontNode = childNodes->front();
2108 typeNameBuf = frontNode->GetName();
2110 typeNameBuf = frontNode->ToString();
2113 childNodes = frontNode->GetChildNodes();
2126 const char* mangled_name = ti.name();
2132struct FunctionSplitInfo {
2134 std::string fReturnType;
2137 std::string fScopeName;
2140 std::string fFunctionName;
2144 std::vector<std::string> fFunctionTemplateArguments;
2147 std::vector<std::string> fFunctionParameters;
2156 std::stack<char> expected;
2157 for (std::size_t pos = 0, end = haystack.length(); pos < end; ++pos) {
2158 char c = haystack[pos];
2159 if (expected.empty()) {
2160 if (needles.find(
c) != std::string_view::npos)
2163 if (
c == expected.top()) {
2169 case '<': expected.emplace(
'>');
break;
2170 case '(': expected.emplace(
')');
break;
2171 case '[': expected.emplace(
']');
break;
2174 return std::string_view::npos;
2180 std::size_t lenHaystack = haystack.length();
2181 std::size_t prevAfterColumn = 0;
2183 std::size_t posColumn = FindNonNestedNeedles(haystack.substr(prevAfterColumn),
":");
2184 if (posColumn == std::string_view::npos)
2185 return std::string_view::npos;
2186 prevAfterColumn += posColumn;
2188 if (prevAfterColumn + 1 >= lenHaystack)
2189 return std::string_view::npos;
2192 if (haystack[prevAfterColumn] ==
':')
2193 return prevAfterColumn - 1;
2197 return std::string_view::npos;
2202 while (!str.empty() && std::isspace(str[0]))
2203 str.remove_prefix(1);
2204 while (!str.empty() && std::isspace(str.back()))
2205 str.remove_suffix(1);
2213 return std::string(sv.data(), sv.length());
2226 std::size_t posArgs = FindNonNestedNeedles(decl,
"(");
2229 std::size_t prevAfterWhiteSpace = 0;
2230 static const char whitespace[] =
" \t\n";
2231 while (declNoArgs.length() > prevAfterWhiteSpace) {
2232 std::size_t posWS = FindNonNestedNeedles(declNoArgs.substr(prevAfterWhiteSpace), whitespace);
2233 if (posWS == std::string_view::npos)
2235 prevAfterWhiteSpace += posWS + 1;
2236 while (declNoArgs.length() > prevAfterWhiteSpace
2237 && strchr(whitespace, declNoArgs[prevAfterWhiteSpace]))
2238 ++prevAfterWhiteSpace;
2242 std::size_t endReturn = prevAfterWhiteSpace;
2243 while (declNoArgs.length() > endReturn
2244 && strchr(
"&* \t \n", declNoArgs[endReturn]))
2251 std::size_t prevAtScope = FindNonNestedDoubleColons(scopeFunctionTmplt);
2252 while (prevAtScope != std::string_view::npos
2253 && scopeFunctionTmplt.length() > prevAtScope + 2) {
2254 std::size_t posScope = FindNonNestedDoubleColons(scopeFunctionTmplt.substr(prevAtScope + 2));
2255 if (posScope == std::string_view::npos)
2257 prevAtScope += posScope + 2;
2260 std::size_t afterScope = prevAtScope + 2;
2261 if (prevAtScope == std::string_view::npos) {
2266 result.
fScopeName =
ToString(StripSurroundingSpace(scopeFunctionTmplt.substr(0, prevAtScope)));
2270 std::size_t posTmpltOpen = FindNonNestedNeedles(funcNameTmplArgs,
"<");
2271 if (posTmpltOpen != std::string_view::npos) {
2276 std::size_t posTmpltClose = FindNonNestedNeedles(tmpltArgs,
">");
2277 if (posTmpltClose != std::string_view::npos) {
2278 tmpltArgs = tmpltArgs.substr(0, posTmpltClose);
2279 std::size_t prevAfterArg = 0;
2280 while (tmpltArgs.length() > prevAfterArg) {
2281 std::size_t posComma = FindNonNestedNeedles(tmpltArgs.substr(prevAfterArg),
",");
2282 if (posComma == std::string_view::npos) {
2286 prevAfterArg += posComma + 1;
2296 if (posArgs != std::string_view::npos) {
2299 std::size_t posEndArgs = FindNonNestedNeedles(params,
")");
2300 if (posEndArgs != std::string_view::npos) {
2301 params = params.substr(0, posEndArgs);
2302 std::size_t prevAfterArg = 0;
2303 while (params.length() > prevAfterArg) {
2304 std::size_t posComma = FindNonNestedNeedles(params.substr(prevAfterArg),
",");
2305 if (posComma == std::string_view::npos) {
2310 prevAfterArg += posComma + 1;
static RooMathCoreReg dummy
static void R__FindTrailing(std::string &full, std::string &stars)
static void ResolveTypedefImpl(const char *tname, unsigned int len, unsigned int &cursor, bool &modified, std::string &result)
static size_t findNameEnd(const std::string_view full)
static bool IsDefElement(const char *elementName, const char *defaultElementName, const char *classname)
return whether or not 'elementName' is the STL default Element for type 'classname'
static void ResolveTypedefProcessType(const char *tname, unsigned int, unsigned int cursor, bool constprefix, unsigned int start_of_type, unsigned int end_of_type, unsigned int mod_start_of_type, bool &modified, std::string &result)
static void RemoveStd(std::string &name, size_t pos=0)
Remove std:: and any potential inline namespace (well compiler detail namespace.
static size_t StdLen(const std::string_view name)
Return the length, if any, taken by std:: and any potential inline namespace (well compiler detail na...
virtual bool GetPartiallyDesugaredNameWithScopeHandling(const std::string &, std::string &, bool=true)=0
virtual ~TInterpreterLookupHelper()
virtual bool IsAlreadyPartiallyDesugaredName(const std::string &, const std::string &)=0
virtual bool IsDeclaredScope(const std::string &, bool &)=0
virtual void ShuttingDownSignal()=0
virtual void GetPartiallyDesugaredName(std::string &)=0
virtual bool ExistingTypeCheck(const std::string &, std::string &)=0
basic_string_view< char > string_view
std::string ToString(const T &val)
Utility function for conversion to strings.
ROOT::ESTLType STLKind(std::string_view type)
Converts STL container name to number.
bool IsDefComp(const char *comp, const char *classname)
return whether or not 'compare' is the STL default comparator for type 'classname'
std::string ResolveTypedef(const char *tname, bool resolveAll=false)
std::string CleanType(const char *typeDesc, int mode=0, const char **tail=0)
Cleanup type description, redundant blanks removed and redundant tail ignored return *tail = pointer ...
bool IsStdArray(std::string_view name)
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
bool IsDefHash(const char *hashname, const char *classname)
return whether or not 'hashname' is the STL default hash for type 'classname'
bool IsStdPair(std::string_view name)
bool IsInterpreterDetail(const char *type)
Return true if the type is one the interpreter details which are only forward declared (ClassInfo_t e...
std::string InsertStd(const char *tname)
bool SplitFunction(std::string_view decl, FunctionSplitInfo &result)
Split a function declaration into its different parts.
std::string GetLong64_Name(const char *original)
Replace 'long long' and 'unsigned long long' by 'Long64_t' and 'ULong64_t'.
bool IsDefPred(const char *predname, const char *classname)
return whether or not 'predname' is the STL default predicate for type 'classname'
char * DemangleTypeIdName(const std::type_info &ti, int &errorCode)
Demangle in a portable way the type id name.
const char * GetUnqualifiedName(const char *name)
Return the start of the unqualified name include in 'original'.
bool IsVectorBool(const char *name)
void Init(TClassEdit::TInterpreterLookupHelper *helper)
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
std::string ShortType(const char *typeDesc, int mode)
Return the absolute type of typeDesc.
char * DemangleName(const char *mangled_name, int &errorCode)
bool IsArtificial(std::string_view name)
bool GetStdArrayProperties(const char *typeName, std::string &typeNameBuf, std::array< int, 5 > &maxIndices, int &ndim)
std::string GetNameForIO(const std::string &templateInstanceName, TClassEdit::EModType mode=TClassEdit::kNone, bool *hasChanged=nullptr)
int STLArgs(int kind)
Return number of arguments for STL container before allocator.
int GetSplit(const char *type, std::vector< std::string > &output, int &nestedLoc, EModType mode=TClassEdit::kNone)
Stores in output (after emptying it) the split type.
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
bool IsDefAlloc(const char *alloc, const char *classname)
return whether or not 'allocname' is the STL default allocator for type 'classname'
bool IsUniquePtr(std::string_view name)
bool IsSTLBitset(const char *type)
Return true is the name is std::bitset<number> or bitset<number>
ROOT::ESTLType UnderlyingIsSTLCont(std::string_view type)
Return the type of STL collection, if any, that is the underlying type of the given type.
EComplexType GetComplexType(const char *)
static constexpr double second
Result of splitting a function declaration into fReturnType fScopeName::fFunctionName<fFunctionTempla...
std::string fFunctionName
Name of the function.
std::vector< std::string > fFunctionTemplateArguments
Template arguments of the function template specialization, if any; will contain one element "" for f...
std::string fScopeName
Name of the scope qualification of the function, possibly empty.
std::vector< std::string > fFunctionParameters
Function parameters.
std::string fReturnType
Return type of the function, might be empty if the function declaration string did not provide it.
bool IsTemplate()
Check if the type is a template.
int IsSTLCont(int testAlloc=0) const
type : type name: vector<list<classA,allocator>,allocator> testAlloc: if true, we test allocator,...
TSplitType(const char *type2split, EModType mode=TClassEdit::kNone)
default constructor
std::vector< std::string > fElements
ROOT::ESTLType IsInSTL() const
type : type name: vector<list<classA,allocator>,allocator>[::iterator] result: 0 : not stl container ...
void ShortType(std::string &answer, int mode)
Return the absolute type of typeDesc into the string answ.
static void output(int code)