File indexing completed on 2025-01-18 10:11:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef ROOT_TClassEdit
0014 #define ROOT_TClassEdit
0015
0016 #include <ROOT/RConfig.hxx>
0017 #include "RConfigure.h"
0018 #include <stdlib.h>
0019 #ifdef R__WIN32
0020 #ifndef UNDNAME_COMPLETE
0021 #define UNDNAME_COMPLETE 0x0000
0022 #endif
0023 extern "C" {
0024 char *__unDName(char *demangled, const char *mangled, int out_len,
0025 void * (* pAlloc )(size_t), void (* pFree )(void *),
0026 unsigned short int flags);
0027 }
0028 #else
0029 #include <cxxabi.h>
0030 #endif
0031 #include <string>
0032 #include <vector>
0033 #include <array>
0034 #include <typeinfo>
0035
0036 #include "ESTLType.h"
0037
0038 #ifdef R__OLDHPACC
0039 namespace std {
0040 using ::string;
0041 using ::vector;
0042 }
0043 #endif
0044
0045 #if defined(__CYGWIN__)
0046
0047 #include <sstream>
0048 namespace std {
0049 template <typename T>
0050 string to_string(T value) {
0051 ostringstream os;
0052 os << value;
0053 return os.str();
0054 }
0055 }
0056 #endif
0057
0058 namespace cling {
0059 class Interpreter;
0060 }
0061 namespace ROOT {
0062 namespace TMetaUtils {
0063 class TNormalizedCtxt;
0064 }
0065 }
0066 #include <string_view>
0067
0068
0069
0070
0071
0072
0073 namespace TClassEdit {
0074
0075 enum EModType {
0076 kNone = 0,
0077 kDropTrailStar = 1<<0,
0078 kDropDefaultAlloc = 1<<1,
0079 kDropAlloc = 1<<2,
0080 kInnerClass = 1<<3,
0081 kInnedMostClass = 1<<4,
0082 kDropStlDefault = 1<<5,
0083 kDropComparator = 1<<6,
0084 kDropAllDefault = 1<<7,
0085 kLong64 = 1<<8,
0086 kDropStd = 1<<9,
0087 kKeepOuterConst = 1<<10,
0088 kResolveTypedef = 1<<11,
0089 kDropPredicate = 1<<12,
0090 kDropHash = 1<<13
0091 };
0092
0093 enum ESTLType {
0094 kNotSTL = ROOT::kNotSTL,
0095 kVector = ROOT::kSTLvector,
0096 kList = ROOT::kSTLlist,
0097 kForwardlist = ROOT::kSTLforwardlist,
0098 kDeque = ROOT::kSTLdeque,
0099 kMap = ROOT::kSTLmap,
0100 kMultiMap = ROOT::kSTLmultimap,
0101 kSet = ROOT::kSTLset,
0102 kMultiSet = ROOT::kSTLmultiset,
0103 kUnorderedSet = ROOT::kSTLunorderedset,
0104 kUnorderedMultiSet = ROOT::kSTLunorderedmultiset,
0105 kUnorderedMap = ROOT::kSTLunorderedmap,
0106 kUnorderedMultiMap = ROOT::kSTLunorderedmultimap,
0107 kBitSet = ROOT::kSTLbitset,
0108 kEnd = ROOT::kSTLend
0109 };
0110
0111 enum class EComplexType : short {
0112 kNone,
0113 kDouble,
0114 kFloat,
0115 kInt,
0116 kLong
0117 };
0118
0119 EComplexType GetComplexType(const char*);
0120
0121 class TInterpreterLookupHelper {
0122 public:
0123 TInterpreterLookupHelper() { }
0124 virtual ~TInterpreterLookupHelper();
0125
0126 virtual bool ExistingTypeCheck(const std::string & ,
0127 std::string & ) = 0;
0128 virtual void GetPartiallyDesugaredName(std::string & ) = 0;
0129 virtual bool IsAlreadyPartiallyDesugaredName(const std::string & ,
0130 const std::string & ) = 0;
0131 virtual bool IsDeclaredScope(const std::string & , bool & ) = 0;
0132 virtual bool GetPartiallyDesugaredNameWithScopeHandling(const std::string & ,
0133 std::string & ,
0134 bool = true) = 0;
0135 virtual void ShuttingDownSignal() = 0;
0136 };
0137
0138 struct TSplitType {
0139
0140 const char *fName;
0141 std::vector<std::string> fElements;
0142 int fNestedLocation;
0143
0144 TSplitType(const char *type2split, EModType mode = TClassEdit::kNone);
0145
0146 int IsSTLCont(int testAlloc=0) const;
0147 ROOT::ESTLType IsInSTL() const;
0148 void ShortType(std::string &answer, int mode);
0149 bool IsTemplate();
0150
0151 private:
0152 TSplitType(const TSplitType&) = delete;
0153 TSplitType &operator=(const TSplitType &) = delete;
0154 };
0155
0156 void Init(TClassEdit::TInterpreterLookupHelper *helper);
0157
0158 std::string CleanType (const char *typeDesc,int mode = 0,const char **tail = nullptr);
0159 inline bool IsArtificial(std::string_view name) { return name.find('@') != name.npos; }
0160 bool IsDefAlloc(const char *alloc, const char *classname);
0161 bool IsDefAlloc(const char *alloc, const char *keyclassname, const char *valueclassname);
0162 bool IsDefComp (const char *comp , const char *classname);
0163 bool IsDefPred(const char *predname, const char *classname);
0164 bool IsDefHash(const char *hashname, const char *classname);
0165 bool IsInterpreterDetail(const char *type);
0166 bool IsSTLBitset(const char *type);
0167 ROOT::ESTLType UnderlyingIsSTLCont(std::string_view type);
0168 ROOT::ESTLType IsSTLCont (std::string_view type);
0169 int IsSTLCont (const char *type,int testAlloc);
0170 bool IsStdClass(const char *type);
0171 bool IsVectorBool(const char *name);
0172 void GetNormalizedName(std::string &norm_name, std::string_view name);
0173 std::string GetLong64_Name(const char *original);
0174 std::string GetLong64_Name(const std::string& original);
0175 int GetSplit (const char *type, std::vector<std::string> &output, int &nestedLoc, EModType mode = TClassEdit::kNone);
0176 ROOT::ESTLType STLKind(std::string_view type);
0177 int STLArgs (int kind);
0178 std::string ResolveTypedef(const char *tname, bool resolveAll = false);
0179 std::string ShortType (const char *typeDesc, int mode);
0180 std::string InsertStd(const char *tname);
0181 const char* GetUnqualifiedName(const char*name);
0182 inline bool IsUniquePtr(std::string_view name) {return 0 == name.compare(0, 11, "unique_ptr<");}
0183 inline bool IsStdArray(std::string_view name) {return 0 == name.compare(0, 6, "array<");}
0184 inline bool IsStdPair(std::string_view name)
0185 {
0186 return 0 == name.compare(0, 10, "std::pair<") || 0 == name.compare(0, 5, "pair<");
0187 }
0188 inline bool IsStdPairBase(std::string_view name)
0189 {
0190 return 0 == name.compare(0, 17, "std::__pair_base<") || 0 == name.compare(0, 12, "__pair_base<");
0191 }
0192 inline std::string GetUniquePtrType(std::string_view name)
0193 {
0194
0195 std::vector<std::string> v;
0196 int i;
0197 GetSplit(name.data(), v, i);
0198 return v[1];
0199 }
0200 std::string GetNameForIO(const std::string& templateInstanceName,
0201 TClassEdit::EModType mode = TClassEdit::kNone,
0202 bool* hasChanged = nullptr);
0203 bool GetStdArrayProperties(const char* typeName,
0204 std::string& typeNameBuf,
0205 std::array<int, 5>& maxIndices,
0206 int& ndim);
0207
0208 inline char* DemangleName(const char* mangled_name, int& errorCode)
0209 {
0210
0211
0212
0213 errorCode=0;
0214 #ifdef R__WIN32
0215 char *demangled_name = __unDName(0, mangled_name, 0, malloc, free, UNDNAME_COMPLETE);
0216 if (!demangled_name) {
0217 errorCode = -1;
0218 return nullptr;
0219 }
0220 std::string demangledName = demangled_name;
0221 if (demangledName.compare(0, 6, "class ") == 0)
0222 demangledName.erase(0, 6);
0223 else if (demangledName.compare(0, 7, "struct ") == 0)
0224 demangledName.erase(0, 7);
0225 strcpy(demangled_name, demangledName.c_str());
0226 #else
0227 char *demangled_name = abi::__cxa_demangle(mangled_name, nullptr, nullptr, &errorCode);
0228 if (!demangled_name || errorCode) {
0229 free(demangled_name);
0230 return nullptr;
0231 }
0232 #endif
0233 return demangled_name;
0234 }
0235 char* DemangleTypeIdName(const std::type_info& ti, int& errorCode);
0236
0237
0238
0239
0240 struct FunctionSplitInfo {
0241
0242 std::string fReturnType;
0243
0244
0245 std::string fScopeName;
0246
0247
0248 std::string fFunctionName;
0249
0250
0251
0252 std::vector<std::string> fFunctionTemplateArguments;
0253
0254
0255 std::vector<std::string> fFunctionParameters;
0256 };
0257
0258
0259 bool SplitFunction(std::string_view decl, FunctionSplitInfo &result);
0260 }
0261
0262 #endif