Logo ROOT   master
Reference Guide
TClingMethodInfo.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_TClingMethodInfo
13 #define ROOT_TClingMethodInfo
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TClingMethodInfo //
18 // //
19 // Emulation of the CINT MethodInfo class. //
20 // //
21 // The CINT C++ interpreter provides an interface to metadata about //
22 // a function through the MethodInfo class. This class provides the //
23 // same functionality, using an interface as close as possible to //
24 // MethodInfo but the typedef metadata comes from the Clang C++ //
25 // compiler, not CINT. //
26 // //
27 //////////////////////////////////////////////////////////////////////////
28 
29 #include "TClingDeclInfo.h"
30 
31 #include "TString.h"
32 #include "TDictionary.h"
33 
34 #include "clang/AST/DeclBase.h"
35 #include "llvm/ADT/SmallVector.h"
36 
37 namespace cling {
38  class Interpreter;
39 }
40 
41 namespace clang {
42  class FunctionDecl;
43  class CXXMethodDecl;
44 }
45 
46 namespace ROOT {
47  namespace TMetaUtils {
48  class TNormalizedCtxt;
49  }
50 }
51 
52 class TClingClassInfo;
53 class TClingTypeInfo;
54 
55 class TClingMethodInfo final : public TClingDeclInfo {
56 private:
57  cling::Interpreter *fInterp; // Cling interpreter, we do *not* own.
58  llvm::SmallVector<clang::DeclContext *, 2> fContexts; // Set of DeclContext that we will iterate over.
59  bool fFirstTime; // Flag for first time incrementing iterator, cint semantics are weird.
60  unsigned int fContextIdx; // Index in fContexts of DeclContext we are iterating over.
61  clang::DeclContext::decl_iterator fIter; // Our iterator.
62  std::string fTitle; // The meta info for the method.
63  const clang::FunctionDecl *fTemplateSpec; // an all-default-template-args function.
64  llvm::SmallVector<clang::Decl *,4> fDefDataSpecFuns; // decl_begin() will skip these special members, materialized from DefinitionData
65  llvm::SmallVector<clang::Decl *,4>::const_iterator fDefDataSpecFunIter; // Iterator over fDefDataSpecFuns
66 
67  const clang::Decl* GetDeclSlow() const;
68 
69 public:
70  explicit TClingMethodInfo(cling::Interpreter *interp)
71  : TClingDeclInfo(nullptr), fInterp(interp), fFirstTime(true), fContextIdx(0U), fTitle(""),
72  fTemplateSpec(0) {}
73 
76 
77  // Takes concrete decl and disables the iterator.
78  TClingMethodInfo(cling::Interpreter *, const clang::FunctionDecl *);
79  TClingMethodInfo(cling::Interpreter *, TClingClassInfo *);
80 
82 
83  const clang::FunctionDecl *GetMethodDecl() const;
85  cling::Interpreter *GetInterpreter() const { return fInterp; }
86  void CreateSignature(TString &signature) const;
87  void Init(const clang::FunctionDecl *);
88  void *InterfaceMethod(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const;
89 
90  const clang::Decl *GetDecl() const override {
91  if (const clang::Decl* SingleDecl = TClingDeclInfo::GetDecl())
92  return SingleDecl;
93  return GetDeclSlow();
94  }
95  int NArg() const;
96  int NDefaultArg() const;
97  int InternalNext();
98  int Next();
99  long Property() const;
100  long ExtraProperty() const;
101  TClingTypeInfo *Type() const;
102  std::string GetMangledName() const;
103  const char *GetPrototype();
104  const char *Name() const override;
105  const char *TypeName() const;
106  const char *Title();
107 };
108 
109 #endif // ROOT_TClingMethodInfo
Returns the available number of logical cores.
Definition: RNumpyDS.hxx:30
llvm::SmallVector< clang::DeclContext *, 2 > fContexts
Emulation of the CINT MethodInfo class.
clang::DeclContext::decl_iterator fIter
void * InterfaceMethod(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
Basic string class.
Definition: TString.h:131
const char * GetPrototype()
std::string GetMangledName() const
const char * Title()
const void * DeclId_t
Definition: TDictionary.h:209
void CreateSignature(TString &signature) const
llvm::SmallVector< clang::Decl *, 4 >::const_iterator fDefDataSpecFunIter
const char * TypeName() const
cling::Interpreter * GetInterpreter() const
llvm::SmallVector< clang::Decl *, 4 > fDefDataSpecFuns
Emulation of the CINT TypeInfo class.
long ExtraProperty() const
const clang::FunctionDecl * GetMethodDecl() const
void Init(const clang::FunctionDecl *)
unsigned int fContextIdx
TClingMethodInfo & operator=(const TClingMethodInfo &in)
const char * Name() const override
TDictionary::DeclId_t GetDeclId() const
std::string fTitle
virtual const clang::Decl * GetDecl() const
Print a TSeq at the prompt:
Definition: TDatime.h:115
Emulation of the CINT ClassInfo class.
const clang::Decl * GetDeclSlow() const
TClingMethodInfo(cling::Interpreter *interp)
The file contains a base class of TCling*Info classes.
const clang::FunctionDecl * fTemplateSpec
const clang::Decl * GetDecl() const override
TClingTypeInfo * Type() const
cling::Interpreter * fInterp