ROOT  6.06/09
Reference Guide
TClingTypedefInfo.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_TClingTypedefInfo
13 #define ROOT_TClingTypedefInfo
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TClingTypedefInfo //
18 // //
19 // Emulation of the CINT TypedefInfo class. //
20 // //
21 // The CINT C++ interpreter provides an interface to metadata about //
22 // a typedef through the TypedefInfo class. This class provides the //
23 // same functionality, using an interface as close as possible to //
24 // TypedefInfo but the typedef metadata comes from the Clang C++ //
25 // compiler, not CINT. //
26 // //
27 //////////////////////////////////////////////////////////////////////////
28 
29 #include "cling/Interpreter/Interpreter.h"
30 #include "clang/AST/ASTContext.h"
31 #include "clang/AST/Decl.h"
32 #include "clang/Frontend/CompilerInstance.h"
33 
34 #include <vector>
35 #include <string>
36 
37 namespace ROOT {
38  namespace TMetaUtils {
39  class TNormalizedCtxt;
40  }
41 }
42 
44 
45 private:
46 
47  cling::Interpreter *fInterp; // Cling interpreter, we do *not* own.
48  bool fFirstTime; // We need to skip the first increment to support the cint Next() semantics.
49  bool fDescend; // Flag for signaling the need to descend on this advancement.
50  clang::DeclContext::decl_iterator fIter; // Current decl in scope.
51  const clang::Decl *fDecl; // Current decl.
52  std::vector<clang::DeclContext::decl_iterator> fIterStack; // Recursion stack for traversing nested scopes.
53  std::string fTitle; // The meta info for the typedef.
54 
55 public:
56 
57  explicit TClingTypedefInfo(cling::Interpreter *interp)
58  : fInterp(interp), fFirstTime(true), fDescend(false), fDecl(0), fTitle("")
59  {
60  const clang::TranslationUnitDecl *TU = fInterp->getCI()->getASTContext().getTranslationUnitDecl();
61  const clang::DeclContext *DC = llvm::cast<clang::DeclContext>(TU);
62  fIter = DC->decls_begin();
63  }
64 
65  explicit TClingTypedefInfo(cling::Interpreter *, const char *);
66 
67  explicit TClingTypedefInfo(cling::Interpreter *, const clang::TypedefNameDecl *);
68 
69  const clang::Decl *GetDecl() const;
70  void Init(const char *name);
71  bool IsValid() const;
72  int InternalNext();
73  int Next();
74  long Property() const;
75  int Size() const;
76  const char *TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const;
77  const char *Name() const;
78  const char *Title();
79 
80 };
81 
82 #endif // ROOT_TClingTypedefInfo
int InternalNext()
Increment the iterator, return true if new position is valid.
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
void Init(const char *name)
Lookup named typedef and reset the iterator to point to it.
const clang::Decl * fDecl
std::vector< clang::DeclContext::decl_iterator > fIterStack
clang::DeclContext::decl_iterator fIter
const char * TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Get the name of the underlying type of the current typedef.
ClassImp(TIterator) Bool_t TIterator return false
Compare two iterator objects.
Definition: TIterator.cxx:20
int Next()
Increment the iterator.
long Property() const
Return a bit mask of metadata about the current typedef.
TClingTypedefInfo(cling::Interpreter *interp)
const clang::Decl * GetDecl() const
Get the current typedef declaration.
const char * Name() const
Get the name of the current typedef.
int Size() const
Return the size in bytes of the underlying type of the current typedef.
Emulation of the CINT TypedefInfo class.
#define name(a, b)
Definition: linkTestLib0.cpp:5
bool IsValid() const
Return true if the current iterator position is valid.
cling::Interpreter * fInterp