33#include <unordered_map>
39#define RTLD_DEFAULT ((void *)::GetModuleHandle(NULL))
40#define dlsym(library, function_name) ::GetProcAddress((HMODULE)library, function_name)
47 const static bool foundSymbol = dlsym(RTLD_DEFAULT,
"usedToIdentifyRootClingByDlSym");
68 if (enums && !enums->fIsLoaded) {
74 if (dataMembers && dataMembers->GetSize() > 0) {
75 fData.reserve(dataMembers->GetSize() );
76 for (auto * obj : *dataMembers) {
77 TDataMember * dm = dynamic_cast<TDataMember*>(obj);
82 fPRealData.reserve(100);
84 std::vector<TString> &fDepClasses;
85 std::unordered_map<std::string, int> fDepClassIdx;
87 DepClassDedup(std::vector<TString> &depClasses): fDepClasses(depClasses)
89 R__ASSERT(fDepClasses.empty() &&
"Expected fDepClasses to be empty before fililng it!");
94 if (fDepClasses.size() != fDepClassIdx.size())
95 ::Error(
"TProtoClass::DepClassDedup::~DepClassDedup",
96 "Mismatching size of fDepClasses and index map! Please report.");
99 int GetIdx(
const char *
name) {
100 auto itins = fDepClassIdx.insert({
name, fDepClasses.size()});
102 fDepClasses.emplace_back(
name);
104 return itins.first->second;
106 } depClassDedup(fDepClasses);
108 if (!cl->GetCollectionProxy()) {
110 cl->BuildRealData(
nullptr,
true );
114 for (
auto realDataObj: *cl->GetListOfRealData()) {
118 TProtoRealData protoRealData(rd);
121 protoRealData.fClassIndex = depClassDedup.GetIdx(clRD->GetName());
125 fPRealData.emplace_back(protoRealData);
145 if (cl->HasInterpreterInfo())
146 fSizeof =
gCling->ClassInfo_Size(cl->GetClassInfo());
151 cl->CalculateStreamerOffset();
152 fOffsetStreamer = cl->fOffsetStreamer;
224 Info(
"FillTClass",
"Returning w/o doing anything. %s is a STL collection.",cl->
GetName());
229 Info(
"FillTClass",
"Returning w/o doing anything. %s is a namespace.",cl->
GetName());
232 Error(
"FillTClass",
"TClass %s already initialized!", cl->
GetName());
236 Fatal(
"FillTClass",
"Filling TClass %s a second time but none of the info is in the TClass instance ... ", cl->
GetName());
249 if (element.IsAClass() ) {
294 temp->Add((
TEnum*) enumAsTObj);
306 "For %s the sizeof provided by GenerateInitInstance (%d) is different from the one provided by TProtoClass (%d)",
316 if (cl->
fBase.load()) {
317 for (
auto base: *cl->
fBase) {
322 for (
auto dm: *cl->
fData) {
328 for (
auto en: *cl->
fEnums) {
329 ((
TEnum*)en)->SetClass(cl);
335 TClass* currentRDClass = cl;
340 size_t element_next_idx = 0;
344 if (element.IsAClass() ) {
352 const char *classname =
GetClassName(element.fClassIndex);
361 size_t hint_offset =
fPRealData[element_next_idx].fOffset - element.fOffset;
362 size_t hint_size = 0;
364 size_t end = element_next_idx + 1;
368 hint_size =
fPRealData[end].fOffset - element.fOffset;
370 hint_size =
fSizeof - element.fOffset;
372 currentRDClass =
TClass::GetClass(classname,
true,
false, hint_offset, hint_size);
374 if (!currentRDClass) {
377 "Cannot find TClass for %s; Creating an empty one in the kForwardDeclared state.", classname);
383 if (!currentRDClass)
continue;
391 Info(
"FillTClass",
"Real data for class %s is not empty - make a new one",cl->
GetName() );
400 prevLevel = element.fLevel;
408 Info(
"FillTClas",
"Real data for class %s is not empty - make a new one. Class has no Proto-realdata",cl->
GetName() );
448 assert(cl !=
nullptr);
490 "Cannot find data member # %d of class %s for parent %s!",
fDMIndex, dmClass->
GetName(),
499 if (dm) realMemberName = dm->
GetName();
501 realMemberName = (
fDMIndex == 0) ?
"first" :
"second";
504 realMemberName =
TString(
"*")+realMemberName;
509 for (
int idim = 0; idim < dm->
GetArrayDim(); ++idim)
512 std::string typeNameBuf;
514 std::array<Int_t, 5> maxIndices;
519 for (
Int_t idim = 0; idim < ndim; ++idim) {
525 if (prevData &&
fLevel > 0 ) {
526 if (
fLevel-prevLevel == 1)
528 else if (
fLevel <= prevLevel) {
530 std::string prevName = prevData->
GetName();
532 std::string parentName;
533 for (
int i = 0; i < prevLevel-
fLevel+1; ++i) {
534 parentName = prevName.substr(0, prevName.find_last_of(
".") );
535 prevName = parentName;
561 for (
auto * obj : *dmList) {
569 ::Error(
"TProtoClass::DataMemberIndex",
"data member %s is not found in class %s",
name, cl->
GetName());
589 for (
auto * obj : *dmList) {
598 ::Error(
"TProtoClass::FindDataMember",
"data member with index %d is not found in class %s",index,cl->
GetName());
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
const char Option_t
Option string (const char).
static bool IsFromRootCling()
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
externInt_t gErrorIgnoreLevel
errors with level below this value will be ignored. Default is kUnset.
externTInterpreter * gCling
static bool IsFromRootCling()
Each class (see TClass) has a linked list of its base class(es).
TClass instances represent classes, structs and namespaces in the ROOT type system.
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
EState fState
!Current 'state' of the class (Emulated,Interpreted,Loaded)
std::atomic< TList * > fBase
std::atomic< Char_t > fCanSplit
!Indicates whether this class can be split or not. Values are -1, 0, 1, 2
Bool_t fIsSyntheticPair
Indicates whether this class represents a pair and was not created from a dictionary nor interpreter ...
std::atomic< UInt_t > fCheckSum
std::atomic< TListOfEnums * > fEnums
std::atomic< Long_t > fProperty
!Property See TClass::Property() for details
void SetStreamerImpl(Int_t streamerType)
Internal routine to set fStreamerImpl based on the value of fStreamerType.
TList * GetListOfDataMembers(Bool_t load=kTRUE)
Return list containing the TDataMembers of a class.
std::atomic< TListOfDataMembers * > fData
Long_t Property() const override
Returns the properties of the TClass as a bit field stored as a Long_t value.
Long_t fClassProperty
!C++ Property of the class (is abstract, has virtual table, etc.)
std::atomic< Bool_t > fHasRootPcmInfo
!Whether info was loaded from a root pcm.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
void ls(Option_t *option="") const override
List (ls) all objects in this collection.
All ROOT classes may have RTTI (run time type identification) support added.
Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
Long_t Property() const override
Get property description word. For meaning of bits see EProperty.
Int_t GetArrayDim() const
Return number of array dimensions.
const char * GetTypeName() const
Get the decayed type name of this data member, removing const and volatile qualifiers,...
TClass * GetClass() const
The TEnum class implements the enum type.
A collection of TDataMember objects designed for fast access given a DeclId_t and for keep track of T...
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
void AddLast(TObject *obj) override
Add object at the end of the list.
const char * GetName() const override
Returns name of object.
Bool_t TestBit(UInt_t f) const
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Int_t TestBits(UInt_t f) const
TObject()
TObject constructor.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Bool_t FillTClass(TClass *pcl)
Move data from this TProtoClass into cl.
virtual ~TProtoClass()
Destructor.
const char * GetClassName(Int_t index) const
const TList * GetListOfEnums()
std::vector< TDataMember * > fData
std::vector< TProtoRealData > fPRealData
void Delete(Option_t *opt="") override
Delete the containers that are usually owned by their TClass.
static TDataMember * FindDataMember(TClass *cl, Int_t index, bool quiet)
Find the requested TDataMember.
static Int_t DataMemberIndex(TClass *cl, const char *name)
bool fOwner
! True if owns its content, false if it got a reference to the TClass content.
The TRealData class manages the effective list of all data members for a given class.
const char * GetName() const override
Returns name of object.
TDataMember * GetDataMember() const
void SetIsObject(Bool_t isObject)
const char * Data() const
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
bool IsStdArray(std::string_view name)
bool IsStdPair(std::string_view name)
bool GetStdArrayProperties(const char *typeName, std::string &typeNameBuf, std::array< int, 5 > &maxIndices, int &ndim)
void SetFlag(UInt_t f, Bool_t on=kTRUE)
Bool_t TestFlag(UInt_t f) const
TRealData * CreateRealData(TClass *currentClass, TClass *parent, TRealData *parentData, int prevLevel, bool quiet) const
Create a TRealData from this, with its data member coming from dmClass.
virtual ~TProtoRealData()
Destructor to pin vtable.