Logo ROOT  
Reference Guide
TClingDataMemberInfo.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_TClingDataMemberInfo
13#define ROOT_TClingDataMemberInfo
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// TClingDataMemberInfo //
18// //
19// Emulation of the CINT DataMemberInfo class. //
20// //
21// The CINT C++ interpreter provides an interface to metadata about //
22// the data members of a class through the DataMemberInfo class. This //
23// class provides the same functionality, using an interface as close //
24// as possible to DataMemberInfo but the data member metadata comes //
25// from the Clang C++ compiler, not CINT. //
26// //
27//////////////////////////////////////////////////////////////////////////
28
29#include "TClingDeclInfo.h"
30#include "TClingMemberIter.h"
31#include "TDictionary.h"
32
33#include <vector>
34#include <string>
35
36namespace clang {
37 class Decl;
38 class Type;
39 class ValueDecl;
40}
41
42namespace ROOT {
43 namespace TMetaUtils {
44 class TNormalizedCtxt;
45 }
46}
47
48class TClingClassInfo;
49
50/// Iterate over VarDecl, FieldDecl, EnumConstantDecl, IndirectFieldDecl, and
51/// UsingShadowDecls thereof, within a scope, recursing through "transparent"
52/// scopes (see DCIter::HandleInlineDeclContext()).
55
56protected:
57 // TODO:
58 //const clang::Decl *
59 //InstantiateTemplateWithDefaults(const clang::RedeclarableTemplateDecl *TD) const final;
60
61 bool ShouldSkip(const clang::Decl* FD) const final;
62 bool ShouldSkip(const clang::UsingShadowDecl* USD) const final;
63
64public:
66 TClingDataMemberIter(cling::Interpreter *interp, clang::DeclContext *DC, TDictionary::EMemberSelection selection)
67 : TClingMemberIter(interp, DC), fSelection(selection)
68 {
69 }
70};
71
73
74private:
75
76 cling::Interpreter *fInterp; // Cling interpreter, we do *not* own.
77 TClingClassInfo *fClassInfo = nullptr; // ClassInfo for the decl context, for X<Float16_t> vs X<float>.
78 TClingDataMemberIter fIter; // Current decl.
79 std::string fTitle; // The meta info for the member.
80 bool fFirstTime = true; // We need to skip the first increment to support the cint Next() semantics.
81
82 mutable std::string fIoType;
83 mutable std::string fIoName;
84 union {
85 float fFloat;
86 double fDouble;
87 long fLong;
88 } fConstInitVal; // Result of VarDecl::evaluateValue()
89 inline void CheckForIoTypeAndName () const;
90
91 // Invalidate the name caches.
92 void ClearNames() {
93 fNameCache.clear();
94 fIoType.clear();
95 fIoName.clear();
96 }
97
98public:
99
100 explicit TClingDataMemberInfo(cling::Interpreter *interp)
101 : TClingDeclInfo(nullptr), fInterp(interp) {}
102
103 TClingDataMemberInfo(cling::Interpreter *interp, TClingClassInfo *ci, TDictionary::EMemberSelection selection);
104
105 // Takes concrete decl and disables the iterator.
106 // ValueDecl is the common base between enum constant, var decl and field decl
107 TClingDataMemberInfo(cling::Interpreter *interp, const clang::ValueDecl *, TClingClassInfo *);
108
110
111 int ArrayDim() const;
112 const clang::Decl *GetDecl() const override {
113 if (const clang::Decl* SingleDecl = TClingDeclInfo::GetDecl())
114 return SingleDecl;
115 return *fIter;
116 }
117 const clang::ValueDecl *GetAsValueDecl() const;
118 const clang::UsingShadowDecl *GetAsUsingShadowDecl() const;
119
120 /// Get the ValueDecl, or if this represents a UsingShadowDecl, the underlying target ValueDecl.
121 const clang::ValueDecl *GetTargetValueDecl() const;
122 DeclId_t GetDeclId() const;
123 const clang::Type *GetClassAsType() const;
124 int MaxIndex(int dim) const;
125 int Next();
126 long Offset();
127 long Property() const;
128 long TypeProperty() const;
129 int TypeSize() const;
130 const char *TypeName() const;
131 const char *TypeTrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const;
132 const char *Name() const override;
133 const char *Title();
134 llvm::StringRef ValidArrayIndex() const;
135
136};
137
138#endif // ROOT_TClingDataMemberInfo
The file contains a base class of TCling*Info classes.
Emulation of the CINT ClassInfo class.
Emulation of the CINT DataMemberInfo class.
const char * TypeName() const
const clang::Type * GetClassAsType() const
const clang::Decl * GetDecl() const override
const char * TypeTrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const
const clang::UsingShadowDecl * GetAsUsingShadowDecl() const
int MaxIndex(int dim) const
TClingClassInfo * fClassInfo
TClingDataMemberInfo(cling::Interpreter *interp)
union TClingDataMemberInfo::@29 fConstInitVal
cling::Interpreter * fInterp
const clang::ValueDecl * GetTargetValueDecl() const
Get the ValueDecl, or if this represents a UsingShadowDecl, the underlying target ValueDecl.
const clang::ValueDecl * GetAsValueDecl() const
llvm::StringRef ValidArrayIndex() const
const char * Name() const override
TDictionary::DeclId_t DeclId_t
TClingDataMemberIter fIter
Iterate over VarDecl, FieldDecl, EnumConstantDecl, IndirectFieldDecl, and UsingShadowDecls thereof,...
TClingDataMemberIter(cling::Interpreter *interp, clang::DeclContext *DC, TDictionary::EMemberSelection selection)
TDictionary::EMemberSelection fSelection
bool ShouldSkip(const clang::Decl *FD) const final
TClingDataMemberIter()=default
std::string fNameCache
virtual const clang::Decl * GetDecl() const
Iterate over all DeclT-s (or UsingShadowDecl-s pointing to DeclT-s) of a decl context,...
EMemberSelection
Kinds of members to include in lists.
Definition: TDictionary.h:214
const void * DeclId_t
Definition: TDictionary.h:222
Type
enumeration specifying the integration types.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21