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
37namespace cling {
38 class Interpreter;
39}
40
41class TClingClassInfo;
42
44
45private:
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
58public:
59
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
82private:
83 OffsetPtrFunc_t GenerateBaseOffsetFunction(TClingClassInfo* derivedClass, TClingClassInfo* targetClass, void* address, bool isDerivedObject) const;
84};
85
86#endif // ROOT_TClingBaseClassInfo
ptrdiff_t(* OffsetPtrFunc_t)(void *, bool)
Emulation of the CINT BaseClassInfo class.
const char * TmpltName() const
const char * Name() const
const clang::Decl * fDecl
ptrdiff_t Offset(void *address=0, bool isDerivedObject=true) const
TClingClassInfo * fBaseInfo
TClingClassInfo * fClassInfo
OffsetPtrFunc_t GenerateBaseOffsetFunction(TClingClassInfo *derivedClass, TClingClassInfo *targetClass, void *address, bool isDerivedObject) const
TClingBaseClassInfo(cling::Interpreter *, TClingClassInfo *)
void FullName(std::string &output, const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
TClingBaseClassInfo & operator=(const TClingBaseClassInfo &)
cling::Interpreter * fInterp
std::vector< std::pair< std::pair< const clang::Decl *, clang::CXXRecordDecl::base_class_const_iterator >, long > > fIterStack
int InternalNext(int onlyDirect)
clang::CXXRecordDecl::base_class_const_iterator fIter
TClingClassInfo * GetBase() const
Emulation of the CINT ClassInfo class.
static void output()