Logo ROOT   master
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 
36 namespace cling {
37  class Interpreter;
38 }
39 
40 class TClingClassInfo;
41 
43 
44 private:
45 
46  cling::Interpreter *fInterp; // Cling interpreter, we do *not* own.
47  TClingClassInfo *fClassInfo; // Class we were intialized with, we own.
48  bool fFirstTime; // Flag to provide Cint semantics for iterator advancement (not first time)
49  bool fDescend; // Flag for signaling the need to descend on this advancement.
50  const clang::Decl *fDecl; // Current class whose bases we are iterating through, we do *not* own.
51  clang::CXXRecordDecl::base_class_const_iterator fIter; // Current iterator.
52  TClingClassInfo *fBaseInfo; // Base class our iterator is currently pointing at, we own.
53  std::vector<std::pair<std::pair<const clang::Decl*, clang::CXXRecordDecl::base_class_const_iterator>, long> > fIterStack; // Iterator stack.
54  long fOffset; // Offset of the current base, fDecl, in the most-derived class.
55  bool fClassInfoOwnership; // We created the fClassInfo and we need to delete it in the constructor.
56 
57 public:
58 
60  if (fClassInfoOwnership) delete fClassInfo;
61  delete fBaseInfo;
62  }
63 
64  TClingBaseClassInfo(cling::Interpreter*, TClingClassInfo*);
65  TClingBaseClassInfo(cling::Interpreter*, TClingClassInfo* derived, TClingClassInfo* base);
68 
69  TClingClassInfo *GetBase() const;
70  int InternalNext(int onlyDirect);
71  bool IsValid() const;
72  int Next();
73  int Next(int onlyDirect);
74  ptrdiff_t Offset(void * address = 0, bool isDerivedObject = true) const;
75  long Property() const;
76  long Tagnum() const;
77  void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const;
78  const char *Name() const;
79  const char *TmpltName() const;
80 
81 private:
82  OffsetPtrFunc_t GenerateBaseOffsetFunction(TClingClassInfo* derivedClass, TClingClassInfo* targetClass, void* address, bool isDerivedObject) const;
83 };
84 
85 #endif // ROOT_TClingBaseClassInfo
const char * TmpltName() const
std::vector< std::pair< std::pair< const clang::Decl *, clang::CXXRecordDecl::base_class_const_iterator >, long > > fIterStack
TClingBaseClassInfo & operator=(const TClingBaseClassInfo &)
TClingBaseClassInfo(cling::Interpreter *, TClingClassInfo *)
ptrdiff_t(* OffsetPtrFunc_t)(void *, bool)
TClingClassInfo * fBaseInfo
int InternalNext(int onlyDirect)
const char * Name() const
Emulation of the CINT BaseClassInfo class.
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
TClingClassInfo * GetBase() const
const clang::Decl * fDecl
Print a TSeq at the prompt:
Definition: TDatime.h:115
Emulation of the CINT ClassInfo class.
ptrdiff_t Offset(void *address=0, bool isDerivedObject=true) const
cling::Interpreter * fInterp
clang::CXXRecordDecl::base_class_const_iterator fIter
static void output(int code)
Definition: gifencode.c:226
TClingClassInfo * fClassInfo
OffsetPtrFunc_t GenerateBaseOffsetFunction(TClingClassInfo *derivedClass, TClingClassInfo *targetClass, void *address, bool isDerivedObject) const