Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "TClingClassInfo.h"
30#include "TClingDeclInfo.h"
31#include "TClingMemberIter.h"
32#include "TDictionary.h"
33
34#include <vector>
35#include <string>
36
37namespace clang {
38 class Decl;
39 class Type;
40 class ValueDecl;
41}
42
43namespace ROOT {
44 namespace TMetaUtils {
45 class TNormalizedCtxt;
46 }
47}
48
49/// Iterate over VarDecl, FieldDecl, EnumConstantDecl, IndirectFieldDecl, and
50/// UsingShadowDecls thereof, within a scope, recursing through "transparent"
51/// scopes (see DCIter::HandleInlineDeclContext()).
54
55protected:
56 // TODO:
57 //const clang::Decl *
58 //InstantiateTemplateWithDefaults(const clang::RedeclarableTemplateDecl *TD) const final;
59
60 bool ShouldSkip(const clang::Decl* FD) const final;
61 bool ShouldSkip(const clang::UsingShadowDecl* USD) const final;
62
63public:
65 TClingDataMemberIter(cling::Interpreter *interp, clang::DeclContext *DC, TDictionary::EMemberSelection selection)
66 : TClingMemberIter(interp, DC), fSelection(selection)
67 {
68 }
69};
70
72
73private:
74
75 cling::Interpreter *fInterp; // Cling interpreter, we do *not* own.
76 TClingClassInfo fClassInfo; // ClassInfo for the decl context, for X<Float16_t> vs X<float>.
77 TClingDataMemberIter fIter; // Current decl.
78 std::string fTitle; // The meta info for the member.
79 bool fFirstTime = true; // We need to skip the first increment to support the cint Next() semantics.
80
81 mutable std::string fIoType;
82 mutable std::string fIoName;
83 union {
84 float fFloat;
85 double fDouble;
86 long fLong;
87 } fConstInitVal; // Result of VarDecl::evaluateValue()
88 inline void CheckForIoTypeAndName () const;
89
90 // Invalidate the name caches.
91 void ClearNames() {
92 fNameCache.clear();
93 fIoType.clear();
94 fIoName.clear();
95 }
96
97public:
98
99 explicit TClingDataMemberInfo(cling::Interpreter *interp)
100 : TClingDeclInfo(nullptr), fInterp(interp) {}
101
102 TClingDataMemberInfo(cling::Interpreter *interp, TClingClassInfo *ci, TDictionary::EMemberSelection selection);
103
104 // Takes concrete decl and disables the iterator.
105 // ValueDecl is the common base between enum constant, var decl and field decl
106 TClingDataMemberInfo(cling::Interpreter *interp, const clang::ValueDecl *, TClingClassInfo *);
107
109
110 int ArrayDim() const;
111 const clang::Decl *GetDecl() const override {
112 if (const clang::Decl* SingleDecl = TClingDeclInfo::GetDecl())
113 return SingleDecl;
114 return *fIter;
115 }
116 const clang::ValueDecl *GetAsValueDecl() const;
117 const clang::UsingShadowDecl *GetAsUsingShadowDecl() const;
118
119 /// Get the ValueDecl, or if this represents a UsingShadowDecl, the underlying target ValueDecl.
120 const clang::ValueDecl *GetTargetValueDecl() const;
121 DeclId_t GetDeclId() const;
122 const clang::Type *GetClassAsType() const;
123 int MaxIndex(int dim) const;
124 int Next();
126 long Property() const;
127 long TypeProperty() const;
128 int TypeSize() const;
129 const char *TypeName() const;
130 const char *TypeTrueName(const ROOT::TMetaUtils::TNormalizedCtxt &normCtxt) const;
131 const char *Name() const override;
132 const char *Title();
133 llvm::StringRef ValidArrayIndex() const;
134
135};
136
137#endif // ROOT_TClingDataMemberInfo
long Longptr_t
Definition RtypesCore.h:82
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
union TClingDataMemberInfo::@28 fConstInitVal
const clang::UsingShadowDecl * GetAsUsingShadowDecl() const
TClingDataMemberInfo(cling::Interpreter *interp)
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.
const void * DeclId_t
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...