33using std::string, std::string_view, std::vector, std::set;
39struct ShuttingDownSignaler :
public T {
42 ShuttingDownSignaler() =
default;
43 ShuttingDownSignaler(T &&in) :
T(std::move(in)) {}
45 ~ShuttingDownSignaler()
47 if (gInterpreterHelper)
54void RemoveSpace(std::string_view &s)
56 while (!s.empty() && s[0] ==
' ')
64size_t StdLen(
const std::string_view
name)
67 if (
name.compare(0, 5,
"std::") == 0) {
72 if (gInterpreterHelper) {
73 for (
size_t i = 5; i <
name.length(); ++i) {
77 std::string scope(
name.data(), i);
81 static ShuttingDownSignaler<std::set<std::string>> gInlined;
82 static std::atomic_flag spinFlag = ATOMIC_FLAG_INIT;
87 isInlined = (gInlined.find(scope) != gInlined.end());
92 if (i + 1 <
name.length() &&
name[i + 1] ==
':') {
96 std::string scoperesult;
102 gInlined.insert(scope);
105 if (i + 1 <
name.length() &&
name[i + 1] ==
':') {
123void RemoveStd(std::string &
name,
size_t pos = 0)
125 size_t len = StdLen({
name.data() + pos,
name.length() - pos});
135void RemoveStd(std::string_view &
name)
146void RemoveScopeResolution(std::string &
name)
148 if (
name.length() > 2 &&
name[0] ==
':' &&
name[1] ==
':') {
159 if (0 == strncmp(clName,
"complex<", 8)) {
160 const char *clNamePlus8 = clName + 8;
161 if (0 == strcmp(
"float>", clNamePlus8)) {
164 if (0 == strcmp(
"double>", clNamePlus8)) {
167 if (0 == strcmp(
"int>", clNamePlus8)) {
170 if (0 == strcmp(
"long>", clNamePlus8)) {
185 if (
this == gInterpreterHelper)
186 gInterpreterHelper =
nullptr;
193 gInterpreterHelper = helper;
256 if (k<0) kind = -kind;
262 if(kind>2) kind = - kind;
293 if (
fElements[narg-1].empty() ==
false &&
297 || 0 ==
fElements[narg-1].compare(0,6,
"const*")
298 || 0 ==
fElements[narg-1].compare(0,6,
"const&")
299 || 0 ==
fElements[narg-1].compare(0,6,
"const[")
300 || 0 ==
fElements[narg-1].compare(
"const")
303 if ((
mode&1)==0) tailLoc = narg-1;
305 else { assert(
fElements[narg-1].empty()); };
315 const int iall =
STLArgs(kind);
319 while(narg-1>iall) {
fElements.pop_back(); narg--;}
331 bool allocRemoved =
false;
337 if (narg-1 == iall+1) {
339 bool dropAlloc =
false;
393 if (!allocRemoved && narg-1 == iall+1) {
397 if (narg-1 == iall) narg--;
420 bool predRemoved =
false;
438 unsigned int offset = (0==strncmp(
"const ",
fElements[0].c_str(),6)) ? 6 : 0;
443 static const std::string sharedPtrDef = std::to_string(__gnu_cxx::__default_lock_policy);
445 static const std::string sharedPtrDef = std::to_string(2);
455 for (
int i=1;i<narg; i++) {
461 unsigned int offset = (0==strncmp(
"const ",
fElements[i].c_str(),6)) ? 6 : 0;
472 if (gInterpreterHelper &&
475 if (!typeresult.empty() && typeresult !=
fElements[i]) {
483 unsigned int tailOffset = 0;
484 if (tailLoc &&
fElements[tailLoc].compare(0,5,
"const") == 0) {
497 int nargNonDefault = 0;
498 std::string nonDefName = answ;
500 std::string nameSuperLong =
fName;
501 if (gInterpreterHelper)
503 while (++nargNonDefault < narg) {
506 const char* closeTemplate =
" >";
507 if (nonDefName[nonDefName.length() - 1] !=
'>')
509 string nondef = nonDefName + closeTemplate;
510 if (gInterpreterHelper &&
513 if (nargNonDefault>1) nonDefName +=
",";
516 if (nargNonDefault < narg)
517 narg = nargNonDefault;
521 {
for (
int i=1;i<narg-1; i++) { answ +=
fElements[i]; answ+=
",";} }
522 if (narg>1) { answ +=
fElements[narg-1]; }
525 if ( answ.at(answ.size()-1) ==
'>') {
537 if (tailLoc) answ +=
fElements[tailLoc].c_str()+tailOffset;
553 if (
type.length() == 0)
556 if (
type.compare(0,6,
"const ")==0) {
offset += 6; }
563 static const char *stls[] =
564 {
"any",
"vector",
"list",
"deque",
"map",
"multimap",
"set",
"multiset",
"bitset",
565 "forward_list",
"unordered_set",
"unordered_multiset",
"unordered_map",
"unordered_multimap",
nullptr};
566 static const size_t stllen[] =
567 { 3, 6, 4, 5, 3, 8, 3, 8, 6,
568 12, 13, 18, 13, 18, 0};
584 for (
int k = 1; stls[k]; ++k) {
585 if (
len == stllen[k]) {
600 static const char stln[] =
602 { 1, 1, 1, 1, 3, 3, 2, 2, 1,
605 assert(std::size_t(kind) <
sizeof(stln) &&
"index is out of bounds");
615 for(
size_t i = 0; i < full.length(); ++i) {
617 case '<': { ++level;
break; }
619 if (level == 0)
return i;
624 if (level == 0)
return i;
630 return full.length();
637 return pos +
findNameEnd( {full.data()+pos,full.length()-pos} );
646 string_view
a( allocname );
649 constexpr auto length = std::char_traits<char>::length;
650 constexpr static int clalloclen =
length(
"class ");
651 if (
a.compare(0,clalloclen,
"class ") == 0) {
652 a.remove_prefix(clalloclen);
656 if (
a==
"alloc")
return true;
657 if (
a==
"__default_alloc_template<true,0>")
return true;
658 if (
a==
"__malloc_alloc_template<0>")
return true;
660 constexpr static int alloclen =
length(
"allocator<");
661 if (
a.compare(0,alloclen,
"allocator<") != 0) {
664 a.remove_prefix(alloclen);
669 string_view k = classname;
672 if (
a.compare(0,k.length(),k) != 0) {
676 std::string valuepart;
679 std::string norm_value;
682 if (valuepart != norm_value) {
685 a.remove_prefix(end);
687 a.remove_prefix(k.length());
692 if (
a.compare(0, 1,
">") != 0) {
704 const char *keyclassname,
705 const char *valueclassname)
707 if (
IsDefAlloc(allocname,keyclassname))
return true;
709 string_view
a( allocname );
713 constexpr auto length = std::char_traits<char>::length;
714 constexpr static int alloclen =
length(
"allocator<");
715 if (
a.compare(0,alloclen,
"allocator<") != 0) {
718 a.remove_prefix(alloclen);
723 constexpr static int pairlen =
length(
"pair<");
724 if (
a.compare(0,pairlen,
"pair<") != 0) {
727 a.remove_prefix(pairlen);
729 const static int constlen = strlen(
"const");
730 if (
a.compare(0,constlen+1,
"const ") == 0) {
731 a.remove_prefix(constlen+1);
737 string_view k = keyclassname;
739 if (k.compare(0,constlen+1,
"const ") == 0) {
740 k.remove_prefix(constlen+1);
743 if (
a.compare(0,k.length(),k) != 0) {
747 std::string alloc_keypart;
750 std::string norm_key;
753 if (alloc_keypart != norm_key) {
754 if ( norm_key[norm_key.length()-1] ==
'*' ) {
758 norm_key +=
" const";
760 if (alloc_keypart != norm_key) {
764 a.remove_prefix(end);
767 a.remove_prefix(k.length());
769 if (
a.compare(0, constlen,
"const") == 0) {
770 a.remove_prefix(constlen);
780 string_view
v = valueclassname;
783 if (
a.compare(0,
v.length(),
v) != 0) {
787 std::string valuepart;
790 std::string norm_value;
793 if (valuepart != norm_value) {
796 a.remove_prefix(end);
798 a.remove_prefix(
v.length());
803 if (
a.compare(0, 1,
">") != 0) {
814static bool IsDefElement(
const char *elementName,
const char* defaultElementName,
const char *classname)
816 string c = elementName;
818 size_t pos = StdLen(
c);
820 const int elementlen = strlen(defaultElementName);
821 if (
c.compare(pos,elementlen,defaultElementName) != 0) {
826 string k = classname;
827 if (
c.compare(pos,k.length(),k) != 0) {
836 std::string norm_key;
839 if (keypart != norm_key) {
847 if (
c.compare(pos,1,
">")!=0 &&
c.compare(pos,2,
" >")!=0) {
898 norm_name = std::string(
name);
907 if (gInterpreterHelper) {
915 std::string typeresult;
917 if (!typeresult.empty()) {
918 norm_name = typeresult;
930 std::string first, second;
933 norm_name = splitname.
fElements[0] +
"<" + first +
"," + second;
934 if (!second.empty() && second.back() ==
'>')
944 RemoveScopeResolution(norm_name);
946 if (gInterpreterHelper) {
948 std::string typeresult;
952 if (!typeresult.empty()) {
960 RemoveScopeResolution(norm_name);
982 static const char* longlong_s =
"long long";
983 static const char* ulonglong_s =
"unsigned long long";
984 static const unsigned int longlong_len = strlen(longlong_s);
985 static const unsigned int ulonglong_len = strlen(ulonglong_s);
990 while( (pos =
result.find(ulonglong_s,pos) ) >=0 ) {
991 result.replace(pos, ulonglong_len,
"ULong64_t");
994 while( (pos =
result.find(longlong_s,pos) ) >=0 ) {
995 result.replace(pos, longlong_len,
"Long64_t");
1005 const char *lastPos = original;
1011 else if ( *
cursor ==
':' ) {
1012 if (depth==0 && *(
cursor+1) ==
':' && *(
cursor+2) !=
'\0') {
1027 const char *t = full.c_str();
1028 const unsigned int tlen( full.size() );
1030 const char *starloc = t + tlen - 1;
1031 bool hasconst =
false;
1032 if ( (*starloc)==
't'
1033 && (starloc-t) > 4 && 0 == strncmp((starloc-4),
"const",5)
1034 && ( (*(starloc-5)) ==
' ' || (*(starloc-5)) ==
'*' || (*(starloc-5)) ==
'&'
1035 || (*(starloc-5)) ==
'>' || (*(starloc-5)) ==
']') ) {
1038 if ((*starloc-1)==
' ') {
1044 if ( hasconst || (*starloc)==
'*' || (*starloc)==
'&' || (*starloc)==
']' ) {
1045 bool isArray = ( (*starloc)==
']' );
1046 while( t<=(starloc-1) && ((*(starloc-1))==
'*' || (*(starloc-1))==
'&' || (*(starloc-1))==
't' || isArray)) {
1049 isArray = ! ( (*starloc)==
'[' );
1050 }
else if ( (*(starloc-1))==
't' ) {
1051 if ( (starloc-1-t) > 5 && 0 == strncmp((starloc-5),
"const",5)
1052 && ( (*(starloc-6)) ==
' ' || (*(starloc-6)) ==
'*' || (*(starloc-6)) ==
'&'
1053 || (*(starloc-6)) ==
'>' || (*(starloc-6)) ==
']')) {
1064 if ((*(starloc-1))==
' ') {
1069 const unsigned int starlen = strlen(starloc);
1070 full.erase(tlen-starlen,starlen);
1071 }
else if (hasconst) {
1073 const unsigned int starlen = strlen(starloc);
1074 full.erase(tlen-starlen,starlen);
1094 if (strlen(
type)==0)
return 0;
1096 int cleantypeMode = 1 ;
1105 bool isString =
false;
1106 bool isStdString =
false;
1107 bool isConst =
false;
1108 size_t prefix_offset = 0;
1110 if (full.compare(prefix_offset, 6,
"const ") == 0) {
1111 prefix_offset += isConst =
true;
1113 if (full.compare(prefix_offset, 5,
"std::") == 0) {
1117 if (full.compare(prefix_offset, 9,
"__cxx11::") == 0) {
1120 if (full.compare(prefix_offset, 17,
"basic_string<char") == 0) {
1122 prefix_offset += 17;
1126 size_t offset = prefix_offset;
1127 if ( full[
offset] ==
'>' ) {
1129 }
else if (full[
offset] ==
',') {
1131 if (full.compare(
offset, 5,
"std::") == 0) {
1134 constexpr auto char_traits_s =
"char_traits<char>";
1137 static constexpr unsigned int char_traits_len = std::char_traits<char>::length(char_traits_s);
1138 if (full.compare(
offset, char_traits_len, char_traits_s) == 0) {
1139 offset += char_traits_len;
1140 if ( full[
offset] ==
'>') {
1142 }
else if (full[
offset] ==
' ' && full[
offset+1] ==
'>') {
1145 }
else if (full[
offset] ==
',') {
1147 if (full.compare(
offset, 5,
"std::") == 0) {
1150 static const char* allocator_s =
"allocator<char>";
1151 static const unsigned int allocator_len = strlen(allocator_s);
1152 if (full.compare(
offset, allocator_len, allocator_s) == 0) {
1154 if ( full[
offset] ==
'>') {
1156 }
else if (full[
offset] ==
' ' && full[
offset+1] ==
'>') {
1177 output.push_back(
string());
1180 output.push_back(
"const std::string");
1182 output.push_back(
"const string");
1186 output.push_back(
"std::string");
1188 output.push_back(
"string");
1191 if (
offset < full.length()) {
1194 string right( full.substr(
offset) );
1197 output.back().append(right.c_str()+1);
1198 output.push_back(stars);
1200 output.push_back(
"");
1202 return output.size();
1208 unsigned int offset = (0==strncmp(
"const ",full.c_str(),6)) ? 6 : 0;
1209 RemoveStd( full,
offset );
1213 if ( !full.empty() ) {
1217 const char *
c = strchr(full.c_str(),
'<');
1220 output.push_back(
string(full,0,
c - full.c_str()));
1224 int parenthesis = 0;
1225 for ( ; *
cursor !=
'\0' && !(level == 0 && parenthesis == 0 && *
cursor ==
'>'); ++
cursor) {
1229 }
else if (*
cursor ==
')') {
1236 case '<': ++level;
break;
1237 case '>': --level;
break;
1240 output.push_back(std::string(
c+1,
cursor));
1247 if (*(
cursor-1) ==
' ') {
1248 output.push_back(std::string(
c+1,
cursor-1));
1250 output.push_back(std::string(
c+1,
cursor));
1256 nestedLoc = output.size();
1257 output.push_back((
cursor+1));
1259 }
else if (level >= 0) {
1261 output.push_back(std::string(
c+1,
cursor));
1265 output.push_back(
string());
1266 output.push_back(full);
1269 if (!output.empty()) output.push_back(stars);
1270 return output.size();
1292 constexpr static std::array<const char *, 3> remove{
"class",
"const",
"volatile"};
1293 constexpr static auto lengths = []()
constexpr {
1294 std::array<std::size_t, std::size(remove)> ret{};
1295 for (std::size_t i = 0; i < remove.size(); i++)
1296 ret[i] = std::char_traits<char>::length(remove[i]);
1301 result.reserve(strlen(typeDesc)*2);
1303 std::vector<char> parensStack;
1306 for(
c=typeDesc;*
c;
c++) {
1309 if (!isalnum(
c[ 1]) &&
c[ 1] !=
'_')
continue;
1311 if (kbl && (
mode>=2 || parensStack.empty())) {
1313 size_t n = (
mode) ? std::size(remove) : 1;
1316 for (
size_t k = 0; k <
n; k++) {
1317 auto rlen = lengths[k];
1320 if (strncmp(remove[k],
c,rlen))
continue;
1323 if (isalnum(
c[rlen]) ||
c[rlen]==
'_' ||
c[rlen]==
'$')
continue;
1325 c+=rlen-1; done = 1;
break;
1330 kbl = (!isalnum(
c[ 0]) &&
c[ 0]!=
'_' &&
c[ 0]!=
'$' &&
c[0]!=
'[' &&
c[0]!=
']' &&
c[0]!=
'-' &&
c[0]!=
'@');
1334 if (*
c ==
'<' || *
c ==
'(')
1335 parensStack.push_back(*
c);
1337 if (parensStack.empty() && !isalnum(*
c)) {
1338 if (!strchr(
"*&:._$ []-@",*
c))
break;
1346 if (*
c ==
'>' && !parensStack.empty() && parensStack.back() ==
'<')
1347 parensStack.pop_back();
1348 else if (*
c ==
')' && !parensStack.empty() && parensStack.back() ==
'(')
1349 parensStack.pop_back();
1387 if (
len < 2 || strncmp(
type+
len-2,
"_t",2) != 0)
return false;
1389 unsigned char offset = 0;
1390 if (strncmp(
type,
"const ",6)==0) {
offset += 6; }
1391 static const char *names[] = {
"CallFunc_t",
"ClassInfo_t",
"BaseClassInfo_t",
1392 "DataMemberInfo_t",
"FuncTempInfo_t",
"MethodInfo_t",
"MethodArgInfo_t",
1393 "TypeInfo_t",
"TypedefInfo_t",
nullptr};
1395 for(
int k=1;names[k];k++) {
if (strcmp(
type+
offset,names[k])==0)
return true;}
1404 size_t offset = StdLen(classname);
1405 if ( strncmp(classname+
offset,
"bitset<",std::char_traits<char>::length(
"bitset<"))==0)
return true;
1423 if (
type.compare(0,6,
"const ",6) == 0)
1424 type.remove_prefix(6);
1426 while(
type[
type.length()-1]==
'*' ||
1429 type.remove_suffix(1);
1442 auto pos =
type.find(
'<');
1446 for (
decltype(
type.length()) level = 1;
c <
type.length(); ++
c) {
1447 if (
type[
c] ==
'<') ++level;
1448 if (
type[
c] ==
'>') --level;
1449 if (level == 0)
break;
1451 if (
c != (
type.length()-1) ) {
1471 if (!strchr(
type,
'<'))
return 0;
1482 constexpr auto length = std::char_traits<char>::length;
1483 classname += StdLen( classname );
1484 if ( strcmp(classname,
"string")==0 )
return true;
1485 if ( strncmp(classname,
"bitset<",
length(
"bitset<"))==0)
return true;
1486 if (
IsStdPair(classname) )
return true;
1487 if ( strcmp(classname,
"allocator")==0)
return true;
1488 if ( strncmp(classname,
"allocator<",
length(
"allocator<"))==0)
return true;
1489 if ( strncmp(classname,
"greater<",
length(
"greater<"))==0)
return true;
1490 if ( strncmp(classname,
"less<",
length(
"less<"))==0)
return true;
1491 if ( strncmp(classname,
"equal_to<",
length(
"equal_to<"))==0)
return true;
1492 if ( strncmp(classname,
"hash<",
length(
"hash<"))==0)
return true;
1493 if ( strncmp(classname,
"auto_ptr<",
length(
"auto_ptr<"))==0)
return true;
1495 if ( strncmp(classname,
"vector<",
length(
"vector<"))==0)
return true;
1496 if ( strncmp(classname,
"list<",
length(
"list<"))==0)
return true;
1497 if ( strncmp(classname,
"forward_list<",
length(
"forward_list<"))==0)
return true;
1498 if ( strncmp(classname,
"deque<",
length(
"deque<"))==0)
return true;
1499 if ( strncmp(classname,
"map<",
length(
"map<"))==0)
return true;
1500 if ( strncmp(classname,
"multimap<",
length(
"multimap<"))==0)
return true;
1501 if ( strncmp(classname,
"set<",
length(
"set<"))==0)
return true;
1502 if ( strncmp(classname,
"multiset<",
length(
"multiset<"))==0)
return true;
1503 if ( strncmp(classname,
"unordered_set<",
length(
"unordered_set<"))==0)
return true;
1504 if ( strncmp(classname,
"unordered_multiset<",
length(
"unordered_multiset<"))==0)
return true;
1505 if ( strncmp(classname,
"unordered_map<",
length(
"unordered_map<"))==0)
return true;
1506 if ( strncmp(classname,
"unordered_multimap<",
length(
"unordered_multimap<"))==0)
return true;
1507 if ( strncmp(classname,
"bitset<",
length(
"bitset<"))==0)
return true;
1508 if ( strncmp(classname,
"ROOT::VecOps::RVec<",
length(
"ROOT::VecOps::RVec<"))==0)
return true;
1529 unsigned int start_of_type,
1530 unsigned int end_of_type,
1531 unsigned int mod_start_of_type,
1535 std::string
type(modified && (mod_start_of_type <
result.length()) ?
1536 result.substr(mod_start_of_type, string::npos)
1537 :
string(tname, start_of_type, end_of_type == 0 ?
cursor - start_of_type : end_of_type - start_of_type));
1542 if (!typeresult.empty()) {
1545 result.replace(mod_start_of_type, string::npos,
1550 result += string(tname,0,start_of_type);
1551 if (constprefix && typeresult.compare(0,6,
"const ",6) == 0) {
1552 result += typeresult.substr(6,string::npos);
1557 }
else if (modified) {
1558 result.replace(mod_start_of_type, string::npos,
1562 if (end_of_type != 0 && end_of_type!=
cursor) {
1563 result += std::string(tname,end_of_type,
cursor-end_of_type);
1570 if (end_of_type != 0 && end_of_type!=
cursor) {
1571 result += std::string(tname,end_of_type,
cursor-end_of_type);
1590 bool constprefix =
false;
1592 if (tname[
cursor]==
' ') {
1606 if (modified)
result +=
"const ";
1614 unsigned int start_of_type =
cursor;
1615 unsigned int end_of_type = 0;
1616 unsigned int mod_start_of_type =
result.length();
1617 unsigned int prevScope =
cursor;
1623 if (modified)
result += (tname+prevScope);
1628 scope =
result.substr(mod_start_of_type, string::npos);
1629 scope += std::string(tname+prevScope,
cursor-prevScope);
1631 scope = std::string(tname, start_of_type,
cursor - start_of_type);
1633 std::string scoperesult;
1634 bool isInlined =
false;
1638 if (!scoperesult.empty()) {
1641 if (constprefix && scoperesult.compare(0,6,
"const ",6) != 0) mod_start_of_type -= 6;
1642 result.replace(mod_start_of_type, string::npos,
1647 mod_start_of_type = start_of_type;
1648 result += string(tname,0,start_of_type);
1653 }
else if (modified) {
1654 result += std::string(tname+prevScope,
cursor+2-prevScope);
1658 if (modified)
result += std::string(tname+prevScope,
cursor+2-prevScope);
1659 }
else if (isInlined) {
1663 mod_start_of_type = start_of_type;
1664 result += string(tname,0,start_of_type);
1666 result += string(tname,start_of_type,prevScope - start_of_type);
1668 }
else if (modified) {
1669 result += std::string(tname+prevScope,
cursor+2-prevScope);
1684 for (; next !=
cursor && nStars < 2 && next <
len; next++) {
1685 if (
' ' == tname[next]) {
1688 }
else if (
'*' == tname[next]) {
1690 }
else if (
')' == tname[next]) {
1708 result += std::string(tname+prevScope,
cursor+1-prevScope);
1722 if (modified)
result +=
"::";
1728 if (modified)
result +=
',';
1733 if (modified)
result +=
" >";
1738 if (modified)
result +=
")";
1744 if (tname[
cursor] !=
' ')
break;
1745 if (modified) prevScope =
cursor+1;
1757 if (next <
len && 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] ==
')' || tname[next+5] ==
']'))
1762 result += string(tname,0,start_of_type);
1764 mod_start_of_type = start_of_type + 6;
1765 result += string(tname,start_of_type,end_of_type-start_of_type);
1766 }
else if (mod_start_of_type <
result.length()) {
1767 result.insert(mod_start_of_type,
"const ");
1768 mod_start_of_type += 6;
1771 mod_start_of_type += 6;
1772 result += string(tname,start_of_type,end_of_type-start_of_type);
1776 prevScope = end_of_type;
1777 if ((next+5)==
len || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
')' || tname[next+5] ==
'[') {
1780 }
else if (next!=
len && tname[next] !=
'*' && tname[next] !=
'&') {
1793 if (next <
len && strncmp(tname+next,
"const",5) == 0) {
1794 if ((next+5)==
len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>' || tname[next+5] ==
')' || tname[next+5] ==
'[') {
1799 (tname[next] ==
' ' || tname[next] ==
'*' || tname[next] ==
'&')) {
1802 if (next <
len && strncmp(tname+next,
"const",5) == 0) {
1803 if ((next+5)==
len || tname[next+5] ==
' ' || tname[next+5] ==
'*' || tname[next+5] ==
'&' || tname[next+5] ==
',' || tname[next+5] ==
'>'|| tname[next+5] ==
')' || tname[next+5] ==
'[') {
1815 if (modified && prevScope) {
1816 result += std::string(tname+prevScope,(end_of_type == 0 ?
cursor : end_of_type)-prevScope);
1820 if (modified)
result +=
',';
1826 if (modified && prevScope) {
1827 result += std::string(tname+prevScope,(end_of_type == 0 ?
cursor : end_of_type)-prevScope);
1839 if (prevScope && modified)
result += std::string(tname+prevScope,(end_of_type == 0 ?
cursor : end_of_type)-prevScope);
1856 if (!tname || *tname == 0)
1858 if (!gInterpreterHelper)
1867 if (
result.empty())
return tname;
1871 unsigned int len = strlen(tname);
1874 bool modified =
false;
1877 if (!modified)
return tname;
1891 static const char* sSTLtypes[] = {
1904 "basic_istringstream",
1907 "basic_ostringstream",
1911 "basic_stringstream",
1940 "istreambuf_iterator",
1949 "localedef utility",
1966 "moneypunct_byname",
1978 "ostreambuf_iterator",
1984 "pointer_to_binary_function",
1985 "pointer_to_unary_function",
1989 "raw_storage_iterator",
2008 "unordered_multimap",
2009 "unordered_multiset",
2016 if (!tname || *tname == 0)
return "";
2018 auto initSetSTLtypes = []() {
2019 std::set<std::string> iSetSTLtypes;
2021 const size_t nSTLtypes =
sizeof(sSTLtypes) /
sizeof(
const char*);
2022 for (
size_t i = 0; i < nSTLtypes; ++i)
2023 iSetSTLtypes.insert(sSTLtypes[i]);
2024 return iSetSTLtypes;
2026 static ShuttingDownSignaler<std::set<std::string>> sSetSTLtypes{ initSetSTLtypes() };
2029 size_t len = strlen(tname);
2031 ret.reserve(
len + 20);
2035 bool precScope =
false;
2036 while (!(isalnum(tname[
b]) || tname[
b] ==
'_') &&
b <
len) {
2037 precScope = (
b <
len - 2) && (tname[
b] ==
':') && (tname[
b + 1] ==
':');
2049 while (
e <
len && (isalnum(tname[
e]) || tname[
e] ==
'_'))
2054 if (iSTLtype != sSetSTLtypes.end())
2077 if (!mother)
return false;
2078 bool isSTLContOrArray =
true;
2079 while (
nullptr != mother){
2085 return isSTLContOrArray;
2093 if (clName.back() !=
'>') {
2098 std::vector<std::string>
v;
2103 auto argsEnd =
v.end();
2104 auto argsBeginPlusOne = ++
v.begin();
2105 auto argPos = std::find_if(argsBeginPlusOne, argsEnd,
2106 [](std::string& arg){return (!arg.empty() && arg.front() ==
':');});
2107 if (argPos != argsEnd) {
2108 const int length = clName.size();
2109 int wedgeBalance = 0;
2110 int lastOpenWedge = 0;
2111 for (
int i=
length-1;i>-1;i--) {
2112 auto&
c = clName.at(i);
2116 }
else if (
c ==
'>') {
2118 }
else if (
c ==
':' && 0 == wedgeBalance) {
2120 auto nameToClean = clName.substr(0,i-1);
2129 cleanName += clName.substr(i+1,lastOpenWedge-i-1);
2132 auto lastTemplate = &clName.data()[i+1];
2144 unsigned int nargs =
v.size() - 2;
2145 for (
unsigned int i=0;i<nargs;++i) {
2181 name += node->ToString() +
",";
2185 name +=
name.back() ==
'>' ?
" >" :
">";
2218 std::string& typeNameBuf,
2219 std::array<int, 5>& maxIndices,
2229 for (ndim = 1;ndim <=5 ; ndim++) {
2230 maxIndices[ndim-1] = std::atoi(childNodes->back()->GetName().c_str());
2231 auto& frontNode = childNodes->front();
2232 typeNameBuf = frontNode->GetName();
2234 typeNameBuf = frontNode->ToString();
2237 childNodes = frontNode->GetChildNodes();
2250 const char* mangled_name = ti.name();
2256struct FunctionSplitInfo {
2258 std::string fReturnType;
2261 std::string fScopeName;
2264 std::string fFunctionName;
2268 std::vector<std::string> fFunctionTemplateArguments;
2271 std::vector<std::string> fFunctionParameters;
2278 std::size_t FindNonNestedNeedles(std::string_view haystack, string_view needles)
2280 std::stack<char> expected;
2281 for (std::size_t pos = 0, end = haystack.length(); pos < end; ++pos) {
2282 char c = haystack[pos];
2283 if (expected.empty()) {
2284 if (needles.find(
c) != std::string_view::npos)
2287 if (
c == expected.top()) {
2293 case '<': expected.emplace(
'>');
break;
2294 case '(': expected.emplace(
')');
break;
2295 case '[': expected.emplace(
']');
break;
2298 return std::string_view::npos;
2302 std::size_t FindNonNestedDoubleColons(std::string_view haystack)
2304 std::size_t lenHaystack = haystack.length();
2305 std::size_t prevAfterColumn = 0;
2307 std::size_t posColumn = FindNonNestedNeedles(haystack.substr(prevAfterColumn),
":");
2308 if (posColumn == std::string_view::npos)
2309 return std::string_view::npos;
2310 prevAfterColumn += posColumn;
2312 if (prevAfterColumn + 1 >= lenHaystack)
2313 return std::string_view::npos;
2316 if (haystack[prevAfterColumn] ==
':')
2317 return prevAfterColumn - 1;
2321 return std::string_view::npos;
2324 std::string_view StripSurroundingSpace(std::string_view str)
2326 while (!str.empty() && std::isspace(str[0]))
2327 str.remove_prefix(1);
2328 while (!str.empty() && std::isspace(str.back()))
2329 str.remove_suffix(1);
2333 std::string
ToString(std::string_view sv)
2337 return std::string(sv.data(), sv.length());
2350 std::size_t posArgs = FindNonNestedNeedles(decl,
"(");
2351 std::string_view declNoArgs = decl.substr(0, posArgs);
2353 std::size_t prevAfterWhiteSpace = 0;
2354 static const char whitespace[] =
" \t\n";
2355 while (declNoArgs.length() > prevAfterWhiteSpace) {
2356 std::size_t posWS = FindNonNestedNeedles(declNoArgs.substr(prevAfterWhiteSpace), whitespace);
2357 if (posWS == std::string_view::npos)
2359 prevAfterWhiteSpace += posWS + 1;
2360 while (declNoArgs.length() > prevAfterWhiteSpace
2361 && strchr(whitespace, declNoArgs[prevAfterWhiteSpace]))
2362 ++prevAfterWhiteSpace;
2366 std::size_t endReturn = prevAfterWhiteSpace;
2367 while (declNoArgs.length() > endReturn
2368 && strchr(
"&* \t \n", declNoArgs[endReturn]))
2371 result.fReturnType =
ToString(StripSurroundingSpace(declNoArgs.substr(0, endReturn)));
2374 std::string_view scopeFunctionTmplt = declNoArgs.substr(endReturn);
2375 std::size_t prevAtScope = FindNonNestedDoubleColons(scopeFunctionTmplt);
2376 while (prevAtScope != std::string_view::npos
2377 && scopeFunctionTmplt.length() > prevAtScope + 2) {
2378 std::size_t posScope = FindNonNestedDoubleColons(scopeFunctionTmplt.substr(prevAtScope + 2));
2379 if (posScope == std::string_view::npos)
2381 prevAtScope += posScope + 2;
2384 std::size_t afterScope = prevAtScope + 2;
2385 if (prevAtScope == std::string_view::npos) {
2390 result.fScopeName =
ToString(StripSurroundingSpace(scopeFunctionTmplt.substr(0, prevAtScope)));
2391 std::string_view funcNameTmplArgs = scopeFunctionTmplt.substr(afterScope);
2393 result.fFunctionTemplateArguments.clear();
2394 std::size_t posTmpltOpen = FindNonNestedNeedles(funcNameTmplArgs,
"<");
2395 if (posTmpltOpen != std::string_view::npos) {
2396 result.fFunctionName =
ToString(StripSurroundingSpace(funcNameTmplArgs.substr(0, posTmpltOpen)));
2399 std::string_view tmpltArgs = funcNameTmplArgs.substr(posTmpltOpen + 1);
2400 std::size_t posTmpltClose = FindNonNestedNeedles(tmpltArgs,
">");
2401 if (posTmpltClose != std::string_view::npos) {
2402 tmpltArgs = tmpltArgs.substr(0, posTmpltClose);
2403 std::size_t prevAfterArg = 0;
2404 while (tmpltArgs.length() > prevAfterArg) {
2405 std::size_t posComma = FindNonNestedNeedles(tmpltArgs.substr(prevAfterArg),
",");
2406 if (posComma == std::string_view::npos) {
2409 result.fFunctionTemplateArguments.emplace_back(
ToString(StripSurroundingSpace(tmpltArgs.substr(prevAfterArg, posComma))));
2410 prevAfterArg += posComma + 1;
2413 result.fFunctionTemplateArguments.emplace_back(
ToString(StripSurroundingSpace(tmpltArgs.substr(prevAfterArg))));
2416 result.fFunctionName =
ToString(StripSurroundingSpace(funcNameTmplArgs));
2419 result.fFunctionParameters.clear();
2420 if (posArgs != std::string_view::npos) {
2422 std::string_view params = decl.substr(posArgs + 1);
2423 std::size_t posEndArgs = FindNonNestedNeedles(params,
")");
2424 if (posEndArgs != std::string_view::npos) {
2425 params = params.substr(0, posEndArgs);
2426 std::size_t prevAfterArg = 0;
2427 while (params.length() > prevAfterArg) {
2428 std::size_t posComma = FindNonNestedNeedles(params.substr(prevAfterArg),
",");
2429 if (posComma == std::string_view::npos) {
2430 result.fFunctionParameters.emplace_back(
ToString(StripSurroundingSpace(params.substr(prevAfterArg))));
2433 result.fFunctionParameters.emplace_back(
ToString(StripSurroundingSpace(params.substr(prevAfterArg, posComma))));
2434 prevAfterArg += posComma + 1;
static const char * ToString(ENameCycleError err)
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)
return
Invalidate stored TCling state for declarations included in transaction âTâ.
if(isa< VarDecl >(D)||isa< FieldDecl >(D)||isa< EnumConstantDecl >(D))
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
An helper class to dismount the name and remount it changed whenever necessary.
NameCleanerForIO(const std::string &clName="", TClassEdit::EModType mode=TClassEdit::kNone, NameCleanerForIO *mother=nullptr)
NameCleanerForIO * fMother
const std::string & GetName()
std::vector< std::unique_ptr< NameCleanerForIO > > fArgumentNodes
const std::vector< std::unique_ptr< NameCleanerForIO > > * GetChildNodes() const
bool AreAncestorsSTLContOrArray()
A spin mutex-as-code-guard class.
A RAII helper to remove and readd enclosing _Atomic() It expects no spaces at the beginning or end of...
virtual bool CheckInClassTable(const std::string &, std::string &)=0
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
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)
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 CleanType(const char *typeDesc, int mode=0, const char **tail=nullptr)
Cleanup type description, redundant blanks removed and redundant tail ignored return *tail = pointer ...
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 *)
Result of splitting a function declaration into fReturnType fScopeName::fFunctionName<fFunctionTempla...
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.