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"))
405 #ifdef _CONCURRENCE_H
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();
513 if (
type.length() == 0)
516 if (
type.compare(0,6,
"const ")==0) { offset += 6; }
518 const auto len =
type.length() - offset;
523 static const char *stls[] =
524 {
"any",
"vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset",
525 "forward_list",
"unordered_set",
"unordered_multiset",
"unordered_map",
"unordered_multimap", 0};
526 static const size_t stllen[] =
527 { 3, 6, 4, 5, 3, 8, 3, 8, 6,
528 12, 13, 18, 13, 18, 0};
544 for (
int k = 1; stls[k]; ++k) {
545 if (len == stllen[k]) {
546 if (
type.compare(offset, len, stls[k]) == 0)
558 static const char stln[] =
560 { 1, 1, 1, 1, 3, 3, 2, 2, 1,
572 for(
size_t i = 0; i < full.length(); ++i) {
574 case '<': { ++level;
break; }
576 if (level == 0)
return i;
581 if (level == 0)
return i;
587 return full.length();
594 return pos +
findNameEnd( {full.data()+pos,full.length()-pos} );
606 if (
a==
"alloc")
return true;
607 if (
a==
"__default_alloc_template<true,0>")
return true;
608 if (
a==
"__malloc_alloc_template<0>")
return true;
610 const static int alloclen = strlen(
"allocator<");
611 if (
a.compare(0,alloclen,
"allocator<") != 0) {
614 a.remove_prefix(alloclen);
621 if (
a.compare(0,k.length(),k) != 0) {
625 std::string valuepart;
628 std::string norm_value;
631 if (valuepart != norm_value) {
634 a.remove_prefix(end);
636 a.remove_prefix(k.length());
639 if (
a.compare(0,1,
">")!=0 &&
a.compare(0,2,
" >")!=0) {
651 const char *keyclassname,
652 const char *valueclassname)
654 if (
IsDefAlloc(allocname,keyclassname))
return true;
659 const static int alloclen = strlen(
"allocator<");
660 if (
a.compare(0,alloclen,
"allocator<") != 0) {
663 a.remove_prefix(alloclen);
667 const static int pairlen = strlen(
"pair<");
668 if (
a.compare(0,pairlen,
"pair<") != 0) {
671 a.remove_prefix(pairlen);
673 const static int constlen = strlen(
"const");
674 if (
a.compare(0,constlen+1,
"const ") == 0) {
675 a.remove_prefix(constlen+1);
682 if (k.compare(0,constlen+1,
"const ") == 0) {
683 k.remove_prefix(constlen+1);
686 if (
a.compare(0,k.length(),k) != 0) {
690 std::string alloc_keypart;
693 std::string norm_key;
696 if (alloc_keypart != norm_key) {
697 if ( norm_key[norm_key.length()-1] ==
'*' ) {
701 norm_key +=
" const";
703 if (alloc_keypart != norm_key) {
707 a.remove_prefix(end);
709 size_t end = k.length();
710 if ( (
a[end-1] ==
'*') ||
a[end]==
' ' ) {
711 size_t skipSpace = (
a[end] ==
' ');
712 if (
a.compare(end+skipSpace,constlen,
"const") == 0) {
713 end += constlen+skipSpace;
716 a.remove_prefix(end);
728 if (
a.compare(0,
v.length(),
v) != 0) {
732 std::string valuepart;
735 std::string norm_value;
738 if (valuepart != norm_value) {
741 a.remove_prefix(end);
743 a.remove_prefix(
v.length());
746 if (
a.compare(0,1,
">")!=0 &&
a.compare(0,2,
" >")!=0) {
757 static bool IsDefElement(
const char *elementName,
const char* defaultElementName,
const char *classname)
759 string c = elementName;
763 const int elementlen = strlen(defaultElementName);
764 if (
c.compare(pos,elementlen,defaultElementName) != 0) {
769 string k = classname;
770 if (
c.compare(pos,k.length(),k) != 0) {
779 std::string norm_key;
782 if (keypart != norm_key) {
790 if (
c.compare(pos,1,
">")!=0 &&
c.compare(pos,2,
" >")!=0) {
841 norm_name = std::string(
name);
870 if (norm_name.length()>2 && norm_name[0]==
':' && norm_name[1]==
':') {
871 norm_name.erase(0,2);
874 if (gInterpreterHelper) {
876 std::string typeresult;
880 if (!typeresult.empty()) norm_name = typeresult;
901 static const char* longlong_s =
"long long";
902 static const char* ulonglong_s =
"unsigned long long";
903 static const unsigned int longlong_len = strlen(longlong_s);
904 static const unsigned int ulonglong_len = strlen(ulonglong_s);
906 string result = original;
909 while( (pos = result.find(ulonglong_s,pos) ) >=0 ) {
910 result.replace(pos, ulonglong_len,
"ULong64_t");
913 while( (pos = result.find(longlong_s,pos) ) >=0 ) {
914 result.replace(pos, longlong_len,
"Long64_t");
924 const char *lastPos = original;
927 for(
auto cursor = original; *cursor !=
'\0'; ++cursor) {
928 if ( *cursor ==
'<' || *cursor ==
'(') ++depth;
929 else if ( *cursor ==
'>' || *cursor ==
')' ) --depth;
930 else if ( *cursor ==
':' ) {
931 if (depth==0 && *(cursor+1) ==
':' && *(cursor+2) !=
'\0') {
946 const char *t = full.c_str();
947 const unsigned int tlen( full.size() );
949 const char *starloc = t + tlen - 1;
950 bool hasconst =
false;
952 && (starloc-t) > 4 && 0 == strncmp((starloc-4),
"const",5)
953 && ( (*(starloc-5)) ==
' ' || (*(starloc-5)) ==
'*' || (*(starloc-5)) ==
'&'
954 || (*(starloc-5)) ==
'>' || (*(starloc-5)) ==
']') ) {
957 if ((*starloc-1)==
' ') {
963 if ( hasconst || (*starloc)==
'*' || (*starloc)==
'&' || (*starloc)==
']' ) {
964 bool isArray = ( (*starloc)==
']' );
965 while( t<=(starloc-1) && ((*(starloc-1))==
'*' || (*(starloc-1))==
'&' || (*(starloc-1))==
't' || isArray)) {
968 isArray = ! ( (*starloc)==
'[' );
969 }
else if ( (*(starloc-1))==
't' ) {
970 if ( (starloc-1-t) > 5 && 0 == strncmp((starloc-5),
"const",5)
971 && ( (*(starloc-6)) ==
' ' || (*(starloc-6)) ==
'*' || (*(starloc-6)) ==
'&'
972 || (*(starloc-6)) ==
'>' || (*(starloc-6)) ==
']')) {
983 if ((*(starloc-1))==
' ') {
988 const unsigned int starlen = strlen(starloc);
989 full.erase(tlen-starlen,starlen);
990 }
else if (hasconst) {
992 const unsigned int starlen = strlen(starloc);
993 full.erase(tlen-starlen,starlen);
1013 if (strlen(
type)==0)
return 0;
1015 int cleantypeMode = 1 ;
1024 unsigned int const_offset = (0==strncmp(
"const ",full.c_str(),6)) ? 6 : 0;
1025 bool isString =
false;
1026 bool isStdString =
false;
1027 size_t std_offset = const_offset;
1028 static const char* basic_string_std =
"std::basic_string<char";
1029 static const unsigned int basic_string_std_len = strlen(basic_string_std);
1031 if (full.compare(const_offset,basic_string_std_len,basic_string_std) == 0
1032 && full.size() > basic_string_std_len) {
1036 }
else if (full.compare(const_offset,basic_string_std_len-5,basic_string_std+5) == 0
1037 && full.size() > (basic_string_std_len-5)) {
1040 }
else if (full.find(
"basic_string") != std::string::npos) {
1041 size_t len =
StdLen(full.c_str() + const_offset);
1042 if (len && len != 5 && full.compare(const_offset + len, basic_string_std_len-5, basic_string_std+5) == 0) {
1049 size_t offset = basic_string_std_len - 5;
1050 offset += std_offset;
1051 if ( full[offset] ==
'>' ) {
1053 }
else if (full[offset] ==
',') {
1055 if (full.compare(offset, 5,
"std::") == 0) {
1058 static const char* char_traits_s =
"char_traits<char>";
1059 static const unsigned int char_traits_len = strlen(char_traits_s);
1060 if (full.compare(offset, char_traits_len, char_traits_s) == 0) {
1061 offset += char_traits_len;
1062 if ( full[offset] ==
'>') {
1064 }
else if (full[offset] ==
' ' && full[offset+1] ==
'>') {
1067 }
else if (full[offset] ==
',') {
1069 if (full.compare(offset, 5,
"std::") == 0) {
1072 static const char* allocator_s =
"allocator<char>";
1073 static const unsigned int allocator_len = strlen(allocator_s);
1074 if (full.compare(offset, allocator_len, allocator_s) == 0) {
1075 offset += allocator_len;
1076 if ( full[offset] ==
'>') {
1078 }
else if (full[offset] ==
' ' && full[offset+1] ==
'>') {
1099 output.push_back(
string());
1101 if (isStdString && !(mode &
kDropStd)) {
1102 output.push_back(
"const std::string");
1104 output.push_back(
"const string");
1107 if (isStdString && !(mode &
kDropStd)) {
1108 output.push_back(
"std::string");
1110 output.push_back(
"string");
1113 if (offset < full.length()) {
1116 string right( full.substr(offset) );
1119 output.back().append(right.c_str()+1);
1130 unsigned int offset = (0==strncmp(
"const ",full.c_str(),6)) ? 6 : 0;
1135 if ( !full.empty() ) {
1139 const char *
c = strchr(full.c_str(),
'<');
1142 output.push_back(
string(full,0,
c - full.c_str()));
1146 int parenthesis = 0;
1147 for(cursor =
c + 1; *cursor !=
'\0' && !(level==0 && *cursor ==
'>'); ++cursor) {
1148 if (*cursor ==
'(') {
1151 }
else if (*cursor ==
')') {
1158 case '<': ++level;
break;
1159 case '>': --level;
break;
1162 output.push_back(std::string(
c+1,cursor));
1169 if (*(cursor-1) ==
' ') {
1170 output.push_back(std::string(
c+1,cursor-1));
1172 output.push_back(std::string(
c+1,cursor));
1175 if (*(cursor+1)==
':') {
1178 nestedLoc =
output.size();
1179 output.push_back((cursor+1));
1181 }
else if (level >= 0) {
1183 output.push_back(std::string(
c+1,cursor));
1187 output.push_back(
string());
1214 static const char* remove[] = {
"class",
"const",
"volatile",0};
1215 static bool isinit =
false;
1216 static std::vector<size_t> lengths;
1218 for (
int k=0; remove[k]; ++k) {
1219 lengths.push_back(strlen(remove[k]));
1225 result.reserve(strlen(typeDesc)*2);
1229 for(
c=typeDesc;*
c;
c++) {
1232 if (!isalnum(
c[ 1]) &&
c[ 1] !=
'_')
continue;
1234 if (kbl && (mode>=2 || lev==0)) {
1236 int n = (mode) ? 999 : 1;
1239 for (
int k=0; k<
n && remove[k]; k++) {
1240 int rlen = lengths[k];
1243 if (strncmp(remove[k],
c,rlen))
continue;
1246 if (isalnum(
c[rlen]) ||
c[rlen]==
'_' ||
c[rlen]==
'$')
continue;
1248 c+=rlen-1; done = 1;
break;
1253 kbl = (!isalnum(
c[ 0]) &&
c[ 0]!=
'_' &&
c[ 0]!=
'$' &&
c[0]!=
'[' &&
c[0]!=
']' &&
c[0]!=
'-' &&
c[0]!=
'@');
1257 if (*
c ==
'<' || *
c ==
'(') lev++;
1258 if (lev==0 && !isalnum(*
c)) {
1259 if (!strchr(
"*&:._$ []-@",*
c))
break;
1263 if (
c[0]==
'>' && result.size() && result[result.size()-1]==
'>') result+=
" ";
1267 if (*
c ==
'>' || *
c ==
')') lev--;
1304 size_t len = strlen(
type);
1305 if (len < 2 || strncmp(
type+len-2,
"_t",2) != 0)
return false;
1307 unsigned char offset = 0;
1308 if (strncmp(
type,
"const ",6)==0) { offset += 6; }
1309 static const char *names[] = {
"CallFunc_t",
"ClassInfo_t",
"BaseClassInfo_t",
1310 "DataMemberInfo_t",
"FuncTempInfo_t",
"MethodInfo_t",
"MethodArgInfo_t",
1311 "TypeInfo_t",
"TypedefInfo_t",0};
1313 for(
int k=1;names[k];k++) {
if (strcmp(
type+offset,names[k])==0)
return true;}
1322 size_t offset =
StdLen(classname);
1323 if ( strncmp(classname+offset,
"bitset<",strlen(
"bitset<"))==0)
return true;
1341 if (
type.compare(0,6,
"const ",6) == 0)
1342 type.remove_prefix(6);
1344 while(
type[
type.length()-1]==
'*' ||
1347 type.remove_suffix(1);
1360 auto pos =
type.find(
'<');
1364 for (decltype(
type.length()) level = 1;
c <
type.length(); ++
c) {
1365 if (
type[
c] ==
'<') ++level;
1366 if (
type[
c] ==
'>') --level;
1367 if (level == 0)
break;
1369 if (
c != (
type.length()-1) ) {
1389 if (strchr(
type,
'<')==0)
return 0;
1400 classname +=
StdLen( classname );
1401 if ( strcmp(classname,
"string")==0 )
return true;
1402 if ( strncmp(classname,
"bitset<",strlen(
"bitset<"))==0)
return true;
1403 if (
IsStdPair(classname) )
return true;
1404 if ( strcmp(classname,
"allocator")==0)
return true;
1405 if ( strncmp(classname,
"allocator<",strlen(
"allocator<"))==0)
return true;
1406 if ( strncmp(classname,
"greater<",strlen(
"greater<"))==0)
return true;
1407 if ( strncmp(classname,
"less<",strlen(
"less<"))==0)
return true;
1408 if ( strncmp(classname,
"equal_to<",strlen(
"equal_to<"))==0)
return true;
1409 if ( strncmp(classname,
"hash<",strlen(
"hash<"))==0)
return true;
1410 if ( strncmp(classname,
"auto_ptr<",strlen(
"auto_ptr<"))==0)
return true;
1412 if ( strncmp(classname,
"vector<",strlen(
"vector<"))==0)
return true;
1413 if ( strncmp(classname,
"list<",strlen(
"list<"))==0)
return true;
1414 if ( strncmp(classname,
"forward_list<",strlen(
"forward_list<"))==0)
return true;
1415 if ( strncmp(classname,
"deque<",strlen(
"deque<"))==0)
return true;
1416 if ( strncmp(classname,
"map<",strlen(
"map<"))==0)
return true;
1417 if ( strncmp(classname,
"multimap<",strlen(
"multimap<"))==0)
return true;
1418 if ( strncmp(classname,
"set<",strlen(
"set<"))==0)
return true;
1419 if ( strncmp(classname,
"multiset<",strlen(
"multiset<"))==0)
return true;
1420 if ( strncmp(classname,
"unordered_set<",strlen(
"unordered_set<"))==0)
return true;
1421 if ( strncmp(classname,
"unordered_multiset<",strlen(
"unordered_multiset<"))==0)
return true;
1422 if ( strncmp(classname,
"unordered_map<",strlen(
"unordered_map<"))==0)
return true;
1423 if ( strncmp(classname,
"unordered_multimap<",strlen(
"unordered_multimap<"))==0)
return true;
1424 if ( strncmp(classname,
"bitset<",strlen(
"bitset<"))==0)
return true;
1443 unsigned int cursor,
1445 unsigned int start_of_type,
1446 unsigned int end_of_type,
1447 unsigned int mod_start_of_type,
1449 std::string &result)
1451 std::string
type(modified && (mod_start_of_type < result.length()) ?
1452 result.substr(mod_start_of_type, string::npos)
1453 :
string(tname, start_of_type, end_of_type == 0 ? cursor - start_of_type : end_of_type - start_of_type));
1458 if (!typeresult.empty()) {
1461 result.replace(mod_start_of_type, string::npos,
1466 mod_start_of_type = start_of_type;
1467 result += string(tname,0,start_of_type);
1468 if (constprefix && typeresult.compare(0,6,
"const ",6) == 0) {
1469 result += typeresult.substr(6,string::npos);
1471 result += typeresult;
1474 }
else if (modified) {
1475 result.replace(mod_start_of_type, string::npos,
1479 if (end_of_type != 0 && end_of_type!=cursor) {
1480 result += std::string(tname,end_of_type,cursor-end_of_type);
1487 if (end_of_type != 0 && end_of_type!=cursor) {
1488 result += std::string(tname,end_of_type,cursor-end_of_type);
1498 unsigned int &cursor,
1500 std::string &result)
1507 bool constprefix =
false;
1509 if (tname[cursor]==
' ') {
1512 result += string(tname,0,cursor);
1514 while (tname[cursor]==
' ') ++cursor;
1517 if (tname[cursor]==
'c' && (cursor+6<len)) {
1518 if (strncmp(tname+cursor,
"const ",6) == 0) {
1520 if (modified) result +=
"const ";
1526 if (len > 2 && strncmp(tname+cursor,
"::",2) == 0) {
1530 unsigned int start_of_type = cursor;
1531 unsigned int end_of_type = 0;
1532 unsigned int mod_start_of_type = result.length();
1533 unsigned int prevScope = cursor;
1534 for ( ; cursor<len; ++cursor) {
1535 switch (tname[cursor]) {
1537 if ((cursor+1)>=len || tname[cursor+1]!=
':') {
1539 if (modified) result += (tname+prevScope);
1544 scope = result.substr(mod_start_of_type, string::npos);
1545 scope += std::string(tname+prevScope,cursor-prevScope);
1547 scope = std::string(tname, start_of_type, cursor - start_of_type);
1549 std::string scoperesult;
1550 bool isInlined =
false;
1554 if (!scoperesult.empty()) {
1557 if (constprefix && scoperesult.compare(0,6,
"const ",6) != 0) mod_start_of_type -= 6;
1558 result.replace(mod_start_of_type, string::npos,
1563 mod_start_of_type = start_of_type;
1564 result += string(tname,0,start_of_type);
1566 result += scoperesult;
1569 }
else if (modified) {
1570 result += std::string(tname+prevScope,cursor+2-prevScope);
1574 if (modified) result += std::string(tname+prevScope,cursor+2-prevScope);
1575 }
else if (isInlined) {
1579 mod_start_of_type = start_of_type;
1580 result += string(tname,0,start_of_type);
1582 result += string(tname,start_of_type,prevScope - start_of_type);
1584 }
else if (modified) {
1585 result += std::string(tname+prevScope,cursor+2-prevScope);
1589 prevScope = cursor+1;
1595 result += std::string(tname+prevScope,cursor+1-prevScope);
1601 }
while( cursor<len && tname[cursor] ==
',' );
1603 while (cursor<len && tname[cursor+1]==
' ') ++cursor;
1608 if (cursor+2<len && tname[cursor+1]==
':' && tname[cursor+2]==
':') {
1609 if (modified) result +=
"::";
1611 prevScope = cursor+1;
1613 if ( (cursor+1)<len && tname[cursor+1] ==
',') {
1615 if (modified) result +=
',';
1618 if ( (cursor+1)<len && tname[cursor+1] ==
'>') {
1620 if (modified) result +=
" >";
1623 if ( (cursor+1) >= len) {
1626 if (tname[cursor] !=
' ')
break;
1627 if (modified) prevScope = cursor+1;
1634 end_of_type = cursor;
1636 while ((cursor+1)<len && tname[cursor+1] ==
' ') ++cursor;
1638 auto next = cursor+1;
1639 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] ==
']'))
1644 result += string(tname,0,start_of_type);
1646 mod_start_of_type = start_of_type + 6;
1647 result += string(tname,start_of_type,end_of_type-start_of_type);
1648 }
else if (mod_start_of_type < result.length()) {
1649 result.insert(mod_start_of_type,
"const ");
1650 mod_start_of_type += 6;
1653 mod_start_of_type += 6;
1654 result += string(tname,start_of_type,end_of_type-start_of_type);
1657 end_of_type = cursor+1;
1658 prevScope = end_of_type;
1659 if ((next+5)==len || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1662 }
else if (next!=len && tname[next] !=
'*' && tname[next] !=
'&') {
1672 if (tname[cursor] !=
' ') end_of_type = cursor;
1674 auto next = cursor+1;
1675 if (strncmp(tname+next,
"const",5) == 0) {
1676 if ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1681 (tname[next] ==
' ' || tname[next] ==
'*' || tname[next] ==
'&')) {
1684 if (strncmp(tname+next,
"const",5) == 0) {
1685 if ((next+5)==len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
'[') {
1697 if (modified && prevScope) {
1698 result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1702 if (modified) result +=
',';
1706 if (modified && prevScope) {
1707 result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1711 if (modified) result +=
'>';
1719 if (prevScope && modified) result += std::string(tname+prevScope,(end_of_type == 0 ? cursor : end_of_type)-prevScope);
1736 if (tname == 0 || tname[0] == 0)
1738 if (!gInterpreterHelper)
1747 if (result.empty())
return tname;
1751 unsigned int len = strlen(tname);
1753 unsigned int cursor = 0;
1754 bool modified =
false;
1757 if (!modified)
return tname;
1771 static const char* sSTLtypes[] = {
1784 "basic_istringstream",
1787 "basic_ostringstream",
1791 "basic_stringstream",
1820 "istreambuf_iterator",
1829 "localedef utility",
1846 "moneypunct_byname",
1858 "ostreambuf_iterator",
1864 "pointer_to_binary_function",
1865 "pointer_to_unary_function",
1869 "raw_storage_iterator",
1888 "unordered_multimap",
1889 "unordered_multiset",
1895 static ShuttingDownSignaler<set<string>> sSetSTLtypes;
1897 if (tname==0 || tname[0]==0)
return "";
1899 if (sSetSTLtypes.empty()) {
1901 const size_t nSTLtypes =
sizeof(sSTLtypes) /
sizeof(
const char*);
1902 for (
size_t i = 0; i < nSTLtypes; ++i)
1903 sSetSTLtypes.insert(sSTLtypes[i]);
1907 size_t len = strlen(tname);
1909 ret.reserve(len + 20);
1913 bool precScope =
false;
1914 while (!(isalnum(tname[
b]) || tname[
b] ==
'_') &&
b < len) {
1915 precScope = (
b < len - 2) && (tname[
b] ==
':') && (tname[
b + 1] ==
':');
1927 while (
e < len && (isalnum(tname[
e]) || tname[
e] ==
'_'))
1931 set<string>::const_iterator iSTLtype = sSetSTLtypes.find(
id);
1932 if (iSTLtype != sSetSTLtypes.end())
1947 class NameCleanerForIO {
1949 std::vector<std::unique_ptr<NameCleanerForIO>> fArgumentNodes = {};
1950 NameCleanerForIO* fMother;
1951 bool fHasChanged =
false;
1952 bool AreAncestorsSTLContOrArray()
1954 NameCleanerForIO* mother = fMother;
1955 if (!mother)
return false;
1956 bool isSTLContOrArray =
true;
1957 while (
nullptr != mother){
1960 mother = mother->fMother;
1963 return isSTLContOrArray;
1967 NameCleanerForIO(
const std::string& clName =
"",
1969 NameCleanerForIO* mother =
nullptr):fMother(mother)
1971 if (clName.back() !=
'>') {
1976 std::vector<std::string>
v;
1981 auto argsEnd =
v.end();
1982 auto argsBeginPlusOne = ++
v.begin();
1983 auto argPos = std::find_if(argsBeginPlusOne, argsEnd,
1984 [](std::string& arg){
return (!arg.empty() && arg.front() ==
':');});
1985 if (argPos != argsEnd) {
1986 const int lenght = clName.size();
1987 int wedgeBalance = 0;
1988 int lastOpenWedge = 0;
1989 for (
int i=lenght-1;i>-1;i--) {
1990 auto&
c = clName.at(i);
1994 }
else if (
c ==
'>') {
1996 }
else if (
c ==
':' && 0 == wedgeBalance) {
1998 auto nameToClean = clName.substr(0,i-1);
1999 NameCleanerForIO node(nameToClean, mode);
2000 auto cleanName = node.ToString();
2001 fHasChanged = node.HasChanged();
2007 cleanName += clName.substr(i+1,lastOpenWedge-i-1);
2010 auto lastTemplate = &clName.data()[i+1];
2022 unsigned int nargs =
v.size() - 2;
2023 for (
unsigned int i=0;i<nargs;++i) {
2024 fArgumentNodes.emplace_back(
new NameCleanerForIO(
v[i+1],mode,
this));
2028 bool HasChanged()
const {
return fHasChanged;}
2032 std::string
name(fName);
2034 if (fArgumentNodes.empty())
return name;
2039 name = fArgumentNodes.front()->ToString();
2042 tst.ShortType(
name, 1);
2048 auto stlContType = AreAncestorsSTLContOrArray();
2050 name = fArgumentNodes.front()->ToString();
2057 for (
auto& node : fArgumentNodes) {
2058 name += node->ToString() +
",";
2059 fHasChanged |= node->HasChanged();
2062 name +=
name.back() ==
'>' ?
" >" :
">";
2066 const std::string& GetName() {
return fName;}
2067 const std::vector<std::unique_ptr<NameCleanerForIO>>* GetChildNodes()
const {
return &fArgumentNodes;}
2083 NameCleanerForIO node(templateInstanceName, mode);
2084 auto nameForIO = node.ToString();
2086 *hasChanged = node.HasChanged();
2095 std::string& typeNameBuf,
2096 std::array<int, 5>& maxIndices,
2102 NameCleanerForIO node(typeName);
2105 auto childNodes = node.GetChildNodes();
2106 for (ndim = 1;ndim <=5 ; ndim++) {
2107 maxIndices[ndim-1] = std::atoi(childNodes->back()->GetName().c_str());
2108 auto& frontNode = childNodes->front();
2109 typeNameBuf = frontNode->GetName();
2111 typeNameBuf = frontNode->ToString();
2114 childNodes = frontNode->GetChildNodes();
2127 const char* mangled_name = ti.name();
2133 struct FunctionSplitInfo {
2135 std::string fReturnType;
2138 std::string fScopeName;
2141 std::string fFunctionName;
2145 std::vector<std::string> fFunctionTemplateArguments;
2148 std::vector<std::string> fFunctionParameters;
2157 std::stack<char> expected;
2158 for (std::size_t pos = 0, end = haystack.length(); pos < end; ++pos) {
2159 char c = haystack[pos];
2160 if (expected.empty()) {
2161 if (needles.find(
c) != std::string_view::npos)
2164 if (
c == expected.top()) {
2170 case '<': expected.emplace(
'>');
break;
2171 case '(': expected.emplace(
')');
break;
2172 case '[': expected.emplace(
']');
break;
2175 return std::string_view::npos;
2181 std::size_t lenHaystack = haystack.length();
2182 std::size_t prevAfterColumn = 0;
2184 std::size_t posColumn = FindNonNestedNeedles(haystack.substr(prevAfterColumn),
":");
2185 if (posColumn == std::string_view::npos)
2186 return std::string_view::npos;
2187 prevAfterColumn += posColumn;
2189 if (prevAfterColumn + 1 >= lenHaystack)
2190 return std::string_view::npos;
2193 if (haystack[prevAfterColumn] ==
':')
2194 return prevAfterColumn - 1;
2198 return std::string_view::npos;
2203 while (!str.empty() && std::isspace(str[0]))
2204 str.remove_prefix(1);
2205 while (!str.empty() && std::isspace(str.back()))
2206 str.remove_suffix(1);
2214 return std::string(sv.data(), sv.length());
2227 std::size_t posArgs = FindNonNestedNeedles(decl,
"(");
2230 std::size_t prevAfterWhiteSpace = 0;
2231 static const char whitespace[] =
" \t\n";
2232 while (declNoArgs.length() > prevAfterWhiteSpace) {
2233 std::size_t posWS = FindNonNestedNeedles(declNoArgs.substr(prevAfterWhiteSpace), whitespace);
2234 if (posWS == std::string_view::npos)
2236 prevAfterWhiteSpace += posWS + 1;
2237 while (declNoArgs.length() > prevAfterWhiteSpace
2238 && strchr(whitespace, declNoArgs[prevAfterWhiteSpace]))
2239 ++prevAfterWhiteSpace;
2243 std::size_t endReturn = prevAfterWhiteSpace;
2244 while (declNoArgs.length() > endReturn
2245 && strchr(
"&* \t \n", declNoArgs[endReturn]))
2252 std::size_t prevAtScope = FindNonNestedDoubleColons(scopeFunctionTmplt);
2253 while (prevAtScope != std::string_view::npos
2254 && scopeFunctionTmplt.length() > prevAtScope + 2) {
2255 std::size_t posScope = FindNonNestedDoubleColons(scopeFunctionTmplt.substr(prevAtScope + 2));
2256 if (posScope == std::string_view::npos)
2258 prevAtScope += posScope + 2;
2261 std::size_t afterScope = prevAtScope + 2;
2262 if (prevAtScope == std::string_view::npos) {
2267 result.
fScopeName =
ToString(StripSurroundingSpace(scopeFunctionTmplt.substr(0, prevAtScope)));
2271 std::size_t posTmpltOpen = FindNonNestedNeedles(funcNameTmplArgs,
"<");
2272 if (posTmpltOpen != std::string_view::npos) {
2277 std::size_t posTmpltClose = FindNonNestedNeedles(tmpltArgs,
">");
2278 if (posTmpltClose != std::string_view::npos) {
2279 tmpltArgs = tmpltArgs.substr(0, posTmpltClose);
2280 std::size_t prevAfterArg = 0;
2281 while (tmpltArgs.length() > prevAfterArg) {
2282 std::size_t posComma = FindNonNestedNeedles(tmpltArgs.substr(prevAfterArg),
",");
2283 if (posComma == std::string_view::npos) {
2287 prevAfterArg += posComma + 1;
2297 if (posArgs != std::string_view::npos) {
2300 std::size_t posEndArgs = FindNonNestedNeedles(params,
")");
2301 if (posEndArgs != std::string_view::npos) {
2302 params = params.substr(0, posEndArgs);
2303 std::size_t prevAfterArg = 0;
2304 while (params.length() > prevAfterArg) {
2305 std::size_t posComma = FindNonNestedNeedles(params.substr(prevAfterArg),
",");
2306 if (posComma == std::string_view::npos) {
2311 prevAfterArg += posComma + 1;