Logo ROOT  
Reference Guide
TClingBaseClassInfo.h
Go to the documentation of this file.
1 // @(#)root/core/meta:$Id$
2 // Author: Paul Russo 30/07/2012
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TClingBaseClassInfo
13 #define ROOT_TClingBaseClassInfo
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TClingBaseClassInfo //
18 // //
19 // Emulation of the CINT BaseClassInfo class. //
20 // //
21 // The CINT C++ interpreter provides an interface to metadata about //
22 // the base classes of a class through the BaseClassInfo class. This //
23 // class provides the same functionality, using an interface as close //
24 // as possible to BaseClassInfo but the base class metadata comes from //
25 // the Clang C++ compiler, not CINT. //
26 // //
27 //////////////////////////////////////////////////////////////////////////
28 
29 #include "TClingClassInfo.h"
30 
31 #include "clang/AST/DeclCXX.h"
32 
33 #include <utility>
34 #include <vector>
35 #include <string>
36 
37 namespace cling {
38  class Interpreter;
39 }
40 
41 class TClingClassInfo;
42 
44 
45 private:
46 
47  cling::Interpreter *fInterp; // Cling interpreter, we do *not* own.
48  TClingClassInfo *fClassInfo; // Class we were intialized with, we own.
49  bool fFirstTime; // Flag to provide Cint semantics for iterator advancement (not first time)
50  bool fDescend; // Flag for signaling the need to descend on this advancement.
51  const clang::Decl *fDecl; // Current class whose bases we are iterating through, we do *not* own.
52  clang::CXXRecordDecl::base_class_const_iterator fIter; // Current iterator.
53  TClingClassInfo *fBaseInfo; // Base class our iterator is currently pointing at, we own.
54  std::vector<std::pair<std::pair<const clang::Decl*, clang::CXXRecordDecl::base_class_const_iterator>, long> > fIterStack; // Iterator stack.
55  long fOffset; // Offset of the current base, fDecl, in the most-derived class.
56  bool fClassInfoOwnership; // We created the fClassInfo and we need to delete it in the constructor.
57 
58 public:
59 
61  if (fClassInfoOwnership) delete fClassInfo;
62  delete fBaseInfo;
63  }
64 
65  TClingBaseClassInfo(cling::Interpreter*, TClingClassInfo*);
66  TClingBaseClassInfo(cling::Interpreter*, TClingClassInfo* derived, TClingClassInfo* base);
69 
70  TClingClassInfo *GetBase() const;
71  int InternalNext(int onlyDirect);
72  bool IsValid() const;
73  int Next();
74  int Next(int onlyDirect);
75  ptrdiff_t Offset(void * address = 0, bool isDerivedObject = true) const;
76  long Property() const;
77  long Tagnum() const;
78  void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const;
79  const char *Name() const;
80  const char *TmpltName() const;
81 
82 private:
83  OffsetPtrFunc_t GenerateBaseOffsetFunction(TClingClassInfo* derivedClass, TClingClassInfo* targetClass, void* address, bool isDerivedObject) const;
84 };
85 
86 #endif // ROOT_TClingBaseClassInfo
TClingBaseClassInfo::fClassInfoOwnership
bool fClassInfoOwnership
Definition: TClingBaseClassInfo.h:56
TClingBaseClassInfo::GetBase
TClingClassInfo * GetBase() const
Definition: TClingBaseClassInfo.cxx:156
TClingBaseClassInfo::FullName
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Definition: TClingBaseClassInfo.cxx:557
TClingBaseClassInfo::fInterp
cling::Interpreter * fInterp
Definition: TClingBaseClassInfo.h:47
output
static void output(int code)
Definition: gifencode.c:226
TClingBaseClassInfo::fDescend
bool fDescend
Definition: TClingBaseClassInfo.h:50
TClingBaseClassInfo
Definition: TClingBaseClassInfo.h:43
TClingBaseClassInfo::TClingBaseClassInfo
TClingBaseClassInfo(cling::Interpreter *, TClingClassInfo *)
Definition: TClingBaseClassInfo.cxx:56
TClingBaseClassInfo::fBaseInfo
TClingClassInfo * fBaseInfo
Definition: TClingBaseClassInfo.h:53
TClingBaseClassInfo::IsValid
bool IsValid() const
Definition: TClingBaseClassInfo.cxx:244
TClingBaseClassInfo::fIter
clang::CXXRecordDecl::base_class_const_iterator fIter
Definition: TClingBaseClassInfo.h:52
TClingBaseClassInfo::Tagnum
long Tagnum() const
Definition: TClingBaseClassInfo.cxx:549
TClingClassInfo.h
TClingBaseClassInfo::Next
int Next()
Definition: TClingBaseClassInfo.cxx:353
TClingBaseClassInfo::fFirstTime
bool fFirstTime
Definition: TClingBaseClassInfo.h:49
TClingBaseClassInfo::Name
const char * Name() const
Definition: TClingBaseClassInfo.cxx:566
TClingBaseClassInfo::operator=
TClingBaseClassInfo & operator=(const TClingBaseClassInfo &)
Definition: TClingBaseClassInfo.cxx:135
TClingClassInfo
Definition: TClingClassInfo.h:58
OffsetPtrFunc_t
ptrdiff_t(* OffsetPtrFunc_t)(void *, bool)
Definition: TClingClassInfo.h:56
ROOT::TMetaUtils::TNormalizedCtxt
Definition: TClingUtils.h:138
TClingBaseClassInfo::~TClingBaseClassInfo
~TClingBaseClassInfo()
Definition: TClingBaseClassInfo.h:60
TClingBaseClassInfo::TmpltName
const char * TmpltName() const
Definition: TClingBaseClassInfo.cxx:574
TClingBaseClassInfo::Offset
ptrdiff_t Offset(void *address=0, bool isDerivedObject=true) const
Definition: TClingBaseClassInfo.cxx:411
TClingBaseClassInfo::fOffset
long fOffset
Definition: TClingBaseClassInfo.h:55
TClingBaseClassInfo::fClassInfo
TClingClassInfo * fClassInfo
Definition: TClingBaseClassInfo.h:48
TClingBaseClassInfo::fDecl
const clang::Decl * fDecl
Definition: TClingBaseClassInfo.h:51
TClingBaseClassInfo::GenerateBaseOffsetFunction
OffsetPtrFunc_t GenerateBaseOffsetFunction(TClingClassInfo *derivedClass, TClingClassInfo *targetClass, void *address, bool isDerivedObject) const
Definition: TClingBaseClassInfo.cxx:165
TClingBaseClassInfo::Property
long Property() const
Definition: TClingBaseClassInfo.cxx:488
TClingBaseClassInfo::fIterStack
std::vector< std::pair< std::pair< const clang::Decl *, clang::CXXRecordDecl::base_class_const_iterator >, long > > fIterStack
Definition: TClingBaseClassInfo.h:54
TClingBaseClassInfo::InternalNext
int InternalNext(int onlyDirect)
Definition: TClingBaseClassInfo.cxx:257