Logo ROOT   6.18/05
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
37namespace cling {
38 class Interpreter;
39}
40
41namespace clang {
42 class FunctionDecl;
43}
44
45namespace ROOT {
46 namespace TMetaUtils {
47 class TNormalizedCtxt;
48 }
49}
50
51class TClingClassInfo;
52class TClingTypeInfo;
53
54class TClingMethodInfo final : public TClingDeclInfo {
55private:
56 cling::Interpreter *fInterp; // Cling interpreter, we do *not* own.
57 llvm::SmallVector<clang::DeclContext *, 2> fContexts; // Set of DeclContext that we will iterate over.
58 bool fFirstTime; // Flag for first time incrementing iterator, cint semantics are weird.
59 unsigned int fContextIdx; // Index in fContexts of DeclContext we are iterating over.
60 clang::DeclContext::decl_iterator fIter; // Our iterator.
61 std::string fTitle; // The meta info for the method.
62 const clang::FunctionDecl *fTemplateSpec; // an all-default-template-args function.
63
64 const clang::Decl* GetDeclSlow() const;
65
66public:
67 explicit TClingMethodInfo(cling::Interpreter *interp)
68 : TClingDeclInfo(nullptr), fInterp(interp), fFirstTime(true), fContextIdx(0U), fTitle(""),
69 fTemplateSpec(0) {}
70
73
74 // Takes concrete decl and disables the iterator.
75 TClingMethodInfo(cling::Interpreter *, const clang::FunctionDecl *);
76 TClingMethodInfo(cling::Interpreter *, TClingClassInfo *);
77
79
80 const clang::FunctionDecl *GetMethodDecl() const;
82 cling::Interpreter *GetInterpreter() const { return fInterp; }
83 void CreateSignature(TString &signature) const;
84 void Init(const clang::FunctionDecl *);
85 void *InterfaceMethod(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const;
86
87 const clang::Decl *GetDecl() const override {
88 if (const clang::Decl* SingleDecl = TClingDeclInfo::GetDecl())
89 return SingleDecl;
90 return GetDeclSlow();
91 }
92 int NArg() const;
93 int NDefaultArg() const;
94 int InternalNext();
95 int Next();
96 long Property() const;
97 long ExtraProperty() const;
98 TClingTypeInfo *Type() const;
99 std::string GetMangledName() const;
100 const char *GetPrototype();
101 const char *Name() override;
102 const char *TypeName() const;
103 const char *Title();
104};
105
106#endif // ROOT_TClingMethodInfo
The file contains a base class of TCling*Info classes.
Emulation of the CINT ClassInfo class.
virtual const clang::Decl * GetDecl() const
Emulation of the CINT MethodInfo class.
const char * Name() override
clang::DeclContext::decl_iterator fIter
TClingMethodInfo & operator=(const TClingMethodInfo &in)
std::string GetMangledName() const
const char * TypeName() const
cling::Interpreter * GetInterpreter() const
void * InterfaceMethod(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
unsigned int fContextIdx
const clang::Decl * GetDecl() const override
const char * GetPrototype()
void Init(const clang::FunctionDecl *)
const clang::FunctionDecl * GetMethodDecl() const
long ExtraProperty() const
const clang::Decl * GetDeclSlow() const
llvm::SmallVector< clang::DeclContext *, 2 > fContexts
TClingMethodInfo(cling::Interpreter *interp)
void CreateSignature(TString &signature) const
std::string fTitle
const char * Title()
TDictionary::DeclId_t GetDeclId() const
cling::Interpreter * fInterp
TClingTypeInfo * Type() const
const clang::FunctionDecl * fTemplateSpec
Emulation of the CINT TypeInfo class.
const void * DeclId_t
Definition: TDictionary.h:206
Basic string class.
Definition: TString.h:131
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21