Logo ROOT   6.08/07
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  cling::Interpreter::PushTransactionRAII RAII(fInterp);
63  fIter = DC->decls_begin();
64  }
65 
66  explicit TClingTypedefInfo(cling::Interpreter *, const char *);
67 
68  explicit TClingTypedefInfo(cling::Interpreter *, const clang::TypedefNameDecl *);
69 
70  const clang::Decl *GetDecl() const;
71  void Init(const char *name);
72  bool IsValid() const;
73  int InternalNext();
74  int Next();
75  long Property() const;
76  int Size() const;
77  const char *TrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const;
78  const char *Name() const;
79  const char *Title();
80 
81 };
82 
83 #endif // ROOT_TClingTypedefInfo
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
const char * Title
Definition: TXMLSetup.cxx:68
const char * Size
Definition: TXMLSetup.cxx:56
const clang::Decl * fDecl
std::vector< clang::DeclContext::decl_iterator > fIterStack
clang::DeclContext::decl_iterator fIter
const char * Name
Definition: TXMLSetup.cxx:67
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Definition: TClassEdit.cxx:119
TClingTypedefInfo(cling::Interpreter *interp)
std::string TrueName(const clang::FieldDecl &m)
TrueName strips the typedefs and array dimensions.
Emulation of the CINT TypedefInfo class.
cling::Interpreter * fInterp
char name[80]
Definition: TGX11.cxx:109